fix(backup): return the deleted plan's id, ARN, version and deletion date from DeleteBackupPlan (#7276)

This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-02 16:05:30 -04:00
1 parent 3cc7551613
commit 1f0b4cffca
3 files changed
+32 -6

No files matched your search

@@ -310,8 +310,13 @@ public class BackupController {
@DELETE
@Path("/backup/plans/{backupPlanId}")
public Response deleteBackupPlan(@PathParam("backupPlanId") String planId) {
service.deleteBackupPlan(planId);
return Response.noContent().build();
BackupPlan plan = service.deleteBackupPlan(planId);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupPlanId", plan.getBackupPlanId());
out.put("BackupPlanArn", plan.getBackupPlanArn());
out.put("DeletionDate", plan.getDeletionDate());
out.put("VersionId", plan.getVersionId());
return Response.ok(out).build();
}
@GET
@@ -678,9 +678,9 @@ public class BackupService {
}
}
public void deleteBackupPlan(String planId) {
public BackupPlan deleteBackupPlan(String planId) {
synchronized (lockFor(planLockKey(planId))) {
getBackupPlan(planId);
BackupPlan plan = getBackupPlan(planId);
long selectionCount = selectionStore.scan(k -> true).stream()
.filter(s -> planId.equals(s.getBackupPlanId()))
.count();
@@ -689,6 +689,8 @@ public class BackupService {
"Backup plan has active selections and cannot be deleted", 400);
}
planStore.delete(planId);
plan.setDeletionDate(Instant.now().getEpochSecond());
return plan;
}
}
@@ -582,7 +582,7 @@ class BackupIntegrationTest {
given().header("Authorization", AUTH)
.when().delete("/backup/plans/" + otherPlanId)
.then().statusCode(204);
.then().statusCode(200);
}
@Test
@@ -650,12 +650,31 @@ class BackupIntegrationTest {
@Test
@Order(81)
void deleteBackupPlan() {
String versionId = given()
.header("Authorization", AUTH)
.when()
.get("/backup/plans/" + planId + "/")
.then()
.statusCode(200)
.extract().path("VersionId");
given()
.header("Authorization", AUTH)
.when()
.delete("/backup/plans/" + planId)
.then()
.statusCode(204);
.statusCode(200)
.body("BackupPlanId", equalTo(planId))
.body("BackupPlanArn", endsWith(":backup-plan:" + planId))
.body("VersionId", equalTo(versionId))
.body("DeletionDate", notNullValue());
given()
.header("Authorization", AUTH)
.when()
.get("/backup/plans/" + planId + "/")
.then()
.statusCode(400);
}
@Test