Python Examples - Overview and Setup
The Python examples turn the API requests in this Learning Hub into reusable command-line tools. They use API-key authentication, share one Manager client, and separate API logic from command-line presentation.
Download and Install
Section titled “Download and Install”- Download the Python examples archive.
- Extract it and enter the project directory.
- Ask uv to install the pinned Python release and dependencies.
unzip sdwan-api-python-examples.zipcd sdwan-api-python-examplesuv python installuv syncThe project is pinned to Python 3.12. It has one direct runtime dependency: requests.
Project Structure
Section titled “Project Structure”sdwan-api-python-examples/├── monitoring/ Monitoring and statistics APIs│ ├── cases.py Reusable queries and use-case registry│ ├── run_cases.py CLI for registered monitoring use cases│ └── approute.py Application and AppRoute examples├── configuration/ Configuration APIs│ ├── config_groups.py UX 2.0 Configuration Group examples│ └── feature_profiles.py UX 2.0 Feature Profile examples├── administration/ Administration APIs│ ├── users.py User administration examples│ └── legacy_settings.py Undocumented legacy settings examples├── inventory/ Device inventory APIs│ └── devices.py Inventory and running configuration├── utilities/ Shared authentication, CLI, and output code└── tests/ Unit tests for the client and use casesConfigure the Environment
Section titled “Configure the Environment”Create a local .env file from the safe template:
cp .env.example .envvmanage=192.168.1.10port=443apikey=replace-with-your-api-keysystem_ip=10.0.0.20The .env file contains secrets and must not be committed or shared. It is excluded by the supplied .gitignore rules when the examples are used in this project.
Run a Command
Section titled “Run a Command”Run modules from the extracted project root:
uv run -m inventory.devices listuv run -m monitoring.run_cases applications --hours 24The command pattern is:
uv run -m <module> [global options] <command> [command options]Global options such as --insecure, --output, and --save must appear before the command:
uv run -m monitoring.run_cases --insecure --output json sites --hours 24Output and TLS Options
Section titled “Output and TLS Options”| Option | Purpose |
|---|---|
--output table |
Display selected fields in a dependency-free table |
--output json |
Display the complete response as formatted JSON |
--save PATH |
Save the complete JSON response to a file |
--timeout SECONDS |
Set the request timeout |
--ca-bundle PATH |
Verify Manager TLS with a private CA bundle |
--insecure |
Disable TLS verification for an isolated lab |
TLS verification is enabled by default. Prefer --ca-bundle for a private CA; use --insecure only when a lab Manager has a self-signed certificate.
Next Step
Section titled “Next Step”Read Shared Manager Client to understand authentication and the reusable HTTP layer, or go directly to Python Monitoring Examples.