-
Notifications
You must be signed in to change notification settings - Fork 57
Generating with DPG
If you don't have autorest, install autorest first. If you have autorest already, we suggest you reset the installed plugins with autorest --reset
first.
LLC generation in Python is called "version tolerant generation". Simple usage is as follow:
autorest --python --version-tolerant --input-file=myswagger.json
You can check this with autorest --list-installed
. If the version if not the right one, call autorest --reset
to force an update.
DISCLAIMER: All of the flags mentioned here, and the code generated with these flags are marked as provisional, meaning they are subject to change.
Set up your configuration file how you would normally. Then, you will add a selection of the following files, based off of the type of client you want.
All Of The Flags That Work With Current AutoRest Should Still Work Here. See existing flags here.
Our new version tolerant clients are much more version tolerant across different API versions. Our aim here is: if a change is not breaking in a swagger, it will not be breaking for the version tolerant clients. Going forward, we are going to be recommending version tolerant clients more and more.
The convenience
operations here take much greater use of keyword-only and kwarg parameters for more version tolerance, and we deal with pure JSON input and output bodies.
Currently we do not have our version tolerant models yet, so by default these SDKs do not come with models, though that can be overriden by passing in provisional flag --models-mode=msrest
.
Add the following flag to your config file:
version-tolerant: true
A Low Level Client is a client with only request builders and a send_request
method on the client. There are no convenience operations / models.
Add the following flag to your config file:
low-level-client: true
These provisional flags offer more granularity then using either of the flags above. They can be used in conjunction with any of the above flags, or with existing AutoRest flags.
Flag | Description | current AutoRest default | Version tolerant client default | Low Level Client default |
---|---|---|---|---|
—-models-mode=msrest|none |
Whether you want a model layer or not. | msrest |
none |
none |
--builders-visibility=public|hidden|embedded |
How visible you want your request builders to be. With public , you get a public rest layer with your request builders. With private , you still get a separate layer with your request builders, but it is hidden. Finally, with embedded , you get the builders embedded in your operations files. |
embedded |
embedded |
public |
--show-operations |
Whether you want a convenience operations layer on top of the request builders, or not. | True |
True |
False |
--show-send-request |
Whether you want the send_request method on your client to be public or not. |
False |
True |
True |
--only-path-and-body-parameters-positional |
Whether you want to make all non-path and non-body parameters in your methods keyword-only. | False |
True |
N/A |
--add-python3-operation-files |
Whether you want python3 typed sync operation files. |
False |
False |
N/A |
--combine-operation-files |
Whether you want to combine all of the operation group files into one file (one for sync and one for async) | False |
True |
N/A |
Generating should be exactly the same, just make sure your autorest.python version is 5.9.0+
. Additionally, make note the code you generate with these provisional flags is provisional as well, and that the generated code requires azure-core
version 1.18.0
+ to run.