-
Notifications
You must be signed in to change notification settings - Fork 3k
Dataplane Codegen Quick Start with tools
The documentation describes how to generate Dataplane Codegen code with tools quickly.
-
Python 3.6 or later is required
-
Nodejs 14.x.x or later is required
-
Fork and clone the azure-sdk-for-python repo.
-
Create a branch to work in.
assume work path is D:\
-
create virtual environment
python -m venv venv-dev .\venv-dev\Scripts\Activate.ps1
If it is the first time for service to generate SDK, you need the script to help generate necessary files(setup.py, CHANGELOG.md, etc) which are necessary for a complete Python package, and go to Create;If you just want to update code, go to Update
Before using the script, you need to run the following command:
pip install -r D:\azure-sdk-for-python\scripts\quickstart_tooling_dpg\dev_requirements.txt
The scripts needs necessary parameters to generate SDK code:
-
--input-file
: absolute path or url path of swagger input file. For example:https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json
orD:\azure-rest-api-specs\specification\webpubsub\data-plane\WebPubSub\stable\2021-10-01\webpubsub.json
-
--output-folder
: absolute path where generated SDK package will be put -
--package-name
: package name. For example: "azure-messaging-webpubsub" -
--package-pprint-name
: print name of the package. For example: "Azure Web PubSub Service" -
--client-name
: client name. For example: "WebPubSubServiceClient" -
--security-scope
/--security-header-name
: If authentication is AADToken,security-scope
is needed, like: https://webpubsub.azure.com/.default"; if authentication is api key,security-header-name
is needed. See authentication
Here is the example, just try to run :
- AADToken authentication
python D:\azure-sdk-for-python\scripts\quickstart_tooling_dpg\main.py --output-folder D:\azure-sdk-for-python\sdk\dpgexample\azure-messaging-webpubsubservic --input-file https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json --security-scope https://webpubsub.azure.com/.default --package-name azure-messaging-webpubsubserviceexample --package-pprint-name "Azure WebPubSub Service" --client-name WebPubSubServiceClient
Or
-
Api key authentication
python D:\azure-sdk-for-python\scripts\quickstart_tooling_dpg\main.py --output-folder D:\azure-sdk-for-python\sdk\dpgexample\azure-messaging-webpubsubservic --input-file https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json --security-header-name ApiKeyHeader --package-name azure-messaging-webpubsubserviceexample --package-pprint-name "Azure WebPubSub Service" --client-name WebPubSubServiceClient
After running the scripts successfully, it creates necessary files and common test framework. But remember to edit README.md
, test files under tests
and sample files under samples
since customers need more info to understand the package. You don't need it anymore after one-time successful run. Go to Update if you need to regenerate code.(webpubsub is a good example)
The tool will create test framework. If you want to add testcase, please reference test guidance.
This tool create blank sample file, feel free to add your own code or delete it if it is not needed.
After Create, there will be READMD.md
under swagger
folder of output_folder
. If need to update the code, step into swagger
folder and run the following command:
autorest --version=3.7.2 --use=@autorest/[email protected] --use=@autorest/[email protected] README.md