Skip to content

Commit 0278d0e

Browse files
CLOUDP-369800-backup-compliance-policy few enhancements
1 parent 209048c commit 0278d0e

3 files changed

Lines changed: 34 additions & 29 deletions

File tree

cfn-resources/backup-compliance-policy/cmd/resource/handlers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func checkPolicyNotFound(policy *admin.DataProtectionSettings20231001, apiResp *
8282

8383
func HandleCreate(req *handler.Request, client *util.MongoDBClient, model *Model) handler.ProgressEvent {
8484
if IsCallback(req) {
85-
return validateProgress(client, model, false)
85+
return validateProgress(client, model, false, constants.CREATE)
8686
}
8787

8888
ctx := context.Background()
@@ -145,7 +145,7 @@ func HandleRead(req *handler.Request, client *util.MongoDBClient, model *Model)
145145

146146
func HandleUpdate(req *handler.Request, client *util.MongoDBClient, model *Model) handler.ProgressEvent {
147147
if IsCallback(req) {
148-
return validateProgress(client, model, false)
148+
return validateProgress(client, model, false, constants.UPDATE)
149149
}
150150

151151
ctx := context.Background()
@@ -179,7 +179,7 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, model *Model
179179

180180
func HandleDelete(req *handler.Request, client *util.MongoDBClient, model *Model) handler.ProgressEvent {
181181
if IsCallback(req) {
182-
return validateProgress(client, model, true)
182+
return validateProgress(client, model, true, constants.DELETE)
183183
}
184184

185185
ctx := context.Background()
@@ -269,7 +269,7 @@ func inProgressEvent(model *Model, policy *admin.DataProtectionSettings20231001)
269269
}
270270
}
271271

272-
func validateProgress(client *util.MongoDBClient, model *Model, isDelete bool) handler.ProgressEvent {
272+
func validateProgress(client *util.MongoDBClient, model *Model, isDelete bool, operation constants.CfnFunctions) handler.ProgressEvent {
273273
ctx := context.Background()
274274
projectID := *model.ProjectId
275275

@@ -281,7 +281,7 @@ func validateProgress(client *util.MongoDBClient, model *Model, isDelete bool) h
281281
if isPendingActionError(err) {
282282
return inProgressEvent(model, policy)
283283
}
284-
return handleError(resp, constants.CREATE, err)
284+
return handleError(resp, operation, err)
285285
}
286286

287287
if isDelete && policyDeleted {

cfn-resources/backup-compliance-policy/cmd/resource/mappings.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ func ExpandOnDemandPolicyItem(item *OnDemandPolicyItem) *admin.BackupComplianceO
233233
}
234234

235235
func ExpandScheduledPolicyItem(item *ScheduledPolicyItem, frequencyType string) admin.BackupComplianceScheduledPolicyItem {
236+
if item == nil {
237+
return admin.BackupComplianceScheduledPolicyItem{
238+
FrequencyType: frequencyType,
239+
}
240+
}
236241
frequencyInterval := 0
237242
if item.FrequencyInterval != nil {
238243
frequencyInterval = *item.FrequencyInterval

cfn-resources/backup-compliance-policy/docs/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -230,51 +230,51 @@ ISO 8601 timestamp in UTC of when the Backup Compliance Policy settings were las
230230

231231
Email address of the user who last updated the Backup Compliance Policy settings.
232232

233-
#### Id
233+
#### OnDemandPolicyItem.Id
234234

235-
Returns the <code>Id</code> value.
235+
Unique identifier of the on-demand backup policy item.
236236

237-
#### FrequencyType
237+
#### OnDemandPolicyItem.FrequencyType
238238

239-
Returns the <code>FrequencyType</code> value.
239+
Frequency type of the on-demand backup policy item. Always returns "ondemand".
240240

241-
#### Id
241+
#### PolicyItemHourly.Id
242242

243-
Returns the <code>Id</code> value.
243+
Unique identifier of the hourly backup policy item.
244244

245-
#### FrequencyType
245+
#### PolicyItemHourly.FrequencyType
246246

247-
Returns the <code>FrequencyType</code> value.
247+
Frequency type of the hourly backup policy item. Always returns "hourly".
248248

249-
#### Id
249+
#### PolicyItemDaily.Id
250250

251-
Returns the <code>Id</code> value.
251+
Unique identifier of the daily backup policy item.
252252

253-
#### FrequencyType
253+
#### PolicyItemDaily.FrequencyType
254254

255-
Returns the <code>FrequencyType</code> value.
255+
Frequency type of the daily backup policy item. Always returns "daily".
256256

257-
#### Id
257+
#### PolicyItemWeekly.Id
258258

259-
Returns the <code>Id</code> value.
259+
Unique identifier of the weekly backup policy item(s). For arrays, use index notation (e.g., PolicyItemWeekly[0].Id).
260260

261-
#### FrequencyType
261+
#### PolicyItemWeekly.FrequencyType
262262

263-
Returns the <code>FrequencyType</code> value.
263+
Frequency type of the weekly backup policy item(s). Always returns "weekly". For arrays, use index notation (e.g., PolicyItemWeekly[0].FrequencyType).
264264

265-
#### Id
265+
#### PolicyItemMonthly.Id
266266

267-
Returns the <code>Id</code> value.
267+
Unique identifier of the monthly backup policy item(s). For arrays, use index notation (e.g., PolicyItemMonthly[0].Id).
268268

269-
#### FrequencyType
269+
#### PolicyItemMonthly.FrequencyType
270270

271-
Returns the <code>FrequencyType</code> value.
271+
Frequency type of the monthly backup policy item(s). Always returns "monthly". For arrays, use index notation (e.g., PolicyItemMonthly[0].FrequencyType).
272272

273-
#### Id
273+
#### PolicyItemYearly.Id
274274

275-
Returns the <code>Id</code> value.
275+
Unique identifier of the yearly backup policy item(s). For arrays, use index notation (e.g., PolicyItemYearly[0].Id).
276276

277-
#### FrequencyType
277+
#### PolicyItemYearly.FrequencyType
278278

279-
Returns the <code>FrequencyType</code> value.
279+
Frequency type of the yearly backup policy item(s). Always returns "yearly". For arrays, use index notation (e.g., PolicyItemYearly[0].FrequencyType).
280280

0 commit comments

Comments
 (0)