Skip to content

Commit

Permalink
INTMDB-239: added fields for cloud provider snapshot (#261)
Browse files Browse the repository at this point in the history
* added fields for cloud provider snapshot

* fixes nit

Co-authored-by: Edgar Lopez <[email protected]>
  • Loading branch information
coderGo93 and Edgar Lopez authored Oct 15, 2021
1 parent da83419 commit c17a67c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
35 changes: 23 additions & 12 deletions mongodbatlas/cloud_provider_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@ var _ CloudProviderSnapshotsService = &CloudProviderSnapshotsServiceOp{}

// CloudProviderSnapshot represents a cloud provider snapshot.
type CloudProviderSnapshot struct {
ID string `json:"id,omitempty"` // Unique identifier of the snapshot.
RetentionInDays int `json:"retentionInDays,omitempty"` // The number of days that Atlas should retain the on-demand snapshot. Must be at least 1 .
CreatedAt string `json:"createdAt,omitempty"` // UTC ISO 8601 formatted point in time when Atlas took the snapshot.
ExpiresAt string `json:"expiresAt,omitempty"` // UTC ISO 8601 formatted point in time when Atlas will delete the snapshot.
Description string `json:"description,omitempty"` // Description of the on-demand snapshot.
Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources.
MasterKeyUUID string `json:"masterKeyUUID,omitempty"` // Unique ID of the AWS KMS Customer Master Key used to encrypt the snapshot. Only visible for clusters using Encryption at Rest via Customer KMS.
MongodVersion string `json:"mongodVersion,omitempty"` // Version of the MongoDB server.
SnapshotType string `json:"snapshotType,omitempty"` // Specified the type of snapshot. Valid values are onDemand and scheduled.
Status string `json:"status,omitempty"` // Current status of the snapshot. One of the following values: queued, inProgress, completed, failed
StorageSizeBytes int `json:"storageSizeBytes,omitempty"` // Specifies the size of the snapshot in bytes.
Type string `json:"type,omitempty"` // Specifies the type of cluster: replicaSet or shardedCluster.
ID string `json:"id,omitempty"` // Unique identifier of the snapshot.
RetentionInDays int `json:"retentionInDays,omitempty"` // The number of days that Atlas should retain the on-demand snapshot. Must be at least 1 .
CreatedAt string `json:"createdAt,omitempty"` // UTC ISO 8601 formatted point in time when Atlas took the snapshot.
ExpiresAt string `json:"expiresAt,omitempty"` // UTC ISO 8601 formatted point in time when Atlas will delete the snapshot.
Description string `json:"description,omitempty"` // Description of the on-demand snapshot.
Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources.
MasterKeyUUID string `json:"masterKeyUUID,omitempty"` // Unique ID of the AWS KMS Customer Master Key used to encrypt the snapshot. Only visible for clusters using Encryption at Rest via Customer KMS.
MongodVersion string `json:"mongodVersion,omitempty"` // Version of the MongoDB server.
SnapshotType string `json:"snapshotType,omitempty"` // Specified the type of snapshot. Valid values are onDemand and scheduled.
Status string `json:"status,omitempty"` // Current status of the snapshot. One of the following values: queued, inProgress, completed, failed
StorageSizeBytes int `json:"storageSizeBytes,omitempty"` // Specifies the size of the snapshot in bytes.
Type string `json:"type,omitempty"` // Specifies the type of cluster: replicaSet or shardedCluster.
CloudProvider string `json:"cloudProvider,omitempty"` // Cloud provider that stores this snapshot. Atlas returns this parameter when "type": "replicaSet".
Members []*Member `json:"members,omitempty"` // List of ReplicaSetName and the cloud provider where the snapshots are stored. Atlas returns this parameter when "type": "shardedCluster".
ReplicaSetName string `json:"replicaSetName,omitempty"` // Label given to the replica set from which Atlas took this snapshot. Atlas returns this parameter when "type": "replicaSet".
SnapshotsIds []string `json:"snapshotIds,omitempty"` // Unique identifiers of the snapshots created for the shards and config server for a sharded cluster.
}

// CloudProviderSnapshots represents all cloud provider snapshots.
Expand All @@ -72,6 +76,13 @@ type SnapshotReqPathParameters struct {
JobID string `json:"jobId,omitempty"` // The unique identifier of the restore job to retrieve.
}

// Member represents all member of cloud provider snapshot.
type Member struct {
ID string `json:"id,omitempty"` // Cloud provider that stores this snapshot.
CloudProvider string `json:"cloudProvider,omitempty"` // Unique identifier for the sharded cluster snapshot.
ReplicaSetName string `json:"replicaSetName,omitempty"` // Label given to a shard or config server from which Atlas took this snapshot.
}

// GetAllCloudProviderSnapshots gets all cloud provider snapshots for the specified cluster.
//
// See more: https://docs.atlas.mongodb.com/reference/api/cloud-provider-snapshot-get-all/
Expand Down
36 changes: 25 additions & 11 deletions mongodbatlas/cloud_provider_snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestCloudProviderSnapshots_GetAllCloudProviderSnapshots(t *testing.T) {
],
"results": [
{
"cloudProvider": "AZURE",
"createdAt": "2018-08-01T20:02:07Z",
"expiresAt": "2018-08-04T20:03:11Z",
"id": "5b6211ff87d9d663c59d3feg",
Expand All @@ -59,6 +60,8 @@ func TestCloudProviderSnapshots_GetAllCloudProviderSnapshots(t *testing.T) {
}
],
"mongodVersion": "3.6.6",
"replicaSetName": "newCluster",
"snapshotType": "scheduled",
"storageSizeBytes": 1778012160,
"type": "replicaSet"
}
Expand All @@ -81,9 +84,10 @@ func TestCloudProviderSnapshots_GetAllCloudProviderSnapshots(t *testing.T) {
},
Results: []*CloudProviderSnapshot{
{
CreatedAt: "2018-08-01T20:02:07Z",
ExpiresAt: "2018-08-04T20:03:11Z",
ID: "5b6211ff87d9d663c59d3feg",
CloudProvider: "AZURE",
CreatedAt: "2018-08-01T20:02:07Z",
ExpiresAt: "2018-08-04T20:03:11Z",
ID: "5b6211ff87d9d663c59d3feg",
Links: []*Link{
{
Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/5b6212af90dc76637950a2c6/clusters/MyCluster/backup/snapshots/5b6211ff87d9d663c59d3feg",
Expand All @@ -95,6 +99,8 @@ func TestCloudProviderSnapshots_GetAllCloudProviderSnapshots(t *testing.T) {
},
},
MongodVersion: "3.6.6",
ReplicaSetName: "newCluster",
SnapshotType: "scheduled",
StorageSizeBytes: 1778012160,
Type: "replicaSet",
},
Expand Down Expand Up @@ -122,6 +128,7 @@ func TestCloudProviderSnapshots_GetOneCloudProviderSnapshot(t *testing.T) {
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{
"cloudProvider": "AZURE",
"createdAt": "2018-08-01T20:02:07Z",
"description": "SomeDescription",
"expiresAt": "2018-08-04T20:03:11Z",
Expand All @@ -137,6 +144,7 @@ func TestCloudProviderSnapshots_GetOneCloudProviderSnapshot(t *testing.T) {
}
],
"mongodVersion": "4.0.3",
"replicaSetName": "newCluster",
"snapshotType": "onDemand",
"status": "queued",
"storageSizeBytes": 1778012160,
Expand All @@ -150,10 +158,11 @@ func TestCloudProviderSnapshots_GetOneCloudProviderSnapshot(t *testing.T) {
}

expected := &CloudProviderSnapshot{
CreatedAt: "2018-08-01T20:02:07Z",
Description: "SomeDescription",
ExpiresAt: "2018-08-04T20:03:11Z",
ID: "5b6211ff87d9d663c59d3feg",
CloudProvider: "AZURE",
CreatedAt: "2018-08-01T20:02:07Z",
Description: "SomeDescription",
ExpiresAt: "2018-08-04T20:03:11Z",
ID: "5b6211ff87d9d663c59d3feg",
Links: []*Link{
{
Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/5b6212af90dc76637950a2c6/clusters/MyCluster/backup/snapshots/5b6211ff87d9d663c59d3feg",
Expand All @@ -165,6 +174,7 @@ func TestCloudProviderSnapshots_GetOneCloudProviderSnapshot(t *testing.T) {
},
},
MongodVersion: "4.0.3",
ReplicaSetName: "newCluster",
SnapshotType: "onDemand",
Status: "queued",
StorageSizeBytes: 1778012160,
Expand Down Expand Up @@ -208,6 +218,7 @@ func TestCloudProviderSnapshots_Create(t *testing.T) {
}

fmt.Fprint(w, `{
"cloudProvider": "AZURE",
"createdAt": "2018-12-31T20:54:03Z",
"description": "SomeDescription ",
"expiresAt": "2019-01-05T20:54:03Z",
Expand All @@ -223,6 +234,7 @@ func TestCloudProviderSnapshots_Create(t *testing.T) {
}
],
"mongodVersion": "4.0.4",
"replicaSetName": "newCluster",
"snapshotType": "onDemand",
"status": "queued",
"storageSizeBytes": 0,
Expand All @@ -236,10 +248,11 @@ func TestCloudProviderSnapshots_Create(t *testing.T) {
}

expected := &CloudProviderSnapshot{
CreatedAt: "2018-12-31T20:54:03Z",
Description: "SomeDescription ",
ExpiresAt: "2019-01-05T20:54:03Z",
ID: "6d3b81eb87d9d61e37598558",
CloudProvider: "AZURE",
CreatedAt: "2018-12-31T20:54:03Z",
Description: "SomeDescription ",
ExpiresAt: "2019-01-05T20:54:03Z",
ID: "6d3b81eb87d9d61e37598558",
Links: []*Link{
{
Href: "https://cloud.mongodb.com/api/atlas/v1.0/groups/6d2065c687d9d64ae7acdg41/clusters/Cluster0/backup/snapshots/6d3b81eb87d9d61e37598558",
Expand All @@ -251,6 +264,7 @@ func TestCloudProviderSnapshots_Create(t *testing.T) {
},
},
MongodVersion: "4.0.4",
ReplicaSetName: "newCluster",
SnapshotType: "onDemand",
Status: "queued",
StorageSizeBytes: 0,
Expand Down

0 comments on commit c17a67c

Please sign in to comment.