diff --git a/apps/backend/backend_get.c b/apps/backend/backend_get.c index f1c132f3..2d8eefd6 100644 --- a/apps/backend/backend_get.c +++ b/apps/backend/backend_get.c @@ -336,6 +336,8 @@ element2value(clicon_handle h, * @retval -1 Error * @see from_client_get * @see from_client_get_config + * @note pagination uses appending xpath with predicate, eg [position() 0) { cprintf(cb, ",%s", pretty?"\n":""); --commas; } } + #ifdef LIST_PAGINATION /* identify md:annotations as RFC 7952 Sec 5.2.1*/ + if (metacbc){ + cprintf(cb, "%s", cbuf_get(metacbc)); + } +#endif + +#if 0 /* identify md:annotations as RFC 7952 Sec 5.2.1*/ for (i=0; itrue$limit]]>]]>" "alicepublic17]]>]]>$" + xmllist="" # for netconf + xmllist2="" # for restconf xml + jsonlist="" # for restconf json + jsonmeta="" + let i=0 + for li in $list; do + if [ $i = 0 ]; then + if [ $limit == 0 ]; then + el="$li" + el2="$li" + else + el="$li" + el2="$li" + jsonmeta=",\"@example-social:uint8-numbers\":\[{\"clixon-netconf-list-pagination:remaining\":$remaining}\]" + fi + jsonlist="$li" + else + el="$li" + el2="$li" jsonlist="$jsonlist,$li" + fi + xmllist="$xmllist$el" + xmllist2="$xmllist2$el2" + let i++ + done - new "clixon limit=$limit NETCONF get" - expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue$limit]]>]]>" "alicepublic17]]>]]>$" + jsonstr="" + if [ $limit -eq 0 ]; then + limitxmlstr="" + else + limitxmlstr="$limit" + jsonstr="?limit=$limit" + fi + if [ $offset -eq 0 ]; then + offsetxmlstr="" + else + offsetxmlstr="$offset" + if [ -z "$jsonstr" ]; then + jsonstr="?offset=$offset" + else + jsonstr="${jsonstr}&offset=$offset" + fi + fi + new "limit=$limit NETCONF get-config" +# expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue$limitxmlstr$offsetxmlstr]]>]]>" "alicepublic$xmllist]]>]]>$" + + new "limit=$limit NETCONF get" +# expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue$limitxmlstr$offsetxmlstr]]>]]>" "alicepublic$xmllist]]>]]>$" new "limit=$limit Parameter RESTCONF xml" - expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-collection+xml" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers?limit=$limit)" 0 "HTTP/$HVER 200" "Content-Type: application/yang-collection+xml" "17" + expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-collection+xml" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers${jsonstr})" 0 "HTTP/$HVER 200" "Content-Type: application/yang-collection+xml" "$xmllist2" - # XXX [17] new "limit=$limit Parameter RESTCONF json" - expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-collection+json" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers?limit=$limit)" 0 "HTTP/$HVER 200" "Content-Type: application/yang-collection+json" '{"yang-collection":{"example-social:uint8-numbers":17,"@example-social:uint8-numbers": \[{"clixon-netconf-list-pagination:remaining": 5}\]}}' -} + expectpart "$(curl $CURLOPTS -X GET -H "Accept: application/yang-collection+json" $RCPROTO://localhost/restconf/data/example-social:members/member=alice/favorites/uint8-numbers${jsonstr})" 0 "HTTP/$HVER 200" "Content-Type: application/yang-collection+json" "{\"yang-collection\":{\"example-social:uint8-numbers\":\[$jsonlist\]$jsonmeta}" + +} # testrunf new "test params: -f $cfg -s startup -- -sS $fstate" @@ -313,10 +358,35 @@ new "wait restconf" wait_restconf new "A.3.1.1. limit=1" -testlimit 1 5 "[17]" +testlimit 0 1 5 "17" -#new "A.3.1.2. limit=2" -#testlimit 2 4 "[17 13]" +new "A.3.1.2. limit=2" +testlimit 0 2 4 "17 13" + +new "A.3.1.3. limit=5" +testlimit 0 5 1 "17 13 11 7 5" + +new "A.3.1.4. limit=6" +testlimit 0 6 0 "17 13 11 7 5 3" + +new "A.3.1.5. limit=7" +testlimit 0 7 0 "17 13 11 7 5 3" + +new "A.3.2.1. offset=1" +testlimit 1 0 0 "13 11 7 5 3" + +new "A.3.2.2. offset=2" +testlimit 2 0 0 "11 7 5 3" + +new "A.3.2.3. offset=5" +testlimit 5 0 0 "3" + +#new "A.3.2.4. offset=6" +#testlimit 6 0 0 "" + +# This is incomplete wrt the draft +new "A.3.7. limit=2 offset=2" +testlimit 2 2 2 "11 7" # CLI # XXX This relies on a very specific clispec command: need a more generic test diff --git a/yang/clixon/clixon-netconf-list-pagination@2021-08-27.yang b/yang/clixon/clixon-netconf-list-pagination@2021-08-27.yang index 8730da6f..1bdd138e 100644 --- a/yang/clixon/clixon-netconf-list-pagination@2021-08-27.yang +++ b/yang/clixon/clixon-netconf-list-pagination@2021-08-27.yang @@ -105,7 +105,7 @@ module clixon-netconf-list-pagination { default "unbounded"; description "The maximum number of list entries to return. The - value of the 'count' parameter is either an integer + value of the 'limit' parameter is either an integer greater than or equal to 1, or the string 'unbounded'. The string 'unbounded' is the default value."; } @@ -119,7 +119,7 @@ module clixon-netconf-list-pagination { default "none"; description "The first list item to return. - the 'skip' parameter is either an integer greater than + the 'offset' parameter is either an integer greater than or equal to 1, or the string 'unbounded'. The string 'unbounded' is the default value."; }