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
new file mode 100644
index 00000000000..c11395375df
--- /dev/null
+++ b/docs/client/initializing.md
@@ -0,0 +1,99 @@
+#
Initializing Your Python Client
+
+The first step to using your generated client in code is to import and initialize your client. Our SDKs are modelled such
+that the client is the main point of access to the generated code.
+
+## Importing Your Client
+
+You import your client from the namespace specified when generating (under flag `--namespace`). For the sake of this example,
+let's say the namespace is `azure.pets`. Your client's name is detailed in the swagger, (TODO link to swagger docs), and let's say
+ours is called `PetsClient`.
+
+Putting this together, we import our client like so:
+
+```python
+from azure.pets import PetsClient
+```
+
+## 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:
+
+| Library | Description | Min Version
+|------------------|-------------|-------------
+|[`azure-core`][azure_core_library]|The most important library to have installed. It provides shared exceptions and modules for all the Python SDK client libraries.|1.8.2
+|[`msrest`][msrest_library]|Library mainly used for serializing and deserializing objects|0.6.18
+|[`azure-mgmt-core`][azure_mgmt_core_library]|Required if you're generating mgmt plane code (see `--azure-arm` flag in our [flag index][flag_index]. Provides mgmt plane specific shared exceptions and modules.|1.2.1
+
+> Note: We highly recommend tying your library to a major version, for instance, adding `azure-core<2.0.0` to tie the `azure-core` library to `1.x.x`
+
+## Initializing and Authenticating Your Client
+
+Next, on to initialization. Your constructor can take any number of parameters. By default we generate our clients with an [Azure Active Directory (AAD) token credential][aad_authentication]. We always recommend
+using a [credential type][identity_credentials] obtained from the [`azure-identity`][azure_identity_library] library for AAD authentication. For this example,
+we use the most common [`DefaultAzureCredential`][default_azure_credential].
+
+As an installation note, the [`azure-identity`][azure_identity_library] library is not a requirement in the basic `setup.py` file we generate
+(see `--basic-setup-py` in our [flag index][flag_index] for more information), so you would need to explicitly include this library.
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+```
+
+You can also have your generated client take in an [`AzureKeyCredential`][azure_key_credential] instead. To do so, generate with flag `--credential-types=AzureKeyCredential`,
+and for more information on this flag, see our [flag index][flag_index]
+
+```python
+from azure.core.credentials import AzureKeyCredential
+from azure.pets import PetsClient
+
+credential = "myCredential"
+client = PetsClient(credential=AzureKeyCredential(credential))
+```
+
+Each of these credential types also correspond to their own authentication policies that handle the credential. AutoRest automatically generates with the following default authentication policies based on the credential types:
+
+| Credential Type | Authentication Policy
+|------------------|-------------
+|[`TokenCredential`][aad_authentication] | [`BearerTokenCredentialPolicy`][bearer_token_credential_policy]
+|[`AzureKeyCredential`][azure_key_credential] | [`AzureKeyCredentialPolicy`][azure_key_credential_policy]
+
+Currently, we only support generating credentials of type [`TokenCredential`][aad_authentication] and / or [`AzureKeyCredential`][azure_key_credential]. If you'd like to use your own custom credential,
+you can pass the custom type into the client. However, you may have to use a custom authentication policy to handle the credential. That can also be passed in to the
+client. Say your custom credential is called `MyCredential`, and the policy that handles this credential is called `MyAuthenticationPolicy`. Initializing your
+client would look something like `client = PetsClient(credential=MyCredential(), authentication_policy=MyAuthenticationPolicy())`, though this of course varies
+based on inputs.
+
+## Multi API Client
+
+Initializing your Multi API client is very similar to initializing a normal client. The only difference is there's an added optional
+parameter `api_version`. With this parameter, you can specify the API version you want your client to have. If not specified, the multi
+API client uses the default API version.
+
+Using the Multi API client we generated in our [multi API generation][multiapi_generation], our example client uses default API version
+`v2`. If we would like our client at runtime to have API version `v1`, we would initialize our client like:
+
+```python
+from azure.identity import DefaultAzureCredential
+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/
+[msrest_library]: https://pypi.org/project/msrest/
+[azure_mgmt_core_library]: https://pypi.org/project/azure-mgmt-core/
+[azure_identity_library]: https://pypi.org/project/azure-identity/
+[flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md
+[aad_authentication]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
+[identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#credentials
+[default_azure_credential]: https://docs.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
+[azure_key_credential]: https://docs.microsoft.com/python/api/azure-core/azure.core.credentials.azurekeycredential?view=azure-python
+[bearer_token_credential_policy]: https://docs.microsoft.com/python/api/azure-core/azure.core.pipeline.policies.bearertokencredentialpolicy?view=azure-python
+[azure_key_credential_policy]: https://docs.microsoft.com/python/api/azure-core/azure.core.pipeline.policies.azurekeycredentialpolicy?view=azure-python
diff --git a/docs/client/models.md b/docs/client/models.md
new file mode 100644
index 00000000000..31af143eeb5
--- /dev/null
+++ b/docs/client/models.md
@@ -0,0 +1,39 @@
+#
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. We've included a code snippet showing you how to access models in both situations.
+
+```python
+from azure.multiapi.sample import MultiapiServiceClient
+from azure.identity import DefaultAzureCredential
+
+client = MultiapiServiceClient(credential=DefaultAzureCredential())
+
+default_api_version_models = client.models()
+v3_models = client.models(api_version='3.0.0')
+```
+
+
+[models_ex]: ../samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py#L91
diff --git a/docs/client/operations.md b/docs/client/operations.md
new file mode 100644
index 00000000000..00436da620a
--- /dev/null
+++ b/docs/client/operations.md
@@ -0,0 +1,157 @@
+#
Calling Operations with Your Python Client
+
+AutoRest provides both synchronous and asynchronous method overloads for each service operation.
+Depending on your swagger definition, operations can be accessed through operation groups (TODO: link to swagger docs) on the client,
+or directly on the client.
+
+## Operation Group vs No Operation Group
+
+If your swagger defines an operation group for your operation (for example, in [this][operation_group_example] swagger, the operation `list`
+is part of operation group `application`), you would access the operation through `client.application.list()`.
+
+If there's no operation group, as in [this][mixin_example] case, you would access the operation directly from the client
+itself, i.e. `client.get_dog()`.
+
+## Regular Operations
+
+### Sync Operations
+
+We will be using the [example swagger][pets_swagger] in our main docs repo. After [initializing][initializing] our client, we
+call our operation like this:
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+dog = client.get_dog()
+```
+
+### Async Operations
+
+When calling our async operations, we use our async client, which is in a different module. Following the [example above](#sync-operations "Sync Operations"),
+our call to `get_dog` looks like this:
+
+```python
+import asyncio
+from azure.identity import DefaultAzureCredential
+from azure.pets.aio import PetsClient
+
+async def get_my_dog():
+ async with PetsClient(credential=DefaultAzureCredential()) as client:
+ dog = await client.get_dog()
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(get_my_dog())
+loop.close()
+```
+
+## Long Running Operations
+
+Long-running operations are operations which consist of an initial request sent to the service to start an operation, followed by polling the service at intervals to determine whether the operation has completed or failed, and if it has succeeded, to get the result.
+
+In concurrence with our [python guidelines][poller_guidelines], all of our long running operations are prefixed with `begin_`, to signify the starting of the long running operation.
+
+For our example, we will use the long running operation generated from [this][example_swagger] swagger. Let's say we generated this swagger with namespace `azure.lro`.
+
+### Sync Long Running Operations
+
+By default, our sync long running operations return an [`LROPoller`][lro_poller] polling object, though there [are ways][custom_poller] of changing this. Calling `.wait()` on this poller
+waits for the operation to finish, while calling `.result()` both waits on the operation and returns the final response.
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.lro import PollingPagingExampleClient
+from azure.lro.models import Product
+
+client = PollingPagingExampleClient(credential=DefaultAzureCredential())
+input_product = Product(id=1, name="My Polling Example")
+poller = client.begin_basic_polling(product=input_product)
+output_product = poller.result()
+```
+
+### Async Long Running Operations
+
+By default, our async long running operations return an [`AsyncLROPoller`][async_lro_poller] polling object, though there [are ways][custom_poller] of changing this. Same as the sync version,
+calling `.wait()` on this poller waits for the operation to finish, while calling `.result()` both waits on the operation and returns the final response.
+
+```python
+import asyncio
+from azure.identity import DefaultAzureCredential
+from azure.lro.aio import PollingPagingExampleClient
+from azure.lro.models import Product
+
+async def basic_polling():
+ async with PollingPagingExampleClient(credential=DefaultAzureCredential()) as client:
+ input_product = Product(id=1, name="My Polling Example")
+ poller = await client.begin_basic_polling(product=input_product)
+ output_product = await poller.result()
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(basic_polling())
+loop.close()
+```
+
+## Paging Operations
+
+A paging operation pages through lists of data, returning an iterator for the items. Network calls get made when users start iterating through the output, not when the operation
+is initially called.
+
+For our example, we will use the long running operation generated from [this][example_swagger] swagger. Let's say we generated this swagger with namespace `azure.paging`.
+
+### Sync Paging Operations
+
+By default, our sync paging operations return an [`ItemPaged`][item_paged] pager, though there [are ways][custom_pager] of changing this. The initial call to the function returns
+the pager, but doesn't make any network calls. Instead, calls are made when users start iterating, with each network call returning a page of data.
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.paging import PollingPagingExampleClient
+
+client = PollingPagingExampleClient(credential=DefaultAzureCredential())
+pages = client.basic_paging()
+[print(page) for page in pages]
+```
+
+### Async Paging Operations
+
+By default, our async paging operations return an [`AsyncItemPaged`][async_item_paged] pager, though there [are ways][custom_pager] of changing this. Since network calls aren't
+made until starting to page, our generated operation is synchronous, and there's no need to wait the initial call to the function. Since network calls are made when iterating,
+we have to do async looping.
+
+```python
+import asyncio
+from azure.identity import DefaultAzureCredential
+from azure.paging.aio import PollingPagingExampleClient
+
+async def basic_paging():
+ async with PollingPagingExampleClient(credential=DefaultAzureCredential()) as client:
+ pages = client.basic_paging() # note how there's no awaiting here
+ async for page in pages: # since network calls are only made during iteration, we await the network calls when iterating
+ print(page)
+
+loop = asyncio.get_event_loop()
+loop.run_until_complete(basic_paging())
+loop.close()
+```
+
+
+## Advanced: LRO + paging
+
+We also support generating a long running paging operation. In this case, we return a poller from the operation, and the final result from the poller is
+a pager that pages through the final lists of data.
+
+
+
+[operation_group_example]: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/batch/data-plane/Microsoft.Batch/stable/2020-09-01.12.0/BatchService.json#L64
+[mixin_example]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json#L20
+[pets_swagger]: https://github.com/Azure/autorest/blob/master/docs/openapi/examples/pets.json
+[initializing]: ./initializing.md
+[lro_poller]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
+[custom_poller]: ../generate/directives.md#generate-with-a-custom-poller
+[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/python/api/azure-core/azure.core.polling.asynclropoller?view=azure-python
+[item_paged]: https://docs.microsoft.com/python/api/azure-core/azure.core.paging.itempaged?view=azure-python
+[custom_pager]: ../generate/directives.md#generate-with-a-custom-pager
+[async_item_paged]: https://docs.microsoft.com/python/api/azure-core/azure.core.async_paging.asyncitempaged?view=azure-python
\ No newline at end of file
diff --git a/docs/client/readme.md b/docs/client/readme.md
new file mode 100644
index 00000000000..f1ea82ba0f2
--- /dev/null
+++ b/docs/client/readme.md
@@ -0,0 +1,17 @@
+#
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]
+* [Troubleshooting][troubleshooting]
+* [Tracing][tracing]
+
+
+[generate]: https://github.com/Azure/autorest/tree/master/docs/generate/readme.md
+[initializing]: ./initializing.md
+[operations]: ./operations.md
+[models]: ./models.md
+[troubleshooting]: ./troubleshooting.md
+[tracing]: ./tracing.md
\ No newline at end of file
diff --git a/docs/client/tracing.md b/docs/client/tracing.md
new file mode 100644
index 00000000000..9e237ea0da9
--- /dev/null
+++ b/docs/client/tracing.md
@@ -0,0 +1,92 @@
+#
Tracing
+
+Our generated code can natively support tracing libraries [`OpenCensus`][open_census] and [`OpenTelemetry`][open_telemetry]. To do so, generate with flag `--trace` (see our [flag index][flag_index] for more information).
+
+## OpenCensus
+
+First step is to install our [`OpenCensus` library][our_open_census_library]:
+
+```python
+pip install azure-core-tracing-opencensus
+```
+
+Our generated SDKs handle retrieving context for you, so there's no need to pass in any context. Additionally, the
+OpenCensus threading plugin is included when installing this package.
+
+Since there is no explicit context you need to pass, you can create your usual OpenCensus tracer and call the generated SDKs.
+The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.).
+
+```python
+from opencensus.ext.azure.trace_exporter import AzureExporter
+from opencensus.trace.tracer import Tracer
+from opencensus.trace.samplers import AlwaysOnSampler
+
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+exporter = AzureExporter(
+ instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
+)
+tracer = Tracer(exporter=exporter, sampler=AlwaysOnSampler())
+with tracer.span(name="MyApplication") as span:
+ client = PetsClient(credential=DefaultAzureCredential())
+ dog = client.get_dog() # Call will be traced
+```
+
+## OpenTelemetry
+
+First step is to install our [`OpenTelemetry` library][our_open_telemetry_library]:
+
+```python
+pip install azure-core-tracing-opentelemetry
+```
+
+Our generated SDKs handle retrieving context for you, so there's no need to pass in any context.
+Since there is no explicit context you need to pass, you can create your usual OpenTelemetry tracer and call the generated SDKs.
+The following example uses [`Azure Monitor`'s][azure_monitor] exporter, but you can use any exporter ([Zipkin][zipkin], etc.).
+
+```python
+# Declare OpenTelemetry as an enabled tracing plugin for Azure SDKs
+from azure.core.settings import settings
+from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
+
+settings.tracing_implementation = OpenTelemetrySpan
+
+# In the below example, we use the Azure Monitor exporter, but you can use anything OpenTelemetry supports
+from azure_monitor import AzureMonitorSpanExporter
+exporter = AzureMonitorSpanExporter(
+ instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
+)
+
+# Regular open telemetry usage from here, see https://github.com/open-telemetry/opentelemetry-python
+# for details
+from opentelemetry import trace
+from opentelemetry.sdk.trace import TracerProvider
+from opentelemetry.sdk.trace.export import ConsoleSpanExporter
+from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
+
+# Simple console exporter
+exporter = ConsoleSpanExporter()
+
+trace.set_tracer_provider(TracerProvider())
+tracer = trace.get_tracer(__name__)
+trace.get_tracer_provider().add_span_processor(
+ SimpleExportSpanProcessor(exporter)
+)
+
+# Example with our Pets example
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+dog = client.get_dog() # Call will be traced
+```
+
+
+[open_census]: https://opencensus.io/
+[open_telemetry]: https://opentelemetry.io/
+[flag_index]: https://github.com/Azure/autorest/tree/master/docs/generate/flags.md
+[our_open_census_library]: https://pypi.org/project/azure-core-tracing-opencensus/
+[azure_monitor]: https://pypi.org/project/opentelemetry-azure-monitor/
+[zipkin]: https://zipkin.io/
+[our_open_telemetry_library]: https://pypi.org/project/azure-core-tracing-opentelemetry/
diff --git a/docs/client/troubleshooting.md b/docs/client/troubleshooting.md
new file mode 100644
index 00000000000..79e2a88e974
--- /dev/null
+++ b/docs/client/troubleshooting.md
@@ -0,0 +1,91 @@
+#
Troubleshooting
+
+## Error Handling
+
+Our generated clients raise [exceptions defined in `azure-core`][azure_core_exceptions]. While the base for all exceptions is [`AzureError`][azure_error],
+[`HttpResponseError`][http_response_error] is also a common base catch-all for exceptions, as these errors are thrown in the case of a request being made, and a non-successful
+status code being received from the service.
+
+Our generated code also offers some default mapping of status codes to exceptions. These are `401` to [`ClientAuthenticationError`][client_authentication_error], `404` to
+[`ResourceNotFoundError`][resource_not_found_error], and `409` to [`ResourceExistsError`][resource_exists_error].
+
+A very basic form of error handling looks like this:
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+try:
+ dog = client.get_dog()
+except HttpResponseError as e:
+ print("{}: {}".format(e.status_code, e.message))
+```
+
+You can also catch errors with more granularity, i.e. just catching a `ResourceExistsError`.
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+try:
+ dog = client.get_dog()
+except ResourceExistsError as e:
+ print(e.message)
+```
+
+A final note regarding error models: If you define your own special error model (like [this][error_model]), we still expose these to the users. Though the error thrown to
+the user will be one defined in [`azure-core`][azure_core_exceptions] (most likely [`HttpResponseError`][http_response_error]), we expose your specially-defined swagger
+models through the `model` property on the returned error. I.e.:
+
+```python
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+client = PetsClient(credential=DefaultAzureCredential())
+try:
+ dog = client.get_dog()
+except HttpResponseError as e:
+ pet_action_error = e.model
+```
+
+## Logging
+
+Our generated libraries use the standard [`logging`][logging] library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO level.
+Our logger's name is `azure`.
+
+Detailed DEBUG level logging, including request/response bodies and un-redacted headers, can be enabled on a client with the logging_enable argument:
+
+```python
+import logging
+import sys
+from azure.identity import DefaultAzureCredential
+from azure.pets import PetsClient
+
+# Create a logger for the 'azure' SDK
+logger = logging.getLogger('azure')
+logger.setLevel(logging.DEBUG)
+
+# Configure a console output
+handler = logging.StreamHandler(stream=sys.stdout)
+logger.addHandler(handler)
+
+client = PetsClient(credential=DefaultAzureCredential(), logging_enable=True)
+```
+
+Network trace logging can also be enabled for any single operation:
+
+```python
+dog = client.get_dog(logging_enable=True)
+```
+
+
+[azure_core_exceptions]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core#azure-core-library-exceptions
+[azure_error]: https://docs.microsoft.com/python/api/azure-core/azure.core.exceptions.azureerror?view=azure-python
+[http_response_error]: https://docs.microsoft.com/python/api/azure-core/azure.core.exceptions.httpresponseerror?view=azure-python
+[client_authentication_error]: https://docs.microsoft.com/python/api/azure-core/azure.core.exceptions.clientauthenticationerror?view=azure-python
+[resource_not_found_error]: https://docs.microsoft.com/python/api/azure-core/azure.core.exceptions.resourcenotfounderror?view=azure-python
+[resource_exists_error]: https://docs.microsoft.com/python/api/azure-core/azure.core.exceptions.resourceexistserror?view=azure-python
+[error_model]: https://github.com/Azure/autorest.testserver/blob/master/swagger/xms-error-responses.json#L220
+[logging]: https://docs.python.org/3.5/library/logging.html
\ No newline at end of file
diff --git a/docs/developer/readme.md b/docs/developer/readme.md
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/docs/faq.md b/docs/faq.md
new file mode 100644
index 00000000000..fd848ed4e0f
--- /dev/null
+++ 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
new file mode 100644
index 00000000000..bfe37dd3eb0
--- /dev/null
+++ b/docs/generate/directives.md
@@ -0,0 +1,166 @@
+#
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:
+
+````
+```yaml
+directive:
+ from: swagger-document
+ where: ...
+ transform: ...
+```
+````
+
+Additionally, they all require you to specify which operation you would like to modify. You refer to operation using it's path in the swagger, and the HTTP verb it's listed under.
+So, if you were modifying the `put` operation under the path `/directives/polling`, your `where` part of the directive would look like `where: '$.paths["/directives/polling"].put'`
+
+Where they differ is in the conditions your custom objects need to fulfill, how you mark the directive, and how they change the generated code.
+
+The following scenarios all use the [pollingPaging.json][polling_paging_swagger] example swagger.
+
+
+* [Generate with a Custom Poller](#generate-with-a-custom-poller "Generate with a Custom Poller")
+* [Generate with a Custom Default Polling Method](#generate-with-a-custom-default-polling-method "Generate with a Custom Default Polling Method")
+* [Generate with a Custom Pager](#generate-with-a-custom-pager "Generate with a Custom Pager")
+* [Generate with a Custom Paging Method](#generate-with-a-custom-paging-method "Generate with a Custom Paging Method")
+
+## Generate with a Custom Poller
+
+By default, a long running operation will generate with poller [`LROPoller`][lro_poller_docs] from [azure-core][azure_core_pypi]'s polling library (the async version being [`AsyncLROPoller`][async_lro_poller_docs]). With this directive, you can change the generated code to generate with your custom poller.
+
+### Custom Poller Conditions
+
+1. It must take in a `Generic` of the final response object type, i.e. its definition should look like `class CustomPoller(Generic[PollingReturnType]):`
+2. The initialization parameters must be the same as [`LROPoller`][lro_poller_docs]'s
+3. If you want continuation token support on your poller, you need to implement class method `from_continuation_token` with the same method signature as [`LROPoller`][lro_poller_docs]'s
+
+We will be modifying the long running operation in the [example swagger][polling_paging_swagger], so the `where` in our directive will be `where: '$.paths["/directives/polling"].put'`
+
+We use `$["x-python-custom-poller-sync"]` and `$["x-python-custom-poller-async"]` to specify our sync and async custom pollers. You have to use the full import path of the custom poller you're specifying, i.e. `my.library.CustomPoller`. Putting this altogether, we get the following directive, which we will insert in our config file.
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/polling"].put'
+ transform: >
+ $["x-python-custom-poller-sync"] = "my.library.CustomPoller";
+ $["x-python-custom-poller-async"] = "my.library.aio.AsyncCustomPoller"
+```
+
+To illustrate the generated code difference, here is the before and after of typing and docstrings. Not including the full code for the sake of room.
+
+**Without directive:**
+#
+
+**With directive:**
+#
+
+
+## Generate with a Custom Default Polling Method
+
+By default, a long running operation will generate with default polling method [`LROBasePolling`][lro_base_polling_docs], or [`ARMPolling`][arm_polling_docs] in `azure-arm` mode (the async versions being [`AsyncLROBasePolling`][async_lro_base_polling_docs] and [`AsyncARMPolling`][async_arm_polling_docs]). With this directive, you can change the generated code to generate with your custom default polling method.
+
+You can also pass in a polling method through `kwargs` to each operation. Use this directive if you want the generated code to generate with your custom default polling method, instead of passing in your custom polling method to the generated code.
+
+### Custom Default Polling Method Conditions
+
+1. It must implement the abstract base class for [`PollingMethod`][polling_method_docs] (async [`AsyncPollingMethod` docs here][async_polling_method_docs]). You can also inherit from one of our existing polling method implementations, for example [`LROBasePolling`][lro_base_polling_docs], and modify as needed.
+
+We use `$["x-python-custom-default-polling-method-sync"]` and `$["x-python-custom-default-polling-method-async"]` to specify our sync and async custom default polling methods. You have to use the full import path of the custom default polling method you're specifying, i.e. `my.library.CustomDefaultPollingMethod`. Putting this altogether, we get the following directive, which we will insert in our config file.
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/polling"].put'
+ transform: >
+ $["x-python-custom-default-polling-method-sync"] = "my.library.CustomDefaultPollingMethod";
+ $["x-python-custom-default-polling-method-async"] = "my.library.aio.AsyncCustomDefaultPollingMethod"
+```
+
+To illustrate the generated code difference, here is the before and after of typing and docstrings. Not including the full code for the sake of room.
+
+**Without directive:**
+#
+
+**With directive:**
+#
+
+## Generate with a Custom Pager
+
+By default, a paging operation will generate with pager [`ItemPaged`][item_paged_docs] from [azure-core][azure_core_pypi]'s polling library (the async version being [`AsyncItemPaged`][async_item_paged_docs]). With this directive, you can change the generated code to generate with your custom pager.
+
+### Custom Pager Conditions
+
+1. Your custom pager must have the same initialization parameters as [`ItemPaged`][item_paged_docs]
+
+We will be modifying the paging operation in the [example swagger][polling_paging_swagger], so the `where` in our directive will be `where: '$.paths["/directives/paging"].get'`
+
+We use `$["x-python-custom-pager-sync"]` and `$["x-python-custom-pager-async"]` to specify our sync and async custom pagers. You have to use the full import path of the custom pager you're specifying, i.e. `my.library.CustomPager`. Putting this altogether, we get the following directive, which we will insert in our config file.
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/paging"].get'
+ transform: >
+ $["x-python-custom-pager-sync"] = "my.library.CustomPager";
+ $["x-python-custom-pager-async"] = "my.library.aio.AsyncCustomPager"
+```
+
+To illustrate the generated code difference, here is the before and after of typing and docstrings. Not including the full code for the sake of room.
+
+**Without directive:**
+#
+
+**With directive:**
+#
+
+## Generate with a Custom Default Paging Method
+
+By default, a pageable operation will generate with default sans I/O paging method `BasicPagingMethod`. With this directive, you can change the generated code to generate with your custom default paging method.
+
+You can also pass in a paging method through `kwargs` to each operation. Use this directive if you want the generated code to generate with your custom default paging method, instead of passing in your custom paging method to the generated code.
+
+### Custom Default Paging Method Conditions
+
+1. It must implement the sans I/O abstract base class for `PagingMethodABC`
+
+We use `$["x-python-custom-default-paging-method]` to specify our default paging method. You have to use the full import path of the custom default paging method you're specifying, i.e. `my.library.CustomDefaultPagingMethod`. Putting this altogether, we get the following directive, which we will insert in our config file.
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/paging"].get'
+ transform: >
+ $["x-python-custom-default-paging-method"] = "my.library.CustomDefaultPagingMethod";
+```
+
+Here is the before and after of the generated code.
+
+**Without directive:**
+#
+
+**With directive:**
+#
+
+
+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/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/python/api/azure-core/azure.core.polling.asynclropoller?view=azure-python
+[polling_paging_swagger]: ../samples/specification/directives/pollingPaging.json
+
+[lro_base_polling_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.base_polling.lrobasepolling?view=azure-python
+[async_lro_base_polling_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.async_base_polling.asynclrobasepolling?view=azure-python
+[arm_polling_docs]: https://docs.microsoft.com/python/api/azure-mgmt-core/azure.mgmt.core.polling.arm_polling.armpolling?view=azure-python
+[async_arm_polling_docs]: https://docs.microsoft.com/python/api/azure-mgmt-core/azure.mgmt.core.polling.async_arm_polling.asyncarmpolling?view=azure-python
+[polling_method_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.pollingmethod?view=azure-python
+[async_polling_method_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.asyncpollingmethod?view=azure-python
+
+[item_paged_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.paging.itempaged?view=azure-python
+[async_item_paged_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.async_paging.asyncitempaged?view=azure-python
+[sample_directives]: ../samples/specification/directives/readme.md
diff --git a/docs/generate/multiapi.md b/docs/generate/multiapi.md
new file mode 100644
index 00000000000..902adbd4815
--- /dev/null
+++ b/docs/generate/multiapi.md
@@ -0,0 +1,76 @@
+#
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"][tags] docs to find out how to set this up. In this example we will 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
+
+````
+### Multi API generation
+
+These settings apply only when `--multiapi` is specified on the command line.
+```yaml $(multiapi)
+```
+````
+
+With `multiapi`, we want to batch execute each of our API versions:
+
+````
+### Multi API generation
+
+These settings apply only when `--multiapi` is specified on the command line.
+```yaml $(multiapi)
+batch:
+ - tag: v1
+ - tag: v2
+ - tag: v3
+ - multiapiscript: true
+```
+````
+
+With this code, AutoRest will first generate the files listed under the `v1` tag, then the files listed under the `v2` tag.
+After generating these though, AutoRest needs to generate the multiapi client on top of these files. This layer will wire users
+to the correct API version based on which API version the user wants. To add this layer, you need to include a `multiapiscript` section
+of your config. Users should never specify `multiapiscript` on the command line, but it is a required flag in a configuration
+file to let AutoRest know it has to run its multiapi script.
+
+````
+``` yaml $(multiapiscript)
+output-folder: $(python-sdks-folder)/generated/azure/multiapi/sample
+clear-output-folder: false
+perform-load: false
+```
+````
+
+> Note: `perform-load` is an internal configuration field used by AutoRest to decide whether it should try to load an input file. Since we're not actively generating
+> from an inputted swagger field in the `multiapiscript` step, we include this in our yaml code block.
+
+Now, if you have `clear-output-folder` specified in your general settings, you would also have to include `clear-output-folder: false` inside
+your `multiapiscript` block. This is because `clear-output-folder` clears your output folder before each generation, which is not what we want
+if we want to batch generate multiple API versions, then generate a multiAPI client over that.
+
+A final note about optional flags in this section: If you don't specify a default API version, the generated client will use the latest GA service version as the default API version for users, which in our case is `v2`. Meaning, if a user does not pass in an `api_version` value to the generated multi API client, that client will use the default API version `v2`. Thus, if you want another API version, say `v1` to be the default API for users, you would include `default-api: v1` in this `multiapiscript` section.
+
+Finally, we have to actually call the `multiapiscript` section, so we add it to our batch execution:
+
+````
+### Multi API generation
+
+These settings apply only when `--multiapi` is specified on the command line.
+
+```yaml $(multiapi)
+batch:
+ - tag: v1
+ - tag: v2
+ - tag: v3
+ - multiapiscript: true
+```
+````
+
+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
new file mode 100644
index 00000000000..45b529d5c87
--- /dev/null
+++ b/docs/generate/readme.md
@@ -0,0 +1,11 @@
+#
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.
+
+* [Generating Multi API code][multiapi]
+* [Generating with Directives][directives]
+
+
+[general]: https://github.com/Azure/autorest/tree/master/docs/generate/readme.md
+[multiapi]: ./multiapi.md
+[directives]: ./directives.md
\ No newline at end of file
diff --git a/docs/images/after_paging_directive.png b/docs/images/after_paging_directive.png
new file mode 100644
index 00000000000..3f591501ba2
Binary files /dev/null and b/docs/images/after_paging_directive.png differ
diff --git a/docs/images/after_paging_method_directive.png b/docs/images/after_paging_method_directive.png
new file mode 100644
index 00000000000..2feee2bfc48
Binary files /dev/null and b/docs/images/after_paging_method_directive.png differ
diff --git a/docs/images/after_polling_directive.png b/docs/images/after_polling_directive.png
new file mode 100644
index 00000000000..74c7d15de42
Binary files /dev/null and b/docs/images/after_polling_directive.png differ
diff --git a/docs/images/after_polling_method_directive.png b/docs/images/after_polling_method_directive.png
new file mode 100644
index 00000000000..8d3cda85550
Binary files /dev/null and b/docs/images/after_polling_method_directive.png differ
diff --git a/docs/images/before_paging_directive.png b/docs/images/before_paging_directive.png
new file mode 100644
index 00000000000..50a9a507c4d
Binary files /dev/null and b/docs/images/before_paging_directive.png differ
diff --git a/docs/images/before_paging_method_directive.png b/docs/images/before_paging_method_directive.png
new file mode 100644
index 00000000000..5047ed79c06
Binary files /dev/null and b/docs/images/before_paging_method_directive.png differ
diff --git a/docs/images/before_polling_directive.png b/docs/images/before_polling_directive.png
new file mode 100644
index 00000000000..ff091bafcd8
Binary files /dev/null and b/docs/images/before_polling_directive.png differ
diff --git a/docs/images/before_polling_method_directive.png b/docs/images/before_polling_method_directive.png
new file mode 100644
index 00000000000..77e507cf3fe
Binary files /dev/null and b/docs/images/before_polling_method_directive.png differ
diff --git a/docs/images/logo.png b/docs/images/logo.png
new file mode 100644
index 00000000000..5ed86d23c29
Binary files /dev/null and b/docs/images/logo.png differ
diff --git a/docs/migrate/readme.md b/docs/migrate/readme.md
new file mode 100644
index 00000000000..548f20d284b
--- /dev/null
+++ b/docs/migrate/readme.md
@@ -0,0 +1,43 @@
+#
Migrating to Latest AutoRest
+
+See the [main docs][main_docs] for changes in versioning and flags, this section focuses on how the generated code differs.
+
+## Breaking Changes
+
+* The credential system has been completely revamped:
+ - Previously we had used `azure.common.credentials` or `msrestazure.azure_active_directory` instances, which
+ are no longer supported. We now use credentials from [`azure_identity`][azure_identity_credentials] and the [`AzureKeyCredential`][azure_key_credential] from
+ [`azure-core`][azure_core_library].
+ - The `credentials` parameter to the service client has been renamed to `credential`
+* The `config` attribute is no longer exposed on the client, and custom configurations should be passed as a kwarg. For example, we now have `Client(credential, subscription_id, enable_logging=True`).
+For a complete set of supported inputs to your client, see our list of [acceptable initialization parameters in azure-core][azure_core_init_parameters].
+* You can't import a `version` module anymore, use `__version__` instead. Additionally, we only generate a version file if you specify a package version on the command line (`--package-version`), or you
+tell AutoRest during generation time to keep the current version file in the directory (`--keep-version-file`). See our [flag index][flag_index] for more information on these 2 flags.
+* Long running operations that used to return a `msrest.polling.LROPoller` now return a [`azure.core.polling.LROPoller`][lro_poller_docs] by default. These operations are also now prefixed with `begin_`.
+* The exception tree has been simplified, and now most exceptions are an [`azure.core.exceptions.HttpResponseError`][http_response_error]. `CloudError` has been removed.
+* Most of the operation kwargs have changed. The most noticeable are:
+ - `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
+
+* 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.
+* The client now natively supports tracing libraries such as [`OpenCensus`][open_census] and [`OpenTelemetry`][open_telemetry]. Use the flag `--trace` to generate
+code for this, and you can see our [tracing docs][tracing_docs] for more information.
+
+
+
+[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/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/master/docs/generate/flags.md
+[lro_poller_docs]: https://docs.microsoft.com/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
+[http_response_error]: https://docs.microsoft.com/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
+[mypy]: https://mypy.readthedocs.io/en/stable/introduction.html
+[open_census]: https://opencensus.io/
+[open_telemetry]: https://opentelemetry.io/
+[tracing_docs]: ../client/tracing.md
\ No newline at end of file
diff --git a/docs/readme.md b/docs/readme.md
new file mode 100644
index 00000000000..63ab5ad9a2e
--- /dev/null
+++ b/docs/readme.md
@@ -0,0 +1,37 @@
+# AutoRest Python Documentation
+
+These documents are Python-specific, see [our main docs][main_docs] for more general information
+
+
+1. Generating Python Clients with AutoRest
+ - How do I generate code? Main documents are [here][main_generate], while python-specific docs are [here][python_generate]
+
+2. Using Your Generated Python Client
+ - How do I [use my Python client][python_client] now that I've generated it? Main docs are [here][main_client]
+
+3. Migrating from AutoRest 2.0 to 3.0
+ - 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][python_dev]? Main docs [here][main_dev]
+
+5. Samples
+ - [Sample][sample] readmes and generated code for common scenarios.
+
+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
+[main_client]: https://github.com/Azure/autorest/tree/master/docs/generate/client.md
+[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
+[sample]: ./samples/readme.md
+[faq]: ./faq.md
+[troubleshooting]: ./troubleshooting.md
diff --git a/docs/samples/readme.md b/docs/samples/readme.md
new file mode 100644
index 00000000000..d005f741ccb
--- /dev/null
+++ b/docs/samples/readme.md
@@ -0,0 +1,23 @@
+#
Sample Python Generation
+
+Here are our samples for common generation scenarios
+
+
+| Scenario | README | Generated Code
+|------------------|-------------|-------------
+|Generating most basic | [readme.md][basic_readme] | [generated][basic_generated]
+|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]
+
+
+[basic_readme]: ./specification/basic/readme.md
+[basic_generated]: ./specification/basic/generated
+[mgmt]: https://docs.microsoft.com/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/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..519d6083e60
--- /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/python/api/azure-core/azure.core.credentials.azurekeycredential?view=azure-python
diff --git a/docs/samples/specification/basic/generated/azure/__init__.py b/docs/samples/specification/basic/generated/azure/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/basic/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/basic/generated/azure/basic/__init__.py b/docs/samples/specification/basic/generated/azure/basic/__init__.py
new file mode 100644
index 00000000000..5960c353a89
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/__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/basic/generated/azure/basic/sample/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/__init__.py
new file mode 100644
index 00000000000..78354a67f97
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py b/docs/samples/specification/basic/generated/azure/basic/sample/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..b497da828e3
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/sample/_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 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 ._configuration import AutoRestHeadTestServiceConfiguration
+from .operations import HttpSuccessOperations
+
+
+class AutoRestHeadTestService(object):
+ """Test Infrastructure for AutoRest.
+
+ :ivar http_success: HttpSuccessOperations operations
+ :vartype http_success: azure.basic.sample.operations.HttpSuccessOperations
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ base_url=None, # type: Optional[str]
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(**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/basic/generated/azure/basic/sample/_configuration.py b/docs/samples/specification/basic/generated/azure/basic/sample/_configuration.py
new file mode 100644
index 00000000000..5bcc364b7cd
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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 AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+ """
+
+ def __init__(
+ self,
+ **kwargs # type: Any
+ ):
+ # type: (...) -> None
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ kwargs.setdefault('sdk_moniker', 'basic-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/basic/generated/azure/basic/sample/_version.py b/docs/samples/specification/basic/generated/azure/basic/sample/_version.py
new file mode 100644
index 00000000000..eae7c95b6fb
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/aio/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/__init__.py
new file mode 100644
index 00000000000..6e499e6a6b1
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py
new file mode 100644
index 00000000000..7a5f74a7ff9
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/sample/aio/_auto_rest_head_test_service.py
@@ -0,0 +1,56 @@
+# 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 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.basic.sample.aio.operations.HttpSuccessOperations
+ :param str base_url: Service URL
+ """
+
+ def __init__(
+ self,
+ base_url: Optional[str] = None,
+ **kwargs: Any
+ ) -> None:
+ if not base_url:
+ base_url = 'http://localhost:3000'
+ self._config = AutoRestHeadTestServiceConfiguration(**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/basic/generated/azure/basic/sample/aio/_configuration.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/_configuration.py
new file mode 100644
index 00000000000..7e46511ac0b
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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 AutoRestHeadTestServiceConfiguration(Configuration):
+ """Configuration for AutoRestHeadTestService.
+
+ Note that all parameters used to create this instance are saved as instance
+ attributes.
+ """
+
+ def __init__(
+ self,
+ **kwargs: Any
+ ) -> None:
+ super(AutoRestHeadTestServiceConfiguration, self).__init__(**kwargs)
+
+ kwargs.setdefault('sdk_moniker', 'basic-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/basic/generated/azure/basic/sample/aio/operations/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py b/docs/samples/specification/basic/generated/azure/basic/sample/aio/operations/_http_success_operations.py
new file mode 100644
index 00000000000..9092065ba58
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/operations/__init__.py b/docs/samples/specification/basic/generated/azure/basic/sample/operations/__init__.py
new file mode 100644
index 00000000000..ab55c6fdc9f
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/operations/_http_success_operations.py b/docs/samples/specification/basic/generated/azure/basic/sample/operations/_http_success_operations.py
new file mode 100644
index 00000000000..389b8e00ddf
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/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/basic/generated/azure/basic/sample/py.typed b/docs/samples/specification/basic/generated/azure/basic/sample/py.typed
new file mode 100644
index 00000000000..e5aff4f83af
--- /dev/null
+++ b/docs/samples/specification/basic/generated/azure/basic/sample/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
\ No newline at end of file
diff --git a/docs/samples/specification/basic/generated/setup.py b/docs/samples/specification/basic/generated/setup.py
new file mode 100644
index 00000000000..7ac2e486923
--- /dev/null
+++ b/docs/samples/specification/basic/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-basic-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-basic-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/basic/readme.md b/docs/samples/specification/basic/readme.md
new file mode 100644
index 00000000000..c2cfc939b41
--- /dev/null
+++ b/docs/samples/specification/basic/readme.md
@@ -0,0 +1,13 @@
+# Sample Basic Generation
+
+### Settings
+
+``` yaml
+input-file: ../../../../node_modules/@microsoft.azure/autorest.testserver/swagger/head.json
+namespace: azure.basic.sample
+package-name: azure-basic-sample
+license-header: MICROSOFT_MIT_NO_VERSION
+package-version: 0.1.0
+basic-setup-py: true
+clear-output-folder: true
+```
\ No newline at end of file
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/samples/specification/directives/pollingPaging.json b/docs/samples/specification/directives/pollingPaging.json
new file mode 100644
index 00000000000..6cebec831ff
--- /dev/null
+++ b/docs/samples/specification/directives/pollingPaging.json
@@ -0,0 +1,116 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "Polling Paging Example",
+ "description": "Show polling and paging generation",
+ "version": "1.0.0"
+ },
+ "host": "localhost:3000",
+ "schemes": [
+ "http"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "consumes": [
+ "application/json"
+ ],
+ "paths": {
+ "/directives/polling": {
+ "put": {
+ "x-ms-long-running-operation": true,
+ "operationId": "basicPolling",
+ "description": "A simple polling operation.",
+ "parameters": [
+ {
+ "name": "product",
+ "description": "Product to put",
+ "in": "body",
+ "schema": {
+ "$ref": "#/definitions/Product"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Initial response",
+ "schema": {
+ "$ref": "#/definitions/Product"
+ }
+ },
+ "204": {
+ "description": "Final response"
+ },
+ "default": {
+ "description": "Unexpected error",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ },
+ "/directives/paging": {
+ "get": {
+ "x-ms-pageable": { "nextLinkName": "nextLink" },
+ "operationId": "basicPaging",
+ "description": "A simple paging operation.",
+ "responses": {
+ "200": {
+ "description": "Your paged items.",
+ "schema": {
+ "$ref": "#/definitions/ProductResult"
+ }
+ },
+ "default": {
+ "description": "Unexpected error"
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "Error": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "message": {
+ "type": "string"
+ }
+ }
+ },
+ "ProductResult": {
+ "type": "object",
+ "properties": {
+ "value": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Product"
+ }
+ },
+ "nextLink": {
+ "type": "string"
+ }
+ }
+ },
+ "Product": {
+ "type": "object",
+ "properties": {
+ "properties": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
diff --git a/docs/samples/specification/directives/readme.md b/docs/samples/specification/directives/readme.md
new file mode 100644
index 00000000000..bdcc118b2e0
--- /dev/null
+++ b/docs/samples/specification/directives/readme.md
@@ -0,0 +1,57 @@
+# Sample Directives Generation
+
+### Settings
+
+``` yaml
+input-file: pollingPaging.json
+namespace: azure.directives.sample
+package-name: azure-directives-sample
+license-header: MICROSOFT_MIT_NO_VERSION
+package-version: 0.1.0
+basic-setup-py: true
+clear-output-folder: true
+```
+
+### Override LROPoller to custom Poller
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/polling"].put'
+ transform: >
+ $["x-python-custom-poller-sync"] = "my.library.CustomPoller";
+ $["x-python-custom-poller-async"] = "my.library.aio.AsyncCustomPoller"
+```
+
+### Override Default Polling Method to Custom Polling Method
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/polling"].put'
+ transform: >
+ $["x-python-custom-default-polling-method-sync"] = "my.library.CustomDefaultPollingMethod";
+ $["x-python-custom-default-polling-method-async"] = "my.library.aio.AsyncCustomDefaultPollingMethod"
+```
+
+
+### Override ItemPaged to Custom Pager
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/paging"].get'
+ transform: >
+ $["x-python-custom-pager-sync"] = "my.library.CustomPager";
+ $["x-python-custom-pager-async"] = "my.library.aio.AsyncCustomPager"
+```
+
+### Override Default Paging Method to Custom Paging Method
+
+```yaml
+directive:
+ from: swagger-document
+ where: '$.paths["/directives/paging"].get'
+ transform: >
+ $["x-python-custom-default-paging-method"] = "my.library.CustomDefaultPagingMethod";
+```
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..1dc4ce21c78
--- /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/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/docs/troubleshooting.md b/docs/troubleshooting.md
new file mode 100644
index 00000000000..ac35a4eaf11
--- /dev/null
+++ b/docs/troubleshooting.md
@@ -0,0 +1,52 @@
+#
Troubleshooting
+
+## Generation Errors
+
+There are two broad kinds of errors you can run into when generating: one kind is thrown earlier in the AutoRest pipeline and has to do with malformed swaggers (see [our main docs][main_docs] for more information). The other kind is thrown by the Python generator itself.
+
+The general AutoRest errors are thrown like this
+
+```
+FATAL: Error: Enum types of 'object' and format 'undefined' are not supported. Correct your input (HdiNodeTypes).
+ Error: Plugin modelerfour reported failure.
+```
+
+While the Python generator throws Python errors, such as:
+
+```
+ERROR: [main.Process:52] Python generator raised an exception
+Traceback (most recent call last):
+ ...
+ValueError: --credential-scopes must be used with the --add-credential flag
+ Error: Plugin codegen reported failure.
+```
+
+Both of these issues should give you enough information to fix the error. If not, please let us know in either the [main repo][autorest_issues], or in the [Python repo][autorest_python_issues]. Also let us know if you believe
+there are erroneous errors being thrown.
+
+## Debugging
+
+Our [main docs][main_debugging] show you how to pass in flags (`--verbose` / `--debug`) to get more debugging logs for your AutoRest calls.
+
+If you'd like to actually debug through our code, you need to first clone our [repo]. These debugging steps are specific to VS Code.
+
+Once debugging our code, you need to add this to the VSCode launch configuration (`launch.json`). This configuration tells VS Code to attach at port `5678`, the default port.
+
+```
+{
+ "name": "Python: Attach",
+ "type": "python",
+ "request": "attach",
+ "port": 5678,
+ "host": "localhost"
+}
+```
+
+Once this has been successfully added, all that's needed is to add flag `--python.debugger` on our command line. You should now be able to step through the Python generator's code base.
+
+
+[main_docs]: https://github.com/Azure/autorest/tree/master/docs/generate/troubleshooting.md
+[autorest_issues]: https://github.com/Azure/autorest/issues
+[autorest_python_issues]: https://github.com/Azure/autorest.python/issues
+[main_debugging]: https://github.com/Azure/autorest/tree/master/docs/generate/troubleshooting.md#debugging
+[autorest_python_repo]: https://github.com/Azure/autorest.python/tree/autorestv3
\ No newline at end of file
diff --git a/tasks.py b/tasks.py
index 5617e4f247e..f1d8dfbc555 100644
--- a/tasks.py
+++ b/tasks.py
@@ -264,6 +264,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
@@ -334,3 +335,28 @@ 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,
+ "basic": 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)