NAME
Azure::SDK::Core::Pager - lazy traversal of Azure paged operations
SYNOPSIS
my $pager = Azure::SDK::Core::Pager->new(
fetch_page => sub ($continuation_token) {
return $client->list_widgets(marker => $continuation_token);
},
);
while (my $item = $pager->next_item) {
process($item);
}
my $resumed = Azure::SDK::Core::Pager->new(
continuation_token => $saved_token,
fetch_page => $fetch_page,
);
DESCRIPTION
Fetches no data until next_page or next_item is called. Each page remains the only collection retained by the pager, so traversing a large result set does not require materializing every item.
The fetch callback receives the opaque continuation token for the requested page and must return an Azure::SDK::Core::Page. Repeated continuation tokens throw instead of allowing an infinite request loop.
CONSTRUCTOR
new
Named parameters:
fetch_pageRequired code reference that accepts a continuation token and returns a page.
continuation_tokenOptional opaque token from which the first request resumes.
METHODS
next_page
Fetches and returns the next page, or undef after the last page.
next_item
Returns the next item, fetching pages as needed, or undef after the last item. Azure SDK model collections are expected to contain defined values.
has_more
True while another page may be fetched. Before the first request this is true; after fetching a page without a continuation token it is false.
continuation_token
The token that the next page request will use, or undef when exhausted. Before the first request this is the constructor's resume token.
current_page
The most recently fetched page, or undef before the first request.
items
The current page's item array reference, or an empty array before the first request.