Skip to content

Commit ab5f7e9

Browse files
authored
feat: Adds acceptDataRisksAndForceReplicaSetReconfig parameter in cluster and advanced cluster (#518)
1 parent 354f5e2 commit ab5f7e9

File tree

4 files changed

+84
-57
lines changed

4 files changed

+84
-57
lines changed

mongodbatlas/advanced_clusters.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,28 @@ var _ AdvancedClustersService = &AdvancedClustersServiceOp{}
4444

4545
// AdvancedCluster represents MongoDB cluster.
4646
type AdvancedCluster struct {
47-
BackupEnabled *bool `json:"backupEnabled,omitempty"`
48-
BiConnector *BiConnector `json:"biConnector,omitempty"`
49-
ClusterType string `json:"clusterType,omitempty"`
50-
ConnectionStrings *ConnectionStrings `json:"connectionStrings,omitempty"`
51-
DiskSizeGB *float64 `json:"diskSizeGB,omitempty"`
52-
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
53-
GroupID string `json:"groupId,omitempty"`
54-
ID string `json:"id,omitempty"`
55-
Labels []Label `json:"labels,omitempty"`
56-
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
57-
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
58-
Name string `json:"name,omitempty"`
59-
Paused *bool `json:"paused,omitempty"`
60-
PitEnabled *bool `json:"pitEnabled,omitempty"`
61-
StateName string `json:"stateName,omitempty"`
62-
ReplicationSpecs []*AdvancedReplicationSpec `json:"replicationSpecs,omitempty"`
63-
CreateDate string `json:"createDate,omitempty"`
64-
RootCertType string `json:"rootCertType,omitempty"`
65-
VersionReleaseSystem string `json:"versionReleaseSystem,omitempty"`
66-
TerminationProtectionEnabled *bool `json:"terminationProtectionEnabled,omitempty"`
67-
Tags []*Tag `json:"tags,omitempty"`
47+
AcceptDataRisksAndForceReplicaSetReconfig string `json:"acceptDataRisksAndForceReplicaSetReconfig,omitempty"`
48+
BackupEnabled *bool `json:"backupEnabled,omitempty"`
49+
BiConnector *BiConnector `json:"biConnector,omitempty"`
50+
ClusterType string `json:"clusterType,omitempty"`
51+
ConnectionStrings *ConnectionStrings `json:"connectionStrings,omitempty"`
52+
DiskSizeGB *float64 `json:"diskSizeGB,omitempty"`
53+
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
54+
GroupID string `json:"groupId,omitempty"`
55+
ID string `json:"id,omitempty"`
56+
Labels []Label `json:"labels,omitempty"`
57+
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
58+
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
59+
Name string `json:"name,omitempty"`
60+
Paused *bool `json:"paused,omitempty"`
61+
PitEnabled *bool `json:"pitEnabled,omitempty"`
62+
StateName string `json:"stateName,omitempty"`
63+
ReplicationSpecs []*AdvancedReplicationSpec `json:"replicationSpecs,omitempty"`
64+
CreateDate string `json:"createDate,omitempty"`
65+
RootCertType string `json:"rootCertType,omitempty"`
66+
VersionReleaseSystem string `json:"versionReleaseSystem,omitempty"`
67+
TerminationProtectionEnabled *bool `json:"terminationProtectionEnabled,omitempty"`
68+
Tags []*Tag `json:"tags,omitempty"`
6869
}
6970

7071
type AdvancedReplicationSpec struct {

mongodbatlas/advanced_clusters_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestAdvancedClusters_List(t *testing.T) {
4848
"readPreference": "secondary"
4949
},
5050
"clusterType": "REPLICASET",
51+
"acceptDataRisksAndForceReplicaSetReconfig": "2021-03-02T22:25:18Z",
5152
"createDate": "2021-03-02T22:25:18Z",
5253
"diskSizeGB": 10.0,
5354
"encryptionAtRestProvider": "NONE",
@@ -112,6 +113,7 @@ func TestAdvancedClusters_List(t *testing.T) {
112113
"readPreference": "secondary"
113114
},
114115
"clusterType": "GEOSHARDED",
116+
"acceptDataRisksAndForceReplicaSetReconfig": "2021-03-02T22:27:46Z",
115117
"createDate": "2021-03-02T22:27:46Z",
116118
"diskSizeGB": 40.0,
117119
"encryptionAtRestProvider": "NONE",
@@ -294,7 +296,8 @@ func TestAdvancedClusters_List(t *testing.T) {
294296
},
295297
},
296298
},
297-
CreateDate: "2021-03-02T22:25:18Z",
299+
CreateDate: "2021-03-02T22:25:18Z",
300+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:25:18Z",
298301
RootCertType: "DST",
299302
},
300303
{
@@ -393,6 +396,7 @@ func TestAdvancedClusters_List(t *testing.T) {
393396
},
394397
},
395398
}},
399+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:27:46Z",
396400
CreateDate: "2021-03-02T22:27:46Z",
397401
RootCertType: "DST",
398402
VersionReleaseSystem: "LTS",
@@ -636,6 +640,7 @@ func TestAdvancedClusters_Create(t *testing.T) {
636640
"readPreference": "secondary"
637641
},
638642
"clusterType": "GEOSHARDED",
643+
"acceptDataRisksAndForceReplicaSetReconfig": "2021-03-02T22:27:46Z",
639644
"createDate": "2021-03-02T22:27:46Z",
640645
"diskSizeGB": 40.0,
641646
"encryptionAtRestProvider": "NONE",
@@ -832,6 +837,7 @@ func TestAdvancedClusters_Create(t *testing.T) {
832837
},
833838
},
834839
}},
840+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:27:46Z",
835841
CreateDate: "2021-03-02T22:27:46Z",
836842
RootCertType: "DST",
837843
VersionReleaseSystem: "LTS",
@@ -938,6 +944,7 @@ func TestAdvancedClusters_Create(t *testing.T) {
938944
},
939945
},
940946
}},
947+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:27:46Z",
941948
CreateDate: "2021-03-02T22:27:46Z",
942949
RootCertType: "DST",
943950
VersionReleaseSystem: "LTS",
@@ -960,6 +967,7 @@ func TestAdvancedClusters_Update(t *testing.T) {
960967
"readPreference": "secondary"
961968
},
962969
"clusterType": "GEOSHARDED",
970+
"acceptDataRisksAndForceReplicaSetReconfig": "2021-03-02T22:27:46Z",
963971
"createDate": "2021-03-02T22:27:46Z",
964972
"diskSizeGB": 40.0,
965973
"encryptionAtRestProvider": "NONE",
@@ -1149,6 +1157,7 @@ func TestAdvancedClusters_Update(t *testing.T) {
11491157
},
11501158
},
11511159
}},
1160+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:27:46Z",
11521161
CreateDate: "2021-03-02T22:27:46Z",
11531162
RootCertType: "DST",
11541163
}
@@ -1248,6 +1257,7 @@ func TestAdvancedClusters_Update(t *testing.T) {
12481257
},
12491258
},
12501259
}},
1260+
AcceptDataRisksAndForceReplicaSetReconfig: "2021-03-02T22:27:46Z",
12511261
CreateDate: "2021-03-02T22:27:46Z",
12521262
RootCertType: "DST",
12531263
}

