diff --git a/ChangeLog.md b/ChangeLog.md index c9e716378be..7ac23fb8a42 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,15 @@ # Change Log +### 2021-05-17 - 5.8.0 + +min Autorest core version: 3.3.0 + +min Modelerfour version: 4.19.1 + +**New Features** + +- Add support for parameters and properties that can be of type "Anything". #946 + ### 2021-04-20 - 5.7.0 min Autorest core version: 3.1.0 diff --git a/README.md b/README.md index 697a6943131..c2b35999d1a 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio pass-thru: - model-deduplicator - subset-reducer -version: ^3.1.0 +version: ~3.3.0 use-extension: - "@autorest/modelerfour": ^4.15.456 + "@autorest/modelerfour": ~4.19.1 modelerfour: group-parameters: true diff --git a/autorest/codegen/models/__init__.py b/autorest/codegen/models/__init__.py index 8d69f1c84c9..098def60012 100644 --- a/autorest/codegen/models/__init__.py +++ b/autorest/codegen/models/__init__.py @@ -27,6 +27,7 @@ __all__ = [ "AzureKeyCredentialSchema", + "AnySchema", "BaseModel", "BaseSchema", "CodeModel", diff --git a/autorest/codegen/models/primitive_schemas.py b/autorest/codegen/models/primitive_schemas.py index e54a99653af..435c9cf3206 100644 --- a/autorest/codegen/models/primitive_schemas.py +++ b/autorest/codegen/models/primitive_schemas.py @@ -81,7 +81,16 @@ def serialization_type(self) -> str: @property def docstring_type(self) -> str: - return "object" + return "any" + + @property + def type_annotation(self) -> str: + return "Any" + + def imports(self) -> FileImport: + file_import = FileImport() + file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) + return file_import class NumberSchema(PrimitiveSchema): @@ -374,6 +383,7 @@ def get_primitive_schema(namespace: str, yaml_data: Dict[str, Any]) -> "Primitiv "duration": DurationSchema, "byte-array": ByteArraySchema, "any": AnySchema, + "any-object": AnySchema, "binary": IOSchema } schema_type = yaml_data["type"] diff --git a/package.json b/package.json index ca618f293ac..d0e0e936ac3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "5.7.0", + "version": "5.8.0", "description": "The Python extension for generators in AutoRest.", "scripts": { "prepare": "node run-python3.js prepare.py", @@ -28,7 +28,7 @@ }, "devDependencies": { "@autorest/autorest": "^3.0.0", - "@microsoft.azure/autorest.testserver": "^3.0.20" + "@microsoft.azure/autorest.testserver": "^3.0.23" }, "files": [ "autorest/**/*.py", diff --git a/tasks.py b/tasks.py index 9b33c1de29f..bd0c72a9a4e 100644 --- a/tasks.py +++ b/tasks.py @@ -32,6 +32,7 @@ class _SwaggerGroup(Enum): _VANILLA_SWAGGER_MAPPINGS = { 'AdditionalProperties': 'additionalProperties.json', + 'Anything': 'any-type.json', 'ParameterFlattening': 'parameter-flattening.json', 'BodyArray': 'body-array.json', 'BodyBoolean': 'body-boolean.json', diff --git a/test/vanilla/AcceptanceTests/asynctests/test_anything.py b/test/vanilla/AcceptanceTests/asynctests/test_anything.py new file mode 100644 index 00000000000..fcdbfe954ff --- /dev/null +++ b/test/vanilla/AcceptanceTests/asynctests/test_anything.py @@ -0,0 +1,58 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from async_generator import yield_, async_generator +from anything.aio import AnythingClient + +@pytest.fixture +@async_generator +async def client(): + async with AnythingClient(base_url="http://localhost:3000") as client: + await yield_(client) + +@pytest.mark.asyncio +async def test_get_string(client): + assert await client.get_string() == 'anything' + +@pytest.mark.asyncio +async def test_put_string(client): + await client.put_string(input="anything") + +@pytest.mark.asyncio +async def test_get_object(client): + assert await client.get_object() == {"message": "An object was successfully returned"} + +@pytest.mark.asyncio +async def test_put_object(client): + await client.put_object({'foo': 'bar'}) + +@pytest.mark.asyncio +async def test_get_array(client): + assert await client.get_array() == ['foo', 'bar'] + +@pytest.mark.asyncio +async def test_put_array(client): + await client.put_array(['foo', 'bar']) diff --git a/test/vanilla/AcceptanceTests/test_anything.py b/test/vanilla/AcceptanceTests/test_anything.py new file mode 100644 index 00000000000..f2c1f4766c5 --- /dev/null +++ b/test/vanilla/AcceptanceTests/test_anything.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- +import pytest +from anything import AnythingClient + +@pytest.fixture +def client(): + with AnythingClient(base_url="http://localhost:3000") as client: + yield client + +def test_get_string(client): + assert client.get_string() == 'anything' + +def test_put_string(client): + client.put_string(input="anything") + +def test_get_object(client): + assert client.get_object() == {"message": "An object was successfully returned"} + +def test_put_object(client): + client.put_object({'foo': 'bar'}) + +def test_get_array(client): + assert client.get_array() == ['foo', 'bar'] + +def test_put_array(client): + client.put_array(['foo', 'bar']) diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py index 2eb33f7278a..b30059636f7 100644 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py +++ b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models.py @@ -19,7 +19,7 @@ class PetAPTrue(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: @@ -57,7 +57,7 @@ class CatAPTrue(PetAPTrue): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: @@ -199,7 +199,7 @@ class PetAPObject(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: diff --git a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py index 553f2e837ef..b5e3beda5c3 100644 --- a/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py +++ b/test/vanilla/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, Optional +from typing import Any, Dict, Optional from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -21,7 +21,7 @@ class PetAPTrue(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: @@ -43,12 +43,7 @@ class PetAPTrue(msrest.serialization.Model): } def __init__( - self, - *, - id: int, - additional_properties: Optional[Dict[str, object]] = None, - name: Optional[str] = None, - **kwargs + self, *, id: int, additional_properties: Optional[Dict[str, Any]] = None, name: Optional[str] = None, **kwargs ): super(PetAPTrue, self).__init__(**kwargs) self.additional_properties = additional_properties @@ -66,7 +61,7 @@ class CatAPTrue(PetAPTrue): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: @@ -94,7 +89,7 @@ def __init__( self, *, id: int, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, name: Optional[str] = None, friendly: Optional[bool] = None, **kwargs @@ -227,7 +222,7 @@ class PetAPObject(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Required. :type id: int :param name: @@ -249,12 +244,7 @@ class PetAPObject(msrest.serialization.Model): } def __init__( - self, - *, - id: int, - additional_properties: Optional[Dict[str, object]] = None, - name: Optional[str] = None, - **kwargs + self, *, id: int, additional_properties: Optional[Dict[str, Any]] = None, name: Optional[str] = None, **kwargs ): super(PetAPObject, self).__init__(**kwargs) self.additional_properties = additional_properties diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.py new file mode 100644 index 00000000000..a21610becba --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._anything_client import AnythingClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ["AnythingClient"] + +try: + from ._patch import patch_sdk # type: ignore + + patch_sdk() +except ImportError: + pass diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py new file mode 100644 index 00000000000..33f52a30e0c --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_anything_client.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import AnythingClientConfiguration +from .operations import AnythingClientOperationsMixin + + +class AnythingClient(AnythingClientOperationsMixin): + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param str base_url: Service URL + """ + + def __init__( + self, + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AnythingClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_configuration.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_configuration.py new file mode 100644 index 00000000000..20dd340ae21 --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_configuration.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + +class AnythingClientConfiguration(Configuration): + """Configuration for AnythingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__( + self, **kwargs # type: Any + ): + # type: (...) -> None + super(AnythingClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "anythingclient/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/_version.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/__init__.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/__init__.py new file mode 100644 index 00000000000..44f32de2d0a --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/__init__.py @@ -0,0 +1,11 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._anything_client import AnythingClient + +__all__ = ["AnythingClient"] diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py new file mode 100644 index 00000000000..bbbc9610eaa --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_anything_client.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + +from ._configuration import AnythingClientConfiguration +from .operations import AnythingClientOperationsMixin + + +class AnythingClient(AnythingClientOperationsMixin): + """Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + + :param str base_url: Service URL + """ + + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: + if not base_url: + base_url = "http://localhost:3000" + self._config = AnythingClientConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {} # type: Dict[str, Any] + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + http_request.url = self._client.format_url(http_request.url) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AnythingClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py new file mode 100644 index 00000000000..b5720beca20 --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + + +class AnythingClientConfiguration(Configuration): + """Configuration for AnythingClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + """ + + def __init__(self, **kwargs: Any) -> None: + super(AnythingClientConfiguration, self).__init__(**kwargs) + + kwargs.setdefault("sdk_moniker", "anythingclient/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py new file mode 100644 index 00000000000..f8a033838cd --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._anything_client_operations import AnythingClientOperationsMixin + +__all__ = [ + "AnythingClientOperationsMixin", +] diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py new file mode 100644 index 00000000000..f2a0a078dfa --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py @@ -0,0 +1,278 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AnythingClientOperationsMixin: + @distributed_trace_async + async def get_object(self, **kwargs: Any) -> Any: + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_object.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace_async + async def put_object(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_object.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace_async + async def get_string(self, **kwargs: Any) -> Any: + """Basic get that returns an string as anything. Returns string 'foo'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_string.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace_async + async def put_string(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + :param input: Pass in 'anything' for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_string.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace_async + async def get_array(self, **kwargs: Any) -> Any: + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_array.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/anything/array"} # type: ignore + + @distributed_trace_async + async def put_array(self, input: Any, **kwargs: Any) -> None: + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_array.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/__init__.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/__init__.py new file mode 100644 index 00000000000..f8a033838cd --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/__init__.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._anything_client_operations import AnythingClientOperationsMixin + +__all__ = [ + "AnythingClientOperationsMixin", +] diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py b/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py new file mode 100644 index 00000000000..f076092a8fa --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/operations/_anything_client_operations.py @@ -0,0 +1,306 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar("T") + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + + +class AnythingClientOperationsMixin(object): + @distributed_trace + def get_object( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an object as anything. Returns object { 'message': 'An object was + successfully returned' }. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_object.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace + def put_object( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an object as anything. Pass in {'foo': 'bar'} to get a 200 and anything + else to get an object error. + + :param input: Pass in {'foo': 'bar'} for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_object.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_object.metadata = {"url": "/anything/object"} # type: ignore + + @distributed_trace + def get_string( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an string as anything. Returns string 'foo'. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_string.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace + def put_string( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an string as anything. Pass in 'anything' to get a 200 and anything else to + get an object error. + + :param input: Pass in 'anything' for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_string.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_string.metadata = {"url": "/anything/string"} # type: ignore + + @distributed_trace + def get_array( + self, **kwargs # type: Any + ): + # type: (...) -> Any + """Basic get that returns an array as anything. Returns string ['foo', 'bar']. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: any, or the result of cls(response) + :rtype: any + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop("cls", None) # type: ClsType[Any] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {})) + accept = "application/json" + + # Construct URL + url = self.get_array.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Accept"] = self._serialize.header("accept", accept, "str") + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize("object", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_array.metadata = {"url": "/anything/array"} # type: ignore + + @distributed_trace + def put_array( + self, + input, # type: Any + **kwargs # type: Any + ): + # type: (...) -> None + """Basic put that puts an array as anything. Pass in ['foo', 'bar'] to get a 200 and anything else + to get an object error. + + :param input: Pass in ['foo', 'bar'] for a 200, anything else for an object error. + :type input: any + :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", {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.put_array.metadata["url"] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters["Content-Type"] = self._serialize.header("content_type", content_type, "str") + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(input, "object") + body_content_kwargs["content"] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + put_array.metadata = {"url": "/anything/array"} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/anything/py.typed b/test/vanilla/Expected/AcceptanceTests/Anything/anything/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/anything/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/test/vanilla/Expected/AcceptanceTests/Anything/setup.py b/test/vanilla/Expected/AcceptanceTests/Anything/setup.py new file mode 100644 index 00000000000..aad55e23843 --- /dev/null +++ b/test/vanilla/Expected/AcceptanceTests/Anything/setup.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "anythingclient" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.21", "azure-core<2.0.0,>=1.8.2"] + +setup( + name=NAME, + version=VERSION, + description="AnythingClient", + author_email="", + url="", + keywords=["Swagger", "AnythingClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + Service client for testing basic anything types. Those schemas without types can be anything: primitive, object, array. + """, +) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py index 041c753c97c..ebf6ff74a6a 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py @@ -853,7 +853,7 @@ class SmartSalmon(Salmon): :type iswild: bool :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param college_degree: :type college_degree: str """ diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py index 4646b939579..8d72cee77d9 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -955,7 +955,7 @@ class SmartSalmon(Salmon): :type iswild: bool :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param college_degree: :type college_degree: str """ @@ -984,7 +984,7 @@ def __init__( siblings: Optional[List["Fish"]] = None, location: Optional[str] = None, iswild: Optional[bool] = None, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, college_degree: Optional[str] = None, **kwargs ): diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py index 196b00bc28a..ca2fed81527 100644 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py @@ -25,16 +25,16 @@ class ObjectTypeClientOperationsMixin: @distributed_trace_async - async def get(self, **kwargs: Any) -> object: + async def get(self, **kwargs: Any) -> Any: """Basic get that returns an object. Returns object { 'message': 'An object was successfully returned' }. :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[object] + cls = kwargs.pop("cls", None) # type: ClsType[Any] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -68,12 +68,12 @@ async def get(self, **kwargs: Any) -> object: get.metadata = {"url": "/objectType/get"} # type: ignore @distributed_trace_async - async def put(self, put_object: object, **kwargs: Any) -> None: + async def put(self, put_object: Any, **kwargs: Any) -> None: """Basic put that puts an object. Pass in {'foo': 'bar'} to get a 200 and anything else to get an object error. :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type put_object: object + :type put_object: any :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 diff --git a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py index 88eb0d2a785..d928abf0241 100644 --- a/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/ObjectType/objecttype/operations/_object_type_client_operations.py @@ -32,16 +32,16 @@ class ObjectTypeClientOperationsMixin(object): def get( self, **kwargs # type: Any ): - # type: (...) -> object + # type: (...) -> Any """Basic get that returns an object. Returns object { 'message': 'An object was successfully returned' }. :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[object] + cls = kwargs.pop("cls", None) # type: ClsType[Any] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -77,7 +77,7 @@ def get( @distributed_trace def put( self, - put_object, # type: object + put_object, # type: Any **kwargs # type: Any ): # type: (...) -> None @@ -85,7 +85,7 @@ def put( object error. :param put_object: Pass in {'foo': 'bar'} for a 200, anything else for an object error. - :type put_object: object + :type put_object: any :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 diff --git a/test/vanilla/requirements.txt b/test/vanilla/requirements.txt index 775eb49f962..e2474cf114c 100644 --- a/test/vanilla/requirements.txt +++ b/test/vanilla/requirements.txt @@ -7,6 +7,7 @@ msrest>=0.6.21 azure-core>=1.3.0 aiohttp;python_full_version>="3.5.2" -e ./Expected/AcceptanceTests/AdditionalProperties +-e ./Expected/AcceptanceTests/Anything -e ./Expected/AcceptanceTests/BodyArray -e ./Expected/AcceptanceTests/BodyBoolean -e ./Expected/AcceptanceTests/BodyByte