10-13-2019 05:13 AM
Hi,
Is there any pre-cooked way to get the size of a list via RESTCONF? For example, I need to get the number of devices in NSO.
I am now using the query API. but I wonder if we could use xpath in any clever way.
Roque
curl -X POST \
https://nso-alexa:8443/restconf/tailf/query \
-H 'Accept: application/yang-data+json' \
-H 'Authorization: Basic YWRtaW46QzFzY28xMjM0NQ==' \
-H 'Content-Type: application/yang-data+json' \
-d '{
"immediate-query": {
"foreach": "/devices/device",
"select": [
{
"label": "Host name",
"expression": "name",
"result-type": ["string"]
}
],
"sort-by": ["name"],
"limit": 100,
"offset": 1
}
}'
Solved! Go to Solution.
10-14-2019 03:02 AM
There is the possibility to use the XPath count() function to achieve counting list items through the REST Query API.
Following the submitted query, the actual call would look something like:
curl -X POST \
-H 'Authorization: Basic YWRtaW46QzFzY28xMjM0NQ==' \
-H "Content-type: application/yang-data+json" \
https://nso-alexa:8443/restconf/tailf/query \
-d '
{"tailf-rest-query:immediate-query": {
"foreach": "/devices",
"select": [
{"expression": "count(device)",
"result-type": ["string"]
}
]
}
}'
10-14-2019 03:02 AM
There is the possibility to use the XPath count() function to achieve counting list items through the REST Query API.
Following the submitted query, the actual call would look something like:
curl -X POST \
-H 'Authorization: Basic YWRtaW46QzFzY28xMjM0NQ==' \
-H "Content-type: application/yang-data+json" \
https://nso-alexa:8443/restconf/tailf/query \
-d '
{"tailf-rest-query:immediate-query": {
"foreach": "/devices",
"select": [
{"expression": "count(device)",
"result-type": ["string"]
}
]
}
}'
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