Network APIs and data models
Start with structured inventory
Automation means describing a repeatable task so a program can carry it out consistently. Before changing anything, identify each target, its platform, software version, supported management interfaces, model revisions and permitted operations. A Python program can parse responses and build a change plan; Bash can orchestrate local files and command exit codes. SSH-based CLI automation is useful on older equipment, but text output can change between versions. Do not treat successful login as authorization to change configuration. In this chapter all inventory and responses are fictional, and there are no connections to devices.
Model, encoding and protocol
YANG describes a management data tree: names, types, keys, constraints and whether nodes represent configuration or read-only information. It is not a transport protocol. XML and JSON are encodings, while YAML is often used for human-maintained inventory and intent. A valid JSON document can still violate a YANG type or constraint. For example, a fictional interface model requires a Boolean enabled value and an integer MTU between 1280 and 9000. The value "1500" is a string in ordinary JSON, not an integer. This classroom schema is deliberately invented; real YANG JSON rules and ranges depend on the actual model.
Choose the management interface
NETCONF provides XML RPC operations, including configuration reads and edits, commonly over SSH. RESTCONF exposes YANG-modeled resources through HTTP operations, normally secured with TLS, using defined JSON or XML encodings. gNMI uses gRPC and offers Capabilities, Get, Set and Subscribe RPCs; it is useful for structured management and telemetry. A generic REST API need not implement RESTCONF, and a gRPC endpoint need not implement gNMI. Check the advertised features, supported schema and permissions rather than guessing from a port number or product name. See RFC 6241, RFC 8040, RFC 7950 and OpenConfig gNMI 0.10.0 in the source register.
Read a fictional inventory
In the table below, R1 advertises NETCONF candidate support, R2 exposes read-only RESTCONF and R3 advertises gNMI Get and Subscribe for the operator role. Select NETCONF for a proposed candidate-based edit on R1 only after change authorization and further feature checks. Select RESTCONF GET for R2 configuration discovery and gNMI Subscribe for R3 telemetry. The operator cannot infer Set permission from Subscribe permission. The table is a sanitized classroom inventory, not a real capabilities exchange. For each device also record the schema revision and time of observation; stale inventory can be as misleading as a missing capability.
Target | interface | model revision | allowed exampleR1 | NETCONF + candidate | mock-1 | read; edit only with approvalR2 | RESTCONF | mock-1 | GET onlyR3 | gNMI | mock-1 | Get, SubscribeConfiguration is not operational health
An enabled interface may still have no carrier or no usable route. Compare configured values against the desired policy and operational values against service expectations separately. A device response may omit a field due to access restrictions or projection filters; absence must not automatically become false or zero. Read-only discovery should use authenticated, encrypted channels with identity checks and limited privileges. Keep credentials outside inventory and logs. A tool such as Ansible can render structured changes, but a template rendering correctly does not prove that the target understands it or that a service will survive it.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Network APIs and data models Quiz
Reason about management APIs, convergence and safe change validation.
Which item describes schema rather than transport?
Which interface uses XML RPCs for network configuration?
R2 permits only RESTCONF GET. What is authorized?
Which gNMI operation is used for telemetry streaming?
An interface is enabled but lacks carrier. What does this show?