Pagination and safe writes
Listings arrive a page at a time. Writes carry an idempotency key, and can be made conditional on the version you read.
paginate follows the cursors for you and yields one row at a time:
Pass a client method and its usual arguments. Each row is typed as that method's own. A page is requested only when you reach it, so breaking out of the loop stops the requests.
The client sends an Idempotency-Key with every write, and reuses it on each retry, so a write lands once. If you retry yourself, after a page reload or from a queue, pass the key you used the first time:
Read the resource, then send its etag back as ifMatch. The write lands only if nobody changed the resource in between:
A write without ifMatch replaces what is there.