Skip to content

Commit c9ee4b9

Browse files
authored
Merge pull request #94 from mongodb/fixes-cloud-provider-snapshot-backup-policy-data-type-issue
fix: fixes #93 CloudProviderSnapshotBackupPolicy zero values are ignored
2 parents 4372513 + 36a586d commit c9ee4b9

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

mongodbatlas/cloud_provider_snapshot_backup_policies.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ var _ CloudProviderSnapshotBackupPoliciesService = &CloudProviderSnapshotBackupP
3030
type CloudProviderSnapshotBackupPolicy struct {
3131
ClusterID string `json:"clusterId,omitempty"` // Unique identifier of the Atlas cluster.
3232
ClusterName string `json:"clusterName,omitempty"` // Name of the Atlas cluster.
33-
ReferenceHourOfDay int `json:"referenceHourOfDay,omitempty"` // UTC Hour of day between 0 and 23, inclusive, representing which hour of the day that Atlas takes snapshots for backup policy items.
34-
ReferenceMinuteOfHour int `json:"referenceMinuteOfHour,omitempty"` // UTC Minutes after referenceHourOfDay that Atlas takes snapshots for backup policy items. Must be between 0 and 59, inclusive. Number of days back in time you can restore to with point-in-time accuracy.
35-
RestoreWindowDays int `json:"restoreWindowDays,omitempty"` // Number of days back in time you can restore to with point-in-time accuracy. Must be a positive, non-zero integer.
36-
UpdateSnapshots bool `json:"updateSnapshots,omitempty"` // Specify true to apply the retention changes in the updated backup policy to snapshots that Atlas took previously.
33+
ReferenceHourOfDay *int64 `json:"referenceHourOfDay,omitempty"` // UTC Hour of day between 0 and 23, inclusive, representing which hour of the day that Atlas takes snapshots for backup policy items.
34+
ReferenceMinuteOfHour *int64 `json:"referenceMinuteOfHour,omitempty"` // UTC Minutes after referenceHourOfDay that Atlas takes snapshots for backup policy items. Must be between 0 and 59, inclusive. Number of days back in time you can restore to with point-in-time accuracy.
35+
RestoreWindowDays *int64 `json:"restoreWindowDays,omitempty"` // Number of days back in time you can restore to with point-in-time accuracy. Must be a positive, non-zero integer.
36+
UpdateSnapshots *bool `json:"updateSnapshots,omitempty"` // Specify true to apply the retention changes in the updated backup policy to snapshots that Atlas took previously.
3737
NextSnapshot string `json:"nextSnapshot,omitempty"` // UTC ISO 8601 formatted point in time when Atlas will take the next snapshot.
3838
Policies []Policy `json:"policies,omitempty"` // A list of policy definitions for the cluster.
3939
}

mongodbatlas/cloud_provider_snapshot_backup_policies_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/go-test/deep"
10+
"github.com/openlyinc/pointy"
1011
)
1112

1213
func TestCloudProviderSnapshotBackupPolicies_Get(t *testing.T) {
@@ -119,9 +120,9 @@ func TestCloudProviderSnapshotBackupPolicies_Get(t *testing.T) {
119120
},
120121
},
121122
},
122-
ReferenceHourOfDay: 17,
123-
ReferenceMinuteOfHour: 24,
124-
RestoreWindowDays: 7,
123+
ReferenceHourOfDay: pointy.Int64(17),
124+
ReferenceMinuteOfHour: pointy.Int64(24),
125+
RestoreWindowDays: pointy.Int64(7),
125126
}
126127

127128
if diff := deep.Equal(snapshotBackupPolicy, expected); diff != nil {
@@ -217,8 +218,8 @@ func TestCloudProviderSnapshotBackupPolicies_Update(t *testing.T) {
217218
})
218219

219220
updateRequest := &CloudProviderSnapshotBackupPolicy{
220-
ReferenceHourOfDay: 12,
221-
ReferenceMinuteOfHour: 30,
221+
ReferenceHourOfDay: pointy.Int64(12),
222+
ReferenceMinuteOfHour: pointy.Int64(30),
222223
Policies: []Policy{
223224
{
224225
ID: "5c95242c87d9d636e70c28ef",
@@ -240,7 +241,7 @@ func TestCloudProviderSnapshotBackupPolicies_Update(t *testing.T) {
240241
},
241242
},
242243
},
243-
UpdateSnapshots: true,
244+
UpdateSnapshots: pointy.Bool(true),
244245
}
245246

246247
cloudProviderSnapshot, _, err := client.CloudProviderSnapshotBackupPolicies.Update(ctx, groupID, clusterName, updateRequest)
@@ -273,8 +274,8 @@ func TestCloudProviderSnapshotBackupPolicies_Update(t *testing.T) {
273274
},
274275
},
275276
},
276-
ReferenceHourOfDay: 12,
277-
ReferenceMinuteOfHour: 30,
277+
ReferenceHourOfDay: pointy.Int64(12),
278+
ReferenceMinuteOfHour: pointy.Int64(30),
278279
}
279280

280281
if diff := deep.Equal(cloudProviderSnapshot, expected); diff != nil {

0 commit comments

Comments
 (0)