From 94734c05072597f57ad08db482d17becd2f45928 Mon Sep 17 00:00:00 2001 From: Harshita Pandey Date: Mon, 5 Aug 2024 11:54:35 +0530 Subject: [PATCH] Making changes to existing function --- api/v1/api_v1_snapshots.go | 31 ++++++++++--------------------- snapshots.go | 2 +- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/api/v1/api_v1_snapshots.go b/api/v1/api_v1_snapshots.go index d0dbcdb..962993f 100644 --- a/api/v1/api_v1_snapshots.go +++ b/api/v1/api_v1_snapshots.go @@ -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 } @@ -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= + 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, diff --git a/snapshots.go b/snapshots.go index 606987b..e64c436 100644 --- a/snapshots.go +++ b/snapshots.go @@ -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 }