In RESTCONF, what does each child of the API root resource — data, operations and yang-library-version — give a client?
answer
- three children, two mandatory
- config and state in one tree
- RPCs as empty leaves
- a revision date, not a protocol version
basics
~20 sUnder the RESTCONF API root, data is the one combined datastore of configuration and state that clients read and edit, operations lists and invokes the server's YANG RPCs, and yang-library-version gives the ietf-yang-library revision the server implements.
solid answer
~40 sThe API root, written `{+restconf}` because its path is discovered rather than fixed, defines three children. `{+restconf}/data` is mandatory: one conceptual datastore holding configuration and state together, read with GET and edited with POST, PUT, PATCH and DELETE on what it contains; the client can neither create nor delete it. `{+restconf}/operations` is optional and lists each data-model RPC as an empty leaf, invoked with `POST {+restconf}/operations/<module>:<rpc>`; YANG actions are absent because they are invoked on their data node under `/data`. `{+restconf}/yang-library-version` is a mandatory read-only leaf holding the revision date of `ietf-yang-library`, which tells the client which module list to read before it builds any URL. A GET on the root returns all three as `ietf-restconf:restconf`.
code
http · 14 linesGET /mgmt/restconf HTTP/1.1
Host: router1.example.net
Accept: application/yang-data+json
HTTP/1.1 200 OK
Content-Type: application/yang-data+json
{
"ietf-restconf:restconf" : {
"data" : {},
"operations" : {},
"yang-library-version" : "2019-01-04"
}
}go deeper
Name the three children of the RESTCONF root and say in one line what each is for; know that /data mixes configuration and state.
Explain why RPCs sit under /operations while actions are invoked on their data node, and what the client does with the yang-library-version value.
Point out what the root does not offer — individual datastores, capabilities, links — and where a client finds each of them instead.
Weigh RESTCONF's schema-driven, link-free design: clients must load the YANG library first, which ties automation tooling to the device's module set.
## The API root **RESTCONF** (RFC 8040) is an HTTPS interface to data modelled in **YANG**, the IETF's data modelling language for network configuration and state. Every RESTCONF request starts from one **API root**. The RFC writes it as the URI template `{+restconf}` because its path is not fixed: the server announces it through `/.well-known/host-meta`, and `/restconf` is only the path the RFC's own examples use. A GET on the root returns the **API resource** itself, named `ietf-restconf:restconf` in JSON. Its structure comes from the `yang-api` data template in the `ietf-restconf` module, which defines three children: two mandatory, one optional. | Child | Required? | What it holds | Methods a client uses | |---|---|---|---| | `data` | mandatory | the datastore resource: all configuration and state data | GET and HEAD to read; POST, PUT, PATCH, DELETE to edit what is inside | | `operations` | optional — omitted when the server advertises no data-model RPCs | one empty leaf per RPC operation | GET to list, POST to invoke | | `yang-library-version` | mandatory, read-only | the revision date of `ietf-yang-library` | GET | ## `{+restconf}/data` — one datastore, two kinds of data - **A combined view.** RFC 8040 section 3.3.1 describes it as the combined configuration and state data resources a client can access. **Configuration** nodes (`config true`) and **state** nodes (`config false`) sit in one tree; which is which comes from the YANG `config` statement, not from the URL. - **No choice of datastore.** RESTCONF was designed as a subset of NETCONF that eliminates datastores and explicit locking (section 1.2). There is no `/data/running` or `/data/candidate`; the server decides which underlying datastore an edit lands in, and each edit takes effect when it completes. - **The client cannot create or delete it.** It can read it (the reply is a node named `data` in the `ietf-restconf` namespace), create a top-level node inside it with POST, and replace its entire contents with a PUT on `/data` itself — RFC 8040's counterpart of NETCONF `<copy-config>`. - **Top-level paths are module-qualified**, for example `{+restconf}/data/ietf-interfaces:interfaces`. How deeper nodes and list keys are spelt in the path is a separate subject, the URL mapping of YANG schema nodes. ## `{+restconf}/operations` — the RPC catalogue Each YANG `rpc` statement in a module the server advertises becomes an **operation resource** here. A GET on `/operations` lists them, each represented as an empty leaf (`[null]` in JSON). A POST to `{+restconf}/operations/<module>:<rpc>` invokes one, with the RPC's `input` as the body; success returns `200 OK` with a body when the RPC has output, and `204 No Content` when it has none. Two things are deliberately not listed there: 1. **YANG actions.** An action is bound to a data node, so it is invoked with POST on that node's path under `{+restconf}/data`, followed by the action's name. 2. **The edit and retrieval verbs themselves.** HTTP methods stand in for NETCONF's `<get>`, `<get-config>`, `<edit-config>` and `<copy-config>`, so they are not RPCs a client looks up. ## `{+restconf}/yang-library-version` — which module list to read RESTCONF has no discovery of data resources (section 3): the client derives every URL from the YANG modules the server advertises, and those are listed by the `ietf-yang-library` module, which the server MUST implement. The `yang-library-version` leaf holds that module's revision date in `YYYY-MM-DD` form, so the client knows which layout to read before it asks: - The revision published in RFC 7895, which RFC 8040's examples show as `2016-06-21`, lists modules under `{+restconf}/data/ietf-yang-library:modules-state`. - RFC 8525, which obsoletes RFC 7895, carries revision `2019-01-04`. It adds a datastore-aware `yang-library` tree for the Network Management Datastore Architecture (NMDA) and marks `modules-state` deprecated, which an NMDA server SHOULD still populate for older clients. The leaf therefore reports a **library revision**, not the RESTCONF protocol version and not the YANG language version. ## What the root does not give you - **A list of datastores.** `/data` is a single view; reaching `running`, `intended` or `operational` individually needs the NMDA resources RFC 8527 adds under `{+restconf}/ds`. - **Protocol capabilities.** Optional features such as query parameters are advertised in the `ietf-restconf-monitoring` module, read at `{+restconf}/data/ietf-restconf-monitoring:restconf-state/capabilities`. - **Links to children.** RFC 8040 section 1.3 rejects hypermedia links in responses because the YANG modules already tell the client every path. ## Common misreadings - "The root is `/restconf`." It is wherever host-meta says. - "`/data` is the running datastore." It is a combined view of configuration and state. - "Actions live under `/operations`." Only RPCs do.
- Why do RESTCONF responses carry no hypermedia links from /data to its children?RFC 8040 section 1.3 makes RESTCONF schema-driven: knowing the YANG modules the server lists in `ietf-yang-library`, a client can derive every resource URL and message structure, so links in responses are unnecessary. Section 3 states there is no data resource discovery mechanism at all — the advertised modules are the map.
- What status does a successful POST to /operations/<module>:<rpc> return?`200 OK` with a body carrying the RPC's output when there is a response body, and `204 No Content` with no body when the RPC has no output (RFC 8040 sections 3.6 and 4.4.2). An unauthorised caller SHOULD get `403 Forbidden` with error-tag `access-denied`.
saying these in an interview costs you the question
- The RESTCONF root is always /restconf, so discovery is optional.
- /data is the running datastore and holds only configuration.
- YANG actions are listed and invoked under /operations like RPCs.
- yang-library-version reports the RESTCONF protocol version.
- A client can DELETE /data to wipe the device's configuration.