Expand description
Following a paginated API to completion.
The list commands each requested one page and rendered whatever came back.
Bitbucket defaults to 10 items on some collections and 20 on others, so a
pipeline with 11 steps reported 10, and nothing in the output distinguished
that from a complete answer. Jira’s /search/jql caps maxResults at 100
server-side regardless of what is asked for, so a query returning exactly
100 was indistinguishable from a complete result. Both are worse than an
error, because the output looks authoritative.
The behaviour this replaces was reimplemented three times by hand inside
bitbucket/pipelines.rs and bitbucket/variables.rs, in three different
forms with three different levels of care about the URL the server handed
back. It belongs here, next to safe_join, which is the code that already
knows what a trusted origin is.
§Why the wrapper is generic and the driver is not
Every list endpoint wraps its items under a different key: Bitbucket uses
values uniformly, Jira’s search uses issues. A single
fetch_paged<T>(path) -> Vec<T> cannot work, because ApiClient::get::<T>
deserializes the whole body and nothing tells it which key to look under.
Passing the key as a string would mean deserializing to serde_json::Value
and re-parsing, which costs a second parse and throws away the type errors
that make the response structs worth having.
So the wrapper is generic instead: BitbucketPage<T> and JiraPage<T>
both implement Page, the call sites name the wrapper, and their own
bespoke StepList / SearchResponse structs go away. Two impls in total,
not one per call site.
Structs§
- Bitbucket
Page - A Bitbucket collection page.
- Jira
Offset Page - A Jira page from an endpoint that paginates by offset.
- Jira
Page - A Jira
/search/jqlpage. - Page
Info - What a page of results tells us beyond the items themselves.
- Page
Limits - How many items to collect, and how hard to work for them.
Enums§
- Continuation
- How to ask for the next page.
Constants§
- JIRA_
PAGE_ TOKEN_ PARAM - The query parameter Jira’s token-based search expects.
- JIRA_
START_ AT_ PARAM - The query parameter Jira’s offset-paged endpoints advance.
Traits§
- Page
- One page of a paginated response.
Functions§
- fetch_
paged - Follow a paginated endpoint, collecting items until the limit, the budget, or the data runs out.