NAME

WWW::Hetzner::Role::Pagination - Controller helper for collecting paginated API lists

VERSION

version 0.101

SYNOPSIS

package My::API::Widgets;
use Moo;
with 'WWW::Hetzner::Role::Pagination';

sub _list_page {
    my ($self, %params) = @_;
    my $result = $self->client->get('/widgets', params => \%params);
    return ($self->_wrap_list($result->{widgets} // []), $result->{meta});
}

DESCRIPTION

Adds list_all to a controller that implements _list_page. The page helper returns the wrapped entities and the response's meta hashref. This keeps pagination above the HTTP request/response seam and lets controllers preserve their existing one-page list methods.

list_all

my $entities = $controller->list_all(per_page => 50, sort => 'id');

Collects every page starting at page 1, or at the supplied page. Carries all filters and sort values to each request. A response without meta is treated as a single page. Invalid, repeated, or non-advancing next_page metadata raises an error instead of returning a partial list.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.