NAME
Amazon::API::Paginator - execute compiled Amazon::API paginator definitions
SYNOPSIS
my $paginator = Amazon::API::Paginator->new(
definition => $compiled_paginators->{ListThings},
parameters => $parameters,
);
$paginator->add_page($decoded_response);
while ( $paginator->has_next_page ) {
my $next_parameters = $paginator->next_parameters;
... fetch and decode the next page ...
$paginator->add_page($decoded_response);
}
my $result = $paginator->result;
DESCRIPTION
Amazon::API::Paginator is the runtime execution engine for paginator metadata produced by Amazon::API::Paginator::Compiler. It is intentionally independent of HTTP, request serialization, response decoding, and Botocore's raw paginator vocabulary.
A paginator object represents one API invocation. It accumulates result keys, preserves first-page metadata, evaluates continuation and output-token selectors, detects repeated token sets, and builds parameters for the next request from the caller's original parameters.
METHODS
new
my $paginator = Amazon::API::Paginator->new(
definition => $definition,
parameters => $parameters,
);
Both arguments are required hash references. parameters is copied so the caller's hash is never modified.
add_page
$paginator->add_page($decoded_response);
Adds one decoded response page to the aggregate result and computes the token state for the next request. Repeated next-token sets raise an exception rather than allowing an infinite pagination loop.
If an explicit continuation selector is present and evaluates false, pagination ends without evaluating a next request. If continuation is true but no usable output token is present, pagination also ends.
has_next_page
return $paginator->has_next_page;
Returns true when the most recently added page supplied a usable next-token set and continuation permits another request.
next_parameters
my $parameters = $paginator->next_parameters;
Returns a new hash reference containing the original invocation parameters with the current paginator token values applied. Token members with no current value are removed. This preserves caller-supplied request options, including a compiled paginator limit member, without special-case mutation.
Returns undef when pagination is complete.
result
my $result = $paginator->result;
Returns the accumulated result with first-page preserve values merged back into their original response paths.
AUTHOR
See the Amazon::API distribution.