cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
375
Views
5
Helpful
1
Replies
Cisco Employee

RESTCONF: getting list size

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

}

}'

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: RESTCONF: getting list size

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

 

View solution in original post

1 REPLY 1
Cisco Employee

Re: RESTCONF: getting list size

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

 

View solution in original post