mongodbatlas/clusters.go

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -140,39 +140,40 @@ type ConnectionStrings struct {
140140

141141
// Cluster represents MongoDB cluster.
142142
type Cluster struct {
143-
AutoScaling *AutoScaling `json:"autoScaling,omitempty"`
144-
BackupEnabled *bool `json:"backupEnabled,omitempty"` // Deprecated: Use ProviderBackupEnabled instead
145-
BiConnector *BiConnector `json:"biConnector,omitempty"`
146-
ClusterType string `json:"clusterType,omitempty"`
147-
DiskSizeGB *float64 `json:"diskSizeGB,omitempty"`
148-
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
149-
Labels []Label `json:"labels,omitempty"`
150-
ID string `json:"id,omitempty"`
151-
GroupID string `json:"groupId,omitempty"`
152-
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
153-
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
154-
MongoURI string `json:"mongoURI,omitempty"`
155-
MongoURIUpdated string `json:"mongoURIUpdated,omitempty"`
156-
MongoURIWithOptions string `json:"mongoURIWithOptions,omitempty"`
157-
Name string `json:"name,omitempty"`
158-
CreateDate string `json:"createDate,omitempty"`
159-
NumShards *int64 `json:"numShards,omitempty"`
160-
Paused *bool `json:"paused,omitempty"`
161-
PitEnabled *bool `json:"pitEnabled,omitempty"`
162-
ProviderBackupEnabled *bool `json:"providerBackupEnabled,omitempty"`
163-
ProviderSettings *ProviderSettings `json:"providerSettings,omitempty"`
164-
ReplicationFactor *int64 `json:"replicationFactor,omitempty"`
165-
ReplicationSpec map[string]RegionsConfig `json:"replicationSpec,omitempty"`
166-
ReplicationSpecs []ReplicationSpec `json:"replicationSpecs,omitempty"`
167-
SrvAddress string `json:"srvAddress,omitempty"`
168-
StateName string `json:"stateName,omitempty"`
169-
ServerlessBackupOptions *ServerlessBackupOptions `json:"serverlessBackupOptions,omitempty"`
170-
ConnectionStrings *ConnectionStrings `json:"connectionStrings,omitempty"`
171-
Links []*Link `json:"links,omitempty"`
172-
VersionReleaseSystem string `json:"versionReleaseSystem,omitempty"`
173-
RootCertType string `json:"rootCertType,omitempty"`
174-
TerminationProtectionEnabled *bool `json:"terminationProtectionEnabled,omitempty"`
175-
Tags *[]*Tag `json:"tags,omitempty"`
143+
AcceptDataRisksAndForceReplicaSetReconfig string `json:"acceptDataRisksAndForceReplicaSetReconfig,omitempty"`
144+
AutoScaling *AutoScaling `json:"autoScaling,omitempty"`
145+
BackupEnabled *bool `json:"backupEnabled,omitempty"` // Deprecated: Use ProviderBackupEnabled instead
146+
BiConnector *BiConnector `json:"biConnector,omitempty"`
147+
ClusterType string `json:"clusterType,omitempty"`
148+
DiskSizeGB *float64 `json:"diskSizeGB,omitempty"`
149+
EncryptionAtRestProvider string `json:"encryptionAtRestProvider,omitempty"`
150+
Labels []Label `json:"labels,omitempty"`
151+
ID string `json:"id,omitempty"`
152+
GroupID string `json:"groupId,omitempty"`
153+
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
154+
MongoDBMajorVersion string `json:"mongoDBMajorVersion,omitempty"`
155+
MongoURI string `json:"mongoURI,omitempty"`
156+
MongoURIUpdated string `json:"mongoURIUpdated,omitempty"`
157+
MongoURIWithOptions string `json:"mongoURIWithOptions,omitempty"`
158+
Name string `json:"name,omitempty"`
159+
CreateDate string `json:"createDate,omitempty"`
160+
NumShards *int64 `json:"numShards,omitempty"`
161+
Paused *bool `json:"paused,omitempty"`
162+
PitEnabled *bool `json:"pitEnabled,omitempty"`
163+
ProviderBackupEnabled *bool `json:"providerBackupEnabled,omitempty"`
164+
ProviderSettings *ProviderSettings `json:"providerSettings,omitempty"`
165+
ReplicationFactor *int64 `json:"replicationFactor,omitempty"`
166+
ReplicationSpec map[string]RegionsConfig `json:"replicationSpec,omitempty"`
167+
ReplicationSpecs []ReplicationSpec `json:"replicationSpecs,omitempty"`
168+
SrvAddress string `json:"srvAddress,omitempty"`
169+
StateName string `json:"stateName,omitempty"`
170+
ServerlessBackupOptions *ServerlessBackupOptions `json:"serverlessBackupOptions,omitempty"`
171+
ConnectionStrings *ConnectionStrings `json:"connectionStrings,omitempty"`
172+
Links []*Link `json:"links,omitempty"`
173+
VersionReleaseSystem string `json:"versionReleaseSystem,omitempty"`
174+
RootCertType string `json:"rootCertType,omitempty"`
175+
TerminationProtectionEnabled *bool `json:"terminationProtectionEnabled,omitempty"`
176+
Tags *[]*Tag `json:"tags,omitempty"`
176177
}
177178

178179
// ProcessArgs represents the advanced configuration options for the cluster.

mongodbatlas/clusters_test.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func TestClusters_ListClusters(t *testing.T) {
3232
fmt.Fprint(w, `{
3333
"results": [
3434
{
35+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
3536
"autoScaling": {
3637
"diskGBEnabled": true,
3738
"compute": {
@@ -109,6 +110,7 @@ func TestClusters_ListClusters(t *testing.T) {
109110
"tags": [ { "key": "key1", "value": "value1" } ]
110111
},
111112
{
113+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
112114
"autoScaling": {
113115
"diskGBEnabled": true,
114116
"compute": {
@@ -196,6 +198,7 @@ func TestClusters_ListClusters(t *testing.T) {
196198
}
197199

198200
cluster1 := Cluster{
201+
AcceptDataRisksAndForceReplicaSetReconfig: "2017-10-23T21:26:17Z",
199202
AutoScaling: &AutoScaling{
200203
DiskGBEnabled: pointer(true),
201204
Compute: &Compute{
@@ -363,6 +366,7 @@ func TestClusters_Create(t *testing.T) {
363366

364367
createRequest := &Cluster{
365368
ID: "1",
369+
AcceptDataRisksAndForceReplicaSetReconfig: "2017-10-23T21:26:17Z",
366370
AutoScaling: &AutoScaling{DiskGBEnabled: pointer(true),
367371
Compute: &Compute{Enabled: pointer(true), ScaleDownEnabled: pointer(true)}},
368372
BackupEnabled: pointer(true),
@@ -410,6 +414,7 @@ func TestClusters_Create(t *testing.T) {
410414
mux.HandleFunc(fmt.Sprintf("/api/atlas/v1.0/groups/%s/clusters", groupID), func(w http.ResponseWriter, r *http.Request) {
411415
expected := map[string]interface{}{
412416
"id": "1",
417+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
413418
"autoScaling": map[string]interface{}{
414419
"diskGBEnabled": true,
415420
"compute": map[string]interface{}{
@@ -469,6 +474,7 @@ func TestClusters_Create(t *testing.T) {
469474
jsonBlob := `
470475
{
471476
"id":"1",
477+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
472478
"autoScaling": {
473479
"diskGBEnabled": true,
474480
"compute": {
@@ -565,6 +571,7 @@ func TestClusters_Update(t *testing.T) {
565571

566572
updateRequest := &Cluster{
567573
ID: "1",
574+
AcceptDataRisksAndForceReplicaSetReconfig: "2017-10-23T21:26:17Z",
568575
AutoScaling: &AutoScaling{DiskGBEnabled: pointer(true),
569576
Compute: &Compute{Enabled: pointer(true), ScaleDownEnabled: pointer(true)}},
570577
BackupEnabled: pointer(true),
@@ -605,6 +612,7 @@ func TestClusters_Update(t *testing.T) {
605612
mux.HandleFunc(fmt.Sprintf("/api/atlas/v1.0/groups/%s/clusters/%s", groupID, clusterName), func(w http.ResponseWriter, r *http.Request) {
606613
expected := map[string]interface{}{
607614
"id": "1",
615+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
608616
"autoScaling": map[string]interface{}{
609617
"diskGBEnabled": true,
610618
"compute": map[string]interface{}{
@@ -656,6 +664,7 @@ func TestClusters_Update(t *testing.T) {
656664

657665
jsonBlob := `
658666
{
667+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
659668
"autoScaling": {
660669
"diskGBEnabled": true,
661670
"compute": {
@@ -894,6 +903,7 @@ func TestClusters_Get(t *testing.T) {
894903
testMethod(t, r, http.MethodGet)
895904
fmt.Fprint(w, `{
896905
"id":"1",
906+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
897907
"autoScaling": {
898908
"diskGBEnabled": true
899909
},
@@ -969,7 +979,8 @@ func TestClusters_Get(t *testing.T) {
969979
}
970980

971981
expected := &Cluster{
972-
ID: "1",
982+
ID: "1",
983+
AcceptDataRisksAndForceReplicaSetReconfig: "2017-10-23T21:26:17Z",
973984
AutoScaling: &AutoScaling{DiskGBEnabled: pointer(true)},
974985
BackupEnabled: pointer(true),
975986
BiConnector: &BiConnector{Enabled: pointer(false), ReadPreference: "secondary"},
@@ -1066,7 +1077,8 @@ func TestClusters_LoadSampleDataset(t *testing.T) {
10661077
"_id": "1",
10671078
"clusterName": "globalCluster",
10681079
"completeDate": null,
1069-
"createDate": "2021-03-26T16:30:47Z",
1080+
"acceptDataRisksAndForceReplicaSetReconfig": "2021-03-26T16:30:47Z",
1081+
"createDate": "2021-03-26T16:30:47Z",
10701082
"errorMessage": null,
10711083
"state": "WORKING"}`)
10721084
})
@@ -1333,6 +1345,7 @@ func TestClusters_Upgrade(t *testing.T) {
13331345

13341346
upgradeRequest := &Cluster{
13351347
ID: "1",
1348+
AcceptDataRisksAndForceReplicaSetReconfig: "2017-10-23T21:26:17Z",
13361349
AutoScaling: &AutoScaling{DiskGBEnabled: pointer(true),
13371350
Compute: &Compute{Enabled: pointer(true), ScaleDownEnabled: pointer(true)}},
13381351
BackupEnabled: pointer(true),
@@ -1373,6 +1386,7 @@ func TestClusters_Upgrade(t *testing.T) {
13731386
mux.HandleFunc(fmt.Sprintf("/api/atlas/v1.0/groups/%s/clusters/tenantUpgrade", groupID), func(w http.ResponseWriter, r *http.Request) {
13741387
expected := map[string]interface{}{
13751388
"id": "1",
1389+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
13761390
"autoScaling": map[string]interface{}{
13771391
"diskGBEnabled": true,
13781392
"compute": map[string]interface{}{
@@ -1424,6 +1438,7 @@ func TestClusters_Upgrade(t *testing.T) {
14241438

14251439
jsonBlob := `
14261440
{
1441+
"acceptDataRisksAndForceReplicaSetReconfig": "2017-10-23T21:26:17Z",
14271442
"autoScaling": {
14281443
"diskGBEnabled": true,
14291444
"compute": {

0 commit comments

Comments
 (0)