feat(backup): AWS Backup management-plane API (#734)

This commit is contained in:
Hector Ventura authored and GitHub committed 2026-05-07 00:56:34 -05:00
1 parent d51a0f9ce8
commit c2cc053853
24 files changed
+2634 -4

No files matched your search

@@ -116,6 +116,7 @@ public interface EmulatorConfig {
AppConfigDataStorageConfig appconfigdata();
ElastiCacheStorageConfig elasticache();
RdsStorageConfig rds();
BackupStorageConfig backup();
}
interface SsmStorageConfig {
@@ -214,6 +215,13 @@ public interface EmulatorConfig {
Optional<String> mode();
}
interface BackupStorageConfig {
Optional<String> mode();
@WithDefault("5000")
long flushIntervalMs();
}
interface WalConfig {
@WithDefault("30000")
long compactionIntervalMs();
@@ -273,7 +281,17 @@ public interface EmulatorConfig {
CodeBuildServiceConfig codebuild();
CodeDeployServiceConfig codedeploy();
AutoScalingServiceConfig autoscaling();
BackupServiceConfig backup();
Route53ServiceConfig route53();
TransferServiceConfig transfer();
}
interface BackupServiceConfig {
@WithDefault("true")
boolean enabled();
@WithDefault("3")
int jobCompletionDelaySeconds();
}
interface Route53ServiceConfig {
@@ -293,6 +311,11 @@ public interface EmulatorConfig {
String defaultNameserver4();
}
interface TransferServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface AutoScalingServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.services.appconfig.AppConfigController;
import io.github.hectorvent.floci.services.backup.BackupController;
import io.github.hectorvent.floci.services.appconfig.AppConfigDataController;
import io.github.hectorvent.floci.services.bedrockruntime.BedrockRuntimeController;
import io.github.hectorvent.floci.services.cognito.CognitoOAuthController;
@@ -222,6 +223,11 @@ public class ResolvedServiceCatalog {
"autoscaling", config.storage().mode(), 5000L, AwsNamespaces.AUTOSCALING, ServiceProtocol.QUERY,
protocols(ServiceProtocol.QUERY),
Set.of(), Set.of("autoscaling"), Set.of(), Set.of()),
descriptor("backup", "backup", config.services().backup().enabled(), true,
"backup", storageMode(config.storage().services().backup().mode(), config.storage().mode()),
config.storage().services().backup().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("backup"), Set.of(), Set.of(BackupController.class)),
descriptor("ec2messages", "ec2messages", config.services().ssm().enabled(), false,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
@@ -229,7 +235,11 @@ public class ResolvedServiceCatalog {
descriptor("route53", "route53", config.services().route53().enabled(), true,
"route53", config.storage().mode(), 5000L, null, ServiceProtocol.REST_XML,
protocols(ServiceProtocol.REST_XML),
Set.of(), Set.of("route53"), Set.of(), Set.of(Route53Controller.class))
Set.of(), Set.of("route53"), Set.of(), Set.of(Route53Controller.class)),
descriptor("transfer", "transfer", config.services().transfer().enabled(), true,
"transfer", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("TransferService."), Set.of("transfer"), Set.of(), Set.of())
));
}
@@ -0,0 +1,377 @@
package io.github.hectorvent.floci.services.backup;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.services.backup.model.*;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.jboss.logging.Logger;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class BackupController {
private static final Logger LOG = Logger.getLogger(BackupController.class);
private final BackupService service;
private final RegionResolver regionResolver;
private final ObjectMapper objectMapper;
@Inject
public BackupController(BackupService service, RegionResolver regionResolver, ObjectMapper objectMapper) {
this.service = service;
this.regionResolver = regionResolver;
this.objectMapper = objectMapper;
}
// ── Vault ──────────────────────────────────────────────────────────────────
@PUT
@Path("/backup-vaults/{backupVaultName}")
public Response createBackupVault(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName,
String body) throws IOException {
String region = regionResolver.resolveRegion(headers);
JsonNode req = objectMapper.readTree(body == null || body.isBlank() ? "{}" : body);
String encryptionKeyArn = textOrNull(req, "EncryptionKeyArn");
String creatorRequestId = textOrNull(req, "CreatorRequestId");
Map<String, String> tags = readStringMap(req, "BackupVaultTags");
BackupVault vault = service.createBackupVault(vaultName, encryptionKeyArn, creatorRequestId, tags, region);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupVaultName", vault.getBackupVaultName());
out.put("BackupVaultArn", vault.getBackupVaultArn());
out.put("CreationDate", vault.getCreationDate());
return Response.status(200).entity(out).build();
}
@GET
@Path("/backup-vaults/{backupVaultName}")
public Response describeBackupVault(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName) {
String region = regionResolver.resolveRegion(headers);
return Response.ok(service.describeBackupVault(vaultName, region)).build();
}
@DELETE
@Path("/backup-vaults/{backupVaultName}")
public Response deleteBackupVault(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName) {
String region = regionResolver.resolveRegion(headers);
service.deleteBackupVault(vaultName, region);
return Response.noContent().build();
}
@GET
@Path("/backup-vaults/")
public Response listBackupVaults(@Context HttpHeaders headers) {
String region = regionResolver.resolveRegion(headers);
List<BackupVault> vaults = service.listBackupVaults(region);
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("BackupVaultList");
vaults.forEach(list::addPOJO);
return Response.ok(out).build();
}
// ── Plan ───────────────────────────────────────────────────────────────────
@PUT
@Path("/backup/plans/")
public Response createBackupPlan(@Context HttpHeaders headers, String body) throws IOException {
String region = regionResolver.resolveRegion(headers);
JsonNode req = objectMapper.readTree(body);
JsonNode planNode = req.path("BackupPlan");
String planName = planNode.path("BackupPlanName").asText();
List<BackupRule> rules = readRules(planNode.path("Rules"));
String creatorRequestId = textOrNull(req, "CreatorRequestId");
BackupPlan plan = service.createBackupPlan(planName, rules, creatorRequestId, region);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupPlanId", plan.getBackupPlanId());
out.put("BackupPlanArn", plan.getBackupPlanArn());
out.put("CreationDate", plan.getCreationDate());
out.put("VersionId", plan.getVersionId());
return Response.status(200).entity(out).build();
}
@GET
@Path("/backup/plans/{backupPlanId}/")
public Response getBackupPlan(@PathParam("backupPlanId") String planId) {
BackupPlan plan = service.getBackupPlan(planId);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupPlanId", plan.getBackupPlanId());
out.put("BackupPlanArn", plan.getBackupPlanArn());
out.put("CreationDate", plan.getCreationDate());
out.put("VersionId", plan.getVersionId());
ObjectNode planBody = out.putObject("BackupPlan");
planBody.put("BackupPlanName", plan.getBackupPlanName());
planBody.set("Rules", objectMapper.valueToTree(plan.getRules()));
return Response.ok(out).build();
}
@POST
@Path("/backup/plans/{backupPlanId}")
public Response updateBackupPlan(@PathParam("backupPlanId") String planId, String body) throws IOException {
JsonNode req = objectMapper.readTree(body);
JsonNode planNode = req.path("BackupPlan");
String planName = planNode.has("BackupPlanName") ? planNode.path("BackupPlanName").asText() : null;
List<BackupRule> rules = readRules(planNode.path("Rules"));
BackupPlan plan = service.updateBackupPlan(planId, planName, rules);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupPlanId", plan.getBackupPlanId());
out.put("BackupPlanArn", plan.getBackupPlanArn());
out.put("VersionId", plan.getVersionId());
return Response.ok(out).build();
}
@DELETE
@Path("/backup/plans/{backupPlanId}")
public Response deleteBackupPlan(@PathParam("backupPlanId") String planId) {
service.deleteBackupPlan(planId);
return Response.noContent().build();
}
@GET
@Path("/backup/plans/")
public Response listBackupPlans() {
List<BackupPlan> plans = service.listBackupPlans();
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("BackupPlansList");
for (BackupPlan plan : plans) {
ObjectNode item = objectMapper.createObjectNode();
item.put("BackupPlanId", plan.getBackupPlanId());
item.put("BackupPlanArn", plan.getBackupPlanArn());
item.put("BackupPlanName", plan.getBackupPlanName());
item.put("CreationDate", plan.getCreationDate());
item.put("VersionId", plan.getVersionId());
list.add(item);
}
return Response.ok(out).build();
}
// ── Selection ──────────────────────────────────────────────────────────────
@PUT
@Path("/backup/plans/{backupPlanId}/selections/")
public Response createBackupSelection(@PathParam("backupPlanId") String planId,
String body) throws IOException {
JsonNode req = objectMapper.readTree(body);
JsonNode selNode = req.path("BackupSelection");
String selectionName = selNode.path("SelectionName").asText();
String iamRoleArn = selNode.path("IamRoleArn").asText();
List<String> resources = readStringList(selNode.path("Resources"));
List<String> notResources = readStringList(selNode.path("NotResources"));
String creatorRequestId = textOrNull(req, "CreatorRequestId");
BackupSelection sel = service.createBackupSelection(planId, selectionName, iamRoleArn,
resources, notResources, creatorRequestId);
ObjectNode out = objectMapper.createObjectNode();
out.put("SelectionId", sel.getSelectionId());
out.put("BackupPlanId", sel.getBackupPlanId());
out.put("CreationDate", sel.getCreationDate());
return Response.status(200).entity(out).build();
}
@GET
@Path("/backup/plans/{backupPlanId}/selections/{selectionId}")
public Response getBackupSelection(@PathParam("backupPlanId") String planId,
@PathParam("selectionId") String selectionId) {
BackupSelection sel = service.getBackupSelection(planId, selectionId);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupPlanId", sel.getBackupPlanId());
out.put("SelectionId", sel.getSelectionId());
out.put("CreationDate", sel.getCreationDate());
ObjectNode selBody = out.putObject("BackupSelection");
selBody.put("SelectionName", sel.getSelectionName());
selBody.put("IamRoleArn", sel.getIamRoleArn());
selBody.set("Resources", objectMapper.valueToTree(sel.getResources()));
selBody.set("NotResources", objectMapper.valueToTree(sel.getNotResources()));
return Response.ok(out).build();
}
@DELETE
@Path("/backup/plans/{backupPlanId}/selections/{selectionId}")
public Response deleteBackupSelection(@PathParam("backupPlanId") String planId,
@PathParam("selectionId") String selectionId) {
service.deleteBackupSelection(planId, selectionId);
return Response.noContent().build();
}
@GET
@Path("/backup/plans/{backupPlanId}/selections/")
public Response listBackupSelections(@PathParam("backupPlanId") String planId) {
List<BackupSelection> selections = service.listBackupSelections(planId);
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("BackupSelectionsList");
for (BackupSelection sel : selections) {
ObjectNode item = objectMapper.createObjectNode();
item.put("SelectionId", sel.getSelectionId());
item.put("SelectionName", sel.getSelectionName());
item.put("BackupPlanId", sel.getBackupPlanId());
item.put("IamRoleArn", sel.getIamRoleArn());
item.put("CreationDate", sel.getCreationDate());
list.add(item);
}
return Response.ok(out).build();
}
// ── Job ────────────────────────────────────────────────────────────────────
@PUT
@Path("/backup-jobs")
public Response startBackupJob(@Context HttpHeaders headers, String body) throws IOException {
String region = regionResolver.resolveRegion(headers);
JsonNode req = objectMapper.readTree(body);
String vaultName = req.path("BackupVaultName").asText();
String resourceArn = req.path("ResourceArn").asText();
String iamRoleArn = req.path("IamRoleArn").asText();
Lifecycle lifecycle = req.has("Lifecycle")
? objectMapper.treeToValue(req.path("Lifecycle"), Lifecycle.class)
: null;
BackupJob job = service.startBackupJob(vaultName, resourceArn, iamRoleArn, lifecycle, region);
ObjectNode out = objectMapper.createObjectNode();
out.put("BackupJobId", job.getBackupJobId());
out.put("BackupVaultArn", job.getBackupVaultArn());
out.put("CreationDate", job.getCreationDate());
out.put("RecoveryPointArn", "");
return Response.status(200).entity(out).build();
}
@GET
@Path("/backup-jobs/{backupJobId}")
public Response describeBackupJob(@PathParam("backupJobId") String jobId) {
return Response.ok(service.describeBackupJob(jobId)).build();
}
@POST
@Path("/backup-jobs/{backupJobId}")
public Response stopBackupJob(@PathParam("backupJobId") String jobId) {
service.stopBackupJob(jobId);
return Response.noContent().build();
}
@GET
@Path("/backup-jobs/")
public Response listBackupJobs(@QueryParam("byBackupVaultName") String byVaultName,
@QueryParam("byState") String byState,
@QueryParam("byResourceArn") String byResourceArn,
@QueryParam("byResourceType") String byResourceType) {
List<BackupJob> jobs = service.listBackupJobs(byVaultName, byState, byResourceArn, byResourceType);
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("BackupJobs");
jobs.forEach(list::addPOJO);
return Response.ok(out).build();
}
// ── Recovery Point ─────────────────────────────────────────────────────────
@GET
@Path("/backup-vaults/{backupVaultName}/recovery-points/{recoveryPointArn}")
public Response describeRecoveryPoint(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName,
@PathParam("recoveryPointArn") String recoveryPointArn) {
String region = regionResolver.resolveRegion(headers);
return Response.ok(service.describeRecoveryPoint(vaultName, recoveryPointArn, region)).build();
}
@GET
@Path("/backup-vaults/{backupVaultName}/recovery-points/")
public Response listRecoveryPointsByBackupVault(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName) {
String region = regionResolver.resolveRegion(headers);
List<RecoveryPoint> points = service.listRecoveryPointsByBackupVault(vaultName, region);
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("RecoveryPoints");
points.forEach(list::addPOJO);
return Response.ok(out).build();
}
@DELETE
@Path("/backup-vaults/{backupVaultName}/recovery-points/{recoveryPointArn}")
public Response deleteRecoveryPoint(@Context HttpHeaders headers,
@PathParam("backupVaultName") String vaultName,
@PathParam("recoveryPointArn") String recoveryPointArn) {
String region = regionResolver.resolveRegion(headers);
service.deleteRecoveryPoint(vaultName, recoveryPointArn, region);
return Response.noContent().build();
}
// ── Untag (POST /untag/{arn} with body — distinct from shared DELETE /tags pattern) ──
@POST
@Path("/untag/{resourceArn: .*}")
public Response untagResource(@PathParam("resourceArn") String resourceArn,
String body) throws IOException {
JsonNode req = objectMapper.readTree(body);
List<String> tagKeys = readStringList(req.path("TagKeyList"));
service.untagResource(resourceArn, tagKeys);
return Response.noContent().build();
}
// ── Supported resource types ───────────────────────────────────────────────
@GET
@Path("/supported-resource-types")
public Response getSupportedResourceTypes() {
ObjectNode out = objectMapper.createObjectNode();
ArrayNode list = out.putArray("ResourceTypes");
service.getSupportedResourceTypes().forEach(list::add);
return Response.ok(out).build();
}
// ── Helpers ────────────────────────────────────────────────────────────────
private static String textOrNull(JsonNode node, String field) {
JsonNode n = node.path(field);
return n.isMissingNode() || n.isNull() ? null : n.asText();
}
@SuppressWarnings("unchecked")
private Map<String, String> readStringMap(JsonNode node, String field) {
JsonNode mapNode = node.path(field);
if (mapNode.isMissingNode() || mapNode.isNull()) {
return new java.util.HashMap<>();
}
return objectMapper.convertValue(mapNode, Map.class);
}
private static List<String> readStringList(JsonNode node) {
List<String> result = new ArrayList<>();
if (node == null || node.isMissingNode() || node.isNull()) {
return result;
}
node.forEach(n -> result.add(n.asText()));
return result;
}
private List<BackupRule> readRules(JsonNode rulesNode) throws IOException {
List<BackupRule> rules = new ArrayList<>();
if (rulesNode == null || rulesNode.isMissingNode() || !rulesNode.isArray()) {
return rules;
}
for (JsonNode ruleNode : rulesNode) {
rules.add(objectMapper.treeToValue(ruleNode, BackupRule.class));
}
return rules;
}
}
@@ -0,0 +1,456 @@
package io.github.hectorvent.floci.services.backup;
import com.fasterxml.jackson.core.type.TypeReference;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.backup.model.*;
import jakarta.annotation.PreDestroy;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ApplicationScoped
public class BackupService {
private static final Logger LOG = Logger.getLogger(BackupService.class);
private static final List<String> SUPPORTED_RESOURCE_TYPES = List.of(
"S3", "RDS", "DynamoDB", "EFS", "EC2", "EBS",
"Aurora", "DocumentDB", "Neptune", "FSx", "VirtualMachine"
);
private final StorageBackend<String, BackupVault> vaultStore;
private final StorageBackend<String, BackupPlan> planStore;
private final StorageBackend<String, BackupSelection> selectionStore;
private final StorageBackend<String, BackupJob> jobStore;
private final StorageBackend<String, RecoveryPoint> recoveryStore;
private final RegionResolver regionResolver;
private final int jobCompletionDelaySeconds;
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(r -> {
Thread t = new Thread(r, "backup-job-scheduler");
t.setDaemon(true);
return t;
});
@Inject
public BackupService(StorageFactory storageFactory, EmulatorConfig config, RegionResolver regionResolver) {
this.vaultStore = storageFactory.create("backup", "backup-vaults.json", new TypeReference<>() {});
this.planStore = storageFactory.create("backup", "backup-plans.json", new TypeReference<>() {});
this.selectionStore = storageFactory.create("backup", "backup-selections.json", new TypeReference<>() {});
this.jobStore = storageFactory.create("backup", "backup-jobs.json", new TypeReference<>() {});
this.recoveryStore = storageFactory.create("backup", "backup-recovery-points.json", new TypeReference<>() {});
this.regionResolver = regionResolver;
this.jobCompletionDelaySeconds = config.services().backup().jobCompletionDelaySeconds();
}
@PreDestroy
void shutdown() {
scheduler.shutdownNow();
}
// ── Vault ──────────────────────────────────────────────────────────────────
public BackupVault createBackupVault(String vaultName, String encryptionKeyArn,
String creatorRequestId, Map<String, String> tags,
String region) {
String key = vaultKey(region, vaultName);
if (vaultStore.get(key).isPresent()) {
throw new AwsException("AlreadyExistsException", "Backup vault already exists: " + vaultName, 400);
}
BackupVault vault = new BackupVault();
vault.setBackupVaultName(vaultName);
vault.setBackupVaultArn(regionResolver.buildArn("backup", region, "backup-vault:" + vaultName));
vault.setEncryptionKeyArn(encryptionKeyArn);
vault.setCreationDate(Instant.now().getEpochSecond());
vault.setCreatorRequestId(creatorRequestId);
vault.setNumberOfRecoveryPoints(0);
vault.setTags(tags);
vaultStore.put(key, vault);
LOG.infov("Created backup vault {0} in {1}", vaultName, region);
return vault;
}
public BackupVault describeBackupVault(String vaultName, String region) {
return vaultStore.get(vaultKey(region, vaultName))
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Backup vault not found: " + vaultName, 404));
}
public void deleteBackupVault(String vaultName, String region) {
BackupVault vault = describeBackupVault(vaultName, region);
if (vault.getNumberOfRecoveryPoints() > 0) {
throw new AwsException("InvalidRequestException",
"Non-empty backup vault cannot be deleted: " + vaultName, 400);
}
vaultStore.delete(vaultKey(region, vaultName));
}
public List<BackupVault> listBackupVaults(String region) {
String prefix = region + ":";
return vaultStore.scan(k -> k.startsWith(prefix));
}
// ── Plan ───────────────────────────────────────────────────────────────────
public BackupPlan createBackupPlan(String planName, List<BackupRule> rules,
String creatorRequestId, String region) {
String planId = UUID.randomUUID().toString();
BackupPlan plan = new BackupPlan();
plan.setBackupPlanId(planId);
plan.setBackupPlanArn(regionResolver.buildArn("backup", region, "backup-plan:" + planId));
plan.setBackupPlanName(planName);
plan.setCreationDate(Instant.now().getEpochSecond());
plan.setVersionId(shortId());
assignRuleIds(rules);
plan.setRules(rules);
planStore.put(planId, plan);
return plan;
}
public BackupPlan getBackupPlan(String planId) {
return planStore.get(planId)
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Backup plan not found: " + planId, 404));
}
public BackupPlan updateBackupPlan(String planId, String planName, List<BackupRule> rules) {
BackupPlan plan = getBackupPlan(planId);
if (planName != null) {
plan.setBackupPlanName(planName);
}
assignRuleIds(rules);
plan.setRules(rules);
plan.setVersionId(shortId());
planStore.put(planId, plan);
return plan;
}
public void deleteBackupPlan(String planId) {
getBackupPlan(planId);
long selectionCount = selectionStore.scan(k -> true).stream()
.filter(s -> planId.equals(s.getBackupPlanId()))
.count();
if (selectionCount > 0) {
throw new AwsException("InvalidRequestException",
"Backup plan has active selections and cannot be deleted", 400);
}
planStore.delete(planId);
}
public List<BackupPlan> listBackupPlans() {
return planStore.scan(k -> true);
}
// ── Selection ──────────────────────────────────────────────────────────────
public BackupSelection createBackupSelection(String planId, String selectionName,
String iamRoleArn, List<String> resources,
List<String> notResources, String creatorRequestId) {
getBackupPlan(planId);
String selectionId = UUID.randomUUID().toString();
BackupSelection selection = new BackupSelection();
selection.setSelectionId(selectionId);
selection.setSelectionName(selectionName);
selection.setBackupPlanId(planId);
selection.setIamRoleArn(iamRoleArn);
selection.setResources(resources);
selection.setNotResources(notResources);
selection.setCreationDate(Instant.now().getEpochSecond());
selection.setCreatorRequestId(creatorRequestId);
selectionStore.put(selectionId, selection);
return selection;
}
public BackupSelection getBackupSelection(String planId, String selectionId) {
BackupSelection sel = selectionStore.get(selectionId)
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Backup selection not found: " + selectionId, 404));
if (!planId.equals(sel.getBackupPlanId())) {
throw new AwsException("ResourceNotFoundException", "Backup selection not found in plan: " + planId, 404);
}
return sel;
}
public void deleteBackupSelection(String planId, String selectionId) {
getBackupSelection(planId, selectionId);
selectionStore.delete(selectionId);
}
public List<BackupSelection> listBackupSelections(String planId) {
return selectionStore.scan(k -> true).stream()
.filter(s -> planId.equals(s.getBackupPlanId()))
.toList();
}
// ── Job ────────────────────────────────────────────────────────────────────
public BackupJob startBackupJob(String vaultName, String resourceArn, String iamRoleArn,
Lifecycle lifecycle, String region) {
BackupVault vault = describeBackupVault(vaultName, region);
String jobId = UUID.randomUUID().toString();
long now = Instant.now().getEpochSecond();
BackupJob job = new BackupJob();
job.setBackupJobId(jobId);
job.setBackupVaultName(vaultName);
job.setBackupVaultArn(vault.getBackupVaultArn());
job.setResourceArn(resourceArn);
job.setResourceType(inferResourceType(resourceArn));
job.setIamRoleArn(iamRoleArn);
job.setState("CREATED");
job.setPercentDone("0.0");
job.setCreationDate(now);
job.setExpectedCompletionDate(now + jobCompletionDelaySeconds);
job.setStartBy(now + 3600L);
job.setAccountId(regionResolver.getAccountId());
jobStore.put(jobId, job);
scheduler.schedule(() -> transitionJob(jobId, vaultName, region), 1, TimeUnit.SECONDS);
scheduler.schedule(() -> completeJob(jobId, vaultName, region), jobCompletionDelaySeconds, TimeUnit.SECONDS);
return job;
}
public BackupJob describeBackupJob(String jobId) {
return jobStore.get(jobId)
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Backup job not found: " + jobId, 404));
}
public void stopBackupJob(String jobId) {
BackupJob job = describeBackupJob(jobId);
String state = job.getState();
if ("COMPLETED".equals(state) || "ABORTED".equals(state) || "FAILED".equals(state)) {
throw new AwsException("InvalidRequestException",
"Job cannot be stopped in state: " + state, 400);
}
job.setState("ABORTING");
job.setStatusMessage("Job stop requested");
jobStore.put(jobId, job);
scheduler.schedule(() -> abortJob(jobId), 1, TimeUnit.SECONDS);
}
public List<BackupJob> listBackupJobs(String byVaultName, String byState,
String byResourceArn, String byResourceType) {
return jobStore.scan(k -> true).stream()
.filter(j -> byVaultName == null || byVaultName.equals(j.getBackupVaultName()))
.filter(j -> byState == null || byState.equals(j.getState()))
.filter(j -> byResourceArn == null || byResourceArn.equals(j.getResourceArn()))
.filter(j -> byResourceType == null || byResourceType.equals(j.getResourceType()))
.toList();
}
// ── Recovery Point ─────────────────────────────────────────────────────────
public RecoveryPoint describeRecoveryPoint(String vaultName, String recoveryPointArn, String region) {
describeBackupVault(vaultName, region);
return recoveryStore.get(recoveryPointArn)
.filter(rp -> vaultName.equals(rp.getBackupVaultName()))
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
"Recovery point not found: " + recoveryPointArn, 404));
}
public List<RecoveryPoint> listRecoveryPointsByBackupVault(String vaultName, String region) {
describeBackupVault(vaultName, region);
return recoveryStore.scan(k -> true).stream()
.filter(rp -> vaultName.equals(rp.getBackupVaultName()))
.toList();
}
public void deleteRecoveryPoint(String vaultName, String recoveryPointArn, String region) {
RecoveryPoint rp = describeRecoveryPoint(vaultName, recoveryPointArn, region);
recoveryStore.delete(recoveryPointArn);
decrementVaultCount(vaultName, region);
}
// ── Tags ───────────────────────────────────────────────────────────────────
public Map<String, String> listTags(String resourceArn) {
return findTagsByArn(resourceArn);
}
public void tagResource(String resourceArn, Map<String, String> tags) {
applyTags(resourceArn, tags);
}
public void untagResource(String resourceArn, List<String> tagKeys) {
removeTags(resourceArn, tagKeys);
}
// ── Supported resource types ───────────────────────────────────────────────
public List<String> getSupportedResourceTypes() {
return SUPPORTED_RESOURCE_TYPES;
}
// ── Private helpers ────────────────────────────────────────────────────────
private void transitionJob(String jobId, String vaultName, String region) {
jobStore.get(jobId).ifPresent(job -> {
if ("CREATED".equals(job.getState())) {
job.setState("RUNNING");
job.setPercentDone("50.0");
jobStore.put(jobId, job);
}
});
}
private void completeJob(String jobId, String vaultName, String region) {
jobStore.get(jobId).ifPresent(job -> {
if ("RUNNING".equals(job.getState())) {
long now = Instant.now().getEpochSecond();
String rpArn = regionResolver.buildArn("backup", region,
"recovery-point:" + UUID.randomUUID());
job.setState("COMPLETED");
job.setPercentDone("100.0");
job.setCompletionDate(now);
job.setRecoveryPointArn(rpArn);
job.setBackupSizeInBytes(0L);
job.setBytesTransferred(0L);
jobStore.put(jobId, job);
RecoveryPoint rp = new RecoveryPoint();
rp.setRecoveryPointArn(rpArn);
rp.setBackupVaultName(vaultName);
rp.setBackupVaultArn(job.getBackupVaultArn());
rp.setResourceArn(job.getResourceArn());
rp.setResourceType(job.getResourceType());
rp.setIamRoleArn(job.getIamRoleArn());
rp.setStatus("COMPLETED");
rp.setCreationDate(job.getCreationDate());
rp.setCompletionDate(now);
rp.setBackupSizeInBytes(0L);
rp.setStorageClass("WARM");
rp.setEncrypted(false);
recoveryStore.put(rpArn, rp);
incrementVaultCount(vaultName, region);
LOG.infov("Backup job {0} completed, recovery point: {1}", jobId, rpArn);
}
});
}
private void abortJob(String jobId) {
jobStore.get(jobId).ifPresent(job -> {
if ("ABORTING".equals(job.getState())) {
job.setState("ABORTED");
job.setCompletionDate(Instant.now().getEpochSecond());
jobStore.put(jobId, job);
}
});
}
private void incrementVaultCount(String vaultName, String region) {
vaultStore.get(vaultKey(region, vaultName)).ifPresent(vault -> {
vault.setNumberOfRecoveryPoints(vault.getNumberOfRecoveryPoints() + 1);
vaultStore.put(vaultKey(region, vaultName), vault);
});
}
private void decrementVaultCount(String vaultName, String region) {
vaultStore.get(vaultKey(region, vaultName)).ifPresent(vault -> {
vault.setNumberOfRecoveryPoints(Math.max(0, vault.getNumberOfRecoveryPoints() - 1));
vaultStore.put(vaultKey(region, vaultName), vault);
});
}
private Map<String, String> findTagsByArn(String arn) {
Optional<BackupVault> vault = vaultStore.scan(k -> true).stream()
.filter(v -> arn.equals(v.getBackupVaultArn()))
.findFirst();
if (vault.isPresent()) {
return vault.get().getTags();
}
Optional<BackupPlan> plan = planStore.scan(k -> true).stream()
.filter(p -> arn.equals(p.getBackupPlanArn()))
.findFirst();
if (plan.isPresent()) {
return new HashMap<>();
}
throw new AwsException("ResourceNotFoundException", "Resource not found: " + arn, 404);
}
private void applyTags(String arn, Map<String, String> newTags) {
Optional<BackupVault> vaultOpt = vaultStore.scan(k -> true).stream()
.filter(v -> arn.equals(v.getBackupVaultArn()))
.findFirst();
if (vaultOpt.isPresent()) {
BackupVault vault = vaultOpt.get();
vault.getTags().putAll(newTags);
vaultStore.put(vaultKey(vault), vault);
return;
}
throw new AwsException("ResourceNotFoundException", "Resource not found: " + arn, 404);
}
private void removeTags(String arn, List<String> tagKeys) {
Optional<BackupVault> vaultOpt = vaultStore.scan(k -> true).stream()
.filter(v -> arn.equals(v.getBackupVaultArn()))
.findFirst();
if (vaultOpt.isPresent()) {
BackupVault vault = vaultOpt.get();
tagKeys.forEach(vault.getTags()::remove);
vaultStore.put(vaultKey(vault), vault);
return;
}
throw new AwsException("ResourceNotFoundException", "Resource not found: " + arn, 404);
}
private static void assignRuleIds(List<BackupRule> rules) {
if (rules == null) {
return;
}
for (BackupRule rule : rules) {
if (rule.getRuleId() == null) {
rule.setRuleId(UUID.randomUUID().toString());
}
}
}
private static String inferResourceType(String resourceArn) {
if (resourceArn == null) {
return null;
}
if (resourceArn.contains(":s3:::")) {
return "S3";
}
if (resourceArn.contains(":rds:")) {
return "RDS";
}
if (resourceArn.contains(":dynamodb:")) {
return "DynamoDB";
}
if (resourceArn.contains(":ec2:")) {
return "EC2";
}
if (resourceArn.contains(":elasticfilesystem:")) {
return "EFS";
}
return null;
}
private static String vaultKey(String region, String vaultName) {
return region + ":" + vaultName;
}
private static String vaultKey(BackupVault vault) {
String arn = vault.getBackupVaultArn();
// arn:aws:backup:{region}:{account}:backup-vault:{name}
String[] parts = arn.split(":");
return parts[3] + ":" + vault.getBackupVaultName();
}
private static String shortId() {
return UUID.randomUUID().toString().replace("-", "").substring(0, 12);
}
}
@@ -0,0 +1,44 @@
package io.github.hectorvent.floci.services.backup;
import io.github.hectorvent.floci.core.common.TagHandler;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.List;
import java.util.Map;
@ApplicationScoped
public class BackupTagHandler implements TagHandler {
private final BackupService service;
@Inject
public BackupTagHandler(BackupService service) {
this.service = service;
}
@Override
public String serviceKey() {
return "backup";
}
@Override
public String tagsBodyKey() {
return "Tags";
}
@Override
public Map<String, String> listTags(String region, String arn) {
return service.listTags(arn);
}
@Override
public void tagResource(String region, String arn, Map<String, String> tags) {
service.tagResource(arn, tags);
}
@Override
public void untagResource(String region, String arn, List<String> tagKeys) {
service.untagResource(arn, tagKeys);
}
}
@@ -0,0 +1,116 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BackupJob {
@JsonProperty("BackupJobId")
private String backupJobId;
@JsonProperty("BackupVaultName")
private String backupVaultName;
@JsonProperty("BackupVaultArn")
private String backupVaultArn;
@JsonProperty("RecoveryPointArn")
private String recoveryPointArn;
@JsonProperty("ResourceArn")
private String resourceArn;
@JsonProperty("ResourceType")
private String resourceType;
@JsonProperty("IamRoleArn")
private String iamRoleArn;
@JsonProperty("State")
private String state;
@JsonProperty("StatusMessage")
private String statusMessage;
@JsonProperty("CreationDate")
private long creationDate;
@JsonProperty("CompletionDate")
private Long completionDate;
@JsonProperty("ExpectedCompletionDate")
private Long expectedCompletionDate;
@JsonProperty("StartBy")
private Long startBy;
@JsonProperty("BytesTransferred")
private Long bytesTransferred;
@JsonProperty("BackupSizeInBytes")
private Long backupSizeInBytes;
@JsonProperty("PercentDone")
private String percentDone;
@JsonProperty("AccountId")
private String accountId;
public BackupJob() {}
public String getBackupJobId() { return backupJobId; }
public void setBackupJobId(String backupJobId) { this.backupJobId = backupJobId; }
public String getBackupVaultName() { return backupVaultName; }
public void setBackupVaultName(String backupVaultName) { this.backupVaultName = backupVaultName; }
public String getBackupVaultArn() { return backupVaultArn; }
public void setBackupVaultArn(String backupVaultArn) { this.backupVaultArn = backupVaultArn; }
public String getRecoveryPointArn() { return recoveryPointArn; }
public void setRecoveryPointArn(String recoveryPointArn) { this.recoveryPointArn = recoveryPointArn; }
public String getResourceArn() { return resourceArn; }
public void setResourceArn(String resourceArn) { this.resourceArn = resourceArn; }
public String getResourceType() { return resourceType; }
public void setResourceType(String resourceType) { this.resourceType = resourceType; }
public String getIamRoleArn() { return iamRoleArn; }
public void setIamRoleArn(String iamRoleArn) { this.iamRoleArn = iamRoleArn; }
public String getState() { return state; }
public void setState(String state) { this.state = state; }
public String getStatusMessage() { return statusMessage; }
public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; }
public long getCreationDate() { return creationDate; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }
public Long getCompletionDate() { return completionDate; }
public void setCompletionDate(Long completionDate) { this.completionDate = completionDate; }
public Long getExpectedCompletionDate() { return expectedCompletionDate; }
public void setExpectedCompletionDate(Long expectedCompletionDate) { this.expectedCompletionDate = expectedCompletionDate; }
public Long getStartBy() { return startBy; }
public void setStartBy(Long startBy) { this.startBy = startBy; }
public Long getBytesTransferred() { return bytesTransferred; }
public void setBytesTransferred(Long bytesTransferred) { this.bytesTransferred = bytesTransferred; }
public Long getBackupSizeInBytes() { return backupSizeInBytes; }
public void setBackupSizeInBytes(Long backupSizeInBytes) { this.backupSizeInBytes = backupSizeInBytes; }
public String getPercentDone() { return percentDone; }
public void setPercentDone(String percentDone) { this.percentDone = percentDone; }
public String getAccountId() { return accountId; }
public void setAccountId(String accountId) { this.accountId = accountId; }
}
@@ -0,0 +1,65 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BackupPlan {
@JsonProperty("BackupPlanId")
private String backupPlanId;
@JsonProperty("BackupPlanArn")
private String backupPlanArn;
@JsonProperty("BackupPlanName")
private String backupPlanName;
@JsonProperty("CreationDate")
private long creationDate;
@JsonProperty("DeletionDate")
private Long deletionDate;
@JsonProperty("LastExecutionDate")
private Long lastExecutionDate;
@JsonProperty("VersionId")
private String versionId;
@JsonProperty("Rules")
private List<BackupRule> rules = new ArrayList<>();
public BackupPlan() {}
public String getBackupPlanId() { return backupPlanId; }
public void setBackupPlanId(String backupPlanId) { this.backupPlanId = backupPlanId; }
public String getBackupPlanArn() { return backupPlanArn; }
public void setBackupPlanArn(String backupPlanArn) { this.backupPlanArn = backupPlanArn; }
public String getBackupPlanName() { return backupPlanName; }
public void setBackupPlanName(String backupPlanName) { this.backupPlanName = backupPlanName; }
public long getCreationDate() { return creationDate; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }
public Long getDeletionDate() { return deletionDate; }
public void setDeletionDate(Long deletionDate) { this.deletionDate = deletionDate; }
public Long getLastExecutionDate() { return lastExecutionDate; }
public void setLastExecutionDate(Long lastExecutionDate) { this.lastExecutionDate = lastExecutionDate; }
public String getVersionId() { return versionId; }
public void setVersionId(String versionId) { this.versionId = versionId; }
public List<BackupRule> getRules() { return rules; }
public void setRules(List<BackupRule> rules) { this.rules = rules != null ? rules : new ArrayList<>(); }
}
@@ -0,0 +1,83 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class BackupRule {
@JsonProperty("RuleName")
private String ruleName;
@JsonProperty("TargetBackupVaultName")
private String targetBackupVaultName;
@JsonProperty("ScheduleExpression")
private String scheduleExpression;
@JsonProperty("ScheduleExpressionTimezone")
private String scheduleExpressionTimezone;
@JsonProperty("StartWindowMinutes")
private Long startWindowMinutes;
@JsonProperty("CompletionWindowMinutes")
private Long completionWindowMinutes;
@JsonProperty("Lifecycle")
private Lifecycle lifecycle;
@JsonProperty("RecoveryPointTags")
private Map<String, String> recoveryPointTags = new HashMap<>();
@JsonProperty("RuleId")
private String ruleId;
@JsonProperty("CopyActions")
private List<CopyAction> copyActions = new ArrayList<>();
@JsonProperty("EnableContinuousBackup")
private Boolean enableContinuousBackup;
public BackupRule() {}
public String getRuleName() { return ruleName; }
public void setRuleName(String ruleName) { this.ruleName = ruleName; }
public String getTargetBackupVaultName() { return targetBackupVaultName; }
public void setTargetBackupVaultName(String targetBackupVaultName) { this.targetBackupVaultName = targetBackupVaultName; }
public String getScheduleExpression() { return scheduleExpression; }
public void setScheduleExpression(String scheduleExpression) { this.scheduleExpression = scheduleExpression; }
public String getScheduleExpressionTimezone() { return scheduleExpressionTimezone; }
public void setScheduleExpressionTimezone(String scheduleExpressionTimezone) { this.scheduleExpressionTimezone = scheduleExpressionTimezone; }
public Long getStartWindowMinutes() { return startWindowMinutes; }
public void setStartWindowMinutes(Long startWindowMinutes) { this.startWindowMinutes = startWindowMinutes; }
public Long getCompletionWindowMinutes() { return completionWindowMinutes; }
public void setCompletionWindowMinutes(Long completionWindowMinutes) { this.completionWindowMinutes = completionWindowMinutes; }
public Lifecycle getLifecycle() { return lifecycle; }
public void setLifecycle(Lifecycle lifecycle) { this.lifecycle = lifecycle; }
public Map<String, String> getRecoveryPointTags() { return recoveryPointTags; }
public void setRecoveryPointTags(Map<String, String> recoveryPointTags) { this.recoveryPointTags = recoveryPointTags != null ? recoveryPointTags : new HashMap<>(); }
public String getRuleId() { return ruleId; }
public void setRuleId(String ruleId) { this.ruleId = ruleId; }
public List<CopyAction> getCopyActions() { return copyActions; }
public void setCopyActions(List<CopyAction> copyActions) { this.copyActions = copyActions != null ? copyActions : new ArrayList<>(); }
public Boolean getEnableContinuousBackup() { return enableContinuousBackup; }
public void setEnableContinuousBackup(Boolean enableContinuousBackup) { this.enableContinuousBackup = enableContinuousBackup; }
}
@@ -0,0 +1,65 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BackupSelection {
@JsonProperty("SelectionId")
private String selectionId;
@JsonProperty("SelectionName")
private String selectionName;
@JsonProperty("BackupPlanId")
private String backupPlanId;
@JsonProperty("IamRoleArn")
private String iamRoleArn;
@JsonProperty("Resources")
private List<String> resources = new ArrayList<>();
@JsonProperty("NotResources")
private List<String> notResources = new ArrayList<>();
@JsonProperty("CreationDate")
private long creationDate;
@JsonProperty("CreatorRequestId")
private String creatorRequestId;
public BackupSelection() {}
public String getSelectionId() { return selectionId; }
public void setSelectionId(String selectionId) { this.selectionId = selectionId; }
public String getSelectionName() { return selectionName; }
public void setSelectionName(String selectionName) { this.selectionName = selectionName; }
public String getBackupPlanId() { return backupPlanId; }
public void setBackupPlanId(String backupPlanId) { this.backupPlanId = backupPlanId; }
public String getIamRoleArn() { return iamRoleArn; }
public void setIamRoleArn(String iamRoleArn) { this.iamRoleArn = iamRoleArn; }
public List<String> getResources() { return resources; }
public void setResources(List<String> resources) { this.resources = resources != null ? resources : new ArrayList<>(); }
public List<String> getNotResources() { return notResources; }
public void setNotResources(List<String> notResources) { this.notResources = notResources != null ? notResources : new ArrayList<>(); }
public long getCreationDate() { return creationDate; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }
public String getCreatorRequestId() { return creatorRequestId; }
public void setCreatorRequestId(String creatorRequestId) { this.creatorRequestId = creatorRequestId; }
}
@@ -0,0 +1,59 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.HashMap;
import java.util.Map;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BackupVault {
@JsonProperty("BackupVaultName")
private String backupVaultName;
@JsonProperty("BackupVaultArn")
private String backupVaultArn;
@JsonProperty("EncryptionKeyArn")
private String encryptionKeyArn;
@JsonProperty("CreationDate")
private long creationDate;
@JsonProperty("CreatorRequestId")
private String creatorRequestId;
@JsonProperty("NumberOfRecoveryPoints")
private long numberOfRecoveryPoints;
@JsonProperty("Tags")
private Map<String, String> tags = new HashMap<>();
public BackupVault() {}
public String getBackupVaultName() { return backupVaultName; }
public void setBackupVaultName(String backupVaultName) { this.backupVaultName = backupVaultName; }
public String getBackupVaultArn() { return backupVaultArn; }
public void setBackupVaultArn(String backupVaultArn) { this.backupVaultArn = backupVaultArn; }
public String getEncryptionKeyArn() { return encryptionKeyArn; }
public void setEncryptionKeyArn(String encryptionKeyArn) { this.encryptionKeyArn = encryptionKeyArn; }
public long getCreationDate() { return creationDate; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }
public String getCreatorRequestId() { return creatorRequestId; }
public void setCreatorRequestId(String creatorRequestId) { this.creatorRequestId = creatorRequestId; }
public long getNumberOfRecoveryPoints() { return numberOfRecoveryPoints; }
public void setNumberOfRecoveryPoints(long numberOfRecoveryPoints) { this.numberOfRecoveryPoints = numberOfRecoveryPoints; }
public Map<String, String> getTags() { return tags; }
public void setTags(Map<String, String> tags) { this.tags = tags != null ? tags : new HashMap<>(); }
}
@@ -0,0 +1,24 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class CopyAction {
@JsonProperty("DestinationBackupVaultArn")
private String destinationBackupVaultArn;
@JsonProperty("Lifecycle")
private Lifecycle lifecycle;
public CopyAction() {}
public String getDestinationBackupVaultArn() { return destinationBackupVaultArn; }
public void setDestinationBackupVaultArn(String destinationBackupVaultArn) { this.destinationBackupVaultArn = destinationBackupVaultArn; }
public Lifecycle getLifecycle() { return lifecycle; }
public void setLifecycle(Lifecycle lifecycle) { this.lifecycle = lifecycle; }
}
@@ -0,0 +1,24 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class Lifecycle {
@JsonProperty("MoveToColdStorageAfterDays")
private Long moveToColdStorageAfterDays;
@JsonProperty("DeleteAfterDays")
private Long deleteAfterDays;
public Lifecycle() {}
public Long getMoveToColdStorageAfterDays() { return moveToColdStorageAfterDays; }
public void setMoveToColdStorageAfterDays(Long moveToColdStorageAfterDays) { this.moveToColdStorageAfterDays = moveToColdStorageAfterDays; }
public Long getDeleteAfterDays() { return deleteAfterDays; }
public void setDeleteAfterDays(Long deleteAfterDays) { this.deleteAfterDays = deleteAfterDays; }
}
@@ -0,0 +1,110 @@
package io.github.hectorvent.floci.services.backup.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RecoveryPoint {
@JsonProperty("RecoveryPointArn")
private String recoveryPointArn;
@JsonProperty("BackupVaultName")
private String backupVaultName;
@JsonProperty("BackupVaultArn")
private String backupVaultArn;
@JsonProperty("ResourceArn")
private String resourceArn;
@JsonProperty("ResourceType")
private String resourceType;
@JsonProperty("IamRoleArn")
private String iamRoleArn;
@JsonProperty("Status")
private String status;
@JsonProperty("StatusMessage")
private String statusMessage;
@JsonProperty("CreationDate")
private long creationDate;
@JsonProperty("CompletionDate")
private Long completionDate;
@JsonProperty("BackupSizeInBytes")
private Long backupSizeInBytes;
@JsonProperty("Lifecycle")
private Lifecycle lifecycle;
@JsonProperty("EncryptionKeyArn")
private String encryptionKeyArn;
@JsonProperty("IsEncrypted")
private boolean isEncrypted;
@JsonProperty("StorageClass")
private String storageClass;
@JsonProperty("LastRestoreTime")
private Long lastRestoreTime;
public RecoveryPoint() {}
public String getRecoveryPointArn() { return recoveryPointArn; }
public void setRecoveryPointArn(String recoveryPointArn) { this.recoveryPointArn = recoveryPointArn; }
public String getBackupVaultName() { return backupVaultName; }
public void setBackupVaultName(String backupVaultName) { this.backupVaultName = backupVaultName; }
public String getBackupVaultArn() { return backupVaultArn; }
public void setBackupVaultArn(String backupVaultArn) { this.backupVaultArn = backupVaultArn; }
public String getResourceArn() { return resourceArn; }
public void setResourceArn(String resourceArn) { this.resourceArn = resourceArn; }
public String getResourceType() { return resourceType; }
public void setResourceType(String resourceType) { this.resourceType = resourceType; }
public String getIamRoleArn() { return iamRoleArn; }
public void setIamRoleArn(String iamRoleArn) { this.iamRoleArn = iamRoleArn; }
public String getStatus() { return status; }
public void setStatus(String status) { this.status = status; }
public String getStatusMessage() { return statusMessage; }
public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; }
public long getCreationDate() { return creationDate; }
public void setCreationDate(long creationDate) { this.creationDate = creationDate; }
public Long getCompletionDate() { return completionDate; }
public void setCompletionDate(Long completionDate) { this.completionDate = completionDate; }
public Long getBackupSizeInBytes() { return backupSizeInBytes; }
public void setBackupSizeInBytes(Long backupSizeInBytes) { this.backupSizeInBytes = backupSizeInBytes; }
public Lifecycle getLifecycle() { return lifecycle; }
public void setLifecycle(Lifecycle lifecycle) { this.lifecycle = lifecycle; }
public String getEncryptionKeyArn() { return encryptionKeyArn; }
public void setEncryptionKeyArn(String encryptionKeyArn) { this.encryptionKeyArn = encryptionKeyArn; }
public boolean isEncrypted() { return isEncrypted; }
public void setEncrypted(boolean encrypted) { isEncrypted = encrypted; }
public String getStorageClass() { return storageClass; }
public void setStorageClass(String storageClass) { this.storageClass = storageClass; }
public Long getLastRestoreTime() { return lastRestoreTime; }
public void setLastRestoreTime(Long lastRestoreTime) { this.lastRestoreTime = lastRestoreTime; }
}