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.
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"]
}
]
}
}'
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"]
}
]
}
}'