Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Provide a way to automatically load paginated resources #131

Closed
ctreatma opened this issue Aug 28, 2023 · 1 comment · Fixed by #150
Closed

Provide a way to automatically load paginated resources #131

ctreatma opened this issue Aug 28, 2023 · 1 comment · Fixed by #150

Comments

@ctreatma
Copy link
Contributor

In packngo, when a client loads paginated resources (devices, project, etc.), the SDK navigates those pages automatically. For example, this is the part of packngo that automatically loads all pages when listing devices: https://github.com/packethost/packngo/blob/master/devices.go#L485-L500

In the metal-go SDK, since it's generated from an OpenAPI spec and OpenAPI does not have a built-in way to define and navigate paginated resources, we only provide functions that load a single page. Using the pager module from metal-cli as an example, we could add functions to this SDK that automatically load all pages for paginated resources so that it is easier to maintain behavior while migrating from packngo to metal-go

@t0mk t0mk closed this as completed in #150 Sep 27, 2023
t0mk added a commit that referenced this issue Sep 27, 2023
This PR adds logic for generating listing functions capable of going
through all the pages (think devices in a project, or events in a
device).

It adds templates for the new code, docs, and code tests. The templates
are fetched from oag v7.0.0, and then modified for the sake of the
paginated listers.

It uses vendor extension property object in the form
```yaml
     x-paginated:
        x-paginated-property: Events
```

The spec patching part can be done in other oag generated SDKs.

related to #135 

fixes #131

---------

Signed-off-by: Tomáš Karásek <t0mk@users.noreply.github.com>
Co-authored-by: Marques Johansson <mjohansson@equinix.com>
@github-actions
Copy link
Contributor

This issue has been resolved in version 0.23.0 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant