01-18-2018 08:36 AM - edited 03-01-2019 04:04 AM
Hi,
I want to filter the result of a REST GET call to suppress some containers in the output.
Consider the YANG model below as example:
container networks {
list network {
key name;
leaf name {
type string;
}
container test1 {
...content suppressed for brevity...
}
container test2 {
...content suppressed for brevity...
}
}
}
My question is how to fetch all networks and displaying only the content from the container test1, suppressing others (e.g.: test2)?
Thanks in advance
Solved! Go to Solution.
01-18-2018 01:48 PM
Here is an example (I haven't tested it for your model, so you may need to tweak):
URL: http://localhost:8080/api/query
HTTP Method: POST
Payload:
<start-query xmlns="http://tail-f.com/ns/tailf-rest-query">
<foreach>
/networks/network
</foreach>
<select>
<label>test1</label>
<expression>test1</expression>
<result-type>inline</result-type> <== inline as we want a sub-tree
</select>
</start-query>
Response:
<start-query-result>
<query-handle>2</query-handle> <== Note the handle returned
</start-query-result>
To Fetch Result:
URL: http://localhost:8080/api/query
HTTP Method: POST
Payload:
<fetch-query-result xmlns="http://tail-f.com/ns/tailf-rest-query">
<query-handle>2</query-handle> <== supply back the previously returned handle
</fetch-query-result>
Response:
01-18-2018 01:39 PM
Hi There,
Take a look at the Query API (nso_northbound.pdf). It allows for filtering and selecting the nodes to be retrieved.
Thanks.
01-18-2018 01:48 PM
Here is an example (I haven't tested it for your model, so you may need to tweak):
URL: http://localhost:8080/api/query
HTTP Method: POST
Payload:
<start-query xmlns="http://tail-f.com/ns/tailf-rest-query">
<foreach>
/networks/network
</foreach>
<select>
<label>test1</label>
<expression>test1</expression>
<result-type>inline</result-type> <== inline as we want a sub-tree
</select>
</start-query>
Response:
<start-query-result>
<query-handle>2</query-handle> <== Note the handle returned
</start-query-result>
To Fetch Result:
URL: http://localhost:8080/api/query
HTTP Method: POST
Payload:
<fetch-query-result xmlns="http://tail-f.com/ns/tailf-rest-query">
<query-handle>2</query-handle> <== supply back the previously returned handle
</fetch-query-result>
Response:
01-19-2018 08:29 AM
Thank you. I will try it.
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