upbound / up

The @upbound CLI
Apache License 2.0
52 stars 41 forks source link

Handle pagination in APIs that support it #214

Open hasheddan opened 2 years ago

hasheddan commented 2 years ago

What problem are you facing?

Currently, a few of the APIs that up interacts with (primarily up ctp list when UP_MCP_EXPERIMENTAL=true) support pagination with relatively small default values (e.g. 10). If the number of items exceeds that default, we don't support any way for a user to see the items beyond the limit.

How could Upbound help solve your problem?

The following are all options for addressing this, each with varying levels of complexity / functionality trade-off:

  1. Use the maximum size supported by the API by default in the CLI, which provides more breathing room, but users could still hit the limit eventually.
  2. Fetch the maximum size supported by the API and if the total exceeds that automatically use pagination to fetch the rest. Always give the user full results.
  3. Do (2) by default but allow the user to supply a --limit or --count flag to limit the total amount they want to see.

(2) would likely be sufficient for the time-being, and it would not prohibit us from supporting (3) in the future if requested.