Skip to content

Commit 9228383

Browse files
feat: support the pagination at GetAllCloudProviderSnapshots (#96)
1 parent 7d43e28 commit 9228383

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mongodbatlas/cloud_provider_snapshots.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const (
1414
// endpoints of the MongoDB Atlas API.
1515
// See more: https://docs.atlas.mongodb.com/reference/api/cloud-provider-snapshot/
1616
type CloudProviderSnapshotsService interface {
17-
GetAllCloudProviderSnapshots(context.Context, *SnapshotReqPathParameters) (*CloudProviderSnapshots, *Response, error)
17+
GetAllCloudProviderSnapshots(context.Context, *SnapshotReqPathParameters, *ListOptions) (*CloudProviderSnapshots, *Response, error)
1818
GetOneCloudProviderSnapshot(context.Context, *SnapshotReqPathParameters) (*CloudProviderSnapshot, *Response, error)
1919
Create(context.Context, *SnapshotReqPathParameters, *CloudProviderSnapshot) (*CloudProviderSnapshot, *Response, error)
2020
Delete(context.Context, *SnapshotReqPathParameters) (*Response, error)
@@ -61,7 +61,7 @@ type SnapshotReqPathParameters struct {
6161

6262
//GetAllCloudProviderSnapshots gets all cloud provider snapshots for the specified cluster.
6363
//See more: https://docs.atlas.mongodb.com/reference/api/cloud-provider-snapshot-get-all/
64-
func (s *CloudProviderSnapshotsServiceOp) GetAllCloudProviderSnapshots(ctx context.Context, requestParameters *SnapshotReqPathParameters) (*CloudProviderSnapshots, *Response, error) {
64+
func (s *CloudProviderSnapshotsServiceOp) GetAllCloudProviderSnapshots(ctx context.Context, requestParameters *SnapshotReqPathParameters, listOptions *ListOptions) (*CloudProviderSnapshots, *Response, error) {
6565
if requestParameters.GroupID == "" {
6666
return nil, nil, NewArgError("groupId", "must be set")
6767
}
@@ -71,6 +71,11 @@ func (s *CloudProviderSnapshotsServiceOp) GetAllCloudProviderSnapshots(ctx conte
7171

7272
path := fmt.Sprintf("%s/%s/clusters/%s/backup/snapshots", cloudProviderSnapshotsBasePath, requestParameters.GroupID, requestParameters.ClusterName)
7373

74+
path, err := setListOptions(path, listOptions)
75+
if err != nil {
76+
return nil, nil, err
77+
}
78+
7479
req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil)
7580
if err != nil {
7681
return nil, nil, err

mongodbatlas/cloud_provider_snapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestCloudProviderSnapshots_GetAllCloudProviderSnapshots(t *testing.T) {
5353
}`)
5454
})
5555

56-
cloudProviderSnapshots, _, err := client.CloudProviderSnapshots.GetAllCloudProviderSnapshots(ctx, requestParameters)
56+
cloudProviderSnapshots, _, err := client.CloudProviderSnapshots.GetAllCloudProviderSnapshots(ctx, requestParameters, nil)
5757
if err != nil {
5858
t.Fatalf("CloudProviderSnapshots.GetAllCloudProviderSnapshots returned error: %v", err)
5959
}

0 commit comments

Comments
 (0)