Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pagination in hardware-reservation #46

Closed
falfaro opened this issue Jan 23, 2020 · 3 comments · Fixed by #288
Closed

Support pagination in hardware-reservation #46

falfaro opened this issue Jan 23, 2020 · 3 comments · Fixed by #288
Labels
bug Something isn't working question Further information is requested

Comments

@falfaro
Copy link

falfaro commented Jan 23, 2020

Currently the packet-cli hardware-reservation get does not support any form of pagination. For example, to request 1000 records (instead of hard-coded limit of 10).

This can be achieved using curl:

curl -X GET --header 'Accept: application/json' \
  --header "X-Auth-Token: ${PACKET_TOKEN}" \
  "https://api.packet.net/projects/${SOURCE_PROJECT}/hardware-reservations?per_page=1000"

It would be nice if a command-line flag allowed the same.

@displague
Copy link
Member

displague commented Jul 19, 2020

Hi @falfaro, sorry for the months-long delay in responding.

I think this bug may have been fixed in a newer release than the one you were using. I can't pin down which date or version introduced the fix. I would recommend pulling down the latest copy and testing again with that.

If you have a development environment:

git clone https://github.com/packethost/packet-cli/
cd packet-cli
make install

Otherwise, until we release v0.0.8, you can give v0.0.7 a shot from the releases page: https://github.com/packethost/packet-cli/releases/tag/0.0.7

The default behavior within the CLI is to perform lists without pagination. This can be seen here:

https://github.com/packethost/packet-cli/blob/master/cmd/retrieve_hardware_reservations.go#L41-L62

The default behavior of Packngo is to fetch all pages.

In order for a single page to be returned, the listOpt sent by the CLI to Packngo's ListHardwareReservations function would need to include a Page field with a non-default (non-zero) value.

https://github.com/packethost/packngo/blob/4867738f776936b4096ab2e5099227d7e4864b77/hardware_reservations.go#L42-L68

Let us know if updating to the latest version corrects the problem.

@displague displague added bug Something isn't working question Further information is requested labels Jul 19, 2020
@displague
Copy link
Member

This may be dependent on equinixmetal-archive/packngo#63 but I don't know why that is still open.
The work in equinixmetal-archive/packngo#114 is probably what fixed pagination in the CLI but @t0mk said in the description that this was "partial" pagination support.

Unless I am missing something, I think hardware-reservations was covered.

@adrianfurlong
Copy link

Hi there,

I've just installed v0.1.1 and we're still seeing hardware-reservations returning just 10 lines.

ctreatma pushed a commit that referenced this issue Jan 16, 2024
…#288)

Breakout from #270

What this PR does / why we need it:

This PR replaces packngo with metal-go for all interactions with the
Equinix Metal API specifically for hardware sub commands

DISCUSSION POINTS:

Fixes #46

Co-authored-by: codinja1188 <3358152+vasubabu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants