ms::Graph method paginated_result_list (protected)

 <instance of ms::Graph[i]> paginated_result_list \
    [ -max_entries max_entries ] r expected_status_code

Defined in packages/xooauth/tcl/ms-procs.tcl

By default, MSGraph returns for a query just the first 100 results ("pagination"). To obtain more results, it is necessary to issue multiple requests. If "max_entries" is specified, the interface tries to get the requested number of entries. If there are less entries available, just these are returned.

Switches:
-max_entries
(optional)
Parameters:
r
expected_status_code

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
Source code:
set resultDict [:expect_status_code $r $expected_status_code]
set resultList {}

if {$max_entries ne ""} {
    while {1} {
        #
        # Handle pagination in Microsoft Graph. Since the
        # list is returned in the JSON element "value", we
        # have to extract these values and update it later
        # with the result of potentially multiple
        # requests.
        # Details: https://docs.microsoft.com/en-us/graph/paging
        #
        set partialResultList ""
        set nextLink ""
        if {[dict exists $r JSON]} {
            set JSON [dict get $r JSON]
            if {[dict exists $JSON value]} {
                set partialResultList [dict get $JSON value]
            }
            if {[dict exists $JSON @odata.nextLink]} {
                set nextLink [dict get $JSON @odata.nextLink]
            }
        }

        lappend resultList {*}$partialResultList

        set got [llength $resultList]
        ns_log notice "[self] paginated_result_list: got $got max_entries $max_entries"
        if {$got >= $max_entries} {
            set resultList [lrange $resultList 0 $max_entries-1]
            break
        }
        if {$nextLink ne ""} {
            set r [:request -method GET -token [:token] -url $nextLink]
            set resultDict [:expect_status_code $r 200]
        } else {
            #ns_log notice "=== No next link"
            break
        }
    }
    dict set resultDict value $resultList
}
return $resultDict
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: