03-27-2020 01:16 AM
When doing this:
curl --location --request GET 'http://localhost:8080/restconf/data/tailf-ncs:devices' \ --header 'Accept: application/yang-data+json' \ --header 'Cache-Control: no-cache' \ --header 'Authorization: Basic YWRtaW46YWRtaW4=' \ --data-raw ''
I get enormous amounts of data, including complete config of each device. I just want a list o devices similar to running "show devices brief" on NSO. How can I do that with RESTCONF?
03-27-2020 11:54 AM
Hi,
You should review RFC8040 query parameters:
https://tools.ietf.org/html/rfc8040#section-4.8
+---------------+---------+-----------------------------------------+ | Name | Methods | Description | +---------------+---------+-----------------------------------------+ | content | GET, | Select config and/or non-config data | | | HEAD | resources | | | | | | depth | GET, | Request limited subtree depth in the | | | HEAD | reply content | | | | | | fields | GET, | Request a subset of the target resource | | | HEAD | contents | | | | | | filter | GET, | Boolean notification filter for event | | | HEAD | stream resources | | | | | | insert | POST, | Insertion mode for "ordered-by user" | | | PUT | data resources | | | | | | point | POST, | Insertion point for "ordered-by user" | | | PUT | data resources | | | | | | start-time | GET, | Replay buffer start time for event | | | HEAD | stream resources | | | | | | stop-time | GET, | Replay buffer stop time for event | | | HEAD | stream resources | | | | | | with-defaults | GET, | Control the retrieval of default values | | | HEAD | | +---------------+---------+-----------------------------------------+
03-27-2020 12:51 PM
http://localhost:8080/restconf/data/tailf-ncs:devices/device http://localhost:8080/restconf/data/tailf-ncs:devices/device=ios0/config curl -i -u admin:admin http://localhost:8080/restconf/operations/devices/device=ios0/live-status/tailf-ned-cisco-ios-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -d "{\"input\": {\"args\": \"show devices brief\"}}"
03-27-2020 12:55 PM
As Roque stated, review thew RESTCONF query parameters; specifically "depth" and
"fields" are useful for pruning data.
Note though that there might be better performace using the RESTCONF Query API
(it might be called REST Query API in documentation). If it's a one shot query without
the need for pagination use "immediate-query", where the query response contains
the results in the payload; thus eliminiating the need for an explicit "fetch-query-result".
03-14-2024 08:33 PM
curl --location 'https://localhost:4464/restconf/data/tailf-ncs:devices/device?depth=1&fields=name' \
--header 'Accept: application/vnd.yang.collection+xml' \
--header 'Content-Type: application/vnd.yang.collection+xml' \
response like,
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide