From 982b86f37c146d7d31cf7ad9559811d6e48eab61 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 13 Mar 2020 12:05:18 +0000 Subject: [PATCH 1/6] CLOUDP-58634: Add support for checkpoints in the Atlas client --- mongodbatlas/checkpoints.go | 91 +++++++ mongodbatlas/checkpoints_test.go | 356 ++++++++++++++++++++++++++++ mongodbatlas/continuous_snaphots.go | 23 +- mongodbatlas/mongodbatlas.go | 2 + 4 files changed, 462 insertions(+), 10 deletions(-) create mode 100644 mongodbatlas/checkpoints.go create mode 100644 mongodbatlas/checkpoints_test.go diff --git a/mongodbatlas/checkpoints.go b/mongodbatlas/checkpoints.go new file mode 100644 index 000000000..75930bac3 --- /dev/null +++ b/mongodbatlas/checkpoints.go @@ -0,0 +1,91 @@ +package mongodbatlas + +import ( + "context" + "fmt" + "net/http" +) + +const ( + backupCheckpoints = "groups/%s/clusters/%s/backupCheckpoints" +) + +// CheckpointService is an interface for interfacing with the Checkpoint +// endpoints of the MongoDB Atlas API. +type CheckpointService interface { + List(context.Context, string, string, *ListOptions) (*Checkpoints, *Response, error) + Get(context.Context, string, string, string) (*Checkpoint, *Response, error) +} + +//CloudProviderSnapshotRestoreJobsServiceOp handles communication with the CloudProviderSnapshotRestoreJobs related methods of the +//MongoDB Atlas API +type CheckpointsServiceOp struct { + Client RequestDoer +} + +var _ CheckpointService = &CheckpointsServiceOp{} + +type Checkpoint struct { + ClusterID string `json:"clusterId"` + Completed string `json:"completed,omitempty"` + GroupID string `json:"groupId"` + ID string `json:"id,omitempty"` // Unique identifier of the checkpoint. + Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources. + Parts []*Part `json:"parts,omitempty"` + Restorable bool `json:"restorable"` + Started string `json:"started"` + Timestamp string `json:"timestamp"` +} + +// Checkpoints represents all the backup checkpoints related to a cluster. +type Checkpoints struct { + Results []*Checkpoint `json:"results,omitempty"` // Includes one Checkpoint object for each item detailed in the results array section. + Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources. + TotalCount int `json:"totalCount,omitempty"` // Count of the total number of items in the result set. It may be greater than the number of objects in the results array if the entire result set is paginated. +} + +func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterID string, listOptions *ListOptions) (*Checkpoints, *Response, error) { + if groupID == "" { + return nil, nil, NewArgError("groupId", "must be set") + } + if clusterID == "" { + return nil, nil, NewArgError("clusterID", "must be set") + } + + path := fmt.Sprintf(backupCheckpoints, groupID, clusterID) + + req, err := s.Client.NewRequest(ctx, http.MethodGet, path, listOptions) + if err != nil { + return nil, nil, err + } + + root := new(Checkpoints) + resp, err := s.Client.Do(ctx, req, root) + + return root, resp, err +} + +func (s CheckpointsServiceOp) Get(ctx context.Context, groupID, clusterID, checkpointID string) (*Checkpoint, *Response, error) { + if groupID == "" { + return nil, nil, NewArgError("groupId", "must be set") + } + if clusterID == "" { + return nil, nil, NewArgError("clusterID", "must be set") + } + if checkpointID == "" { + return nil, nil, NewArgError("checkpointID", "must be set") + } + + basePath := fmt.Sprintf(backupCheckpoints, groupID, clusterID) + path := fmt.Sprintf("%s/%s", basePath, checkpointID) + req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil) + + if err != nil { + return nil, nil, err + } + + root := new(Checkpoint) + resp, err := s.Client.Do(ctx, req, root) + + return root, resp, err +} diff --git a/mongodbatlas/checkpoints_test.go b/mongodbatlas/checkpoints_test.go new file mode 100644 index 000000000..368b4708e --- /dev/null +++ b/mongodbatlas/checkpoints_test.go @@ -0,0 +1,356 @@ +package mongodbatlas + +import ( + "fmt" + "net/http" + "testing" + + "github.com/go-test/deep" +) + +func TestCheckpoints_List(t *testing.T) { + setup() + defer teardown() + + groupID := "6b8cd3c380eef5349ef77gf7" + clusterName := "Cluster0" + + path := fmt.Sprintf("/groups/%s/clusters/%s/backupCheckpoints", groupID, clusterName) + + mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodGet) + fmt.Fprint(w, `{ + "links":[ + { + "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints?pageNum=1&itemsPerPage=100", + "rel":"self" + } + ], + "results":[ + { + "clusterId":"6b8cd61180eef547110159d9", + "completed":"2018-02-08T23:20:25Z", + "groupId":"6b8cd3c380eef5349ef77gf7", + "id":"5a7cdb3980eef53de5bffdcf", + "links":[ + { + "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints", + "rel":"self" + } + ], + "parts":[ + { + "replicaSetName":"Cluster0-shard-1", + "shardName":"Cluster0-shard-1", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":1 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-shard-0", + "shardName":"Cluster0-shard-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":1 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-config-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":2 + }, + "typeName":"CONFIG_SERVER_REPLICA_SET" + } + ], + "restorable":true, + "started":"2018-02-08T23:20:25Z", + "timestamp":"2018-02-08T23:19:37Z" + }, + { + "clusterId":"6b8cd61180eef547110159d9", + "completed":"2018-02-09T14:50:33Z", + "groupId":"6b8cd3c380eef5349ef77gf7", + "id":"5a7db53987d9d64fe298ff46", + "links":[ + { + "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints?pretty=true", + "rel":"self" + } + ], + "parts":[ + { + "replicaSetName":"Cluster0-shard-1", + "shardName":"Cluster0-shard-1", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-09T14:50:33Z", + "increment":1 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-shard-0", + "shardName":"Cluster0-shard-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-09T14:50:33Z", + "increment":2 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-config-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-09T14:50:33Z", + "increment":4 + }, + "typeName":"CONFIG_SERVER_REPLICA_SET" + } + ], + "restorable":true, + "started":"2018-02-09T14:50:33Z", + "timestamp":"2018-02-09T14:50:18Z" + } + ], + "totalCount":2 + }`, + ) + }) + + snapshots, _, err := client.Checkpoints.List(ctx, groupID, clusterName, nil) + if err != nil { + t.Fatalf("Checkpoints.List returned error: %v", err) + } + + expected := &Checkpoints{ + Results: []*Checkpoint{ + { + ClusterID: "6b8cd61180eef547110159d9", + Completed: "2018-02-08T23:20:25Z", + GroupID: "6b8cd3c380eef5349ef77gf7", + ID: "5a7cdb3980eef53de5bffdcf", + Links: []*Link{ + { + Rel: "self", + Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints", + }, + }, + Parts: []*Part{ + { + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }, + }, + { + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }, + }, + { + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 2, + }, + }, + }, + Restorable: true, + Started: "2018-02-08T23:20:25Z", + Timestamp: "2018-02-08T23:19:37Z", + }, + { + ClusterID: "6b8cd61180eef547110159d9", + Completed: "2018-02-09T14:50:33Z", + GroupID: "6b8cd3c380eef5349ef77gf7", + ID: "5a7db53987d9d64fe298ff46", + Links: []*Link{ + { + Rel: "self", + Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints?pretty=true", + }, + }, + Parts: []*Part{ + { + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 1, + }, + }, + { + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 2, + }, + }, + { + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 4, + }, + }, + }, + Restorable: true, + Started: "2018-02-09T14:50:33Z", + Timestamp: "2018-02-09T14:50:18Z", + }, + }, + Links: []*Link{ + { + Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints?pageNum=1&itemsPerPage=100", + Rel: "self", + }, + }, + TotalCount: 2, + } + + if diff := deep.Equal(snapshots, expected); diff != nil { + t.Error(diff) + } +} + +func TestCheckpoints_Get(t *testing.T) { + setup() + defer teardown() + + groupID := "6b8cd3c380eef5349ef77gf7" + clusterName := "Cluster0" + checkpointID := "6b8cd61180eef547110159d9" + path := fmt.Sprintf("/groups/%s/clusters/%s/backupCheckpoints/%s", groupID, clusterName, checkpointID) + + mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodGet) + fmt.Fprint(w, `{ + "clusterId":"6b8cd61180eef547110159d9", + "completed":"2018-02-08T23:20:25Z", + "groupId":"6b8cd3c380eef5349ef77gf7", + "id":"5a7cdb3980eef53de5bffdcf", + "links":[ + { + "href":"https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints", + "rel":"self" + } + ], + "parts":[ + { + "replicaSetName":"Cluster0-shard-1", + "shardName":"Cluster0-shard-1", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":1 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-shard-0", + "shardName":"Cluster0-shard-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":1 + }, + "typeName":"REPLICA_SET" + }, + { + "replicaSetName":"Cluster0-config-0", + "tokenDiscovered":true, + "tokenTimestamp":{ + "date":"2018-02-08T23:20:25Z", + "increment":2 + }, + "typeName":"CONFIG_SERVER_REPLICA_SET" + } + ], + "restorable":true, + "started":"2018-02-08T23:20:25Z", + "timestamp":"2018-02-08T23:19:37Z" + }`) + }) + + cloudProviderSnapshot, _, err := client.Checkpoints.Get(ctx, groupID, clusterName, checkpointID) + if err != nil { + t.Fatalf("ContinuousSnapshots.Get returned error: %v", err) + } + + expected := &Checkpoint{ + ClusterID: "6b8cd61180eef547110159d9", + Completed: "2018-02-08T23:20:25Z", + GroupID: "6b8cd3c380eef5349ef77gf7", + ID: "5a7cdb3980eef53de5bffdcf", + Links: []*Link{ + { + Rel: "self", + Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/6b8cd3c380eef5349ef77gf7/clusters/Cluster0/backupCheckpoints", + }, + }, + Parts: []*Part{ + { + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }, + }, + { + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }, + }, + { + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 2, + }, + }, + }, + Restorable: true, + Started: "2018-02-08T23:20:25Z", + Timestamp: "2018-02-08T23:19:37Z", + } + + if diff := deep.Equal(cloudProviderSnapshot, expected); diff != nil { + t.Error(diff) + } +} diff --git a/mongodbatlas/continuous_snaphots.go b/mongodbatlas/continuous_snaphots.go index acb479200..55d58e462 100644 --- a/mongodbatlas/continuous_snaphots.go +++ b/mongodbatlas/continuous_snaphots.go @@ -46,16 +46,19 @@ type ContinuousSnapshot struct { } type Part struct { - ClusterID string `json:"clusterId"` - CompressionSetting string `json:"compressionSetting"` - DataSizeBytes int64 `json:"dataSizeBytes"` - EncryptionEnabled bool `json:"encryptionEnabled"` - FileSizeBytes int64 `json:"fileSizeBytes"` - MasterKeyUUID string `json:"masterKeyUUID,omitempty"` - MongodVersion string `json:"mongodVersion"` - ReplicaSetName string `json:"replicaSetName"` - StorageSizeBytes int64 `json:"storageSizeBytes"` - TypeName string `json:"typeName"` + ClusterID string `json:"clusterId,omitempty"` + CompressionSetting string `json:"compressionSetting,omitempty"` + DataSizeBytes int64 `json:"dataSizeBytes,omitempty"` + EncryptionEnabled bool `json:"encryptionEnabled,omitempty"` + FileSizeBytes int64 `json:"fileSizeBytes,omitempty"` + MasterKeyUUID string `json:"masterKeyUUID,omitempty"` + MongodVersion string `json:"mongodVersion,omitempty"` + ReplicaSetName string `json:"replicaSetName,omitempty"` + StorageSizeBytes int64 `json:"storageSizeBytes,omitempty"` + TypeName string `json:"typeName"` + ShardName string `json:"shardName,omitempty"` + TokenDiscovered bool `json:"tokenDiscovered,omitempty"` + TokenTimestamp SnapshotTimestamp `json:"tokenTimestamp,omitempty"` } type NamespaceFilter struct { diff --git a/mongodbatlas/mongodbatlas.go b/mongodbatlas/mongodbatlas.go index 81b7254c2..6d553c84a 100644 --- a/mongodbatlas/mongodbatlas.go +++ b/mongodbatlas/mongodbatlas.go @@ -61,6 +61,7 @@ type Client struct { X509AuthDBUsers X509AuthDBUsersService ContinuousSnapshots ContinuousSnapshotsService ContinuousRestoreJobs ContinuousRestoreJobsService + Checkpoints CheckpointService onRequestCompleted RequestCompletionCallback } @@ -175,6 +176,7 @@ func NewClient(httpClient *http.Client) *Client { c.PrivateEndpoints = &PrivateEndpointsServiceOp{Client: c} c.X509AuthDBUsers = &X509AuthDBUsersServiceOp{Client: c} c.ContinuousRestoreJobs = &ContinuousRestoreJobsServiceOp{Client: c} + c.Checkpoints = &CheckpointsServiceOp{Client: c} return c } From 221d5d2e22b19864759444ce6c205d474c52f2fe Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 13 Mar 2020 14:43:13 +0000 Subject: [PATCH 2/6] Refactoring --- .../{checkpoints.go => atlas_checkpoints.go} | 30 +++++++++---------- ...ints_test.go => atlas_checkpoints_test.go} | 6 ++-- mongodbatlas/mongodbatlas.go | 4 +-- 3 files changed, 20 insertions(+), 20 deletions(-) rename mongodbatlas/{checkpoints.go => atlas_checkpoints.go} (67%) rename mongodbatlas/{checkpoints_test.go => atlas_checkpoints_test.go} (97%) diff --git a/mongodbatlas/checkpoints.go b/mongodbatlas/atlas_checkpoints.go similarity index 67% rename from mongodbatlas/checkpoints.go rename to mongodbatlas/atlas_checkpoints.go index 75930bac3..136fc9317 100644 --- a/mongodbatlas/checkpoints.go +++ b/mongodbatlas/atlas_checkpoints.go @@ -10,20 +10,20 @@ const ( backupCheckpoints = "groups/%s/clusters/%s/backupCheckpoints" ) -// CheckpointService is an interface for interfacing with the Checkpoint +// AtlasCheckpointService is an interface for interfacing with the Checkpoint // endpoints of the MongoDB Atlas API. -type CheckpointService interface { +type AtlasCheckpointService interface { List(context.Context, string, string, *ListOptions) (*Checkpoints, *Response, error) Get(context.Context, string, string, string) (*Checkpoint, *Response, error) } -//CloudProviderSnapshotRestoreJobsServiceOp handles communication with the CloudProviderSnapshotRestoreJobs related methods of the -//MongoDB Atlas API -type CheckpointsServiceOp struct { +// AtlasCheckpointsServiceOp handles communication with the checkpoint related methods of the +// MongoDB Atlas API +type AtlasCheckpointsServiceOp struct { Client RequestDoer } -var _ CheckpointService = &CheckpointsServiceOp{} +var _ AtlasCheckpointService = &AtlasCheckpointsServiceOp{} type Checkpoint struct { ClusterID string `json:"clusterId"` @@ -37,22 +37,22 @@ type Checkpoint struct { Timestamp string `json:"timestamp"` } -// Checkpoints represents all the backup checkpoints related to a cluster. +// AtlasCheckpoints represents all the backup checkpoints related to a cluster. type Checkpoints struct { Results []*Checkpoint `json:"results,omitempty"` // Includes one Checkpoint object for each item detailed in the results array section. Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources. TotalCount int `json:"totalCount,omitempty"` // Count of the total number of items in the result set. It may be greater than the number of objects in the results array if the entire result set is paginated. } -func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterID string, listOptions *ListOptions) (*Checkpoints, *Response, error) { +func (s AtlasCheckpointsServiceOp) List(ctx context.Context, groupID, clusterName string, listOptions *ListOptions) (*Checkpoints, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set") } - if clusterID == "" { - return nil, nil, NewArgError("clusterID", "must be set") + if clusterName == "" { + return nil, nil, NewArgError("clusterName", "must be set") } - path := fmt.Sprintf(backupCheckpoints, groupID, clusterID) + path := fmt.Sprintf(backupCheckpoints, groupID, clusterName) req, err := s.Client.NewRequest(ctx, http.MethodGet, path, listOptions) if err != nil { @@ -65,18 +65,18 @@ func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterID strin return root, resp, err } -func (s CheckpointsServiceOp) Get(ctx context.Context, groupID, clusterID, checkpointID string) (*Checkpoint, *Response, error) { +func (s AtlasCheckpointsServiceOp) Get(ctx context.Context, groupID, clusterName, checkpointID string) (*Checkpoint, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set") } - if clusterID == "" { - return nil, nil, NewArgError("clusterID", "must be set") + if clusterName == "" { + return nil, nil, NewArgError("clusterName", "must be set") } if checkpointID == "" { return nil, nil, NewArgError("checkpointID", "must be set") } - basePath := fmt.Sprintf(backupCheckpoints, groupID, clusterID) + basePath := fmt.Sprintf(backupCheckpoints, groupID, clusterName) path := fmt.Sprintf("%s/%s", basePath, checkpointID) req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil) diff --git a/mongodbatlas/checkpoints_test.go b/mongodbatlas/atlas_checkpoints_test.go similarity index 97% rename from mongodbatlas/checkpoints_test.go rename to mongodbatlas/atlas_checkpoints_test.go index 368b4708e..17eccfa66 100644 --- a/mongodbatlas/checkpoints_test.go +++ b/mongodbatlas/atlas_checkpoints_test.go @@ -125,9 +125,9 @@ func TestCheckpoints_List(t *testing.T) { ) }) - snapshots, _, err := client.Checkpoints.List(ctx, groupID, clusterName, nil) + snapshots, _, err := client.AtlasCheckpoints.List(ctx, groupID, clusterName, nil) if err != nil { - t.Fatalf("Checkpoints.List returned error: %v", err) + t.Fatalf("AtlasCheckpoints.List returned error: %v", err) } expected := &Checkpoints{ @@ -298,7 +298,7 @@ func TestCheckpoints_Get(t *testing.T) { }`) }) - cloudProviderSnapshot, _, err := client.Checkpoints.Get(ctx, groupID, clusterName, checkpointID) + cloudProviderSnapshot, _, err := client.AtlasCheckpoints.Get(ctx, groupID, clusterName, checkpointID) if err != nil { t.Fatalf("ContinuousSnapshots.Get returned error: %v", err) } diff --git a/mongodbatlas/mongodbatlas.go b/mongodbatlas/mongodbatlas.go index 6d553c84a..90b489cfc 100644 --- a/mongodbatlas/mongodbatlas.go +++ b/mongodbatlas/mongodbatlas.go @@ -61,7 +61,7 @@ type Client struct { X509AuthDBUsers X509AuthDBUsersService ContinuousSnapshots ContinuousSnapshotsService ContinuousRestoreJobs ContinuousRestoreJobsService - Checkpoints CheckpointService + AtlasCheckpoints AtlasCheckpointService onRequestCompleted RequestCompletionCallback } @@ -176,7 +176,7 @@ func NewClient(httpClient *http.Client) *Client { c.PrivateEndpoints = &PrivateEndpointsServiceOp{Client: c} c.X509AuthDBUsers = &X509AuthDBUsersServiceOp{Client: c} c.ContinuousRestoreJobs = &ContinuousRestoreJobsServiceOp{Client: c} - c.Checkpoints = &CheckpointsServiceOp{Client: c} + c.AtlasCheckpoints = &AtlasCheckpointsServiceOp{Client: c} return c } From 36cf6d5579cd226d33547fe4155b4bec4cafae5e Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 13 Mar 2020 17:55:13 +0000 Subject: [PATCH 3/6] Addressed PR Comments --- .../{atlas_checkpoints.go => checkpoints.go} | 22 ++- ...heckpoints_test.go => checkpoints_test.go} | 147 ++++++++++-------- mongodbatlas/continuous_snaphots.go | 28 ++-- mongodbatlas/continuous_snapshots_test.go | 62 ++++---- mongodbatlas/mongodbatlas.go | 4 +- 5 files changed, 143 insertions(+), 120 deletions(-) rename mongodbatlas/{atlas_checkpoints.go => checkpoints.go} (74%) rename mongodbatlas/{atlas_checkpoints_test.go => checkpoints_test.go} (73%) diff --git a/mongodbatlas/atlas_checkpoints.go b/mongodbatlas/checkpoints.go similarity index 74% rename from mongodbatlas/atlas_checkpoints.go rename to mongodbatlas/checkpoints.go index 136fc9317..fcd3ea699 100644 --- a/mongodbatlas/atlas_checkpoints.go +++ b/mongodbatlas/checkpoints.go @@ -10,20 +10,20 @@ const ( backupCheckpoints = "groups/%s/clusters/%s/backupCheckpoints" ) -// AtlasCheckpointService is an interface for interfacing with the Checkpoint +// CheckpointService is an interface for interfacing with the Checkpoint // endpoints of the MongoDB Atlas API. -type AtlasCheckpointService interface { +type CheckpointService interface { List(context.Context, string, string, *ListOptions) (*Checkpoints, *Response, error) Get(context.Context, string, string, string) (*Checkpoint, *Response, error) } -// AtlasCheckpointsServiceOp handles communication with the checkpoint related methods of the +// CheckpointsServiceOp handles communication with the checkpoint related methods of the // MongoDB Atlas API -type AtlasCheckpointsServiceOp struct { +type CheckpointsServiceOp struct { Client RequestDoer } -var _ AtlasCheckpointService = &AtlasCheckpointsServiceOp{} +var _ CheckpointService = &CheckpointsServiceOp{} type Checkpoint struct { ClusterID string `json:"clusterId"` @@ -37,14 +37,20 @@ type Checkpoint struct { Timestamp string `json:"timestamp"` } -// AtlasCheckpoints represents all the backup checkpoints related to a cluster. +type CheckpointPart struct { + ShardName string `json:"shardName"` + TokenDiscovered bool `json:"tokenDiscovered"` + TokenTimestamp SnapshotTimestamp `json:"tokenTimestamp"` +} + +// Checkpoints represents all the backup checkpoints related to a cluster. type Checkpoints struct { Results []*Checkpoint `json:"results,omitempty"` // Includes one Checkpoint object for each item detailed in the results array section. Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources. TotalCount int `json:"totalCount,omitempty"` // Count of the total number of items in the result set. It may be greater than the number of objects in the results array if the entire result set is paginated. } -func (s AtlasCheckpointsServiceOp) List(ctx context.Context, groupID, clusterName string, listOptions *ListOptions) (*Checkpoints, *Response, error) { +func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterName string, listOptions *ListOptions) (*Checkpoints, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set") } @@ -65,7 +71,7 @@ func (s AtlasCheckpointsServiceOp) List(ctx context.Context, groupID, clusterNam return root, resp, err } -func (s AtlasCheckpointsServiceOp) Get(ctx context.Context, groupID, clusterName, checkpointID string) (*Checkpoint, *Response, error) { +func (s CheckpointsServiceOp) Get(ctx context.Context, groupID, clusterName, checkpointID string) (*Checkpoint, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set") } diff --git a/mongodbatlas/atlas_checkpoints_test.go b/mongodbatlas/checkpoints_test.go similarity index 73% rename from mongodbatlas/atlas_checkpoints_test.go rename to mongodbatlas/checkpoints_test.go index 17eccfa66..5a5faf315 100644 --- a/mongodbatlas/atlas_checkpoints_test.go +++ b/mongodbatlas/checkpoints_test.go @@ -145,33 +145,36 @@ func TestCheckpoints_List(t *testing.T) { }, Parts: []*Part{ { - ReplicaSetName: "Cluster0-shard-1", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-1", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 1, - }, + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }}, }, { - ReplicaSetName: "Cluster0-shard-0", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-0", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 1, - }, + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }}, }, { - ReplicaSetName: "Cluster0-config-0", - TypeName: "CONFIG_SERVER_REPLICA_SET", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 2, - }, + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + CheckpointPart: CheckpointPart{ + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 2, + }}, }, }, Restorable: true, @@ -191,33 +194,36 @@ func TestCheckpoints_List(t *testing.T) { }, Parts: []*Part{ { - ReplicaSetName: "Cluster0-shard-1", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-1", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-09T14:50:33Z", - Increment: 1, - }, + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 1, + }}, }, { - ReplicaSetName: "Cluster0-shard-0", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-0", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-09T14:50:33Z", - Increment: 2, - }, + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 2, + }}, }, { - ReplicaSetName: "Cluster0-config-0", - TypeName: "CONFIG_SERVER_REPLICA_SET", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-09T14:50:33Z", - Increment: 4, - }, + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + CheckpointPart: CheckpointPart{ + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-09T14:50:33Z", + Increment: 4, + }}, }, }, Restorable: true, @@ -315,34 +321,39 @@ func TestCheckpoints_Get(t *testing.T) { }, }, Parts: []*Part{ + { - ReplicaSetName: "Cluster0-shard-1", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-1", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 1, + ReplicaSetName: "Cluster0-shard-1", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-1", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }, }, }, { - ReplicaSetName: "Cluster0-shard-0", - TypeName: "REPLICA_SET", - ShardName: "Cluster0-shard-0", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 1, - }, + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + CheckpointPart: CheckpointPart{ + ShardName: "Cluster0-shard-0", + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 1, + }}, }, { - ReplicaSetName: "Cluster0-config-0", - TypeName: "CONFIG_SERVER_REPLICA_SET", - TokenDiscovered: true, - TokenTimestamp: SnapshotTimestamp{ - Date: "2018-02-08T23:20:25Z", - Increment: 2, - }, + ReplicaSetName: "Cluster0-config-0", + TypeName: "CONFIG_SERVER_REPLICA_SET", + CheckpointPart: CheckpointPart{ + TokenDiscovered: true, + TokenTimestamp: SnapshotTimestamp{ + Date: "2018-02-08T23:20:25Z", + Increment: 2, + }}, }, }, Restorable: true, diff --git a/mongodbatlas/continuous_snaphots.go b/mongodbatlas/continuous_snaphots.go index 55d58e462..e12b5ed96 100644 --- a/mongodbatlas/continuous_snaphots.go +++ b/mongodbatlas/continuous_snaphots.go @@ -46,19 +46,21 @@ type ContinuousSnapshot struct { } type Part struct { - ClusterID string `json:"clusterId,omitempty"` - CompressionSetting string `json:"compressionSetting,omitempty"` - DataSizeBytes int64 `json:"dataSizeBytes,omitempty"` - EncryptionEnabled bool `json:"encryptionEnabled,omitempty"` - FileSizeBytes int64 `json:"fileSizeBytes,omitempty"` - MasterKeyUUID string `json:"masterKeyUUID,omitempty"` - MongodVersion string `json:"mongodVersion,omitempty"` - ReplicaSetName string `json:"replicaSetName,omitempty"` - StorageSizeBytes int64 `json:"storageSizeBytes,omitempty"` - TypeName string `json:"typeName"` - ShardName string `json:"shardName,omitempty"` - TokenDiscovered bool `json:"tokenDiscovered,omitempty"` - TokenTimestamp SnapshotTimestamp `json:"tokenTimestamp,omitempty"` + ReplicaSetName string `json:"replicaSetName"` + TypeName string `json:"typeName"` + SnapshotPart + CheckpointPart +} + +type SnapshotPart struct { + ClusterID string `json:"clusterId"` + CompressionSetting string `json:"compressionSetting"` + DataSizeBytes int64 `json:"dataSizeBytes"` + EncryptionEnabled bool `json:"encryptionEnabled"` + FileSizeBytes int64 `json:"fileSizeBytes"` + MasterKeyUUID string `json:"masterKeyUUID,omitempty"` + MongodVersion string `json:"mongodVersion"` + StorageSizeBytes int64 `json:"storageSizeBytes"` } type NamespaceFilter struct { diff --git a/mongodbatlas/continuous_snapshots_test.go b/mongodbatlas/continuous_snapshots_test.go index 97de0c8f8..bbcc7099e 100644 --- a/mongodbatlas/continuous_snapshots_test.go +++ b/mongodbatlas/continuous_snapshots_test.go @@ -3,10 +3,11 @@ package mongodbatlas import ( "encoding/json" "fmt" - "github.com/mwielbut/pointy" "net/http" "testing" + "github.com/mwielbut/pointy" + "github.com/go-test/deep" ) @@ -97,15 +98,16 @@ func TestContinuousSnapshots_List(t *testing.T) { }, Parts: []*Part{ { - ClusterID: "7c2487d833e9e75286093696", - CompressionSetting: "GZIP", - DataSizeBytes: 4502, - EncryptionEnabled: false, - FileSizeBytes: 324760, - MongodVersion: "3.6.10", - ReplicaSetName: "Cluster0-shard-0", - StorageSizeBytes: 53248, - TypeName: "REPLICA_SET", + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + SnapshotPart: SnapshotPart{ + ClusterID: "7c2487d833e9e75286093696", + CompressionSetting: "GZIP", + DataSizeBytes: 4502, + EncryptionEnabled: false, + FileSizeBytes: 324760, + MongodVersion: "3.6.10", + StorageSizeBytes: 53248}, }, }, }, @@ -190,15 +192,16 @@ func TestContinuousSnapshots_Get(t *testing.T) { }, Parts: []*Part{ { - ClusterID: "7c2487d833e9e75286093696", - CompressionSetting: "GZIP", - DataSizeBytes: 4502, - EncryptionEnabled: false, - FileSizeBytes: 324760, - MongodVersion: "3.6.10", - ReplicaSetName: "Cluster0-shard-0", - StorageSizeBytes: 53248, - TypeName: "REPLICA_SET", + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + SnapshotPart: SnapshotPart{ + ClusterID: "7c2487d833e9e75286093696", + CompressionSetting: "GZIP", + DataSizeBytes: 4502, + EncryptionEnabled: false, + FileSizeBytes: 324760, + MongodVersion: "3.6.10", + StorageSizeBytes: 53248}, }, }, } @@ -302,16 +305,17 @@ func TestContinuousSnapshots_ChangeExpiry(t *testing.T) { }, Parts: []*Part{ { - ClusterID: "57c2487d833e9e75286093696", - CompressionSetting: "GZIP", - DataSizeBytes: 4502, - EncryptionEnabled: false, - FileSizeBytes: 324760, - MongodVersion: "3.6.10", - ReplicaSetName: "Cluster0-shard-0", - StorageSizeBytes: 53248, - TypeName: "REPLICA_SET", - }, + ReplicaSetName: "Cluster0-shard-0", + TypeName: "REPLICA_SET", + SnapshotPart: SnapshotPart{ + ClusterID: "57c2487d833e9e75286093696", + CompressionSetting: "GZIP", + DataSizeBytes: 4502, + EncryptionEnabled: false, + FileSizeBytes: 324760, + MongodVersion: "3.6.10", + StorageSizeBytes: 53248, + }}, }, } diff --git a/mongodbatlas/mongodbatlas.go b/mongodbatlas/mongodbatlas.go index 90b489cfc..0bc16b088 100644 --- a/mongodbatlas/mongodbatlas.go +++ b/mongodbatlas/mongodbatlas.go @@ -61,7 +61,7 @@ type Client struct { X509AuthDBUsers X509AuthDBUsersService ContinuousSnapshots ContinuousSnapshotsService ContinuousRestoreJobs ContinuousRestoreJobsService - AtlasCheckpoints AtlasCheckpointService + AtlasCheckpoints CheckpointService onRequestCompleted RequestCompletionCallback } @@ -176,7 +176,7 @@ func NewClient(httpClient *http.Client) *Client { c.PrivateEndpoints = &PrivateEndpointsServiceOp{Client: c} c.X509AuthDBUsers = &X509AuthDBUsersServiceOp{Client: c} c.ContinuousRestoreJobs = &ContinuousRestoreJobsServiceOp{Client: c} - c.AtlasCheckpoints = &AtlasCheckpointsServiceOp{Client: c} + c.AtlasCheckpoints = &CheckpointsServiceOp{Client: c} return c } From 24f2fa1861f117f6fcf73dc70ea2ed92886ce7f1 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 13 Mar 2020 18:06:20 +0000 Subject: [PATCH 4/6] Refactoring --- mongodbatlas/checkpoints.go | 6 +++--- mongodbatlas/checkpoints_test.go | 6 +++--- mongodbatlas/mongodbatlas.go | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mongodbatlas/checkpoints.go b/mongodbatlas/checkpoints.go index fcd3ea699..bf9bb093d 100644 --- a/mongodbatlas/checkpoints.go +++ b/mongodbatlas/checkpoints.go @@ -10,9 +10,9 @@ const ( backupCheckpoints = "groups/%s/clusters/%s/backupCheckpoints" ) -// CheckpointService is an interface for interfacing with the Checkpoint +// CheckpointsService is an interface for interfacing with the Checkpoint // endpoints of the MongoDB Atlas API. -type CheckpointService interface { +type CheckpointsService interface { List(context.Context, string, string, *ListOptions) (*Checkpoints, *Response, error) Get(context.Context, string, string, string) (*Checkpoint, *Response, error) } @@ -23,7 +23,7 @@ type CheckpointsServiceOp struct { Client RequestDoer } -var _ CheckpointService = &CheckpointsServiceOp{} +var _ CheckpointsService = &CheckpointsServiceOp{} type Checkpoint struct { ClusterID string `json:"clusterId"` diff --git a/mongodbatlas/checkpoints_test.go b/mongodbatlas/checkpoints_test.go index 5a5faf315..34efca50f 100644 --- a/mongodbatlas/checkpoints_test.go +++ b/mongodbatlas/checkpoints_test.go @@ -125,9 +125,9 @@ func TestCheckpoints_List(t *testing.T) { ) }) - snapshots, _, err := client.AtlasCheckpoints.List(ctx, groupID, clusterName, nil) + snapshots, _, err := client.Checkpoints.List(ctx, groupID, clusterName, nil) if err != nil { - t.Fatalf("AtlasCheckpoints.List returned error: %v", err) + t.Fatalf("Checkpoints.List returned error: %v", err) } expected := &Checkpoints{ @@ -304,7 +304,7 @@ func TestCheckpoints_Get(t *testing.T) { }`) }) - cloudProviderSnapshot, _, err := client.AtlasCheckpoints.Get(ctx, groupID, clusterName, checkpointID) + cloudProviderSnapshot, _, err := client.Checkpoints.Get(ctx, groupID, clusterName, checkpointID) if err != nil { t.Fatalf("ContinuousSnapshots.Get returned error: %v", err) } diff --git a/mongodbatlas/mongodbatlas.go b/mongodbatlas/mongodbatlas.go index 0bc16b088..a3221f5c9 100644 --- a/mongodbatlas/mongodbatlas.go +++ b/mongodbatlas/mongodbatlas.go @@ -51,17 +51,17 @@ type Client struct { EncryptionsAtRest EncryptionsAtRestService WhitelistAPIKeys WhitelistAPIKeysService PrivateIPMode PrivateIPModeService - MaintenanceWindows MaintenanceWindowsService - Teams TeamsService - AtlasUsers AtlasUsersService - GlobalClusters GlobalClustersService - Auditing AuditingsService - AlertConfigurations AlertConfigurationsService - PrivateEndpoints PrivateEndpointsService - X509AuthDBUsers X509AuthDBUsersService - ContinuousSnapshots ContinuousSnapshotsService - ContinuousRestoreJobs ContinuousRestoreJobsService - AtlasCheckpoints CheckpointService + MaintenanceWindows MaintenanceWindowsService + Teams TeamsService + AtlasUsers AtlasUsersService + GlobalClusters GlobalClustersService + Auditing AuditingsService + AlertConfigurations AlertConfigurationsService + PrivateEndpoints PrivateEndpointsService + X509AuthDBUsers X509AuthDBUsersService + ContinuousSnapshots ContinuousSnapshotsService + ContinuousRestoreJobs ContinuousRestoreJobsService + Checkpoints CheckpointsService onRequestCompleted RequestCompletionCallback } @@ -176,7 +176,7 @@ func NewClient(httpClient *http.Client) *Client { c.PrivateEndpoints = &PrivateEndpointsServiceOp{Client: c} c.X509AuthDBUsers = &X509AuthDBUsersServiceOp{Client: c} c.ContinuousRestoreJobs = &ContinuousRestoreJobsServiceOp{Client: c} - c.AtlasCheckpoints = &CheckpointsServiceOp{Client: c} + c.Checkpoints = &CheckpointsServiceOp{Client: c} return c } From 64ca336aaca9d315c6a2a5b5160d38c69e5b159d Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 13 Mar 2020 18:09:24 +0000 Subject: [PATCH 5/6] Fixed lint error --- mongodbatlas/mongodbatlas.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mongodbatlas/mongodbatlas.go b/mongodbatlas/mongodbatlas.go index a3221f5c9..342f9cdc3 100644 --- a/mongodbatlas/mongodbatlas.go +++ b/mongodbatlas/mongodbatlas.go @@ -51,17 +51,17 @@ type Client struct { EncryptionsAtRest EncryptionsAtRestService WhitelistAPIKeys WhitelistAPIKeysService PrivateIPMode PrivateIPModeService - MaintenanceWindows MaintenanceWindowsService - Teams TeamsService - AtlasUsers AtlasUsersService - GlobalClusters GlobalClustersService - Auditing AuditingsService - AlertConfigurations AlertConfigurationsService - PrivateEndpoints PrivateEndpointsService - X509AuthDBUsers X509AuthDBUsersService - ContinuousSnapshots ContinuousSnapshotsService - ContinuousRestoreJobs ContinuousRestoreJobsService - Checkpoints CheckpointsService + MaintenanceWindows MaintenanceWindowsService + Teams TeamsService + AtlasUsers AtlasUsersService + GlobalClusters GlobalClustersService + Auditing AuditingsService + AlertConfigurations AlertConfigurationsService + PrivateEndpoints PrivateEndpointsService + X509AuthDBUsers X509AuthDBUsersService + ContinuousSnapshots ContinuousSnapshotsService + ContinuousRestoreJobs ContinuousRestoreJobsService + Checkpoints CheckpointsService onRequestCompleted RequestCompletionCallback } From b9411d95b0834177ae61ea88afa35a2da74f1fae Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Wed, 18 Mar 2020 09:26:14 +0000 Subject: [PATCH 6/6] Added comments --- mongodbatlas/checkpoints.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mongodbatlas/checkpoints.go b/mongodbatlas/checkpoints.go index bf9bb093d..71e310941 100644 --- a/mongodbatlas/checkpoints.go +++ b/mongodbatlas/checkpoints.go @@ -25,6 +25,7 @@ type CheckpointsServiceOp struct { var _ CheckpointsService = &CheckpointsServiceOp{} +// Checkpoint represents MongoDB Checkpoint type Checkpoint struct { ClusterID string `json:"clusterId"` Completed string `json:"completed,omitempty"` @@ -37,6 +38,7 @@ type Checkpoint struct { Timestamp string `json:"timestamp"` } +// CheckpointPart represents the individual parts that comprise the complete checkpoint. type CheckpointPart struct { ShardName string `json:"shardName"` TokenDiscovered bool `json:"tokenDiscovered"` @@ -50,6 +52,8 @@ type Checkpoints struct { TotalCount int `json:"totalCount,omitempty"` // Count of the total number of items in the result set. It may be greater than the number of objects in the results array if the entire result set is paginated. } +// List all checkpoints for the specified sharded cluster. +// See more: https://docs.atlas.mongodb.com/reference/api/checkpoints-get-all/ func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterName string, listOptions *ListOptions) (*Checkpoints, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set") @@ -71,6 +75,8 @@ func (s CheckpointsServiceOp) List(ctx context.Context, groupID, clusterName str return root, resp, err } +// Get one checkpoint for the specified sharded cluster. +// See more: https://docs.atlas.mongodb.com/reference/api/checkpoints-get-one/ func (s CheckpointsServiceOp) Get(ctx context.Context, groupID, clusterName, checkpointID string) (*Checkpoint, *Response, error) { if groupID == "" { return nil, nil, NewArgError("groupId", "must be set")