On Sat, Feb 13, 2021 at 1:30 AM Tim Landscheidt <tim(a)tim-landscheidt.de> wrote:
Hi,
I'd like to interact with Pagure from within Emacs (Lisp)
and therefore am adding support to Ghub
(
https://github.com/magit/ghub/).
Ghub has a nice unpagination feature that automatically col-
lects all queried data in consecutive requests and builds
one structure from that. For GitHub and some other forges,
this is easy: For example
https://api.github.com/orgs/microsoft/repos returns a JSON
array and has an HTTP header "link" (RFC 8288) that refers
to the next (and the last) page, so a program can mindlessly
request each page, concatenate the arrays, et voilà!
Looking at Pagure's API, there does not seem to exist such
an overarching idea. Therefore (?), the "pagure" command
line utility (
https://github.com/juhp/pagure-cli) has a sep-
arate Haskell command for each API call, and the "libpagure"
Python library (
https://pagure.io/libpagure/) does the same.
Is there a way that a Pagure API client library can be
"clever" with regard to pagination at a low level and pre-
sent the consumer with a DWIM data structure?
(My most-head-scratching problem is
https://src.fedoraproject.org/api/0/user/scfc where there
are two dimensions of pagination, and keys ("forks",
"repos") whose values should be concatenated and another key
("user") whose values should not be.)
Hey, sorry for the late reply!
We don't currently have a way to request from the API a non-paginated
result. The main reason is that with sufficiently large requests, that
could time out or fail. If you want to simulate an unpaginated result,
you could use the response data from the first request to determine
how many requests you need to generate the full one.
For example, with listing issues in a project, the "pagination"
section in the response should give you the necessary information to
iterate through them all and get a complete answer.
This is documented in the API page on
src.fedoraproject.org:
https://src.fedoraproject.org/api
--
真実はいつも一つ!/ Always, there's only one truth!