Skip to content

Commit

Permalink
Making changes to existing function
Browse files Browse the repository at this point in the history
  • Loading branch information
harshitap26 committed Aug 5, 2024
1 parent c093553 commit 94734c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
31 changes: 10 additions & 21 deletions api/v1/api_v1_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ import (
"github.com/dell/goisilon/api"
)

// GetAllIsiSnapshots queries a list of all snapshots on the cluster
func GetAllIsiSnapshots(ctx context.Context,
// GetIsiSnapshots queries a list of all snapshots on the cluster
func GetIsiSnapshots(
ctx context.Context,
client api.Client,
) (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)
if err != nil {
return nil, err
}
snapShotList := resp.SnapshotList
snapshotList := resp.SnapshotList

for {

if resp.Resume == "" {
break
}
Expand All @@ -45,36 +46,24 @@ func GetAllIsiSnapshots(ctx context.Context,
}

var newResp *getIsiSnapshotsResp
err = client.Get(ctx, snapshotsPath, "", snapshotQS, nil, &newResp)
// PAPI call: GET https://1.2.3.4:8080/platform/1/snapshot/snapshots?resume=<resume token>
err := client.Get(ctx, snapshotsPath, "", snapshotQS, nil, &newResp)
if err != nil {
return nil, err
}

snapShotList = append(snapShotList, newResp.SnapshotList...)
snapshotList = append(snapshotList, newResp.SnapshotList...)
resp = newResp
}

isiSnapshotResp := &getIsiSnapshotsResp{
SnapshotList: snapShotList,
SnapshotList: snapshotList,
Total: resp.Total,
Resume: resp.Resume,
}

return isiSnapshotResp, nil
}

// GetIsiSnapshots queries a list of all snapshots on the cluster
func GetIsiSnapshots(
ctx context.Context,
client api.Client,
) (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)
if err != nil {
return nil, err
}
return resp, nil
}

// GetIsiSnapshot queries an individual snapshot on the cluster
func GetIsiSnapshot(
ctx context.Context,
Expand Down
2 changes: 1 addition & 1 deletion snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *Client) GetSnapshots(ctx context.Context) (SnapshotList, error) {
func (c *Client) GetSnapshotsByPath(
ctx context.Context, path string,
) (SnapshotList, error) {
snapshots, err := api.GetAllIsiSnapshots(ctx, c.API)
snapshots, err := api.GetIsiSnapshots(ctx, c.API)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 94734c0

Please sign in to comment.