mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
feat(redshift-serverless): add UpdateSnapshot (#5537)
Change a snapshot's retentionPeriod (-1 for indefinite) with the same validation as CreateSnapshot; an omitted period leaves the snapshot unchanged.
This commit is contained in:
1 parent
dd0f40fcbb
commit
a95b01020b
8 files changed
+104
-1
No files matched your search
+6
@@ -86,6 +86,7 @@ public class RedshiftServerlessJsonHandler {
|
||||
case "CreateSnapshot" -> handleCreateSnapshot(request, region);
|
||||
case "GetSnapshot" -> handleGetSnapshot(request, region);
|
||||
case "ListSnapshots" -> handleListSnapshots(request, region);
|
||||
case "UpdateSnapshot" -> handleUpdateSnapshot(request, region);
|
||||
case "DeleteSnapshot" -> handleDeleteSnapshot(request, region);
|
||||
case "RestoreFromSnapshot" -> handleRestoreFromSnapshot(request, region);
|
||||
case "CreateUsageLimit" -> handleCreateUsageLimit(request, region);
|
||||
@@ -244,6 +245,11 @@ public class RedshiftServerlessJsonHandler {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private Response handleUpdateSnapshot(JsonNode request, String region) {
|
||||
return snapshotResponse(service.updateSnapshot(
|
||||
text(request, "snapshotName"), parseInteger(request, "retentionPeriod"), region));
|
||||
}
|
||||
|
||||
private Response handleDeleteSnapshot(JsonNode request, String region) {
|
||||
return snapshotResponse(service.deleteSnapshot(text(request, "snapshotName"), region));
|
||||
}
|
||||
|
||||
+15
@@ -471,6 +471,21 @@ public class RedshiftServerlessService implements Resettable {
|
||||
return snapshotArn.substring(prefix.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes a snapshot's retention. An omitted period leaves the snapshot as it is, and -1 makes
|
||||
* it indefinite. {@code snapshotRemainingDays} keeps counting from the creation time, because
|
||||
* the snapshot carries no separate retention start.
|
||||
*/
|
||||
public synchronized RedshiftServerlessSnapshot updateSnapshot(String snapshotName, Integer retentionPeriod,
|
||||
String region) {
|
||||
RedshiftServerlessSnapshot snapshot = new RedshiftServerlessSnapshot(getSnapshot(snapshotName, region));
|
||||
if (retentionPeriod != null) {
|
||||
snapshot.setRetentionPeriod(validateRetentionPeriod(retentionPeriod));
|
||||
snapshots.put(storageKey(region, snapshotName), snapshot);
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public synchronized RedshiftServerlessSnapshot deleteSnapshot(String snapshotName, String region) {
|
||||
RedshiftServerlessSnapshot deleted = getSnapshot(snapshotName, region);
|
||||
snapshots.delete(storageKey(region, snapshotName));
|
||||
|
||||
Reference in new issue
Block a user