Skip to content

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.

  1. Download the Python examples archive.
  2. Extract it and enter the project directory.
  3. Ask uv to install the pinned Python release and dependencies.
Terminal window
unzip sdwan-api-python-examples.zip
cd sdwan-api-python-examples
uv python install
uv sync

The project is pinned to Python 3.12. It has one direct runtime dependency: requests.

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 cases

Create a local .env file from the safe template:

Terminal window
cp .env.example .env
vmanage=192.168.1.10
port=443
apikey=replace-with-your-api-key
system_ip=10.0.0.20

The .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 modules from the extracted project root:

Terminal window
uv run -m inventory.devices list
uv run -m monitoring.run_cases applications --hours 24

The 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:

Terminal window
uv run -m monitoring.run_cases --insecure --output json sites --hours 24
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.

Read Shared Manager Client to understand authentication and the reusable HTTP layer, or go directly to Python Monitoring Examples.