Unlike REST implementations, Representational State Transfer Configuration Protocol (RESTCONF) offers deterministic URI strings and JSON formatting based on YANG data models. To retrieve data or configure a device using the RESTCONF interface, you must use the proper URI string to access the resource in question. Each YANG module defines a hierarchy of data that you can use to retrieve the URI and the exact parameters accepted by the JSON payload for RESTCONF-based operations.
A RESTCONF URI is encoded from left to right, starting from the root to the target resource:
{+restconf}/data/<yang-module:container>/<leaf>[?<query_parameters]
{+restconf}/data
is the
root resource for the combined configuration and state data resources that can be
accessed by a client, where {+restconf}
indicates the root URL for the device.
<yang-module:container>
is the base model container being used.
<leaf>
is an
individual element from within the container.
Some network devices can support options sent as <query_parameters>
that
impact returned results.
For example, to access the top-level interfaces
resource within the
openconfig-interfaces
YANG
model, the URL would be:
https://<ip>/rest/restconf/data/openconfig-interfaces:interfaces
.
To access the interfaces data model and collect the data on interface=1 (port 1) on the device: