Basic Examples

Create client

from catalystwan.core.client import create_client

with create_client(
    url=SDWAN_URL,
    port=SDWAN_PORT,
    username=SDWAN_USERNAME,
    password=SDWAN_PASSWORD,
) as client:
    ...

Client Annotation

For typing purposes, we provide the ApiClient type. It can be used to annotate the client.

from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from catalystwan.core.loader import ApiClient

def foo(client: ApiClient):
    ...

API calls and Models

Sending requests is done through the ApiClient object. Wherever it is possible, we use dataclass objects for modelling payloads and responses. If one of the apis uses such model, it can be conveniently accessed by an m property of that api.

def create_embedded_security_profile(client: ApiClient) -> str:
    es_api = client.v1.feature_profile.sdwan.embedded_security
    # Access models through m property.
    es = es_api.m.EmbeddedSecurityDefault(name="NAME", description="DESC")
    es_response = es_api.create_sdwan_embedded_security_feature_profile(es)
    return es_response.id

Device

The easiest way of of finding a device/group of devices with a specific parameter (for example, a hostname or a personality) is to obtain a list of all devices and filter them out.

def get_device(client: ApiClient, personality="vedge") -> str:
    devices = client.device.list_all_devices()
    filtered_devices = [device for device in devices if device.personality == personality]

    return filtered_devices