Skip to content

Models API

Typed normalized models and their JSON Schemas (clijson.models). The field-by-field description of each model is on the Normalized models page.

json_schema

json_schema(intent: str) -> dict[str, Any]

JSON Schema (draft 2020-12) of the normalized output for intent.

Most intents normalize to an array of records; those in :data:SINGLE_RECORD to one object.

>>> json_schema("bgp.summary")["items"]["properties"]["remote_as"]
{'type': ['integer', 'string'], 'description': 'Peer AS; asdot notation (65000.1) stays a string'}

validate

validate(intent: str, records: Any) -> list[str]

Check normalized records against the model for intent; returns a list of problems (empty = valid).

A dependency-free structural check (types, required and unexpected keys) that mirrors :func:json_schema.

record

record(intent: str, **fields: Any) -> dict[str, Any]

Build a record for intent with all schema keys present, in order.

pseudowire_redundancy

pseudowire_redundancy(
    records: list[dict[str, Any]] | None,
    require_backup: bool = False,
) -> RedundancyReport

Check l2vpn.pseudowires records: one forwarding PW per service, backups in standby, nothing down.

Parameters:

Name Type Description Default
records list[dict[str, Any]] | None

result.normalized of a pseudowire command (l2vpn.pseudowires model)

required
require_backup bool

also report services that have no standby / backup pseudowire at all

False

RedundancyReport dataclass

RedundancyReport(
    ok: bool,
    problems: list[str],
    services: list[ServiceStatus],
)

Outcome of :func:pseudowire_redundancy.

INTENTS module-attribute

INTENTS: dict[str, type[Any]] = {
    "system.version": SystemVersion,
    "interfaces.brief": Interface,
    "interfaces.detail": InterfaceDetail,
    "interfaces.description": InterfaceDescription,
    "bgp.summary": BgpNeighbor,
    "ospf.neighbors": OspfNeighbor,
    "isis.adjacency": IsisAdjacency,
    "lldp.neighbors": LldpNeighbor,
    "arp": Arp,
    "ipv6.neighbors": Ipv6Neighbor,
    "routes": Route,
    "ldp.neighbors": LdpNeighbor,
    "bfd.sessions": BfdSession,
    "inventory": Inventory,
    "cpu": Cpu,
    "vrfs": Vrf,
    "mac.table": MacEntry,
    "lag": Lag,
    "l2vpn.pseudowires": Pseudowire,
}

SINGLE_RECORD module-attribute

SINGLE_RECORD = frozenset({'system.version'})