diff --git a/.gitignore b/.gitignore
index 993a7db887d..eeaf919596c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,7 +112,7 @@ venv.bak/
node_modules/
# autorest default folder
-generated
+/generated
**/code-model-v4-no-tags.yaml
# VS code
diff --git a/docs/client/initializing.md b/docs/client/initializing.md
index 13fc5b55846..cf19df88be3 100644
--- a/docs/client/initializing.md
+++ b/docs/client/initializing.md
@@ -15,7 +15,7 @@ Putting this together, we import our client like so:
from azure.pets import PetsClient
```
-### Dependencies of Your Client
+## Minimum Dependencies of Your Client
The only scenario the generated code can force dependencies is if you generate with a `setup.py` file using the `--basic-setup-py` flag.
The following are core libraries your generated code depend on, and the minimum version we highly recommend:
@@ -77,7 +77,6 @@ from azure.pets import PetsClient
client = PetsClient(credential=DefaultAzureCredential(), api_version="v1")
```
-
[multiapi_generation]: ../generate/multiapi.md
[azure_core_library]: https://pypi.org/project/azure-core/
diff --git a/docs/client/models.md b/docs/client/models.md
new file mode 100644
index 00000000000..d71e50aff1e
--- /dev/null
+++ b/docs/client/models.md
@@ -0,0 +1,29 @@
+#
Accessing Models and Enums
+
+## General
+
+Models and enums are generated in the `models` namespace. So, say you are using package `azure.pets`. To access model `Dog`, you would use the following code
+snippet
+
+```
+from azure.pets.models import Dog
+```
+
+Enums are also listed in the `models` namespace, so say you have enum class `DogTypes`. To access the `DALMATION` enum, your code would look like
+
+```
+from azure.pets.models import DogTypes
+
+my_dog_type = DogTypes.DALMATION
+```
+
+## Multi API
+
+There is also a `models` module in a multi API client. There, you can access the latest version of each models.
+
+If you want to access a specific API version's models, you can do so through the [`models()`][models_ex] class method we expose on the multi API client.
+It accepts optional parameter `api_version`. If specified, it will retrieve the models from that API version. Otherwise, retrieves models from the
+default API version the code was generated with.
+
+
+[models_ex]: https://github.com/Azure/autorest.python/blob/autorestv3/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py#L91
diff --git a/docs/client/operations.md b/docs/client/operations.md
index 53efbac7bf6..671129d0e7a 100644
--- a/docs/client/operations.md
+++ b/docs/client/operations.md
@@ -149,7 +149,7 @@ a pager that pages through the final lists of data.
[initializing]: ./initializing.md
[lro_poller]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
[custom_poller]: ../generate/directives.md#generate-with-a-custom-poller
-[example_swagger]: ../generate/examples/pollingPaging.json
+[example_swagger]: ../samples/specification/directives/pollingPaging.json
[poller_guidelines]: https://azure.github.io/azure-sdk/python_design.html#service-operations
[async_lro_poller]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.asynclropoller?view=azure-python
[item_paged]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.paging.itempaged?view=azure-python
diff --git a/docs/client/readme.md b/docs/client/readme.md
index 9afa9ad1690..e4130bba741 100644
--- a/docs/client/readme.md
+++ b/docs/client/readme.md
@@ -1,16 +1,17 @@
-#
Using the Python Client
+#
Using the Python Client
After [generating][generate] your client, this section tells you how to actually use your generated client.
* [Initializing Your Python Client][initializing]
* [Calling Operations with Your Python Client][operations]
+* [Accessing Models and Enums][models]
* [Error Handling][error_handling]
* [Tracing][tracing]
-* Dependencies Your Generated Code Has
[generate]: https://github.com/Azure/autorest/tree/master/docs/generate/readme.md
[initializing]: ./initializing.md
[operations]: ./operations.md
+[models]: ./models.md
[error_handling]: ./error_handling.md
[tracing]: ./tracing.md
\ No newline at end of file
diff --git a/docs/faq.md b/docs/faq.md
index e69de29bb2d..fd848ed4e0f 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -0,0 +1,19 @@
+#
FAQ
+
+1. What are the minimum dependencies?
+
+ The minimum dependencies are listed [here][min_dependencies]. This list will be continuously updated.
+
+2. What version of AutoRest Python should I use?
+
+ We highly recommend you use the latest AutoRest Python version published to [npm][autorest_npm]. The latest version
+ is the default if you use flag `--python`, though you may need to run an `autorest --reset` if it seems
+ the latest version is not being grabbed.
+
+ If you *really* want to use an older version of AutoRest Python,
+ you can specify the version with the flag `--use`, i.e. `--use=@autorest/python@5.x.x`.
+
+
+
+[min_dependencies]: ./client/initializing.md#minimum-dependencies-of-your-client
+[autorest_npm]: https://www.npmjs.com/package/@autorest/python
\ No newline at end of file
diff --git a/docs/generate/directives.md b/docs/generate/directives.md
index 0c4af9843b7..0d41c8854b8 100644
--- a/docs/generate/directives.md
+++ b/docs/generate/directives.md
@@ -1,6 +1,6 @@
#
Python-Specific Directives
-If you want to see how to generally use a directive to change AutoRest behavior, check out the [main docs](https://github.com/Azure/autorest/tree/master/docs/generate/directives.md). This section will go into the Python-specific directives.
+If you want to see how to generally use a directive to change AutoRest behavior, check out the [main docs][main_docs]. This section will go into the Python-specific directives.
These directives all start out with this general skeleton of a directive:
@@ -145,14 +145,14 @@ Here is the before and after of the generated code.
#
-We have put all of these Python-specific directives in a [config file][directive_readme] for you to refer to.
+For a full multiapi config example, see our [sample][sample_directives]
-
+[main_docs]: https://github.com/Azure/autorest/tree/master/docs/generate/directives.md
[lro_poller_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
[azure_core_pypi]: https://pypi.org/project/azure-core/
[async_lro_poller_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.asynclropoller?view=azure-python
-[polling_paging_swagger]: ./examples/pollingPaging.json
+[polling_paging_swagger]: ../samples/specification/directives/pollingPaging.json
[lro_base_polling_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.base_polling.lrobasepolling?view=azure-python
[async_lro_base_polling_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.async_base_polling.asynclrobasepolling?view=azure-python
@@ -163,3 +163,4 @@ We have put all of these Python-specific directives in a [config file][directive
[item_paged_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.paging.itempaged?view=azure-python
[async_item_paged_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.async_paging.asyncitempaged?view=azure-python
+[sample_directives]: ../samples/specification/directives/readme.md
diff --git a/docs/generate/examples/multiapi/readme.md b/docs/generate/examples/multiapi/readme.md
deleted file mode 100644
index 2e6644ba028..00000000000
--- a/docs/generate/examples/multiapi/readme.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generate Pets in Python with Multi API
-
-### General settings
-
-```yaml
-python: true
-package-name: azure-pets
-```
-
-### Multi API generation
-
-These settings apply only when `--multiapi` is specified on the command line.
-
-```yaml $(multiapi)
-batch:
- - tag: v1
- - tag: v2
- - multiapiscript: true
-```
-
-### Multi API script
-
-```yaml $(multiapiscript)
-output-folder: $(python-sdks-folder)/pets/azure-pets/azure/pets
-perform-load: false
-clear-output-folder: false
-```
-
-### Tag: v1
-
-These settings apply only when `--tag=v1` is specified on the command line.
-
-```yaml $(tag) == 'v1'
-input-file: pets.json
-namespace: azure.pets.v1
-output-folder: $(python-sdks-folder)/pets/azure-pets/azure/pets/v1
-```
-
-### Tag: v2
-
-These settings apply only when `--tag=v2` is specified on the command line.
-
-```yaml $(tag) == 'v2'
-input-file: petsv2.json
-namespace: azure.pets.v2
-output-folder: $(python-sdks-folder)/pets/azure-pets/azure/pets/v2
-```
diff --git a/docs/generate/multiapi.md b/docs/generate/multiapi.md
index d3429a504b4..4a212d9723c 100644
--- a/docs/generate/multiapi.md
+++ b/docs/generate/multiapi.md
@@ -1,8 +1,8 @@
-#
Generating a Multi API Python Client with AutoRest
+#
Generating a Multi API Python Client with AutoRest
If you want to generate one client that handles multiple API versions (a common use-case for this is supporting multiple Azure clouds, since a service's API versions can differ between them), this is the section for you. Python is the only language that supports this, hence why these docs are in the Python-specific section.
-Before getting into the multiapi specific sections that need to be added to your readme, you need to make sure you have a tag set up for every single API version you want to generate. See the ["Adding Tags When Generating"](https://github.com/Azure/autorest/tree/master/docs/generate/readme.md#adding-tags-when-generating) docs to find out how to set this up. Following the [main example]((https://github.com/Azure/autorest/tree/master/docs/generate/examples/tags/readme.md), this example will suppose you're generating 2 different API versions: `v1` and `v2`.
+Before getting into the multiapi specific sections that need to be added to your readme, you need to make sure you have a tag set up for every single API version you want to generate. See the ["Adding Tags When Generating"][tags] docs to find out how to set this up. In this example we will s generate 3 different API versions: `v1`, `v2`, and `v3`.
The flag you use on the command line to specify you want multiapi code generation is `--multiapi`. Thus, we need to add a `multiapi` specific section to our readme.
Let's add it underneath `General Settings` to keep it to the top of our readme
@@ -25,6 +25,8 @@ These settings apply only when `--multiapi` is specified on the command line.
batch:
- tag: v1
- tag: v2
+ - tag: v3
+ - multiapiscript: true
```
````
@@ -35,10 +37,10 @@ of your config. Users should never specify `multiapiscript` on the command line,
file to let AutoRest know it has to run its multiapi script.
````
-```yaml $(multiapiscript)
-output-folder: $(python-sdks-folder)/pets/azure-pets/azure/pets
-perform-load: false
+``` yaml $(multiapiscript)
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample
clear-output-folder: false
+perform-load: false
```
````
@@ -62,8 +64,13 @@ These settings apply only when `--multiapi` is specified on the command line.
batch:
- tag: v1
- tag: v2
+ - tag: v3
- multiapiscript: true
```
````
-And that's it! We've included the final config file in our [examples folder](./examples/multiapi/readme.md), please feel free to refer to this.
\ No newline at end of file
+And that's it! We've included the final config file in our [samples folder][samples], please feel free to refer to this.
+
+
+[tags]: https://github.com/Azure/autorest/tree/master/docs/generate/readme.md#adding-tags-when-generating
+[samples]: ../samples/specification/multiapi/readme.md
\ No newline at end of file
diff --git a/docs/generate/readme.md b/docs/generate/readme.md
index baf312f0fdb..45b529d5c87 100644
--- a/docs/generate/readme.md
+++ b/docs/generate/readme.md
@@ -1,4 +1,4 @@
-#
Generating Python Clients with AutoRest
+#
Generating Python Clients with AutoRest
Most of the information you'll need to generate a Python client can be found in the general docs [here][general]. In these docs, we go over a couple Python-specific scenarios.
diff --git a/docs/migrate/readme.md b/docs/migrate/readme.md
index d7cb1ffcb1c..7cbe8ab4b9b 100644
--- a/docs/migrate/readme.md
+++ b/docs/migrate/readme.md
@@ -1,10 +1,8 @@
#
Migrating to Latest AutoRest
-## Generating Changes
+See the [main docs][main_docs] for changes in versioning and flags, this section focuses on how the generated code differs.
-## Generated Code
-
-### Breaking Changes
+## Breaking Changes
* The credential system has been completely revamped:
- Previously we had used `azure.common.credentials` or `msrestazure.azure_active_directory` instances, which
@@ -21,7 +19,7 @@ tell AutoRest during generation time to keep the current version file in the dir
- `raw` has been removed. We now use `cls`, which is a callback that gives access to the internal HTTP response for advanced users.
- For a complete set of supported options, see the [acceptable parameters to operations in azure-core][azure_core_operation_parameters].
-### New Features
+## New Features
* Type annotations using the standard `typing` library. SDKs are [`mypy`][mypy] ready!
* This client has stable and official support for async. Look in the `aio` namespace of your generated package to find the async client.
@@ -30,11 +28,12 @@ code for this, and you can see our [tracing docs][tracing_docs] for more informa
+[main_docs]: https://github.com/Azure/autorest/blob/master/docs/migrate/readme.md
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#credentials
[azure_key_credential]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.credentials.azurekeycredential?view=azure-python
[azure_core_library]: https://pypi.org/project/azure-core/
[azure_core_init_parameters]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies
-[flag_index]: https://github.com/Azure/autorest/blob/new_docs/docs/generate/flags.md
+[flag_index]: https://github.com/Azure/autorest/blob/master/docs/generate/flags.md
[lro_poller_docs]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
[http_response_error]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.exceptions.httpresponseerror?view=azure-python
[azure_core_operation_parameters]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies
diff --git a/docs/readme.md b/docs/readme.md
index 608894a9a7a..0a164a9de49 100644
--- a/docs/readme.md
+++ b/docs/readme.md
@@ -1,6 +1,6 @@
# AutoRest Python Documentation
-These documents are Python-specific, see [our main docs](https://github.com/Azure/autorest/tree/master/docs) for more general information
+These documents are Python-specific, see [our main docs][main_docs] for more general information
1. Generating Python Clients with AutoRest
@@ -13,14 +13,17 @@ These documents are Python-specific, see [our main docs](https://github.com/Azur
- I have old generated code using the previous version of AutoRest. How do I upgrade my code? Main docs [here][main_migrate], Python-specific docs [here][python_migrate]
4. Developing with AutoRest
- - How do I generate or contribute to AutoRest in [dev mode](./developer/readme.md)? Main docs [here][main_dev]
+ - How do I generate or contribute to AutoRest in [dev mode][python_dev] Main docs [here][main_dev]
5. Samples
- - [Sample](./samples/readme.md) readmes and generated code for common scenarios.
+ - [Sample][sample] readmes and generated code for common scenarios.
-6. [FAQ](./faq.md)
+6. [FAQ][faq]
+
+7. [Troubleshooting][troubleshooting]
+[main_docs]: https://github.com/Azure/autorest/tree/master/docs
[main_generate]: https://github.com/Azure/autorest/tree/master/docs/generate/readme.md
[python_generate]: ./generate/readme.md
[python_client]: ./client/readme.md
@@ -28,4 +31,7 @@ These documents are Python-specific, see [our main docs](https://github.com/Azur
[main_migrate]: https://github.com/Azure/autorest/tree/master/docs/migrate/readme.md
[python_migrate]: ./migrate/readme.md
[python_dev]: ./developer/readme.md
-[main_dev]: https://github.com/Azure/autorest/tree/master/docs/dev/readme.md
\ No newline at end of file
+[main_dev]: https://github.com/Azure/autorest/tree/master/docs/dev/readme.md
+[sample]: ./samples/readme.md
+[faq]: ./faq.md
+[trobleshooting]: ./troubleshooting.md
\ No newline at end of file
diff --git a/docs/samples/readme.md b/docs/samples/readme.md
index e69de29bb2d..23291aed850 100644
--- a/docs/samples/readme.md
+++ b/docs/samples/readme.md
@@ -0,0 +1,20 @@
+#
Sample Python Generation
+
+Here are our samples for common generation scenarios
+
+
+| Scenario | README | Generated Code
+|------------------|-------------|-------------
+|Generating [management plane][mgmt] | [readme.md][mgmt_readme] | [generated][mgmt_generated]
+|Generating multi API code | [readme.md][multiapi_readme] | [generated][multiapi_generated]
+|Generating with [`AzureKeyCredential`][azure_key_credential] | [readme.md][azure_key_credential_readme] | [generated][azure_key_credential_generated]
+
+
+[mgmt]: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/control-plane-and-data-plane#control-plane
+[mgmt_readme]: ./specification/management/readme.md
+[mgmt_generated]: ./specification/management/generated
+[multiapi_readme]: ./specification/multiapi/readme.md
+[multiapi_generated]: ./specification/multiapi/generated
+[azure_key_credential]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.credentials.azurekeycredential?view=azure-python
+[azure_key_credential_readme]: ./specification/azure_key_credential/readme.md
+[azure_key_credential_generated]: ./specification/azure_key_credential/generated
\ No newline at end of file
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/__init__.py
new file mode 100644
index 00000000000..78354a67f97
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/__init__.py
@@ -0,0 +1,19 @@
+# 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 ._auto_rest_head_test_service import AutoRestHeadTestService
+from ._version import VERSION
+
+__version__ = VERSION
+__all__ = ['AutoRestHeadTestService']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..996c6764c2a
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_auto_rest_head_test_service.py
@@ -0,0 +1,65 @@
+# 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.credentials import AzureKeyCredential
+
+from ._configuration import AutoRestHeadTestServiceConfiguration
+from .operations import HttpSuccessOperations
+
+
+class AutoRestHeadTestService(object):
+ """Test Infrastructure for AutoRest.
+
+ :ivar http_success: HttpSuccessOperations operations
+ :vartype http_success: azure.key.credential.sample.operations.HttpSuccessOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.AzureKeyCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential, # type: AzureKeyCredential
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(credential, **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)
+
+ self.http_success = HttpSuccessOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> AutoRestHeadTestService
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_configuration.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_configuration.py
new file mode 100644
index 00000000000..f74e87271c3
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_configuration.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 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
+
+ from azure.core.credentials import AzureKeyCredential
+
+
+class AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.AzureKeyCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: AzureKeyCredential
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ kwargs.setdefault('sdk_moniker', 'key-credential-sample/{}'.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')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AzureKeyCredentialPolicy(self.credential, 'Ocp-Apim-Subscription-Key', **kwargs)
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_version.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_version.py
new file mode 100644
index 00000000000..eae7c95b6fb
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_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/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/__init__.py
new file mode 100644
index 00000000000..6e499e6a6b1
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._auto_rest_head_test_service import AutoRestHeadTestService
+__all__ = ['AutoRestHeadTestService']
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..ba0901645e4
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_auto_rest_head_test_service.py
@@ -0,0 +1,60 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, Optional, TYPE_CHECKING
+
+from azure.core import AsyncPipelineClient
+from azure.core.credentials import AzureKeyCredential
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Dict
+
+from ._configuration import AutoRestHeadTestServiceConfiguration
+from .operations import HttpSuccessOperations
+
+
+class AutoRestHeadTestService(object):
+ """Test Infrastructure for AutoRest.
+
+ :ivar http_success: HttpSuccessOperations operations
+ :vartype http_success: azure.key.credential.sample.aio.operations.HttpSuccessOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.AzureKeyCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential: AzureKeyCredential,
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(credential, **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)
+
+ self.http_success = HttpSuccessOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "AutoRestHeadTestService":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_configuration.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_configuration.py
new file mode 100644
index 00000000000..820b1bfb1de
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/_configuration.py
@@ -0,0 +1,55 @@
+# 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.credentials import AzureKeyCredential
+from azure.core.pipeline import policies
+
+from .._version import VERSION
+
+
+class AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.AzureKeyCredential
+ """
+
+ def __init__(
+ self,
+ credential: AzureKeyCredential,
+ **kwargs: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ kwargs.setdefault('sdk_moniker', 'key-credential-sample/{}'.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')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AzureKeyCredentialPolicy(self.credential, 'Ocp-Apim-Subscription-Key', **kwargs)
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/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 ._http_success_operations import HttpSuccessOperations
+
+__all__ = [
+ 'HttpSuccessOperations',
+]
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py
new file mode 100644
index 00000000000..9092065ba58
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/aio/operations/_http_success_operations.py
@@ -0,0 +1,151 @@
+# 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
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class HttpSuccessOperations:
+ """HttpSuccessOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def head200(
+ self,
+ **kwargs
+ ) -> None:
+ """Return 200 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head200.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head200.metadata = {'url': '/http/success/200'} # type: ignore
+
+ async def head204(
+ self,
+ **kwargs
+ ) -> None:
+ """Return 204 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head204.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head204.metadata = {'url': '/http/success/204'} # type: ignore
+
+ async def head404(
+ self,
+ **kwargs
+ ) -> None:
+ """Return 404 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head404.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head404.metadata = {'url': '/http/success/404'} # type: ignore
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/__init__.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/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 ._http_success_operations import HttpSuccessOperations
+
+__all__ = [
+ 'HttpSuccessOperations',
+]
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py
new file mode 100644
index 00000000000..389b8e00ddf
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/operations/_http_success_operations.py
@@ -0,0 +1,158 @@
+# 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
+
+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 HttpSuccessOperations(object):
+ """HttpSuccessOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def head200(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """Return 200 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head200.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head200.metadata = {'url': '/http/success/200'} # type: ignore
+
+ def head204(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """Return 204 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head204.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head204.metadata = {'url': '/http/success/204'} # type: ignore
+
+ def head404(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """Return 404 status code if successful.
+
+ :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', {}))
+
+ # Construct URL
+ url = self.head404.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ head404.metadata = {'url': '/http/success/404'} # type: ignore
diff --git a/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/py.typed b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/azure/key/credential/sample/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/azure_key_credential/generated/setup.py b/docs/samples/specification/azure_key_credential/generated/setup.py
new file mode 100644
index 00000000000..55d98e4ad39
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/generated/setup.py
@@ -0,0 +1,37 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+# coding: utf-8
+
+from setuptools import setup, find_packages
+
+NAME = "azure-key-credential-sample"
+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.18", "azure-core<2.0.0,>=1.8.2"]
+
+setup(
+ name=NAME,
+ version=VERSION,
+ description="azure-key-credential-sample",
+ author_email="",
+ url="",
+ keywords=["Swagger", "AutoRestHeadTestService"],
+ install_requires=REQUIRES,
+ packages=find_packages(),
+ include_package_data=True,
+ long_description="""\
+ Test Infrastructure for AutoRest.
+ """
+)
diff --git a/docs/samples/specification/azure_key_credential/readme.md b/docs/samples/specification/azure_key_credential/readme.md
new file mode 100644
index 00000000000..79df4102563
--- /dev/null
+++ b/docs/samples/specification/azure_key_credential/readme.md
@@ -0,0 +1,21 @@
+# Sample Azure Key Credential Generation
+
+Use the flags `--credential-default-policy-type` and `--credential-key-header-name` to specify you want your credential to be of type [`AzureKeyCredential`][azure_key_credential].
+
+### Settings
+
+``` yaml
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/head.json
+namespace: azure.key.credential.sample
+package-name: azure-key-credential-sample
+license-header: MICROSOFT_MIT_NO_VERSION
+credential-default-policy-type: AzureKeyCredentialPolicy
+credential-key-header-name: Ocp-Apim-Subscription-Key
+add-credential: true
+package-version: 0.1.0
+basic-setup-py: true
+clear-output-folder: true
+```
+
+
+[azure_key_credential]: https://docs.microsoft.com/en-us/python/api/azure-core/azure.core.credentials.azurekeycredential?view=azure-python
diff --git a/docs/samples/specification/directives/generated/azure/__init__.py b/docs/samples/specification/directives/generated/azure/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/directives/generated/azure/directives/__init__.py b/docs/samples/specification/directives/generated/azure/directives/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/__init__.py
new file mode 100644
index 00000000000..36835e327f2
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/__init__.py
@@ -0,0 +1,19 @@
+# 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 ._polling_paging_example import PollingPagingExample
+from ._version import VERSION
+
+__version__ = VERSION
+__all__ = ['PollingPagingExample']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_configuration.py b/docs/samples/specification/directives/generated/azure/directives/sample/_configuration.py
new file mode 100644
index 00000000000..54d68458231
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/_configuration.py
@@ -0,0 +1,51 @@
+# 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 PollingPagingExampleConfiguration(Configuration):
+ """Configuration for PollingPagingExample.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+ """
+
+ def __init__(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ super(PollingPagingExampleConfiguration, self).__init__(**kwargs)
+
+ kwargs.setdefault('sdk_moniker', 'directives-sample/{}'.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/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py b/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py
new file mode 100644
index 00000000000..3ed8cb87f56
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/_polling_paging_example.py
@@ -0,0 +1,58 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from 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, Optional
+
+from ._configuration import PollingPagingExampleConfiguration
+from .operations import PollingPagingExampleOperationsMixin
+from . import models
+
+
+class PollingPagingExample(PollingPagingExampleOperationsMixin):
+ """Show polling and paging generation.
+
+ :param str base_url: Service URL
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ 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 = PollingPagingExampleConfiguration(**kwargs)
+ self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> PollingPagingExample
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/_version.py b/docs/samples/specification/directives/generated/azure/directives/sample/_version.py
new file mode 100644
index 00000000000..eae7c95b6fb
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/_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/docs/samples/specification/directives/generated/azure/directives/sample/aio/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/__init__.py
new file mode 100644
index 00000000000..f7c698ceca1
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._polling_paging_example import PollingPagingExample
+__all__ = ['PollingPagingExample']
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/aio/_configuration.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_configuration.py
new file mode 100644
index 00000000000..f48b2dc0827
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_configuration.py
@@ -0,0 +1,45 @@
+# 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 PollingPagingExampleConfiguration(Configuration):
+ """Configuration for PollingPagingExample.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+ """
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None:
+ super(PollingPagingExampleConfiguration, self).__init__(**kwargs)
+
+ kwargs.setdefault('sdk_moniker', 'directives-sample/{}'.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/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py
new file mode 100644
index 00000000000..4aa6e26b1b5
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/_polling_paging_example.py
@@ -0,0 +1,50 @@
+# 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
+
+from azure.core import AsyncPipelineClient
+from msrest import Deserializer, Serializer
+
+from ._configuration import PollingPagingExampleConfiguration
+from .operations import PollingPagingExampleOperationsMixin
+from .. import models
+
+
+class PollingPagingExample(PollingPagingExampleOperationsMixin):
+ """Show polling and paging generation.
+
+ :param str base_url: Service URL
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ def __init__(
+ self,
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = PollingPagingExampleConfiguration(**kwargs)
+ self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "PollingPagingExample":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/__init__.py
new file mode 100644
index 00000000000..6dfd474c534
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/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 ._polling_paging_example_operations import PollingPagingExampleOperationsMixin
+
+__all__ = [
+ 'PollingPagingExampleOperationsMixin',
+]
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py b/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py
new file mode 100644
index 00000000000..236c642a59e
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/aio/operations/_polling_paging_example_operations.py
@@ -0,0 +1,190 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
+import warnings
+
+from azure.core.async_paging import AsyncList
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.core.polling import AsyncNoPolling, AsyncPollingMethod
+from azure.core.polling.async_base_polling import AsyncLROBasePolling
+from my.library.aio import AsyncCustomPager, AsyncCustomPoller
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class PollingPagingExampleOperationsMixin:
+
+ async def _basic_polling_initial(
+ self,
+ product: Optional["_models.Product"] = None,
+ **kwargs
+ ) -> Optional["_models.Product"]:
+ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Product"]]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self._basic_polling_initial.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')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if product is not None:
+ body_content = self._serialize.body(product, 'Product')
+ else:
+ body_content = None
+ 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, 204]:
+ 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)
+
+ deserialized = None
+ if response.status_code == 200:
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _basic_polling_initial.metadata = {'url': '/directives/polling'} # type: ignore
+
+ async def begin_basic_polling(
+ self,
+ product: Optional["_models.Product"] = None,
+ **kwargs
+ ) -> AsyncCustomPoller["_models.Product"]:
+ """A simple polling operation.
+
+ :param product: Product to put.
+ :type product: ~azure.directives.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of AsyncCustomPoller that returns either Product or the result of cls(response)
+ :rtype: ~my.library.aio.AsyncCustomPoller[~azure.directives.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = await self._basic_polling_initial(
+ product=product,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+
+ def get_long_running_output(pipeline_response):
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+ return deserialized
+
+ if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = AsyncNoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return AsyncCustomPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ else:
+ return AsyncCustomPoller(self._client, raw_result, get_long_running_output, polling_method)
+ begin_basic_polling.metadata = {'url': '/directives/polling'} # type: ignore
+
+ def basic_paging(
+ self,
+ **kwargs
+ ) -> AsyncIterable["_models.ProductResult"]:
+ """A simple paging operation.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either ProductResult or the result of cls(response)
+ :rtype: ~my.library.aio.AsyncCustomPager[~azure.directives.sample.models.ProductResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.basic_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.get(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ async def extract_data(pipeline_response):
+ deserialized = self._deserialize('ProductResult', pipeline_response)
+ list_of_elem = deserialized.value
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, AsyncList(list_of_elem)
+
+ async def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ return pipeline_response
+
+ return AsyncCustomPager(
+ get_next, extract_data
+ )
+ basic_paging.metadata = {'url': '/directives/paging'} # type: ignore
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/models/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/models/__init__.py
new file mode 100644
index 00000000000..71b6a02cf35
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/models/__init__.py
@@ -0,0 +1,25 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+try:
+ from ._models_py3 import Error
+ from ._models_py3 import Product
+ from ._models_py3 import ProductProperties
+ from ._models_py3 import ProductResult
+except (SyntaxError, ImportError):
+ from ._models import Error # type: ignore
+ from ._models import Product # type: ignore
+ from ._models import ProductProperties # type: ignore
+ from ._models import ProductResult # type: ignore
+
+__all__ = [
+ 'Error',
+ 'Product',
+ 'ProductProperties',
+ 'ProductResult',
+]
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/models/_models.py b/docs/samples/specification/directives/generated/azure/directives/sample/models/_models.py
new file mode 100644
index 00000000000..cfbd53c9c4d
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/models/_models.py
@@ -0,0 +1,98 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = kwargs.get('status', None)
+ self.message = kwargs.get('message', None)
+
+
+class Product(msrest.serialization.Model):
+ """Product.
+
+ :param properties:
+ :type properties: ~azure.directives.sample.models.ProductProperties
+ """
+
+ _attribute_map = {
+ 'properties': {'key': 'properties', 'type': 'ProductProperties'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Product, self).__init__(**kwargs)
+ self.properties = kwargs.get('properties', None)
+
+
+class ProductProperties(msrest.serialization.Model):
+ """ProductProperties.
+
+ :param id:
+ :type id: int
+ :param name:
+ :type name: str
+ """
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ 'name': {'key': 'name', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(ProductProperties, self).__init__(**kwargs)
+ self.id = kwargs.get('id', None)
+ self.name = kwargs.get('name', None)
+
+
+class ProductResult(msrest.serialization.Model):
+ """ProductResult.
+
+ :param value:
+ :type value: list[~azure.directives.sample.models.Product]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'value': {'key': 'value', 'type': '[Product]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(ProductResult, self).__init__(**kwargs)
+ self.value = kwargs.get('value', None)
+ self.next_link = kwargs.get('next_link', None)
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/models/_models_py3.py b/docs/samples/specification/directives/generated/azure/directives/sample/models/_models_py3.py
new file mode 100644
index 00000000000..5f7fb807c1a
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/models/_models_py3.py
@@ -0,0 +1,111 @@
+# 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 List, Optional
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ status: Optional[int] = None,
+ message: Optional[str] = None,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = status
+ self.message = message
+
+
+class Product(msrest.serialization.Model):
+ """Product.
+
+ :param properties:
+ :type properties: ~azure.directives.sample.models.ProductProperties
+ """
+
+ _attribute_map = {
+ 'properties': {'key': 'properties', 'type': 'ProductProperties'},
+ }
+
+ def __init__(
+ self,
+ *,
+ properties: Optional["ProductProperties"] = None,
+ **kwargs
+ ):
+ super(Product, self).__init__(**kwargs)
+ self.properties = properties
+
+
+class ProductProperties(msrest.serialization.Model):
+ """ProductProperties.
+
+ :param id:
+ :type id: int
+ :param name:
+ :type name: str
+ """
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ 'name': {'key': 'name', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ id: Optional[int] = None,
+ name: Optional[str] = None,
+ **kwargs
+ ):
+ super(ProductProperties, self).__init__(**kwargs)
+ self.id = id
+ self.name = name
+
+
+class ProductResult(msrest.serialization.Model):
+ """ProductResult.
+
+ :param value:
+ :type value: list[~azure.directives.sample.models.Product]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'value': {'key': 'value', 'type': '[Product]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ value: Optional[List["Product"]] = None,
+ next_link: Optional[str] = None,
+ **kwargs
+ ):
+ super(ProductResult, self).__init__(**kwargs)
+ self.value = value
+ self.next_link = next_link
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/operations/__init__.py b/docs/samples/specification/directives/generated/azure/directives/sample/operations/__init__.py
new file mode 100644
index 00000000000..6dfd474c534
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/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 ._polling_paging_example_operations import PollingPagingExampleOperationsMixin
+
+__all__ = [
+ 'PollingPagingExampleOperationsMixin',
+]
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py b/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py
new file mode 100644
index 00000000000..e88542a917c
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/operations/_polling_paging_example_operations.py
@@ -0,0 +1,196 @@
+# 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.polling import NoPolling, PollingMethod
+from azure.core.polling.base_polling import LROBasePolling
+from my.library import CustomPager, CustomPoller
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class PollingPagingExampleOperationsMixin(object):
+
+ def _basic_polling_initial(
+ self,
+ product=None, # type: Optional["_models.Product"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> Optional["_models.Product"]
+ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Product"]]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self._basic_polling_initial.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')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if product is not None:
+ body_content = self._serialize.body(product, 'Product')
+ else:
+ body_content = None
+ 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, 204]:
+ 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)
+
+ deserialized = None
+ if response.status_code == 200:
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _basic_polling_initial.metadata = {'url': '/directives/polling'} # type: ignore
+
+ def begin_basic_polling(
+ self,
+ product=None, # type: Optional["_models.Product"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> CustomPoller["_models.Product"]
+ """A simple polling operation.
+
+ :param product: Product to put.
+ :type product: ~azure.directives.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.PollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of CustomPoller that returns either Product or the result of cls(response)
+ :rtype: ~my.library.CustomPoller[~azure.directives.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = self._basic_polling_initial(
+ product=product,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+
+ def get_long_running_output(pipeline_response):
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+ return deserialized
+
+ if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = NoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return CustomPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ else:
+ return CustomPoller(self._client, raw_result, get_long_running_output, polling_method)
+ begin_basic_polling.metadata = {'url': '/directives/polling'} # type: ignore
+
+ def basic_paging(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> Iterable["_models.ProductResult"]
+ """A simple paging operation.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either ProductResult or the result of cls(response)
+ :rtype: ~my.library.CustomPager[~azure.directives.sample.models.ProductResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.basic_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.get(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ def extract_data(pipeline_response):
+ deserialized = self._deserialize('ProductResult', pipeline_response)
+ list_of_elem = deserialized.value
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, iter(list_of_elem)
+
+ def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response)
+
+ return pipeline_response
+
+ return CustomPager(
+ get_next, extract_data
+ )
+ basic_paging.metadata = {'url': '/directives/paging'} # type: ignore
diff --git a/docs/samples/specification/directives/generated/azure/directives/sample/py.typed b/docs/samples/specification/directives/generated/azure/directives/sample/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/directives/generated/azure/directives/sample/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/directives/generated/setup.py b/docs/samples/specification/directives/generated/setup.py
new file mode 100644
index 00000000000..22e328c1d0f
--- /dev/null
+++ b/docs/samples/specification/directives/generated/setup.py
@@ -0,0 +1,37 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+# coding: utf-8
+
+from setuptools import setup, find_packages
+
+NAME = "azure-directives-sample"
+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.18", "azure-core<2.0.0,>=1.8.2"]
+
+setup(
+ name=NAME,
+ version=VERSION,
+ description="azure-directives-sample",
+ author_email="",
+ url="",
+ keywords=["Swagger", "PollingPagingExample"],
+ install_requires=REQUIRES,
+ packages=find_packages(),
+ include_package_data=True,
+ long_description="""\
+ Show polling and paging generation.
+ """
+)
diff --git a/docs/generate/examples/pollingPaging.json b/docs/samples/specification/directives/pollingPaging.json
similarity index 100%
rename from docs/generate/examples/pollingPaging.json
rename to docs/samples/specification/directives/pollingPaging.json
diff --git a/docs/generate/examples/directives/readme.md b/docs/samples/specification/directives/readme.md
similarity index 88%
rename from docs/generate/examples/directives/readme.md
rename to docs/samples/specification/directives/readme.md
index 7feb55fab4e..bdcc118b2e0 100644
--- a/docs/generate/examples/directives/readme.md
+++ b/docs/samples/specification/directives/readme.md
@@ -1,16 +1,14 @@
-# Python-Specific Directives
+# Sample Directives Generation
### Settings
``` yaml
input-file: pollingPaging.json
-namespace: python.directives
-package-name: python-directives
-output-folder: $(python-sdks-folder)/directives/python-directives
+namespace: azure.directives.sample
+package-name: azure-directives-sample
license-header: MICROSOFT_MIT_NO_VERSION
package-version: 0.1.0
basic-setup-py: true
-output-artifact: code-model-v4-no-tags
clear-output-folder: true
```
diff --git a/docs/samples/specification/management/generated/azure/__init__.py b/docs/samples/specification/management/generated/azure/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/management/generated/azure/mgmt/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/__init__.py
@@ -0,0 +1 @@
+__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
\ No newline at end of file
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/__init__.py
new file mode 100644
index 00000000000..78354a67f97
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/__init__.py
@@ -0,0 +1,19 @@
+# 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 ._auto_rest_head_test_service import AutoRestHeadTestService
+from ._version import VERSION
+
+__version__ = VERSION
+__all__ = ['AutoRestHeadTestService']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..2bfa59d003b
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_auto_rest_head_test_service.py
@@ -0,0 +1,65 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.mgmt.core import ARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Dict, Optional
+
+ from azure.core.credentials import TokenCredential
+
+from ._configuration import AutoRestHeadTestServiceConfiguration
+from .operations import HttpSuccessOperations
+
+
+class AutoRestHeadTestService(object):
+ """Test Infrastructure for AutoRest.
+
+ :ivar http_success: HttpSuccessOperations operations
+ :vartype http_success: azure.mgmt.sample.operations.HttpSuccessOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs)
+ self._client = ARMPipelineClient(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)
+
+ self.http_success = HttpSuccessOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> AutoRestHeadTestService
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_configuration.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_configuration.py
new file mode 100644
index 00000000000..50435ea2160
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_configuration.py
@@ -0,0 +1,64 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+from ._version import VERSION
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any
+
+ from azure.core.credentials import TokenCredential
+
+
+class AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'mgmt-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/_version.py b/docs/samples/specification/management/generated/azure/mgmt/sample/_version.py
new file mode 100644
index 00000000000..eae7c95b6fb
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/_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/docs/samples/specification/management/generated/azure/mgmt/sample/aio/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/__init__.py
new file mode 100644
index 00000000000..6e499e6a6b1
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._auto_rest_head_test_service import AutoRestHeadTestService
+__all__ = ['AutoRestHeadTestService']
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..5d5f571ef4b
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_auto_rest_head_test_service.py
@@ -0,0 +1,61 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, Optional, TYPE_CHECKING
+
+from azure.mgmt.core import AsyncARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Dict
+
+ from azure.core.credentials_async import AsyncTokenCredential
+
+from ._configuration import AutoRestHeadTestServiceConfiguration
+from .operations import HttpSuccessOperations
+
+
+class AutoRestHeadTestService(object):
+ """Test Infrastructure for AutoRest.
+
+ :ivar http_success: HttpSuccessOperations operations
+ :vartype http_success: azure.mgmt.sample.aio.operations.HttpSuccessOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(credential, **kwargs)
+ self._client = AsyncARMPipelineClient(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)
+
+ self.http_success = HttpSuccessOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "AutoRestHeadTestService":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_configuration.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_configuration.py
new file mode 100644
index 00000000000..1a442bb3934
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/_configuration.py
@@ -0,0 +1,60 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+from .._version import VERSION
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+
+class AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ **kwargs: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'mgmt-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs: Any
+ ) -> None:
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/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 ._http_success_operations import HttpSuccessOperations
+
+__all__ = [
+ 'HttpSuccessOperations',
+]
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py
new file mode 100644
index 00000000000..f68d65949b0
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/aio/operations/_http_success_operations.py
@@ -0,0 +1,155 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class HttpSuccessOperations:
+ """HttpSuccessOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def head200(
+ self,
+ **kwargs
+ ) -> bool:
+ """Return 200 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head200.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head200.metadata = {'url': '/http/success/200'} # type: ignore
+
+ async def head204(
+ self,
+ **kwargs
+ ) -> bool:
+ """Return 204 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head204.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head204.metadata = {'url': '/http/success/204'} # type: ignore
+
+ async def head404(
+ self,
+ **kwargs
+ ) -> bool:
+ """Return 404 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head404.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head404.metadata = {'url': '/http/success/404'} # type: ignore
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/operations/__init__.py b/docs/samples/specification/management/generated/azure/mgmt/sample/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/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 ._http_success_operations import HttpSuccessOperations
+
+__all__ = [
+ 'HttpSuccessOperations',
+]
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py b/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py
new file mode 100644
index 00000000000..0cbc538c44d
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/operations/_http_success_operations.py
@@ -0,0 +1,162 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+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 HttpSuccessOperations(object):
+ """HttpSuccessOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def head200(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> bool
+ """Return 200 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head200.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head200.metadata = {'url': '/http/success/200'} # type: ignore
+
+ def head204(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> bool
+ """Return 204 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head204.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head204.metadata = {'url': '/http/success/204'} # type: ignore
+
+ def head404(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> bool
+ """Return 404 status code if successful.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: bool, or the result of cls(response)
+ :rtype: bool
+ :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', {}))
+
+ # Construct URL
+ url = self.head404.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.head(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 [204, 404]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ return 200 <= response.status_code <= 299
+ head404.metadata = {'url': '/http/success/404'} # type: ignore
diff --git a/docs/samples/specification/management/generated/azure/mgmt/sample/py.typed b/docs/samples/specification/management/generated/azure/mgmt/sample/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/management/generated/azure/mgmt/sample/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/management/generated/setup.py b/docs/samples/specification/management/generated/setup.py
new file mode 100644
index 00000000000..99f370cfcc1
--- /dev/null
+++ b/docs/samples/specification/management/generated/setup.py
@@ -0,0 +1,37 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+# coding: utf-8
+
+from setuptools import setup, find_packages
+
+NAME = "azure-mgmt-sample"
+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.18", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"]
+
+setup(
+ name=NAME,
+ version=VERSION,
+ description="azure-mgmt-sample",
+ author_email="",
+ url="",
+ keywords=["Swagger", "AutoRestHeadTestService"],
+ install_requires=REQUIRES,
+ packages=find_packages(),
+ include_package_data=True,
+ long_description="""\
+ Test Infrastructure for AutoRest.
+ """
+)
diff --git a/docs/samples/specification/management/readme.md b/docs/samples/specification/management/readme.md
new file mode 100644
index 00000000000..9625bd36719
--- /dev/null
+++ b/docs/samples/specification/management/readme.md
@@ -0,0 +1,21 @@
+# Sample Management Generation
+
+Use the flag `--azure-arm` to specify you want to generate [management plane][mgmt] code. For more information, see our [flag index][flag_index]
+
+### Settings
+
+``` yaml
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/head.json
+namespace: azure.mgmt.sample
+package-name: azure-mgmt-sample
+license-header: MICROSOFT_MIT_NO_VERSION
+azure-arm: true
+add-credential: true
+package-version: 0.1.0
+basic-setup-py: true
+clear-output-folder: true
+```
+
+
+[mgmt]: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/control-plane-and-data-plane#control-plane
+[flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/__init__.py
new file mode 100644
index 00000000000..8c8f1f92954
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/__init__.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_configuration.py
new file mode 100644
index 00000000000..eb286639e44
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_configuration.py
@@ -0,0 +1,65 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for
+# license information.
+#
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is
+# regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+from ._version import VERSION
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any
+
+ from azure.core.credentials import TokenCredential
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'azure-multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/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
new file mode 100644
index 00000000000..19206a00bf4
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py
@@ -0,0 +1,150 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for
+# license information.
+#
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is
+# regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.mgmt.core import ARMPipelineClient
+from azure.profiles import KnownProfiles, ProfileDefinition
+from azure.profiles.multiapiclient import MultiApiClientMixin
+from msrest import Deserializer, Serializer
+
+from ._configuration import MultiapiServiceClientConfiguration
+from ._operations_mixin import MultiapiServiceClientOperationsMixin
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Optional
+
+ from azure.core.credentials import TokenCredential
+
+class _SDKClient(object):
+ def __init__(self, *args, **kwargs):
+ """This is a fake class to support current implemetation of MultiApiClientMixin."
+ Will be removed in final version of multiapi azure-core based client
+ """
+ pass
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClientMixin, _SDKClient):
+ """Service client for multiapi client testing.
+
+ This ready contains multiple API versions, to help you deal with all of the Azure clouds
+ (Azure Stack, Azure Government, Azure China, etc.).
+ By default, it uses the latest API version available on public Azure.
+ For production, you should stick to a particular api-version and/or profile.
+ The profile sets a mapping between an operation group and its API version.
+ The api-version parameter sets the default API version if the operation
+ group is not described in the profile.
+
+ :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
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ DEFAULT_API_VERSION = '3.0.0'
+ _PROFILE_TAG = "azure.multiapi.sample.MultiapiServiceClient"
+ LATEST_PROFILE = ProfileDefinition({
+ _PROFILE_TAG: {
+ None: DEFAULT_API_VERSION,
+ 'begin_test_lro': '1.0.0',
+ 'begin_test_lro_and_paging': '1.0.0',
+ 'test_one': '2.0.0',
+ }},
+ _PROFILE_TAG + " latest"
+ )
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ api_version=None, # type: Optional[str]
+ base_url=None, # type: Optional[str]
+ profile=KnownProfiles.default, # type: KnownProfiles
+ **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__(
+ api_version=api_version,
+ profile=profile
+ )
+
+ @classmethod
+ def _models_dict(cls, api_version):
+ return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
+
+ @classmethod
+ def models(cls, api_version=DEFAULT_API_VERSION):
+ """Module depends on the API version:
+
+ * 1.0.0: :mod:`v1.models`
+ * 2.0.0: :mod:`v2.models`
+ * 3.0.0: :mod:`v3.models`
+ """
+ if api_version == '1.0.0':
+ from .v1 import models
+ return models
+ elif api_version == '2.0.0':
+ from .v2 import models
+ return models
+ elif api_version == '3.0.0':
+ from .v3 import models
+ return models
+ raise ValueError("API version {} is not available".format(api_version))
+
+ @property
+ def operation_group_one(self):
+ """Instance depends on the API version:
+
+ * 1.0.0: :class:`OperationGroupOneOperations`
+ * 2.0.0: :class:`OperationGroupOneOperations`
+ * 3.0.0: :class:`OperationGroupOneOperations`
+ """
+ api_version = self._get_api_version('operation_group_one')
+ if api_version == '1.0.0':
+ from .v1.operations import OperationGroupOneOperations as OperationClass
+ elif api_version == '2.0.0':
+ from .v2.operations import OperationGroupOneOperations as OperationClass
+ elif api_version == '3.0.0':
+ from .v3.operations import OperationGroupOneOperations as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
+ return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
+
+ @property
+ def operation_group_two(self):
+ """Instance depends on the API version:
+
+ * 2.0.0: :class:`OperationGroupTwoOperations`
+ * 3.0.0: :class:`OperationGroupTwoOperations`
+ """
+ api_version = self._get_api_version('operation_group_two')
+ if api_version == '2.0.0':
+ from .v2.operations import OperationGroupTwoOperations as OperationClass
+ elif api_version == '3.0.0':
+ from .v3.operations import OperationGroupTwoOperations as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
+ return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
+
+ def close(self):
+ self._client.close()
+ def __enter__(self):
+ self._client.__enter__()
+ return self
+ def __exit__(self, *exc_details):
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py
new file mode 100644
index 00000000000..0b5e0b1f51b
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_operations_mixin.py
@@ -0,0 +1,188 @@
+# 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 msrest import Serializer, Deserializer
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.paging import ItemPaged
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.core.polling import LROPoller, NoPolling, PollingMethod
+from azure.mgmt.core.exceptions import ARMErrorFormat
+from azure.mgmt.core.polling.arm_polling import ARMPolling
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union
+
+
+class MultiapiServiceClientOperationsMixin(object):
+
+ def begin_test_lro(
+ self,
+ product=None, # type: Optional["_models.Product"]
+ **kwargs # type: Any
+ ):
+ """Put in whatever shape of Product you want, will return a Product with id equal to 100.
+
+ :param product: Product to put.
+ :type product: ~azure.multiapi.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.PollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of LROPoller that returns either Product or the result of cls(response)
+ :rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ api_version = self._get_api_version('begin_test_lro')
+ if api_version == '1.0.0':
+ from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'begin_test_lro'".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.begin_test_lro(product, **kwargs)
+
+ def begin_test_lro_and_paging(
+ self,
+ client_request_id=None, # type: Optional[str]
+ test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"]
+ **kwargs # type: Any
+ ):
+ """A long-running paging operation that includes a nextLink that has 10 pages.
+
+ :param client_request_id:
+ :type client_request_id: str
+ :param test_lro_and_paging_options: Parameter group.
+ :type test_lro_and_paging_options: ~azure.multiapi.sample.models.TestLroAndPagingOptions
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.PollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ api_version = self._get_api_version('begin_test_lro_and_paging')
+ if api_version == '1.0.0':
+ from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".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.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
+ message=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ """TestOne should be in an FirstVersionOperationsMixin.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: 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_one')
+ 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
+ else:
+ raise ValueError("API version {} does not have operation 'test_one'".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_one(id, message, **kwargs)
+
+ def test_paging(
+ self,
+ **kwargs # type: Any
+ ):
+ """Returns ModelThree with optionalProperty 'paged'.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ api_version = self._get_api_version('test_paging')
+ if api_version == '3.0.0':
+ from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'test_paging'".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_paging(**kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_version.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_version.py
new file mode 100644
index 00000000000..a30a458f8b5
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_version.py
@@ -0,0 +1,8 @@
+# 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.
+# --------------------------------------------------------------------------
+
+VERSION = "0.1.0"
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/__init__.py
new file mode 100644
index 00000000000..c5088f7a288
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_configuration.py
new file mode 100644
index 00000000000..4243c03bc48
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_configuration.py
@@ -0,0 +1,61 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for
+# license information.
+#
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is
+# regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+from .._version import VERSION
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ **kwargs # type: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'azure-multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs: Any
+ ) -> None:
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/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
new file mode 100644
index 00000000000..fba5def7cef
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py
@@ -0,0 +1,148 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for
+# license information.
+#
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is
+# regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, Optional, TYPE_CHECKING
+
+from azure.mgmt.core import AsyncARMPipelineClient
+from azure.profiles import KnownProfiles, ProfileDefinition
+from azure.profiles.multiapiclient import MultiApiClientMixin
+from msrest import Deserializer, Serializer
+
+from ._configuration import MultiapiServiceClientConfiguration
+from ._operations_mixin import MultiapiServiceClientOperationsMixin
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+class _SDKClient(object):
+ def __init__(self, *args, **kwargs):
+ """This is a fake class to support current implemetation of MultiApiClientMixin."
+ Will be removed in final version of multiapi azure-core based client
+ """
+ pass
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClientMixin, _SDKClient):
+ """Service client for multiapi client testing.
+
+ This ready contains multiple API versions, to help you deal with all of the Azure clouds
+ (Azure Stack, Azure Government, Azure China, etc.).
+ By default, it uses the latest API version available on public Azure.
+ For production, you should stick to a particular api-version and/or profile.
+ The profile sets a mapping between an operation group and its API version.
+ The api-version parameter sets the default API version if the operation
+ group is not described in the profile.
+
+ :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
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ DEFAULT_API_VERSION = '3.0.0'
+ _PROFILE_TAG = "azure.multiapi.sample.MultiapiServiceClient"
+ LATEST_PROFILE = ProfileDefinition({
+ _PROFILE_TAG: {
+ None: DEFAULT_API_VERSION,
+ 'begin_test_lro': '1.0.0',
+ 'begin_test_lro_and_paging': '1.0.0',
+ 'test_one': '2.0.0',
+ }},
+ _PROFILE_TAG + " latest"
+ )
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ 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__(
+ api_version=api_version,
+ profile=profile
+ )
+
+ @classmethod
+ def _models_dict(cls, api_version):
+ return {k: v for k, v in cls.models(api_version).__dict__.items() if isinstance(v, type)}
+
+ @classmethod
+ def models(cls, api_version=DEFAULT_API_VERSION):
+ """Module depends on the API version:
+
+ * 1.0.0: :mod:`v1.models`
+ * 2.0.0: :mod:`v2.models`
+ * 3.0.0: :mod:`v3.models`
+ """
+ if api_version == '1.0.0':
+ from ..v1 import models
+ return models
+ elif api_version == '2.0.0':
+ from ..v2 import models
+ return models
+ elif api_version == '3.0.0':
+ from ..v3 import models
+ return models
+ raise ValueError("API version {} is not available".format(api_version))
+
+ @property
+ def operation_group_one(self):
+ """Instance depends on the API version:
+
+ * 1.0.0: :class:`OperationGroupOneOperations`
+ * 2.0.0: :class:`OperationGroupOneOperations`
+ * 3.0.0: :class:`OperationGroupOneOperations`
+ """
+ api_version = self._get_api_version('operation_group_one')
+ if api_version == '1.0.0':
+ from ..v1.aio.operations import OperationGroupOneOperations as OperationClass
+ elif api_version == '2.0.0':
+ from ..v2.aio.operations import OperationGroupOneOperations as OperationClass
+ elif api_version == '3.0.0':
+ from ..v3.aio.operations import OperationGroupOneOperations as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation group 'operation_group_one'".format(api_version))
+ return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
+
+ @property
+ def operation_group_two(self):
+ """Instance depends on the API version:
+
+ * 2.0.0: :class:`OperationGroupTwoOperations`
+ * 3.0.0: :class:`OperationGroupTwoOperations`
+ """
+ api_version = self._get_api_version('operation_group_two')
+ if api_version == '2.0.0':
+ from ..v2.aio.operations import OperationGroupTwoOperations as OperationClass
+ elif api_version == '3.0.0':
+ from ..v3.aio.operations import OperationGroupTwoOperations as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation group 'operation_group_two'".format(api_version))
+ return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
+
+ async def close(self):
+ await self._client.close()
+ async def __aenter__(self):
+ await self._client.__aenter__()
+ return self
+ async def __aexit__(self, *exc_details):
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py
new file mode 100644
index 00000000000..877924e7421
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py
@@ -0,0 +1,184 @@
+# 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 msrest import Serializer, Deserializer
+from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
+import warnings
+
+from azure.core.async_paging import AsyncItemPaged, AsyncList
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
+from azure.mgmt.core.exceptions import ARMErrorFormat
+from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
+
+
+class MultiapiServiceClientOperationsMixin(object):
+
+ async def begin_test_lro(
+ self,
+ product: Optional["_models.Product"] = None,
+ **kwargs
+ ) -> AsyncLROPoller["_models.Product"]:
+ """Put in whatever shape of Product you want, will return a Product with id equal to 100.
+
+ :param product: Product to put.
+ :type product: ~azure.multiapi.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ api_version = self._get_api_version('begin_test_lro')
+ if api_version == '1.0.0':
+ from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'begin_test_lro'".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.begin_test_lro(product, **kwargs)
+
+ def begin_test_lro_and_paging(
+ self,
+ client_request_id: Optional[str] = None,
+ test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None,
+ **kwargs
+ ) -> AsyncLROPoller[AsyncItemPaged["_models.PagingResult"]]:
+ """A long-running paging operation that includes a nextLink that has 10 pages.
+
+ :param client_request_id:
+ :type client_request_id: str
+ :param test_lro_and_paging_options: Parameter group.
+ :type test_lro_and_paging_options: ~azure.multiapi.sample.models.TestLroAndPagingOptions
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.models.PagingResult]]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ api_version = self._get_api_version('begin_test_lro_and_paging')
+ if api_version == '1.0.0':
+ from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'begin_test_lro_and_paging'".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.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,
+ message: Optional[str] = None,
+ **kwargs
+ ) -> None:
+ """TestOne should be in an FirstVersionOperationsMixin.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: 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_one')
+ 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
+ else:
+ raise ValueError("API version {} does not have operation 'test_one'".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_one(id, message, **kwargs)
+
+ def test_paging(
+ self,
+ **kwargs
+ ) -> AsyncItemPaged["_models.PagingResult"]:
+ """Returns ModelThree with optionalProperty 'paged'.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.models.PagingResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ api_version = self._get_api_version('test_paging')
+ if api_version == '3.0.0':
+ from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass
+ else:
+ raise ValueError("API version {} does not have operation 'test_paging'".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_paging(**kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/models.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/models.py
new file mode 100644
index 00000000000..954f1ee54ab
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/models.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.
+# --------------------------------------------------------------------------
+from .v1.models import *
+from .v2.models import *
+from .v3.models import *
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/py.typed b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/__init__.py
new file mode 100644
index 00000000000..8c8f1f92954
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/__init__.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_configuration.py
new file mode 100644
index 00000000000..f36b4a7abab
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_configuration.py
@@ -0,0 +1,64 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any
+
+ from azure.core.credentials import TokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "1.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json
new file mode 100644
index 00000000000..a33e25965b8
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json
@@ -0,0 +1,127 @@
+{
+ "chosen_version": "1.0.0",
+ "total_api_version_list": ["1.0.0"],
+ "client": {
+ "name": "MultiapiServiceClient",
+ "filename": "_multiapi_service_client",
+ "description": "Service client for multiapi client testing.",
+ "base_url": "\u0027http://localhost:3000\u0027",
+ "custom_base_url": null,
+ "azure_arm": true,
+ "has_lro_operations": true,
+ "client_side_validation": false,
+ "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}",
+ "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}"
+ },
+ "global_parameters": {
+ "sync": {
+ "credential": {
+ "signature": "credential, # type: \"TokenCredential\"",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials.TokenCredential",
+ "required": true
+ }
+ },
+ "async": {
+ "credential": {
+ "signature": "credential: \"AsyncTokenCredential\",",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential",
+ "required": true
+ }
+ },
+ "constant": {
+ },
+ "call": "credential"
+ },
+ "config": {
+ "credential": true,
+ "credential_scopes": ["https://management.azure.com/.default"],
+ "credential_default_policy_type": "BearerTokenCredentialPolicy",
+ "credential_default_policy_type_has_async_version": true,
+ "credential_key_header_name": null,
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
+ },
+ "operation_groups": {
+ "operation_group_one": "OperationGroupOneOperations"
+ },
+ "operation_mixins": {
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.mgmt.core.polling.arm_polling\": [\"ARMPolling\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\", \"Union\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.mgmt.core.polling.async_arm_polling\": [\"AsyncARMPolling\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}",
+ "operations": {
+ "test_one" : {
+ "sync": {
+ "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n",
+ "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\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: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "async": {
+ "coroutine": true,
+ "signature": "async def test_one(\n self,\n id: int,\n message: Optional[str] = None,\n **kwargs\n) -\u003e None:\n",
+ "doc": "\"\"\"TestOne should be in an FirstVersionOperationsMixin.\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: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "call": "id, message"
+ },
+ "_test_lro_initial" : {
+ "sync": {
+ "signature": "def _test_lro_initial(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n",
+ "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "async": {
+ "coroutine": true,
+ "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs\n) -\u003e Optional[\"_models.Product\"]:\n",
+ "doc": "\"\"\"\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "call": "product"
+ },
+ "begin_test_lro" : {
+ "sync": {
+ "signature": "def begin_test_lro(\n self,\n product=None, # type: Optional[\"_models.Product\"]\n **kwargs # type: Any\n):\n",
+ "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.models.Product\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: True for ARMPolling, False for no polling, or a\n polling object for personal polling strategy\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\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 LROPoller that returns either Product or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\""
+ },
+ "async": {
+ "coroutine": true,
+ "signature": "async def begin_test_lro(\n self,\n product: Optional[\"_models.Product\"] = None,\n **kwargs\n) -\u003e AsyncLROPoller[\"_models.Product\"]:\n",
+ "doc": "\"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~azure.multiapi.sample.models.Product\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: True for ARMPolling, False for no polling, or a\n polling object for 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 either Product or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.models.Product]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\""
+ },
+ "call": "product"
+ },
+ "_test_lro_and_paging_initial" : {
+ "sync": {
+ "signature": "def _test_lro_and_paging_initial(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n",
+ "doc": "\"\"\"\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: ~azure.multiapi.sample.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "async": {
+ "coroutine": true,
+ "signature": "async def _test_lro_and_paging_initial(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs\n) -\u003e \"_models.PagingResult\":\n",
+ "doc": "\"\"\"\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: ~azure.multiapi.sample.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: PagingResult, or the result of cls(response)\n:rtype: ~azure.multiapi.sample.models.PagingResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "call": "client_request_id, test_lro_and_paging_options"
+ },
+ "begin_test_lro_and_paging" : {
+ "sync": {
+ "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id=None, # type: Optional[str]\n test_lro_and_paging_options=None, # type: Optional[\"_models.TestLroAndPagingOptions\"]\n **kwargs # type: Any\n):\n",
+ "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: ~azure.multiapi.sample.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: True for ARMPolling, False for no polling, or a\n polling object for personal polling strategy\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\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 LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\""
+ },
+ "async": {
+ "coroutine": false,
+ "signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[\"_models.TestLroAndPagingOptions\"] = None,\n **kwargs\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.PagingResult\"]]:\n",
+ "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: ~azure.multiapi.sample.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: True for ARMPolling, False for no polling, or a\n polling object for 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[~azure.multiapi.sample.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"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py
new file mode 100644
index 00000000000..122ab7416b6
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_multiapi_service_client.py
@@ -0,0 +1,68 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.mgmt.core import ARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Optional
+
+ from azure.core.credentials import TokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from . import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.operations.OperationGroupOneOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ :param str base_url: Service URL
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ 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)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> MultiapiServiceClient
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/__init__.py
new file mode 100644
index 00000000000..c5088f7a288
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_configuration.py
new file mode 100644
index 00000000000..f40b314c57c
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_configuration.py
@@ -0,0 +1,60 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ **kwargs: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "1.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs: Any
+ ) -> None:
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_client.py
new file mode 100644
index 00000000000..299898a9838
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/_multiapi_service_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.mgmt.core import AsyncARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from .. import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.aio.operations.OperationGroupOneOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ :param str base_url: Service URL
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ base_url: Optional[str] = None,
+ **kwargs: 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)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "MultiapiServiceClient":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/__init__.py
new file mode 100644
index 00000000000..1d9facfa368
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/__init__.py
@@ -0,0 +1,15 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..cfd00145e75
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,401 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union
+import warnings
+
+from azure.core.async_paging import AsyncItemPaged, AsyncList
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
+from azure.mgmt.core.exceptions import ARMErrorFormat
+from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin:
+
+ async def test_one(
+ self,
+ id: int,
+ message: Optional[str] = None,
+ **kwargs
+ ) -> None:
+ """TestOne should be in an FirstVersionOperationsMixin.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: 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_one.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['id'] = self._serialize.query("id", id, 'int')
+ if message is not None:
+ query_parameters['message'] = self._serialize.query("message", message, 'str')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore
+
+ async def _test_lro_initial(
+ self,
+ product: Optional["_models.Product"] = None,
+ **kwargs
+ ) -> Optional["_models.Product"]:
+ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Product"]]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self._test_lro_initial.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')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if product is not None:
+ body_content = self._serialize.body(product, 'Product')
+ else:
+ body_content = None
+ 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, 204]:
+ 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)
+
+ deserialized = None
+ if response.status_code == 200:
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore
+
+ async def begin_test_lro(
+ self,
+ product: Optional["_models.Product"] = None,
+ **kwargs
+ ) -> AsyncLROPoller["_models.Product"]:
+ """Put in whatever shape of Product you want, will return a Product with id equal to 100.
+
+ :param product: Product to put.
+ :type product: ~azure.multiapi.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of AsyncLROPoller that returns either Product or the result of cls(response)
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.multiapi.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = await self._test_lro_initial(
+ product=product,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+
+ def get_long_running_output(pipeline_response):
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+ return deserialized
+
+ if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = AsyncNoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return AsyncLROPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ else:
+ return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method)
+ begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore
+
+ async def _test_lro_and_paging_initial(
+ self,
+ client_request_id: Optional[str] = None,
+ test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None,
+ **kwargs
+ ) -> "_models.PagingResult":
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+
+ _maxresults = None
+ _timeout = None
+ if test_lro_and_paging_options is not None:
+ _maxresults = test_lro_and_paging_options.maxresults
+ _timeout = test_lro_and_paging_options.timeout
+ accept = "application/json"
+
+ # Construct URL
+ url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ if client_request_id is not None:
+ header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str')
+ if _maxresults is not None:
+ header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int')
+ if _timeout is not None:
+ header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore
+
+ async def begin_test_lro_and_paging(
+ self,
+ client_request_id: Optional[str] = None,
+ test_lro_and_paging_options: Optional["_models.TestLroAndPagingOptions"] = None,
+ **kwargs
+ ) -> AsyncLROPoller[AsyncItemPaged["_models.PagingResult"]]:
+ """A long-running paging operation that includes a nextLink that has 10 pages.
+
+ :param client_request_id:
+ :type client_request_id: str
+ :param test_lro_and_paging_options: Parameter group.
+ :type test_lro_and_paging_options: ~azure.multiapi.sample.models.TestLroAndPagingOptions
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.models.PagingResult]]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+
+ _maxresults = None
+ _timeout = None
+ if test_lro_and_paging_options is not None:
+ _maxresults = test_lro_and_paging_options.maxresults
+ _timeout = test_lro_and_paging_options.timeout
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ if client_request_id is not None:
+ header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str')
+ if _maxresults is not None:
+ header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int')
+ if _timeout is not None:
+ header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.test_lro_and_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ async def extract_data(pipeline_response):
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+ list_of_elem = deserialized.values
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, AsyncList(list_of_elem)
+
+ async def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ return pipeline_response
+
+ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = await self._test_lro_and_paging_initial(
+ client_request_id=client_request_id,
+ test_lro_and_paging_options=test_lro_and_paging_options,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+ def get_long_running_output(pipeline_response):
+ async def internal_get_next(next_link=None):
+ if next_link is None:
+ return pipeline_response
+ else:
+ return await get_next(next_link)
+
+ return AsyncItemPaged(
+ internal_get_next, extract_data
+ )
+ if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = AsyncNoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return AsyncLROPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..ddef70e3cc5
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_operation_group_one_operations.py
@@ -0,0 +1,85 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations:
+ """OperationGroupOneOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def test_two(
+ self,
+ **kwargs
+ ) -> None:
+ """TestTwo should be in OperationGroupOneOperations.
+
+ :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_two.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = 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_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/__init__.py
new file mode 100644
index 00000000000..2a41a9b7475
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/__init__.py
@@ -0,0 +1,25 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+try:
+ from ._models_py3 import Error
+ from ._models_py3 import PagingResult
+ from ._models_py3 import Product
+ from ._models_py3 import TestLroAndPagingOptions
+except (SyntaxError, ImportError):
+ from ._models import Error # type: ignore
+ from ._models import PagingResult # type: ignore
+ from ._models import Product # type: ignore
+ from ._models import TestLroAndPagingOptions # type: ignore
+
+__all__ = [
+ 'Error',
+ 'PagingResult',
+ 'Product',
+ 'TestLroAndPagingOptions',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models.py
new file mode 100644
index 00000000000..79f5998084d
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models.py
@@ -0,0 +1,99 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = kwargs.get('status', None)
+ self.message = kwargs.get('message', None)
+
+
+class PagingResult(msrest.serialization.Model):
+ """PagingResult.
+
+ :param values:
+ :type values: list[~azure.multiapi.sample.models.Product]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'values': {'key': 'values', 'type': '[Product]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(PagingResult, self).__init__(**kwargs)
+ self.values = kwargs.get('values', None)
+ self.next_link = kwargs.get('next_link', None)
+
+
+class Product(msrest.serialization.Model):
+ """Product.
+
+ :param id:
+ :type id: int
+ """
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Product, self).__init__(**kwargs)
+ self.id = kwargs.get('id', None)
+
+
+class TestLroAndPagingOptions(msrest.serialization.Model):
+ """Parameter group.
+
+ :param maxresults: Sets the maximum number of items to return in the response.
+ :type maxresults: int
+ :param timeout: Sets the maximum time that the server can spend processing the request, in
+ seconds. The default is 30 seconds.
+ :type timeout: int
+ """
+
+ _attribute_map = {
+ 'maxresults': {'key': 'maxresults', 'type': 'int'},
+ 'timeout': {'key': 'timeout', 'type': 'int'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(TestLroAndPagingOptions, self).__init__(**kwargs)
+ self.maxresults = kwargs.get('maxresults', None)
+ self.timeout = kwargs.get('timeout', 30)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models_py3.py
new file mode 100644
index 00000000000..97caecdcc0d
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/models/_models_py3.py
@@ -0,0 +1,112 @@
+# 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 List, Optional
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ status: Optional[int] = None,
+ message: Optional[str] = None,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = status
+ self.message = message
+
+
+class PagingResult(msrest.serialization.Model):
+ """PagingResult.
+
+ :param values:
+ :type values: list[~azure.multiapi.sample.models.Product]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'values': {'key': 'values', 'type': '[Product]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ values: Optional[List["Product"]] = None,
+ next_link: Optional[str] = None,
+ **kwargs
+ ):
+ super(PagingResult, self).__init__(**kwargs)
+ self.values = values
+ self.next_link = next_link
+
+
+class Product(msrest.serialization.Model):
+ """Product.
+
+ :param id:
+ :type id: int
+ """
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ }
+
+ def __init__(
+ self,
+ *,
+ id: Optional[int] = None,
+ **kwargs
+ ):
+ super(Product, self).__init__(**kwargs)
+ self.id = id
+
+
+class TestLroAndPagingOptions(msrest.serialization.Model):
+ """Parameter group.
+
+ :param maxresults: Sets the maximum number of items to return in the response.
+ :type maxresults: int
+ :param timeout: Sets the maximum time that the server can spend processing the request, in
+ seconds. The default is 30 seconds.
+ :type timeout: int
+ """
+
+ _attribute_map = {
+ 'maxresults': {'key': 'maxresults', 'type': 'int'},
+ 'timeout': {'key': 'timeout', 'type': 'int'},
+ }
+
+ def __init__(
+ self,
+ *,
+ maxresults: Optional[int] = None,
+ timeout: Optional[int] = 30,
+ **kwargs
+ ):
+ super(TestLroAndPagingOptions, self).__init__(**kwargs)
+ self.maxresults = maxresults
+ self.timeout = timeout
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/__init__.py
new file mode 100644
index 00000000000..1d9facfa368
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/__init__.py
@@ -0,0 +1,15 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..be8c231b24a
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,411 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.paging import ItemPaged
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.core.polling import LROPoller, NoPolling, PollingMethod
+from azure.mgmt.core.exceptions import ARMErrorFormat
+from azure.mgmt.core.polling.arm_polling import ARMPolling
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin(object):
+
+ def test_one(
+ self,
+ id, # type: int
+ message=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestOne should be in an FirstVersionOperationsMixin.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: 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_one.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['id'] = self._serialize.query("id", id, 'int')
+ if message is not None:
+ query_parameters['message'] = self._serialize.query("message", message, 'str')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore
+
+ def _test_lro_initial(
+ self,
+ product=None, # type: Optional["_models.Product"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> Optional["_models.Product"]
+ cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Product"]]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self._test_lro_initial.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')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if product is not None:
+ body_content = self._serialize.body(product, 'Product')
+ else:
+ body_content = None
+ 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, 204]:
+ 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)
+
+ deserialized = None
+ if response.status_code == 200:
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _test_lro_initial.metadata = {'url': '/multiapi/lro'} # type: ignore
+
+ def begin_test_lro(
+ self,
+ product=None, # type: Optional["_models.Product"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> LROPoller["_models.Product"]
+ """Put in whatever shape of Product you want, will return a Product with id equal to 100.
+
+ :param product: Product to put.
+ :type product: ~azure.multiapi.sample.models.Product
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.PollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of LROPoller that returns either Product or the result of cls(response)
+ :rtype: ~azure.core.polling.LROPoller[~azure.multiapi.sample.models.Product]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.Product"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = self._test_lro_initial(
+ product=product,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+
+ def get_long_running_output(pipeline_response):
+ deserialized = self._deserialize('Product', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+ return deserialized
+
+ if polling is True: polling_method = ARMPolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = NoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return LROPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ else:
+ return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
+ begin_test_lro.metadata = {'url': '/multiapi/lro'} # type: ignore
+
+ def _test_lro_and_paging_initial(
+ self,
+ client_request_id=None, # type: Optional[str]
+ test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> "_models.PagingResult"
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+
+ _maxresults = None
+ _timeout = None
+ if test_lro_and_paging_options is not None:
+ _maxresults = test_lro_and_paging_options.maxresults
+ _timeout = test_lro_and_paging_options.timeout
+ accept = "application/json"
+
+ # Construct URL
+ url = self._test_lro_and_paging_initial.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ if client_request_id is not None:
+ header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str')
+ if _maxresults is not None:
+ header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int')
+ if _timeout is not None:
+ header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ _test_lro_and_paging_initial.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore
+
+ def begin_test_lro_and_paging(
+ self,
+ client_request_id=None, # type: Optional[str]
+ test_lro_and_paging_options=None, # type: Optional["_models.TestLroAndPagingOptions"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> LROPoller[ItemPaged["_models.PagingResult"]]
+ """A long-running paging operation that includes a nextLink that has 10 pages.
+
+ :param client_request_id:
+ :type client_request_id: str
+ :param test_lro_and_paging_options: Parameter group.
+ :type test_lro_and_paging_options: ~azure.multiapi.sample.models.TestLroAndPagingOptions
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :keyword str continuation_token: A continuation token to restart a poller from a saved state.
+ :keyword polling: True for ARMPolling, False for no polling, or a
+ polling object for personal polling strategy
+ :paramtype polling: bool or ~azure.core.polling.PollingMethod
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
+ :return: An instance of LROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]]
+ :raises ~azure.core.exceptions.HttpResponseError:
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+
+ _maxresults = None
+ _timeout = None
+ if test_lro_and_paging_options is not None:
+ _maxresults = test_lro_and_paging_options.maxresults
+ _timeout = test_lro_and_paging_options.timeout
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ if client_request_id is not None:
+ header_parameters['client-request-id'] = self._serialize.header("client_request_id", client_request_id, 'str')
+ if _maxresults is not None:
+ header_parameters['maxresults'] = self._serialize.header("maxresults", _maxresults, 'int')
+ if _timeout is not None:
+ header_parameters['timeout'] = self._serialize.header("timeout", _timeout, 'int')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.test_lro_and_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ def extract_data(pipeline_response):
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+ list_of_elem = deserialized.values
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, iter(list_of_elem)
+
+ def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ return pipeline_response
+
+ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod]
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ lro_delay = kwargs.pop(
+ 'polling_interval',
+ self._config.polling_interval
+ )
+ cont_token = kwargs.pop('continuation_token', None) # type: Optional[str]
+ if cont_token is None:
+ raw_result = self._test_lro_and_paging_initial(
+ client_request_id=client_request_id,
+ test_lro_and_paging_options=test_lro_and_paging_options,
+ cls=lambda x,y,z: x,
+ **kwargs
+ )
+
+ kwargs.pop('error_map', None)
+ kwargs.pop('content_type', None)
+ def get_long_running_output(pipeline_response):
+ def internal_get_next(next_link=None):
+ if next_link is None:
+ return pipeline_response
+ else:
+ return get_next(next_link)
+
+ return ItemPaged(
+ internal_get_next, extract_data
+ )
+ if polling is True: polling_method = ARMPolling(lro_delay, **kwargs)
+ elif polling is False: polling_method = NoPolling()
+ else: polling_method = polling
+ if cont_token:
+ return LROPoller.from_continuation_token(
+ polling_method=polling_method,
+ continuation_token=cont_token,
+ client=self._client,
+ deserialization_callback=get_long_running_output
+ )
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..37c067e24e5
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/operations/_operation_group_one_operations.py
@@ -0,0 +1,90 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations(object):
+ """OperationGroupOneOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def test_two(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestTwo should be in OperationGroupOneOperations.
+
+ :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_two.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = 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_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/py.typed b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/__init__.py
new file mode 100644
index 00000000000..8c8f1f92954
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/__init__.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_configuration.py
new file mode 100644
index 00000000000..7334a67c6b0
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_configuration.py
@@ -0,0 +1,64 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any
+
+ from azure.core.credentials import TokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "2.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json
new file mode 100644
index 00000000000..762f0b455c4
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json
@@ -0,0 +1,80 @@
+{
+ "chosen_version": "2.0.0",
+ "total_api_version_list": ["2.0.0"],
+ "client": {
+ "name": "MultiapiServiceClient",
+ "filename": "_multiapi_service_client",
+ "description": "Service client for multiapi client testing.",
+ "base_url": "\u0027http://localhost:3000\u0027",
+ "custom_base_url": null,
+ "azure_arm": true,
+ "has_lro_operations": false,
+ "client_side_validation": false,
+ "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}",
+ "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}"
+ },
+ "global_parameters": {
+ "sync": {
+ "credential": {
+ "signature": "credential, # type: \"TokenCredential\"",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials.TokenCredential",
+ "required": true
+ }
+ },
+ "async": {
+ "credential": {
+ "signature": "credential: \"AsyncTokenCredential\",",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential",
+ "required": true
+ }
+ },
+ "constant": {
+ },
+ "call": "credential"
+ },
+ "config": {
+ "credential": true,
+ "credential_scopes": ["https://management.azure.com/.default"],
+ "credential_default_policy_type": "BearerTokenCredentialPolicy",
+ "credential_default_policy_type_has_async_version": true,
+ "credential_key_header_name": null,
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
+ },
+ "operation_groups": {
+ "operation_group_one": "OperationGroupOneOperations",
+ "operation_group_two": "OperationGroupTwoOperations"
+ },
+ "operation_mixins": {
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}",
+ "operations": {
+ "test_one" : {
+ "sync": {
+ "signature": "def test_one(\n self,\n id, # type: int\n message=None, # type: Optional[str]\n **kwargs # type: Any\n):\n",
+ "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: ~azure.multiapi.sample.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "async": {
+ "coroutine": true,
+ "signature": "async def test_one(\n self,\n id: int,\n message: Optional[str] = None,\n **kwargs\n) -\u003e \"_models.ModelTwo\":\n",
+ "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: ~azure.multiapi.sample.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"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_client.py
new file mode 100644
index 00000000000..eed6683367f
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_multiapi_service_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.mgmt.core import ARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Optional
+
+ from azure.core.credentials import TokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from .operations import OperationGroupTwoOperations
+from . import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.operations.OperationGroupOneOperations
+ :ivar operation_group_two: OperationGroupTwoOperations operations
+ :vartype operation_group_two: azure.multiapi.sample.operations.OperationGroupTwoOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ 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)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+ self.operation_group_two = OperationGroupTwoOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> MultiapiServiceClient
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/__init__.py
new file mode 100644
index 00000000000..c5088f7a288
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_configuration.py
new file mode 100644
index 00000000000..88ac2f6fa82
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_configuration.py
@@ -0,0 +1,60 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ **kwargs: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "2.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs: Any
+ ) -> None:
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py
new file mode 100644
index 00000000000..7c048980e72
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/_multiapi_service_client.py
@@ -0,0 +1,66 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, Optional, TYPE_CHECKING
+
+from azure.mgmt.core import AsyncARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from .operations import OperationGroupTwoOperations
+from .. import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.aio.operations.OperationGroupOneOperations
+ :ivar operation_group_two: OperationGroupTwoOperations operations
+ :vartype operation_group_two: azure.multiapi.sample.aio.operations.OperationGroupTwoOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = MultiapiServiceClientConfiguration(credential, **kwargs)
+ self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+ self.operation_group_two = OperationGroupTwoOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "MultiapiServiceClient":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/__init__.py
new file mode 100644
index 00000000000..356f78798f2
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/__init__.py
@@ -0,0 +1,17 @@
+# 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 ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+from ._operation_group_two_operations import OperationGroupTwoOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+ 'OperationGroupTwoOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..24d7856dbe4
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,130 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin:
+
+ async def test_one(
+ self,
+ id: int,
+ message: Optional[str] = None,
+ **kwargs
+ ) -> "_models.ModelTwo":
+ """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelTwo, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelTwo
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelTwo"]
+ 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_one.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['id'] = self._serialize.query("id", id, 'int')
+ if message is not None:
+ query_parameters['message'] = self._serialize.query("message", message, 'str')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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)
+
+ deserialized = self._deserialize('ModelTwo', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..6e12b83a8b8
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_one_operations.py
@@ -0,0 +1,143 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations:
+ """OperationGroupOneOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def test_two(
+ self,
+ parameter_one: Optional["_models.ModelTwo"] = None,
+ **kwargs
+ ) -> "_models.ModelTwo":
+ """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo.
+
+ :param parameter_one: A ModelTwo parameter.
+ :type parameter_one: ~azure.multiapi.sample.models.ModelTwo
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelTwo, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelTwo
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelTwo"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ api_version = "2.0.0"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_two.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if parameter_one is not None:
+ body_content = self._serialize.body(parameter_one, 'ModelTwo')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('ModelTwo', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
+
+ async def test_three(
+ self,
+ **kwargs
+ ) -> None:
+ """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo.
+
+ :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_three.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py
new file mode 100644
index 00000000000..7bd947bd451
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_operation_group_two_operations.py
@@ -0,0 +1,89 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupTwoOperations:
+ """OperationGroupTwoOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def test_four(
+ self,
+ parameter_one: bool,
+ **kwargs
+ ) -> None:
+ """TestFour should be in OperationGroupTwoOperations.
+
+ :param parameter_one: A boolean parameter.
+ :type parameter_one: bool
+ :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_four.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/__init__.py
new file mode 100644
index 00000000000..27909a95db1
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/__init__.py
@@ -0,0 +1,19 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+try:
+ from ._models_py3 import Error
+ from ._models_py3 import ModelTwo
+except (SyntaxError, ImportError):
+ from ._models import Error # type: ignore
+ from ._models import ModelTwo # type: ignore
+
+__all__ = [
+ 'Error',
+ 'ModelTwo',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models.py
new file mode 100644
index 00000000000..98abe2ea2ea
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models.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 azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = kwargs.get('status', None)
+ self.message = kwargs.get('message', None)
+
+
+class ModelTwo(msrest.serialization.Model):
+ """Only exists in api version 2.0.0.
+
+ All required parameters must be populated in order to send to Azure.
+
+ :param id: Required.
+ :type id: int
+ :param message:
+ :type message: str
+ """
+
+ _validation = {
+ 'id': {'required': True},
+ }
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(ModelTwo, self).__init__(**kwargs)
+ self.id = kwargs['id']
+ self.message = kwargs.get('message', None)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models_py3.py
new file mode 100644
index 00000000000..706ae4654aa
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/models/_models_py3.py
@@ -0,0 +1,70 @@
+# 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 Optional
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ status: Optional[int] = None,
+ message: Optional[str] = None,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = status
+ self.message = message
+
+
+class ModelTwo(msrest.serialization.Model):
+ """Only exists in api version 2.0.0.
+
+ All required parameters must be populated in order to send to Azure.
+
+ :param id: Required.
+ :type id: int
+ :param message:
+ :type message: str
+ """
+
+ _validation = {
+ 'id': {'required': True},
+ }
+
+ _attribute_map = {
+ 'id': {'key': 'id', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ id: int,
+ message: Optional[str] = None,
+ **kwargs
+ ):
+ super(ModelTwo, self).__init__(**kwargs)
+ self.id = id
+ self.message = message
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/__init__.py
new file mode 100644
index 00000000000..356f78798f2
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/__init__.py
@@ -0,0 +1,17 @@
+# 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 ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+from ._operation_group_two_operations import OperationGroupTwoOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+ 'OperationGroupTwoOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..3a46cf9e141
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,136 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin(object):
+
+ def test_one(
+ self,
+ id, # type: int
+ message=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> "_models.ModelTwo"
+ """TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.
+
+ :param id: An int parameter.
+ :type id: int
+ :param message: An optional string parameter.
+ :type message: str
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelTwo, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelTwo
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelTwo"]
+ 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_one.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['id'] = self._serialize.query("id", id, 'int')
+ if message is not None:
+ query_parameters['message'] = self._serialize.query("message", message, 'str')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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)
+
+ deserialized = self._deserialize('ModelTwo', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..9a376ac7151
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_one_operations.py
@@ -0,0 +1,149 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations(object):
+ """OperationGroupOneOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def test_two(
+ self,
+ parameter_one=None, # type: Optional["_models.ModelTwo"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> "_models.ModelTwo"
+ """TestTwo should be in OperationGroupOneOperations. Takes in ModelTwo and ouputs ModelTwo.
+
+ :param parameter_one: A ModelTwo parameter.
+ :type parameter_one: ~azure.multiapi.sample.models.ModelTwo
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelTwo, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelTwo
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelTwo"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ api_version = "2.0.0"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_two.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if parameter_one is not None:
+ body_content = self._serialize.body(parameter_one, 'ModelTwo')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('ModelTwo', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
+
+ def test_three(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestThree should be in OperationGroupOneOperations. Takes in ModelTwo.
+
+ :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_three.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_three.metadata = {'url': '/multiapi/one/testThreeEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py
new file mode 100644
index 00000000000..f0cd0e65a75
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/operations/_operation_group_two_operations.py
@@ -0,0 +1,94 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupTwoOperations(object):
+ """OperationGroupTwoOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def test_four(
+ self,
+ parameter_one, # type: bool
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestFour should be in OperationGroupTwoOperations.
+
+ :param parameter_one: A boolean parameter.
+ :type parameter_one: bool
+ :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_four.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['parameterOne'] = self._serialize.query("parameter_one", parameter_one, 'bool')
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.post(url, query_parameters, header_parameters)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/py.typed b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/__init__.py
new file mode 100644
index 00000000000..8c8f1f92954
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/__init__.py
@@ -0,0 +1,16 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
+
+try:
+ from ._patch import patch_sdk # type: ignore
+ patch_sdk()
+except ImportError:
+ pass
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_configuration.py
new file mode 100644
index 00000000000..ad12291dfef
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_configuration.py
@@ -0,0 +1,64 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any
+
+ from azure.core.credentials import TokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "3.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json
new file mode 100644
index 00000000000..040954580b9
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json
@@ -0,0 +1,80 @@
+{
+ "chosen_version": "3.0.0",
+ "total_api_version_list": ["3.0.0"],
+ "client": {
+ "name": "MultiapiServiceClient",
+ "filename": "_multiapi_service_client",
+ "description": "Service client for multiapi client testing.",
+ "base_url": "\u0027http://localhost:3000\u0027",
+ "custom_base_url": null,
+ "azure_arm": true,
+ "has_lro_operations": false,
+ "client_side_validation": false,
+ "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}",
+ "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MultiapiServiceClientConfiguration\"], \"._operations_mixin\": [\"MultiapiServiceClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}"
+ },
+ "global_parameters": {
+ "sync": {
+ "credential": {
+ "signature": "credential, # type: \"TokenCredential\"",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials.TokenCredential",
+ "required": true
+ }
+ },
+ "async": {
+ "credential": {
+ "signature": "credential: \"AsyncTokenCredential\",",
+ "description": "Credential needed for the client to connect to Azure.",
+ "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential",
+ "required": true
+ }
+ },
+ "constant": {
+ },
+ "call": "credential"
+ },
+ "config": {
+ "credential": true,
+ "credential_scopes": ["https://management.azure.com/.default"],
+ "credential_default_policy_type": "BearerTokenCredentialPolicy",
+ "credential_default_policy_type_has_async_version": true,
+ "credential_key_header_name": null,
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}"
+ },
+ "operation_groups": {
+ "operation_group_one": "OperationGroupOneOperations",
+ "operation_group_two": "OperationGroupTwoOperations"
+ },
+ "operation_mixins": {
+ "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Iterable\", \"Optional\", \"TypeVar\"]}}}",
+ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}",
+ "operations": {
+ "test_paging" : {
+ "sync": {
+ "signature": "def test_paging(\n self,\n **kwargs # type: Any\n):\n",
+ "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.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\""
+ },
+ "async": {
+ "coroutine": false,
+ "signature": "def test_paging(\n self,\n **kwargs\n) -\u003e AsyncItemPaged[\"_models.PagingResult\"]:\n",
+ "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[~azure.multiapi.sample.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"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_client.py
new file mode 100644
index 00000000000..eed6683367f
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_multiapi_service_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.mgmt.core import ARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Optional
+
+ from azure.core.credentials import TokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from .operations import OperationGroupTwoOperations
+from . import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.operations.OperationGroupOneOperations
+ :ivar operation_group_two: OperationGroupTwoOperations operations
+ :vartype operation_group_two: azure.multiapi.sample.operations.OperationGroupTwoOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials.TokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential, # type: "TokenCredential"
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ 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)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+ self.operation_group_two = OperationGroupTwoOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ def close(self):
+ # type: () -> None
+ self._client.close()
+
+ def __enter__(self):
+ # type: () -> MultiapiServiceClient
+ self._client.__enter__()
+ return self
+
+ def __exit__(self, *exc_details):
+ # type: (Any) -> None
+ self._client.__exit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/__init__.py
new file mode 100644
index 00000000000..c5088f7a288
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/__init__.py
@@ -0,0 +1,10 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from ._multiapi_service_client import MultiapiServiceClient
+__all__ = ['MultiapiServiceClient']
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_configuration.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_configuration.py
new file mode 100644
index 00000000000..780e83cdbf5
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_configuration.py
@@ -0,0 +1,60 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, TYPE_CHECKING
+
+from azure.core.configuration import Configuration
+from azure.core.pipeline import policies
+from azure.mgmt.core.policies import ARMHttpLoggingPolicy
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+VERSION = "unknown"
+
+class MultiapiServiceClientConfiguration(Configuration):
+ """Configuration for MultiapiServiceClient.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ **kwargs: Any
+ ) -> None:
+ if credential is None:
+ raise ValueError("Parameter 'credential' must not be None.")
+ super(MultiapiServiceClientConfiguration, self).__init__(**kwargs)
+
+ self.credential = credential
+ self.api_version = "3.0.0"
+ self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
+ kwargs.setdefault('sdk_moniker', 'multiapi-sample/{}'.format(VERSION))
+ self._configure(**kwargs)
+
+ def _configure(
+ self,
+ **kwargs: Any
+ ) -> None:
+ self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
+ self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
+ self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
+ self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
+ self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
+ self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
+ self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
+ self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
+ self.authentication_policy = kwargs.get('authentication_policy')
+ if self.credential and not self.authentication_policy:
+ self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py
new file mode 100644
index 00000000000..7c048980e72
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/_multiapi_service_client.py
@@ -0,0 +1,66 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import Any, Optional, TYPE_CHECKING
+
+from azure.mgmt.core import AsyncARMPipelineClient
+from msrest import Deserializer, Serializer
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from azure.core.credentials_async import AsyncTokenCredential
+
+from ._configuration import MultiapiServiceClientConfiguration
+from .operations import MultiapiServiceClientOperationsMixin
+from .operations import OperationGroupOneOperations
+from .operations import OperationGroupTwoOperations
+from .. import models
+
+
+class MultiapiServiceClient(MultiapiServiceClientOperationsMixin):
+ """Service client for multiapi client testing.
+
+ :ivar operation_group_one: OperationGroupOneOperations operations
+ :vartype operation_group_one: azure.multiapi.sample.aio.operations.OperationGroupOneOperations
+ :ivar operation_group_two: OperationGroupTwoOperations operations
+ :vartype operation_group_two: azure.multiapi.sample.aio.operations.OperationGroupTwoOperations
+ :param credential: Credential needed for the client to connect to Azure.
+ :type credential: ~azure.core.credentials_async.AsyncTokenCredential
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ credential: "AsyncTokenCredential",
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = MultiapiServiceClientConfiguration(credential, **kwargs)
+ self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
+
+ client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
+ self._serialize = Serializer(client_models)
+ self._serialize.client_side_validation = False
+ self._deserialize = Deserializer(client_models)
+
+ self.operation_group_one = OperationGroupOneOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+ self.operation_group_two = OperationGroupTwoOperations(
+ self._client, self._config, self._serialize, self._deserialize)
+
+ async def close(self) -> None:
+ await self._client.close()
+
+ async def __aenter__(self) -> "MultiapiServiceClient":
+ await self._client.__aenter__()
+ return self
+
+ async def __aexit__(self, *exc_details) -> None:
+ await self._client.__aexit__(*exc_details)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/__init__.py
new file mode 100644
index 00000000000..356f78798f2
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/__init__.py
@@ -0,0 +1,17 @@
+# 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 ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+from ._operation_group_two_operations import OperationGroupTwoOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+ 'OperationGroupTwoOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..9b0e477f519
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,140 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.async_paging import AsyncItemPaged, AsyncList
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin:
+
+ def test_paging(
+ self,
+ **kwargs
+ ) -> AsyncIterable["_models.PagingResult"]:
+ """Returns ModelThree with optionalProperty 'paged'.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.models.PagingResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.test_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.get(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ async def extract_data(pipeline_response):
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+ list_of_elem = deserialized.values
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, AsyncList(list_of_elem)
+
+ async def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ return pipeline_response
+
+ return AsyncItemPaged(
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..a4a0c822d0b
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_one_operations.py
@@ -0,0 +1,99 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations:
+ """OperationGroupOneOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def test_two(
+ self,
+ parameter_one: Optional["_models.ModelThree"] = None,
+ **kwargs
+ ) -> "_models.ModelThree":
+ """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree.
+
+ :param parameter_one: A ModelThree parameter.
+ :type parameter_one: ~azure.multiapi.sample.models.ModelThree
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelThree, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelThree
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelThree"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ api_version = "3.0.0"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_two.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if parameter_one is not None:
+ body_content = self._serialize.body(parameter_one, 'ModelThree')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('ModelThree', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py
new file mode 100644
index 00000000000..1c4f5a8c416
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_operation_group_two_operations.py
@@ -0,0 +1,150 @@
+# 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, IO, Optional, TypeVar, Union
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from ... import models as _models
+
+T = TypeVar('T')
+ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupTwoOperations:
+ """OperationGroupTwoOperations async operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer) -> None:
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ async def test_four(
+ self,
+ input: Optional[Union[IO, "_models.SourcePath"]] = None,
+ **kwargs
+ ) -> None:
+ """TestFour should be in OperationGroupTwoOperations.
+
+ :param input: Input parameter.
+ :type input: IO or ~azure.multiapi.sample.models.SourcePath
+ :keyword str content_type: Media type of the body sent to the API. Default value is "application/json".
+ Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json".
+ :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"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_four.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']:
+ body_content_kwargs['stream_content'] = input
+ elif header_parameters['Content-Type'].split(";")[0] in ['application/json']:
+ if input is not None:
+ body_content = self._serialize.body(input, 'SourcePath')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ else:
+ raise ValueError(
+ "The content_type '{}' is not one of the allowed values: "
+ "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type'])
+ )
+ request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore
+
+ async def test_five(
+ self,
+ **kwargs
+ ) -> None:
+ """TestFive should be in OperationGroupTwoOperations.
+
+ :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_five.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/__init__.py
new file mode 100644
index 00000000000..1c2b0959b7f
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/__init__.py
@@ -0,0 +1,30 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+try:
+ from ._models_py3 import Error
+ from ._models_py3 import ModelThree
+ from ._models_py3 import PagingResult
+ from ._models_py3 import SourcePath
+except (SyntaxError, ImportError):
+ from ._models import Error # type: ignore
+ from ._models import ModelThree # type: ignore
+ from ._models import PagingResult # type: ignore
+ from ._models import SourcePath # type: ignore
+
+from ._multiapi_service_client_enums import (
+ ContentType,
+)
+
+__all__ = [
+ 'Error',
+ 'ModelThree',
+ 'PagingResult',
+ 'SourcePath',
+ 'ContentType',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models.py
new file mode 100644
index 00000000000..576ad1d09ba
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models.py
@@ -0,0 +1,98 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = kwargs.get('status', None)
+ self.message = kwargs.get('message', None)
+
+
+class ModelThree(msrest.serialization.Model):
+ """Only exists in api version 3.0.0.
+
+ :param optional_property:
+ :type optional_property: str
+ """
+
+ _attribute_map = {
+ 'optional_property': {'key': 'optionalProperty', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(ModelThree, self).__init__(**kwargs)
+ self.optional_property = kwargs.get('optional_property', None)
+
+
+class PagingResult(msrest.serialization.Model):
+ """PagingResult.
+
+ :param values:
+ :type values: list[~azure.multiapi.sample.models.ModelThree]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'values': {'key': 'values', 'type': '[ModelThree]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(PagingResult, self).__init__(**kwargs)
+ self.values = kwargs.get('values', None)
+ self.next_link = kwargs.get('next_link', None)
+
+
+class SourcePath(msrest.serialization.Model):
+ """Uri or local path to source data.
+
+ :param source: File source path.
+ :type source: str
+ """
+
+ _validation = {
+ 'source': {'max_length': 2048, 'min_length': 0},
+ }
+
+ _attribute_map = {
+ 'source': {'key': 'source', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ **kwargs
+ ):
+ super(SourcePath, self).__init__(**kwargs)
+ self.source = kwargs.get('source', None)
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models_py3.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models_py3.py
new file mode 100644
index 00000000000..c3eec20e065
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_models_py3.py
@@ -0,0 +1,110 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from typing import List, Optional
+
+from azure.core.exceptions import HttpResponseError
+import msrest.serialization
+
+
+class Error(msrest.serialization.Model):
+ """Error.
+
+ :param status:
+ :type status: int
+ :param message:
+ :type message: str
+ """
+
+ _attribute_map = {
+ 'status': {'key': 'status', 'type': 'int'},
+ 'message': {'key': 'message', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ status: Optional[int] = None,
+ message: Optional[str] = None,
+ **kwargs
+ ):
+ super(Error, self).__init__(**kwargs)
+ self.status = status
+ self.message = message
+
+
+class ModelThree(msrest.serialization.Model):
+ """Only exists in api version 3.0.0.
+
+ :param optional_property:
+ :type optional_property: str
+ """
+
+ _attribute_map = {
+ 'optional_property': {'key': 'optionalProperty', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ optional_property: Optional[str] = None,
+ **kwargs
+ ):
+ super(ModelThree, self).__init__(**kwargs)
+ self.optional_property = optional_property
+
+
+class PagingResult(msrest.serialization.Model):
+ """PagingResult.
+
+ :param values:
+ :type values: list[~azure.multiapi.sample.models.ModelThree]
+ :param next_link:
+ :type next_link: str
+ """
+
+ _attribute_map = {
+ 'values': {'key': 'values', 'type': '[ModelThree]'},
+ 'next_link': {'key': 'nextLink', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ values: Optional[List["ModelThree"]] = None,
+ next_link: Optional[str] = None,
+ **kwargs
+ ):
+ super(PagingResult, self).__init__(**kwargs)
+ self.values = values
+ self.next_link = next_link
+
+
+class SourcePath(msrest.serialization.Model):
+ """Uri or local path to source data.
+
+ :param source: File source path.
+ :type source: str
+ """
+
+ _validation = {
+ 'source': {'max_length': 2048, 'min_length': 0},
+ }
+
+ _attribute_map = {
+ 'source': {'key': 'source', 'type': 'str'},
+ }
+
+ def __init__(
+ self,
+ *,
+ source: Optional[str] = None,
+ **kwargs
+ ):
+ super(SourcePath, self).__init__(**kwargs)
+ self.source = source
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_multiapi_service_client_enums.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_multiapi_service_client_enums.py
new file mode 100644
index 00000000000..0666ddf8a0b
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/models/_multiapi_service_client_enums.py
@@ -0,0 +1,36 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+
+from enum import Enum, EnumMeta
+from six import with_metaclass
+
+class _CaseInsensitiveEnumMeta(EnumMeta):
+ def __getitem__(self, name):
+ return super().__getitem__(name.upper())
+
+ def __getattr__(cls, name):
+ """Return the enum member matching `name`
+ We use __getattr__ instead of descriptors or inserting into the enum
+ class' __dict__ in order to support `name` and `value` being both
+ properties for enum members (which live in the class' __dict__) and
+ enum members themselves.
+ """
+ try:
+ return cls._member_map_[name.upper()]
+ except KeyError:
+ raise AttributeError(name)
+
+
+class ContentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
+ """Content type for upload
+ """
+
+ APPLICATION_PDF = "application/pdf" #: Content Type 'application/pdf'.
+ IMAGE_JPEG = "image/jpeg" #: Content Type 'image/jpeg'.
+ IMAGE_PNG = "image/png" #: Content Type 'image/png'.
+ IMAGE_TIFF = "image/tiff" #: Content Type 'image/tiff'.
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/__init__.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/__init__.py
new file mode 100644
index 00000000000..356f78798f2
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/__init__.py
@@ -0,0 +1,17 @@
+# 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 ._multiapi_service_client_operations import MultiapiServiceClientOperationsMixin
+from ._operation_group_one_operations import OperationGroupOneOperations
+from ._operation_group_two_operations import OperationGroupTwoOperations
+
+__all__ = [
+ 'MultiapiServiceClientOperationsMixin',
+ 'OperationGroupOneOperations',
+ 'OperationGroupTwoOperations',
+]
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py
new file mode 100644
index 00000000000..59e2e3477f3
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_multiapi_service_client_operations.py
@@ -0,0 +1,146 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.paging import ItemPaged
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class MultiapiServiceClientOperationsMixin(object):
+
+ def test_paging(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> Iterable["_models.PagingResult"]
+ """Returns ModelThree with optionalProperty 'paged'.
+
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: An iterator like instance of either PagingResult or the result of cls(response)
+ :rtype: ~azure.core.paging.ItemPaged[~azure.multiapi.sample.models.PagingResult]
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.PagingResult"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ accept = "application/json"
+
+ def prepare_request(next_link=None):
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ if not next_link:
+ # Construct URL
+ url = self.test_paging.metadata['url'] # type: ignore
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+
+ request = self._client.get(url, query_parameters, header_parameters)
+ else:
+ url = next_link
+ query_parameters = {} # type: Dict[str, Any]
+ request = self._client.get(url, query_parameters, header_parameters)
+ return request
+
+ def extract_data(pipeline_response):
+ deserialized = self._deserialize('PagingResult', pipeline_response)
+ list_of_elem = deserialized.values
+ if cls:
+ list_of_elem = cls(list_of_elem)
+ return deserialized.next_link or None, iter(list_of_elem)
+
+ def get_next(next_link=None):
+ request = prepare_request(next_link)
+
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ raise HttpResponseError(response=response, error_format=ARMErrorFormat)
+
+ return pipeline_response
+
+ return ItemPaged(
+ 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/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py
new file mode 100644
index 00000000000..809b5a2bb68
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_one_operations.py
@@ -0,0 +1,104 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, Optional, TypeVar
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupOneOperations(object):
+ """OperationGroupOneOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def test_two(
+ self,
+ parameter_one=None, # type: Optional["_models.ModelThree"]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> "_models.ModelThree"
+ """TestTwo should be in OperationGroupOneOperations. Takes in ModelThree and ouputs ModelThree.
+
+ :param parameter_one: A ModelThree parameter.
+ :type parameter_one: ~azure.multiapi.sample.models.ModelThree
+ :keyword callable cls: A custom type or function that will be passed the direct response
+ :return: ModelThree, or the result of cls(response)
+ :rtype: ~azure.multiapi.sample.models.ModelThree
+ :raises: ~azure.core.exceptions.HttpResponseError
+ """
+ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelThree"]
+ error_map = {
+ 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
+ }
+ error_map.update(kwargs.pop('error_map', {}))
+ api_version = "3.0.0"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_two.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if parameter_one is not None:
+ body_content = self._serialize.body(parameter_one, 'ModelThree')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ deserialized = self._deserialize('ModelThree', pipeline_response)
+
+ if cls:
+ return cls(pipeline_response, deserialized, {})
+
+ return deserialized
+ test_two.metadata = {'url': '/multiapi/one/testTwoEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py
new file mode 100644
index 00000000000..b390729d5cd
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/operations/_operation_group_two_operations.py
@@ -0,0 +1,156 @@
+# coding=utf-8
+# --------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See License.txt in the project root for license information.
+# Code generated by Microsoft (R) AutoRest Code Generator.
+# Changes may cause incorrect behavior and will be lost if the code is regenerated.
+# --------------------------------------------------------------------------
+from typing import TYPE_CHECKING
+import warnings
+
+from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
+from azure.core.pipeline import PipelineResponse
+from azure.core.pipeline.transport import HttpRequest, HttpResponse
+from azure.mgmt.core.exceptions import ARMErrorFormat
+
+from .. import models as _models
+
+if TYPE_CHECKING:
+ # pylint: disable=unused-import,ungrouped-imports
+ from typing import Any, Callable, Dict, Generic, IO, Optional, TypeVar, Union
+
+ T = TypeVar('T')
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
+
+class OperationGroupTwoOperations(object):
+ """OperationGroupTwoOperations operations.
+
+ You should not instantiate this class directly. Instead, you should create a Client instance that
+ instantiates it for you and attaches it as an attribute.
+
+ :ivar models: Alias to model classes used in this operation group.
+ :type models: ~azure.multiapi.sample.models
+ :param client: Client for service requests.
+ :param config: Configuration of service client.
+ :param serializer: An object model serializer.
+ :param deserializer: An object model deserializer.
+ """
+
+ models = _models
+
+ def __init__(self, client, config, serializer, deserializer):
+ self._client = client
+ self._serialize = serializer
+ self._deserialize = deserializer
+ self._config = config
+
+ def test_four(
+ self,
+ input=None, # type: Optional[Union[IO, "_models.SourcePath"]]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestFour should be in OperationGroupTwoOperations.
+
+ :param input: Input parameter.
+ :type input: IO or ~azure.multiapi.sample.models.SourcePath
+ :keyword str content_type: Media type of the body sent to the API. Default value is "application/json".
+ Allowed values are: "application/pdf", "image/jpeg", "image/png", "image/tiff", "application/json".
+ :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"
+ content_type = kwargs.pop("content_type", "application/json")
+ accept = "application/json"
+
+ # Construct URL
+ url = self.test_four.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['Content-Type'] = self._serialize.header("content_type", content_type, 'str')
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ body_content_kwargs = {} # type: Dict[str, Any]
+ if header_parameters['Content-Type'].split(";")[0] in ['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']:
+ body_content_kwargs['stream_content'] = input
+ elif header_parameters['Content-Type'].split(";")[0] in ['application/json']:
+ if input is not None:
+ body_content = self._serialize.body(input, 'SourcePath')
+ else:
+ body_content = None
+ body_content_kwargs['content'] = body_content
+ else:
+ raise ValueError(
+ "The content_type '{}' is not one of the allowed values: "
+ "['application/pdf', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type'])
+ )
+ request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs)
+ pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
+ response = pipeline_response.http_response
+
+ if response.status_code not in [200]:
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
+ error = self._deserialize(_models.Error, response)
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
+
+ if cls:
+ return cls(pipeline_response, None, {})
+
+ test_four.metadata = {'url': '/multiapi/two/testFourEndpoint'} # type: ignore
+
+ def test_five(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ """TestFive should be in OperationGroupTwoOperations.
+
+ :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_five.metadata['url'] # type: ignore
+
+ # Construct parameters
+ query_parameters = {} # type: Dict[str, Any]
+ query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
+
+ # Construct headers
+ header_parameters = {} # type: Dict[str, Any]
+ header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
+
+ request = self._client.put(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_five.metadata = {'url': '/multiapi/two/testFiveEndpoint'} # type: ignore
diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/py.typed b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/multiapi/readme.md b/docs/samples/specification/multiapi/readme.md
new file mode 100644
index 00000000000..3c254deb03f
--- /dev/null
+++ b/docs/samples/specification/multiapi/readme.md
@@ -0,0 +1,66 @@
+# Sample Multi API Generation
+
+This sample generates 3 API version: `v1`, `v2`, and `v3`. We first generate each API version individually in
+a batch execution, then generate a multi API client on top of these generated API versions
+
+### Settings
+
+``` yaml
+namespace: azure.multiapi.sample
+package-name: azure-multiapi-sample
+no-namespace-folders: true
+license-header: MICROSOFT_MIT_NO_VERSION
+azure-arm: true
+add-credential: true
+```
+
+### Multi API Generation
+
+These settings apply only when `--multiapi` is specified on the command line.
+
+``` yaml $(multiapi)
+clear-output-folder: true
+batch:
+ - tag: v1
+ - tag: v2
+ - tag: v3
+ - multiapiscript: true
+```
+
+### Multi API script
+
+``` yaml $(multiapiscript)
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample
+clear-output-folder: false
+perform-load: false
+```
+
+### Tag: v1
+
+These settings apply only when `--tag=v1` is specified on the command line.
+
+``` yaml $(tag) == 'v1'
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/multiapi-v1.json
+namespace: azure.multiapi.sample.v1
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample/v1
+```
+
+### Tag: v2
+
+These settings apply only when `--tag=v2` is specified on the command line.
+
+``` yaml $(tag) == 'v2'
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/multiapi-v2.json
+namespace: azure.multiapi.sample.v2
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample/v2
+```
+
+### Tag: v3
+
+These settings apply only when `--tag=v2` is specified on the command line.
+
+``` yaml $(tag) == 'v3'
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/multiapi-v3.json
+namespace: azure.multiapi.sample.v3
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample/v3
+```
\ No newline at end of file
diff --git a/tasks.py b/tasks.py
index 615c2b10a30..357552df64c 100644
--- a/tasks.py
+++ b/tasks.py
@@ -263,6 +263,7 @@ def regenerate(c, swagger_name=None, debug=False):
regenerate_credential_default_policy(c, debug)
regenerate_package_name_setup_py(c, debug)
regenerate_custom_poller_pager(c, debug)
+ regenerate_samples(c, debug)
@task
@@ -333,3 +334,27 @@ def regenerate_custom_poller_pager(c, debug=False):
f'autorest test/azure/specification/custompollerpager/README.md --use=. --python-sdks-folder={cwd}/test/'
)
_run_autorest([cmd], debug=debug)
+
+@task
+def regenerate_samples(c, debug=False):
+ cwd = os.getcwd()
+ sample_to_special_flags = {
+ "management": None,
+ "multiapi": {
+ "multiapi": True,
+ "python-sdks-folder": f'{cwd}/docs/samples/specification/multiapi'
+ },
+ "azure_key_credential": None,
+ "directives": None,
+ }
+
+ cmds = []
+ for sample, special_flags in sample_to_special_flags.items():
+ cmd = f'autorest docs/samples/specification/{sample}/readme.md --use=. '
+ if special_flags:
+ flag_strings = [
+ f"--{flag}={value}" for flag, value in special_flags.items()
+ ]
+ cmd += " ".join(flag_strings)
+ cmds.append(cmd)
+ _run_autorest(cmds, debug)