cloud/equinix/cli: add list command
This also replaces the packngo library with our fork
Change-Id: I7ef23b840ce0de01109ab5764ed2c23feff72e49
Reviewed-on: https://review.monogon.dev/c/monogon/+/3060
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/cloud/equinix/wrapngo/wrapn.go b/cloud/equinix/wrapngo/wrapn.go
index 4ef7b9b..8ee654c 100644
--- a/cloud/equinix/wrapngo/wrapn.go
+++ b/cloud/equinix/wrapngo/wrapn.go
@@ -110,6 +110,9 @@
// with project pid. This is an expensive method that takes a while to execute,
// handle with care.
ListReservations(ctx context.Context, pid string) ([]packngo.HardwareReservation, error)
+
+ ListOrganizationReservations(ctx context.Context, oid string) ([]packngo.HardwareReservation, error)
+
// MoveReservation moves a reserved device to the given project.
MoveReservation(ctx context.Context, hardwareReservationDID, projectID string) (*packngo.HardwareReservation, error)
@@ -346,6 +349,13 @@
})
}
+func (c *client) ListOrganizationReservations(ctx context.Context, pid string) ([]packngo.HardwareReservation, error) {
+ return wrap(ctx, c, func(cl *packngo.Client) ([]packngo.HardwareReservation, error) {
+ res, _, err := cl.Organizations.ListHardwareReservations(pid, &packngo.ListOptions{Includes: []string{"facility", "device", "project"}})
+ return res, err
+ })
+}
+
func (c *client) MoveReservation(ctx context.Context, hardwareReservationDID, projectID string) (*packngo.HardwareReservation, error) {
return wrap(ctx, c, func(cl *packngo.Client) (*packngo.HardwareReservation, error) {
hr, _, err := cl.HardwareReservations.Move(hardwareReservationDID, projectID)