chipx86 got a fish trophy!
Add initial support for paginators for Hosting Service requests.
Review Request #5885 — Created May 27, 2014 and submitted — Latest diff uploaded
We have functions in
HostingService
subclasses that need to deal with
paginated data. Right now, they're all handling it in their own ways,
but as we move to wrapping more of these in the web API, it's helpful to
standardize them.This introduces a set of paginators that can be used and subclassed by
the more specificHostingService
s to provide a standardized API for
pagination of data.
APIPaginator
is designed to perform API requests and handle pagination
through links returned through the payload or headers in some form.
Subclasses are expected to define how API requests are made and parsed.
ProxyPaginator
attaches to another paginator (typically anAPIPaginator
)
and transforms the results. This allows, for instance, a
HostingServiceClient
to return anAPIPaginator
with raw results, and a
HostingService
to wrap it and return structured data derived from those
raw results.
Unit tests passed.
Tested this manually with an accompanying change to GitHub's
get_remote_repositories
. I was able to page back and forth and get the
results. I also testedstart=
andper_page=
with that.