ms_graph_pager | R Documentation |
Class representing an iterator for a set of paged query results.
An R6 object of class ms_graph_pager
.
token
: The token used to authenticate with the Graph host.
output
: What the pager should yield on each iteration, either "data.frame","list" or "object". See 'Value' below.
new(...)
: Initialize a new user object. See 'Initialization' below.
has_data()
: Returns TRUE if there are pages remaining in the iterator, or FALSE otherwise.
value
: The returned value on each iteration of the pager.
The recommended way to create objects of this class is via the ms_object$get_list_pager()
method, but it can also be initialized directly. The arguments to the new()
method are:
token
: The token used to authenticate with the Graph host.
first_page
: A list containing the first page of results, generally from a call to call_graph_endpoint()
or the do_operation()
method of an AzureGraph R6 object.
next_link_name,value_name
: The names of the components of first_page
containing the link to the next page, and the set of values for the page respectively. The default values are @odata.nextLink
and value
.
generate_objects
: Whether the iterator should return a list containing the parsed JSON for the page values, or convert it into a list of R6 objects. See 'Value' below.
type_filter
: Any extra arguments required to initialise the returned objects. Only used if generate_objects
is TRUE.
default_generator
: The default generator object to use when converting a list of properties into an R6 object, if the class can't be detected. Defaults to ms_object
. Only used if generate_objects
is TRUE.
...
: Any extra arguments required to initialise the returned objects. Only used if generate_objects
is TRUE.
The value
active binding returns the page values for each iteration of the pager. This can take one of 3 forms, based on the initial format of the first page and the generate_objects
argument.
If the first page of results is a data frame (each item has been converted into a row), then the pager will return results as data frames. In this case, the output
field is automatically set to "data.frame" and the generate_objects
initialization argument is ignored. Usually this will be the case when the results are meant to represent external data, eg items in a SharePoint list.
If the first page of results is a list, the generate_objects
argument sets whether to convert the items in each page into R6 objects defined by the AzureGraph class framework. If generate_objects
is TRUE, the output
field is set to "object", and if generate_objects
is FALSE, the output
field is set to "list".
ms_object, extract_list_values
Microsoft Graph overview, Paging documentation
## Not run:
# list direct memberships
firstpage <- call_graph_endpoint(token, "me/memberOf")
pager <- ms_graph_pager$new(token, firstpage)
pager$has_data()
pager$value
# once all the pages have been returned
isFALSE(pager$has_data())
is.null(pager$value)
# returning items, 1 per page, as raw lists of properties
firstpage <- call_graph_endpoint(token, "me/memberOf", options=list(`$top`=1))
pager <- ms_graph_pager$new(token, firstpage, generate_objects=FALSE)
lst <- NULL
while(pager$has_data())
lst <- c(lst, pager$value)
# returning items as a data frame
firstdf <- call_graph_endpoint(token, "me/memberOf", options=list(`$top`=1),
simplify=TRUE)
pager <- ms_graph_pager$new(token, firstdf)
df <- NULL
while(pager$has_data())
df <- vctrs::vec_rbin(df, pager$value)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.