Skip to content

Commit

Permalink
Getting the list of snapshots is not paginated so we don't get them a…
Browse files Browse the repository at this point in the history
…ll. (#1)

* Getting the list of snapshots is not paginated so we don't get them all.

This doesn't paginate, but it makes it so you can filter by the schedule
name when you get the list of snapshots. The default limit is 1000 I
think so it is reasonable that we won't need to paginate in that case.
  • Loading branch information
ebressler authored Apr 1, 2024
1 parent 8750456 commit 28c70a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 9 additions & 2 deletions api/v1/api_v1_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ import (
// GetIsiSnapshots queries a list of all snapshots on the cluster
func GetIsiSnapshots(
ctx context.Context,
client api.Client) (resp *getIsiSnapshotsResp, err error) {
client api.Client, scheduleName string) (resp *getIsiSnapshotsResp, err error) {
// PAPI call: GET https://1.2.3.4:8080/platform/1/snapshot/snapshots
err = client.Get(ctx, snapshotsPath, "", nil, nil, &resp)

var params api.OrderedValues

if scheduleName != "" {
params = api.NewOrderedValues([][]string{})
params.StringAdd("schedule", scheduleName)
}
err = client.Get(ctx, snapshotsPath, "", params, nil, &resp)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1/api_v1_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type IsiSnapshot struct {
ShadowBytes int64 `json:"shadow_bytes"`
Size int64 `json:"size"`
State string `json:"state"`
TargetId int64 `json:"target_it"`
TargetId int64 `json:"target_id"`
TargetName string `json:"target_name"`
}

Expand Down
8 changes: 4 additions & 4 deletions snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
type SnapshotList []*api.IsiSnapshot
type Snapshot *api.IsiSnapshot

func (c *Client) GetSnapshots(ctx context.Context) (SnapshotList, error) {
snapshots, err := api.GetIsiSnapshots(ctx, c.API)
func (c *Client) GetSnapshots(ctx context.Context, scheduleName string) (SnapshotList, error) {
snapshots, err := api.GetIsiSnapshots(ctx, c.API, scheduleName)
if err != nil {
return nil, err
}
Expand All @@ -24,7 +24,7 @@ func (c *Client) GetSnapshots(ctx context.Context) (SnapshotList, error) {
func (c *Client) GetSnapshotsByPath(
ctx context.Context, path string) (SnapshotList, error) {

snapshots, err := api.GetIsiSnapshots(ctx, c.API)
snapshots, err := api.GetIsiSnapshots(ctx, c.API, "")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func (c *Client) GetSnapshot(
if name == "" {
return nil, err
}
snapshotList, err := c.GetSnapshots(ctx)
snapshotList, err := c.GetSnapshots(ctx, "")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 28c70a6

Please sign in to comment.