mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(scheduler): add EventBridge Scheduler service (#260)
* feat(scheduler): add EventBridge Scheduler ScheduleGroup CRUD
Introduces the scheduler service skeleton with ScheduleGroup CRUD over
the REST JSON protocol at /schedule-groups/{Name}. The default group is
lazily seeded on first access, mirroring the EventBridge default bus
pattern. Covers Create/Get/Delete/List, region scoping, name validation,
and the default-group delete guard.
* feat(scheduler): add Java SDK compatibility tests for ScheduleGroup CRUD
* feat(scheduler): add Schedule CRUD operations
This commit is contained in:
1 parent
f4f1752b0d
commit
48b6ca3475
24 files changed
+2771
-4
No files matched your search
@@ -178,6 +178,7 @@ public interface EmulatorConfig {
|
||||
ElastiCacheServiceConfig elasticache();
|
||||
RdsServiceConfig rds();
|
||||
EventBridgeServiceConfig eventbridge();
|
||||
SchedulerServiceConfig scheduler();
|
||||
CloudWatchLogsServiceConfig cloudwatchlogs();
|
||||
CloudWatchMetricsServiceConfig cloudwatchmetrics();
|
||||
SecretsManagerServiceConfig secretsmanager();
|
||||
@@ -286,6 +287,11 @@ public interface EmulatorConfig {
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface SchedulerServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface CloudWatchLogsServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -38,6 +38,7 @@ public class ServiceRegistry {
|
||||
case "elasticache" -> config.services().elasticache().enabled();
|
||||
case "rds" -> config.services().rds().enabled();
|
||||
case "events" -> config.services().eventbridge().enabled();
|
||||
case "scheduler" -> config.services().scheduler().enabled();
|
||||
case "logs" -> config.services().cloudwatchlogs().enabled();
|
||||
case "monitoring" -> config.services().cloudwatchmetrics().enabled();
|
||||
case "secretsmanager" -> config.services().secretsmanager().enabled();
|
||||
@@ -69,6 +70,7 @@ public class ServiceRegistry {
|
||||
if (config.services().elasticache().enabled()) enabled.add("elasticache");
|
||||
if (config.services().rds().enabled()) enabled.add("rds");
|
||||
if (config.services().eventbridge().enabled()) enabled.add("events");
|
||||
if (config.services().scheduler().enabled()) enabled.add("scheduler");
|
||||
if (config.services().cloudwatchlogs().enabled()) enabled.add("logs");
|
||||
if (config.services().cloudwatchmetrics().enabled()) enabled.add("monitoring");
|
||||
if (config.services().secretsmanager().enabled()) enabled.add("secretsmanager");
|
||||
@@ -100,6 +102,7 @@ public class ServiceRegistry {
|
||||
services.put("elasticache", status(config.services().elasticache().enabled()));
|
||||
services.put("rds", status(config.services().rds().enabled()));
|
||||
services.put("events", status(config.services().eventbridge().enabled()));
|
||||
services.put("scheduler", status(config.services().scheduler().enabled()));
|
||||
services.put("logs", status(config.services().cloudwatchlogs().enabled()));
|
||||
services.put("monitoring", status(config.services().cloudwatchmetrics().enabled()));
|
||||
services.put("secretsmanager", status(config.services().secretsmanager().enabled()));
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
package io.github.hectorvent.floci.services.scheduler;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.DeadLetterConfig;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.FlexibleTimeWindow;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.RetryPolicy;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.Schedule;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.ScheduleGroup;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.ScheduleRequest;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.Target;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
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 jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
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 java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AWS EventBridge Scheduler REST endpoints.
|
||||
* Paths mirror the AWS SDK v2 SchedulerClient (e.g. {@code POST /schedule-groups/{Name}}).
|
||||
*/
|
||||
@Path("/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class SchedulerController {
|
||||
|
||||
private final SchedulerService schedulerService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public SchedulerController(SchedulerService schedulerService,
|
||||
RegionResolver regionResolver,
|
||||
ObjectMapper objectMapper) {
|
||||
this.schedulerService = schedulerService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
// ──────────────────────────── CreateScheduleGroup ────────────────────────────
|
||||
|
||||
@POST
|
||||
@Path("/schedule-groups/{name}")
|
||||
public Response createScheduleGroup(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name,
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
Map<String, String> tags = parseTags(body);
|
||||
ScheduleGroup group = schedulerService.createScheduleGroup(name, tags, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("ScheduleGroupArn", group.getArn());
|
||||
return Response.ok(response).build();
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new AwsException("ValidationException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── GetScheduleGroup ────────────────────────────
|
||||
|
||||
@GET
|
||||
@Path("/schedule-groups/{name}")
|
||||
public Response getScheduleGroup(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
ScheduleGroup group = schedulerService.getScheduleGroup(name, region);
|
||||
return Response.ok(buildGroupResponse(group)).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── DeleteScheduleGroup ────────────────────────────
|
||||
|
||||
@DELETE
|
||||
@Path("/schedule-groups/{name}")
|
||||
public Response deleteScheduleGroup(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
schedulerService.deleteScheduleGroup(name, region);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── ListScheduleGroups ────────────────────────────
|
||||
|
||||
@GET
|
||||
@Path("/schedule-groups")
|
||||
public Response listScheduleGroups(@Context HttpHeaders headers,
|
||||
@QueryParam("NamePrefix") String namePrefix) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<ScheduleGroup> groups = schedulerService.listScheduleGroups(namePrefix, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode items = response.putArray("ScheduleGroups");
|
||||
for (ScheduleGroup group : groups) {
|
||||
items.add(objectMapper.valueToTree(buildGroupResponse(group)));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── CreateSchedule ────────────────────────────
|
||||
|
||||
@POST
|
||||
@Path("/schedules/{name}")
|
||||
public Response createSchedule(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name,
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(body != null ? body : "{}");
|
||||
ScheduleRequest req = parseScheduleRequest(node);
|
||||
req.setName(name);
|
||||
Schedule schedule = schedulerService.createSchedule(req, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("ScheduleArn", schedule.getArn());
|
||||
return Response.ok(response).build();
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new AwsException("ValidationException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── GetSchedule ────────────────────────────
|
||||
|
||||
@GET
|
||||
@Path("/schedules/{name}")
|
||||
public Response getSchedule(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name,
|
||||
@QueryParam("groupName") String groupName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
Schedule schedule = schedulerService.getSchedule(name, groupName, region);
|
||||
return Response.ok(buildScheduleResponse(schedule)).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── UpdateSchedule ────────────────────────────
|
||||
|
||||
@PUT
|
||||
@Path("/schedules/{name}")
|
||||
public Response updateSchedule(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name,
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode node = objectMapper.readTree(body != null ? body : "{}");
|
||||
ScheduleRequest req = parseScheduleRequest(node);
|
||||
req.setName(name);
|
||||
Schedule schedule = schedulerService.updateSchedule(req, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("ScheduleArn", schedule.getArn());
|
||||
return Response.ok(response).build();
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new AwsException("ValidationException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── DeleteSchedule ────────────────────────────
|
||||
|
||||
@DELETE
|
||||
@Path("/schedules/{name}")
|
||||
public Response deleteSchedule(@Context HttpHeaders headers,
|
||||
@PathParam("name") String name,
|
||||
@QueryParam("groupName") String groupName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
schedulerService.deleteSchedule(name, groupName, region);
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── ListSchedules ────────────────────────────
|
||||
|
||||
@GET
|
||||
@Path("/schedules")
|
||||
public Response listSchedules(@Context HttpHeaders headers,
|
||||
@QueryParam("ScheduleGroup") String groupName,
|
||||
@QueryParam("NamePrefix") String namePrefix,
|
||||
@QueryParam("State") String state) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<Schedule> schedules = schedulerService.listSchedules(groupName, namePrefix, state, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode items = response.putArray("Schedules");
|
||||
for (Schedule schedule : schedules) {
|
||||
items.add(objectMapper.valueToTree(buildScheduleSummary(schedule)));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
|
||||
private Map<String, Object> buildGroupResponse(ScheduleGroup group) {
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("Name", group.getName());
|
||||
response.put("Arn", group.getArn());
|
||||
response.put("State", group.getState());
|
||||
if (group.getCreationDate() != null) {
|
||||
response.put("CreationDate", toEpochDouble(group.getCreationDate()));
|
||||
}
|
||||
if (group.getLastModificationDate() != null) {
|
||||
response.put("LastModificationDate", toEpochDouble(group.getLastModificationDate()));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildScheduleResponse(Schedule s) {
|
||||
Map<String, Object> r = new HashMap<>();
|
||||
r.put("Name", s.getName());
|
||||
r.put("Arn", s.getArn());
|
||||
r.put("GroupName", s.getGroupName());
|
||||
r.put("State", s.getState());
|
||||
r.put("ScheduleExpression", s.getScheduleExpression());
|
||||
if (s.getScheduleExpressionTimezone() != null) {
|
||||
r.put("ScheduleExpressionTimezone", s.getScheduleExpressionTimezone());
|
||||
}
|
||||
if (s.getFlexibleTimeWindow() != null) {
|
||||
Map<String, Object> ftw = new HashMap<>();
|
||||
ftw.put("Mode", s.getFlexibleTimeWindow().getMode());
|
||||
if (s.getFlexibleTimeWindow().getMaximumWindowInMinutes() != null) {
|
||||
ftw.put("MaximumWindowInMinutes", s.getFlexibleTimeWindow().getMaximumWindowInMinutes());
|
||||
}
|
||||
r.put("FlexibleTimeWindow", ftw);
|
||||
}
|
||||
if (s.getTarget() != null) {
|
||||
Map<String, Object> t = new HashMap<>();
|
||||
t.put("Arn", s.getTarget().getArn());
|
||||
t.put("RoleArn", s.getTarget().getRoleArn());
|
||||
if (s.getTarget().getInput() != null) {
|
||||
t.put("Input", s.getTarget().getInput());
|
||||
}
|
||||
if (s.getTarget().getRetryPolicy() != null) {
|
||||
Map<String, Object> rp = new HashMap<>();
|
||||
if (s.getTarget().getRetryPolicy().getMaximumEventAgeInSeconds() != null) {
|
||||
rp.put("MaximumEventAgeInSeconds", s.getTarget().getRetryPolicy().getMaximumEventAgeInSeconds());
|
||||
}
|
||||
if (s.getTarget().getRetryPolicy().getMaximumRetryAttempts() != null) {
|
||||
rp.put("MaximumRetryAttempts", s.getTarget().getRetryPolicy().getMaximumRetryAttempts());
|
||||
}
|
||||
if (!rp.isEmpty()) {
|
||||
t.put("RetryPolicy", rp);
|
||||
}
|
||||
}
|
||||
if (s.getTarget().getDeadLetterConfig() != null) {
|
||||
Map<String, Object> dlc = new HashMap<>();
|
||||
dlc.put("Arn", s.getTarget().getDeadLetterConfig().getArn());
|
||||
t.put("DeadLetterConfig", dlc);
|
||||
}
|
||||
r.put("Target", t);
|
||||
}
|
||||
if (s.getDescription() != null) {
|
||||
r.put("Description", s.getDescription());
|
||||
}
|
||||
if (s.getActionAfterCompletion() != null) {
|
||||
r.put("ActionAfterCompletion", s.getActionAfterCompletion());
|
||||
}
|
||||
if (s.getStartDate() != null) {
|
||||
r.put("StartDate", toEpochDouble(s.getStartDate()));
|
||||
}
|
||||
if (s.getEndDate() != null) {
|
||||
r.put("EndDate", toEpochDouble(s.getEndDate()));
|
||||
}
|
||||
if (s.getKmsKeyArn() != null) {
|
||||
r.put("KmsKeyArn", s.getKmsKeyArn());
|
||||
}
|
||||
if (s.getCreationDate() != null) {
|
||||
r.put("CreationDate", toEpochDouble(s.getCreationDate()));
|
||||
}
|
||||
if (s.getLastModificationDate() != null) {
|
||||
r.put("LastModificationDate", toEpochDouble(s.getLastModificationDate()));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildScheduleSummary(Schedule s) {
|
||||
Map<String, Object> r = new HashMap<>();
|
||||
r.put("Name", s.getName());
|
||||
r.put("Arn", s.getArn());
|
||||
r.put("GroupName", s.getGroupName());
|
||||
r.put("State", s.getState());
|
||||
if (s.getCreationDate() != null) {
|
||||
r.put("CreationDate", toEpochDouble(s.getCreationDate()));
|
||||
}
|
||||
if (s.getLastModificationDate() != null) {
|
||||
r.put("LastModificationDate", toEpochDouble(s.getLastModificationDate()));
|
||||
}
|
||||
if (s.getTarget() != null) {
|
||||
Map<String, Object> t = new HashMap<>();
|
||||
t.put("Arn", s.getTarget().getArn());
|
||||
r.put("Target", t);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private double toEpochDouble(Instant instant) {
|
||||
return instant.getEpochSecond() + instant.getNano() / 1_000_000_000.0;
|
||||
}
|
||||
|
||||
private String textField(JsonNode node, String field) {
|
||||
JsonNode f = node.get(field);
|
||||
return (f != null && !f.isNull()) ? f.asText() : null;
|
||||
}
|
||||
|
||||
private Instant instantField(JsonNode node, String field) {
|
||||
JsonNode f = node.get(field);
|
||||
if (f != null && !f.isNull() && f.isNumber()) {
|
||||
long millis = Math.round(f.doubleValue() * 1_000);
|
||||
return Instant.ofEpochMilli(millis);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ScheduleRequest parseScheduleRequest(JsonNode node) {
|
||||
ScheduleRequest req = new ScheduleRequest();
|
||||
req.setGroupName(textField(node, "GroupName"));
|
||||
req.setScheduleExpression(textField(node, "ScheduleExpression"));
|
||||
req.setScheduleExpressionTimezone(textField(node, "ScheduleExpressionTimezone"));
|
||||
req.setFlexibleTimeWindow(parseFlexibleTimeWindow(node.get("FlexibleTimeWindow")));
|
||||
req.setTarget(parseTarget(node.get("Target")));
|
||||
req.setDescription(textField(node, "Description"));
|
||||
req.setState(textField(node, "State"));
|
||||
req.setActionAfterCompletion(textField(node, "ActionAfterCompletion"));
|
||||
req.setStartDate(instantField(node, "StartDate"));
|
||||
req.setEndDate(instantField(node, "EndDate"));
|
||||
req.setKmsKeyArn(textField(node, "KmsKeyArn"));
|
||||
return req;
|
||||
}
|
||||
|
||||
private FlexibleTimeWindow parseFlexibleTimeWindow(JsonNode node) {
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
FlexibleTimeWindow ftw = new FlexibleTimeWindow();
|
||||
if (node.has("Mode")) {
|
||||
ftw.setMode(node.get("Mode").asText());
|
||||
}
|
||||
if (node.has("MaximumWindowInMinutes") && !node.get("MaximumWindowInMinutes").isNull()) {
|
||||
ftw.setMaximumWindowInMinutes(node.get("MaximumWindowInMinutes").asInt());
|
||||
}
|
||||
return ftw;
|
||||
}
|
||||
|
||||
private Target parseTarget(JsonNode node) {
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
Target target = new Target();
|
||||
if (node.has("Arn")) {
|
||||
target.setArn(node.get("Arn").asText());
|
||||
}
|
||||
if (node.has("RoleArn")) {
|
||||
target.setRoleArn(node.get("RoleArn").asText());
|
||||
}
|
||||
if (node.has("Input") && !node.get("Input").isNull()) {
|
||||
target.setInput(node.get("Input").asText());
|
||||
}
|
||||
if (node.has("RetryPolicy") && !node.get("RetryPolicy").isNull()) {
|
||||
JsonNode rpNode = node.get("RetryPolicy");
|
||||
RetryPolicy rp = new RetryPolicy();
|
||||
if (rpNode.has("MaximumEventAgeInSeconds") && !rpNode.get("MaximumEventAgeInSeconds").isNull()) {
|
||||
rp.setMaximumEventAgeInSeconds(rpNode.get("MaximumEventAgeInSeconds").asInt());
|
||||
}
|
||||
if (rpNode.has("MaximumRetryAttempts") && !rpNode.get("MaximumRetryAttempts").isNull()) {
|
||||
rp.setMaximumRetryAttempts(rpNode.get("MaximumRetryAttempts").asInt());
|
||||
}
|
||||
target.setRetryPolicy(rp);
|
||||
}
|
||||
if (node.has("DeadLetterConfig") && !node.get("DeadLetterConfig").isNull()) {
|
||||
JsonNode dlcNode = node.get("DeadLetterConfig");
|
||||
DeadLetterConfig dlc = new DeadLetterConfig();
|
||||
if (dlcNode.has("Arn") && !dlcNode.get("Arn").isNull()) {
|
||||
dlc.setArn(dlcNode.get("Arn").asText());
|
||||
}
|
||||
target.setDeadLetterConfig(dlc);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, String> parseTags(String body) throws JsonProcessingException {
|
||||
if (body == null || body.isBlank()) {
|
||||
return Map.of();
|
||||
}
|
||||
Map<String, Object> parsed = objectMapper.readValue(body, Map.class);
|
||||
Object tagsObj = parsed.get("Tags");
|
||||
if (!(tagsObj instanceof List<?> tagList)) {
|
||||
return Map.of();
|
||||
}
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
for (Object entry : tagList) {
|
||||
if (entry instanceof Map<?, ?> tagMap) {
|
||||
Object key = tagMap.get("Key");
|
||||
Object value = tagMap.get("Value");
|
||||
if (key != null && value != null) {
|
||||
tags.put(key.toString(), value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
package io.github.hectorvent.floci.services.scheduler;
|
||||
|
||||
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.scheduler.model.Schedule;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.ScheduleGroup;
|
||||
import io.github.hectorvent.floci.services.scheduler.model.ScheduleRequest;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ApplicationScoped
|
||||
public class SchedulerService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SchedulerService.class);
|
||||
|
||||
// AWS EventBridge Scheduler name constraints: [0-9a-zA-Z-_.]+, 1-64 chars.
|
||||
private static final Pattern NAME_PATTERN = Pattern.compile("[0-9a-zA-Z\\-_.]{1,64}");
|
||||
private static final String DEFAULT_GROUP = "default";
|
||||
|
||||
private final StorageBackend<String, ScheduleGroup> groupStore;
|
||||
private final StorageBackend<String, Schedule> scheduleStore;
|
||||
private final RegionResolver regionResolver;
|
||||
|
||||
@Inject
|
||||
public SchedulerService(StorageFactory storageFactory, RegionResolver regionResolver) {
|
||||
this(
|
||||
storageFactory.create("scheduler", "scheduler-groups.json",
|
||||
new TypeReference<Map<String, ScheduleGroup>>() {}),
|
||||
storageFactory.create("scheduler", "scheduler-schedules.json",
|
||||
new TypeReference<Map<String, Schedule>>() {}),
|
||||
regionResolver
|
||||
);
|
||||
}
|
||||
|
||||
SchedulerService(StorageBackend<String, ScheduleGroup> groupStore,
|
||||
StorageBackend<String, Schedule> scheduleStore,
|
||||
RegionResolver regionResolver) {
|
||||
this.groupStore = groupStore;
|
||||
this.scheduleStore = scheduleStore;
|
||||
this.regionResolver = regionResolver;
|
||||
}
|
||||
|
||||
// ──────────────────────────── Schedule Groups ────────────────────────────
|
||||
|
||||
public ScheduleGroup getOrCreateDefaultGroup(String region) {
|
||||
String key = groupKey(region, DEFAULT_GROUP);
|
||||
return groupStore.get(key).orElseGet(() -> {
|
||||
Instant now = Instant.now();
|
||||
ScheduleGroup group = new ScheduleGroup(
|
||||
DEFAULT_GROUP,
|
||||
buildGroupArn(region, DEFAULT_GROUP),
|
||||
"ACTIVE",
|
||||
now,
|
||||
now
|
||||
);
|
||||
groupStore.put(key, group);
|
||||
return group;
|
||||
});
|
||||
}
|
||||
|
||||
public ScheduleGroup createScheduleGroup(String name, Map<String, String> tags, String region) {
|
||||
validateName(name);
|
||||
if (DEFAULT_GROUP.equals(name)) {
|
||||
throw new AwsException("ConflictException",
|
||||
"ScheduleGroup already exists: " + name, 409);
|
||||
}
|
||||
String key = groupKey(region, name);
|
||||
if (groupStore.get(key).isPresent()) {
|
||||
throw new AwsException("ConflictException",
|
||||
"ScheduleGroup already exists: " + name, 409);
|
||||
}
|
||||
Instant now = Instant.now();
|
||||
ScheduleGroup group = new ScheduleGroup(
|
||||
name,
|
||||
buildGroupArn(region, name),
|
||||
"ACTIVE",
|
||||
now,
|
||||
now
|
||||
);
|
||||
if (tags != null) {
|
||||
group.getTags().putAll(tags);
|
||||
}
|
||||
groupStore.put(key, group);
|
||||
LOG.infov("Created schedule group: {0} in region {1}", name, region);
|
||||
return group;
|
||||
}
|
||||
|
||||
public ScheduleGroup getScheduleGroup(String name, String region) {
|
||||
String effectiveName = (name == null || name.isBlank()) ? DEFAULT_GROUP : name;
|
||||
if (DEFAULT_GROUP.equals(effectiveName)) {
|
||||
return getOrCreateDefaultGroup(region);
|
||||
}
|
||||
validateName(effectiveName);
|
||||
return groupStore.get(groupKey(region, effectiveName))
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
|
||||
"ScheduleGroup not found: " + effectiveName, 404));
|
||||
}
|
||||
|
||||
public void deleteScheduleGroup(String name, String region) {
|
||||
validateName(name);
|
||||
if (DEFAULT_GROUP.equals(name)) {
|
||||
throw new AwsException("ValidationException",
|
||||
"Cannot delete the default schedule group.", 400);
|
||||
}
|
||||
String key = groupKey(region, name);
|
||||
groupStore.get(key)
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
|
||||
"ScheduleGroup not found: " + name, 404));
|
||||
|
||||
// Cascade-delete all schedules in this group (matches AWS behavior)
|
||||
String schedulePrefix = "schedule:" + region + ":" + name + ":";
|
||||
List<String> orphanKeys = scheduleStore.scan(k -> k.startsWith(schedulePrefix))
|
||||
.stream()
|
||||
.map(s -> scheduleKey(region, name, s.getName()))
|
||||
.toList();
|
||||
orphanKeys.forEach(scheduleStore::delete);
|
||||
|
||||
groupStore.delete(key);
|
||||
LOG.infov("Deleted schedule group: {0} (removed {1} schedules)", name, orphanKeys.size());
|
||||
}
|
||||
|
||||
public List<ScheduleGroup> listScheduleGroups(String namePrefix, String region) {
|
||||
getOrCreateDefaultGroup(region);
|
||||
String storagePrefix = "group:" + region + ":";
|
||||
return groupStore.scan(k -> {
|
||||
if (!k.startsWith(storagePrefix)) {
|
||||
return false;
|
||||
}
|
||||
if (namePrefix == null || namePrefix.isBlank()) {
|
||||
return true;
|
||||
}
|
||||
String groupName = k.substring(storagePrefix.length());
|
||||
return groupName.startsWith(namePrefix);
|
||||
});
|
||||
}
|
||||
|
||||
// ──────────────────────────── Schedules ────────────────────────────
|
||||
|
||||
public Schedule createSchedule(ScheduleRequest req, String region) {
|
||||
validateName(req.getName());
|
||||
validateScheduleRequest(req);
|
||||
String effectiveGroup = resolveAndValidateGroup(req.getGroupName());
|
||||
getScheduleGroup(effectiveGroup, region); // verify group exists
|
||||
|
||||
String key = scheduleKey(region, effectiveGroup, req.getName());
|
||||
if (scheduleStore.get(key).isPresent()) {
|
||||
throw new AwsException("ConflictException",
|
||||
"Schedule already exists: " + req.getName(), 409);
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setName(req.getName());
|
||||
schedule.setArn(buildScheduleArn(region, effectiveGroup, req.getName()));
|
||||
schedule.setGroupName(effectiveGroup);
|
||||
schedule.setState(req.getState() != null ? req.getState() : "ENABLED");
|
||||
schedule.setScheduleExpression(req.getScheduleExpression());
|
||||
schedule.setScheduleExpressionTimezone(req.getScheduleExpressionTimezone());
|
||||
schedule.setFlexibleTimeWindow(req.getFlexibleTimeWindow());
|
||||
schedule.setTarget(req.getTarget());
|
||||
schedule.setDescription(req.getDescription());
|
||||
schedule.setActionAfterCompletion(req.getActionAfterCompletion());
|
||||
schedule.setStartDate(req.getStartDate());
|
||||
schedule.setEndDate(req.getEndDate());
|
||||
schedule.setKmsKeyArn(req.getKmsKeyArn());
|
||||
schedule.setCreationDate(now);
|
||||
schedule.setLastModificationDate(now);
|
||||
|
||||
scheduleStore.put(key, schedule);
|
||||
LOG.infov("Created schedule: {0} in group {1}, region {2}", req.getName(), effectiveGroup, region);
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public Schedule getSchedule(String name, String groupName, String region) {
|
||||
validateName(name);
|
||||
String effectiveGroup = resolveAndValidateGroup(groupName);
|
||||
return scheduleStore.get(scheduleKey(region, effectiveGroup, name))
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
|
||||
"Schedule not found: " + name, 404));
|
||||
}
|
||||
|
||||
public Schedule updateSchedule(ScheduleRequest req, String region) {
|
||||
validateName(req.getName());
|
||||
validateScheduleRequest(req);
|
||||
String effectiveGroup = resolveAndValidateGroup(req.getGroupName());
|
||||
String key = scheduleKey(region, effectiveGroup, req.getName());
|
||||
Schedule existing = scheduleStore.get(key)
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
|
||||
"Schedule not found: " + req.getName(), 404));
|
||||
|
||||
Instant now = Instant.now();
|
||||
Schedule updated = new Schedule();
|
||||
updated.setName(req.getName());
|
||||
updated.setArn(existing.getArn());
|
||||
updated.setGroupName(effectiveGroup);
|
||||
updated.setState(req.getState() != null ? req.getState() : "ENABLED");
|
||||
updated.setScheduleExpression(req.getScheduleExpression());
|
||||
updated.setScheduleExpressionTimezone(req.getScheduleExpressionTimezone());
|
||||
updated.setFlexibleTimeWindow(req.getFlexibleTimeWindow());
|
||||
updated.setTarget(req.getTarget());
|
||||
updated.setDescription(req.getDescription());
|
||||
updated.setActionAfterCompletion(req.getActionAfterCompletion());
|
||||
updated.setStartDate(req.getStartDate());
|
||||
updated.setEndDate(req.getEndDate());
|
||||
updated.setKmsKeyArn(req.getKmsKeyArn());
|
||||
updated.setCreationDate(existing.getCreationDate());
|
||||
updated.setLastModificationDate(now);
|
||||
|
||||
scheduleStore.put(key, updated);
|
||||
LOG.infov("Updated schedule: {0} in group {1}", req.getName(), effectiveGroup);
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void deleteSchedule(String name, String groupName, String region) {
|
||||
validateName(name);
|
||||
String effectiveGroup = resolveAndValidateGroup(groupName);
|
||||
String key = scheduleKey(region, effectiveGroup, name);
|
||||
scheduleStore.get(key)
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
|
||||
"Schedule not found: " + name, 404));
|
||||
scheduleStore.delete(key);
|
||||
LOG.infov("Deleted schedule: {0} in group {1}", name, effectiveGroup);
|
||||
}
|
||||
|
||||
public List<Schedule> listSchedules(String groupName, String namePrefix, String state, String region) {
|
||||
String storagePrefix;
|
||||
if (groupName != null && !groupName.isBlank()) {
|
||||
validateName(groupName);
|
||||
storagePrefix = "schedule:" + region + ":" + groupName + ":";
|
||||
} else {
|
||||
storagePrefix = "schedule:" + region + ":";
|
||||
}
|
||||
return scheduleStore.scan(k -> {
|
||||
if (!k.startsWith(storagePrefix)) {
|
||||
return false;
|
||||
}
|
||||
// Extract schedule name (last segment after the last colon)
|
||||
String scheduleName = k.substring(k.lastIndexOf(':') + 1);
|
||||
if (namePrefix != null && !namePrefix.isBlank() && !scheduleName.startsWith(namePrefix)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).stream().filter(s -> {
|
||||
if (state != null && !state.isBlank()) {
|
||||
return state.equals(s.getState());
|
||||
}
|
||||
return true;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
|
||||
private void validateName(String name) {
|
||||
if (name == null || name.isBlank()) {
|
||||
throw new AwsException("ValidationException", "Name is required.", 400);
|
||||
}
|
||||
if (!NAME_PATTERN.matcher(name).matches()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"Name must match pattern [0-9a-zA-Z-_.]{1,64}: " + name, 400);
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveAndValidateGroup(String groupName) {
|
||||
if (groupName == null || groupName.isBlank()) {
|
||||
return DEFAULT_GROUP;
|
||||
}
|
||||
validateName(groupName);
|
||||
return groupName;
|
||||
}
|
||||
|
||||
private void validateScheduleRequest(ScheduleRequest req) {
|
||||
if (req.getScheduleExpression() == null || req.getScheduleExpression().isBlank()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'scheduleExpression' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
if (req.getFlexibleTimeWindow() == null) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'flexibleTimeWindow' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
String flexibleTimeWindowMode = req.getFlexibleTimeWindow().getMode();
|
||||
if (flexibleTimeWindowMode == null || flexibleTimeWindowMode.isBlank()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'flexibleTimeWindow.mode' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
flexibleTimeWindowMode = flexibleTimeWindowMode.trim();
|
||||
if (!"OFF".equals(flexibleTimeWindowMode) && !"FLEXIBLE".equals(flexibleTimeWindowMode)) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value '" + flexibleTimeWindowMode + "' at 'flexibleTimeWindow.mode' failed to satisfy constraint: Member must satisfy enum value set: [OFF, FLEXIBLE]", 400);
|
||||
}
|
||||
if ("FLEXIBLE".equals(flexibleTimeWindowMode)
|
||||
&& req.getFlexibleTimeWindow().getMaximumWindowInMinutes() == null) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'flexibleTimeWindow.maximumWindowInMinutes' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
if ("OFF".equals(flexibleTimeWindowMode)
|
||||
&& req.getFlexibleTimeWindow().getMaximumWindowInMinutes() != null) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value at 'flexibleTimeWindow.maximumWindowInMinutes' failed to satisfy constraint: Member must be null when flexibleTimeWindow.mode is OFF", 400);
|
||||
}
|
||||
if (req.getTarget() == null) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'target' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
if (req.getTarget().getArn() == null || req.getTarget().getArn().isBlank()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'target.arn' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
if (req.getTarget().getRoleArn() == null || req.getTarget().getRoleArn().isBlank()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'target.roleArn' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
if (req.getTarget().getDeadLetterConfig() != null
|
||||
&& (req.getTarget().getDeadLetterConfig().getArn() == null
|
||||
|| req.getTarget().getDeadLetterConfig().getArn().isBlank())) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at 'target.deadLetterConfig.arn' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildGroupArn(String region, String name) {
|
||||
return regionResolver.buildArn("scheduler", region, "schedule-group/" + name);
|
||||
}
|
||||
|
||||
private static String groupKey(String region, String name) {
|
||||
return "group:" + region + ":" + name;
|
||||
}
|
||||
|
||||
private String buildScheduleArn(String region, String groupName, String name) {
|
||||
return regionResolver.buildArn("scheduler", region, "schedule/" + groupName + "/" + name);
|
||||
}
|
||||
|
||||
private static String scheduleKey(String region, String groupName, String name) {
|
||||
return "schedule:" + region + ":" + groupName + ":" + name;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DeadLetterConfig {
|
||||
|
||||
private String arn;
|
||||
|
||||
public DeadLetterConfig() {}
|
||||
|
||||
public DeadLetterConfig(String arn) {
|
||||
this.arn = arn;
|
||||
}
|
||||
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class FlexibleTimeWindow {
|
||||
|
||||
private String mode;
|
||||
private Integer maximumWindowInMinutes;
|
||||
|
||||
public FlexibleTimeWindow() {}
|
||||
|
||||
public FlexibleTimeWindow(String mode, Integer maximumWindowInMinutes) {
|
||||
this.mode = mode;
|
||||
this.maximumWindowInMinutes = maximumWindowInMinutes;
|
||||
}
|
||||
|
||||
public String getMode() { return mode; }
|
||||
public void setMode(String mode) { this.mode = mode; }
|
||||
|
||||
public Integer getMaximumWindowInMinutes() { return maximumWindowInMinutes; }
|
||||
public void setMaximumWindowInMinutes(Integer maximumWindowInMinutes) { this.maximumWindowInMinutes = maximumWindowInMinutes; }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class RetryPolicy {
|
||||
|
||||
private Integer maximumEventAgeInSeconds;
|
||||
private Integer maximumRetryAttempts;
|
||||
|
||||
public RetryPolicy() {}
|
||||
|
||||
public RetryPolicy(Integer maximumEventAgeInSeconds, Integer maximumRetryAttempts) {
|
||||
this.maximumEventAgeInSeconds = maximumEventAgeInSeconds;
|
||||
this.maximumRetryAttempts = maximumRetryAttempts;
|
||||
}
|
||||
|
||||
public Integer getMaximumEventAgeInSeconds() { return maximumEventAgeInSeconds; }
|
||||
public void setMaximumEventAgeInSeconds(Integer maximumEventAgeInSeconds) { this.maximumEventAgeInSeconds = maximumEventAgeInSeconds; }
|
||||
|
||||
public Integer getMaximumRetryAttempts() { return maximumRetryAttempts; }
|
||||
public void setMaximumRetryAttempts(Integer maximumRetryAttempts) { this.maximumRetryAttempts = maximumRetryAttempts; }
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Schedule {
|
||||
|
||||
private String name;
|
||||
private String arn;
|
||||
private String groupName;
|
||||
private String state;
|
||||
private String scheduleExpression;
|
||||
private String scheduleExpressionTimezone;
|
||||
private FlexibleTimeWindow flexibleTimeWindow;
|
||||
private Target target;
|
||||
private String description;
|
||||
private String actionAfterCompletion;
|
||||
private Instant startDate;
|
||||
private Instant endDate;
|
||||
private String kmsKeyArn;
|
||||
private Instant creationDate;
|
||||
private Instant lastModificationDate;
|
||||
|
||||
public Schedule() {}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
|
||||
public String getGroupName() { return groupName; }
|
||||
public void setGroupName(String groupName) { this.groupName = groupName; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
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 FlexibleTimeWindow getFlexibleTimeWindow() { return flexibleTimeWindow; }
|
||||
public void setFlexibleTimeWindow(FlexibleTimeWindow flexibleTimeWindow) { this.flexibleTimeWindow = flexibleTimeWindow; }
|
||||
|
||||
public Target getTarget() { return target; }
|
||||
public void setTarget(Target target) { this.target = target; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getActionAfterCompletion() { return actionAfterCompletion; }
|
||||
public void setActionAfterCompletion(String actionAfterCompletion) { this.actionAfterCompletion = actionAfterCompletion; }
|
||||
|
||||
public Instant getStartDate() { return startDate; }
|
||||
public void setStartDate(Instant startDate) { this.startDate = startDate; }
|
||||
|
||||
public Instant getEndDate() { return endDate; }
|
||||
public void setEndDate(Instant endDate) { this.endDate = endDate; }
|
||||
|
||||
public String getKmsKeyArn() { return kmsKeyArn; }
|
||||
public void setKmsKeyArn(String kmsKeyArn) { this.kmsKeyArn = kmsKeyArn; }
|
||||
|
||||
public Instant getCreationDate() { return creationDate; }
|
||||
public void setCreationDate(Instant creationDate) { this.creationDate = creationDate; }
|
||||
|
||||
public Instant getLastModificationDate() { return lastModificationDate; }
|
||||
public void setLastModificationDate(Instant lastModificationDate) { this.lastModificationDate = lastModificationDate; }
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class ScheduleGroup {
|
||||
|
||||
private String name;
|
||||
private String arn;
|
||||
private String state;
|
||||
private Instant creationDate;
|
||||
private Instant lastModificationDate;
|
||||
private Map<String, String> tags = new HashMap<>();
|
||||
|
||||
public ScheduleGroup() {}
|
||||
|
||||
public ScheduleGroup(String name, String arn, String state,
|
||||
Instant creationDate, Instant lastModificationDate) {
|
||||
this.name = name;
|
||||
this.arn = arn;
|
||||
this.state = state;
|
||||
this.creationDate = creationDate;
|
||||
this.lastModificationDate = lastModificationDate;
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
public Instant getCreationDate() { return creationDate; }
|
||||
public void setCreationDate(Instant creationDate) { this.creationDate = creationDate; }
|
||||
|
||||
public Instant getLastModificationDate() { return lastModificationDate; }
|
||||
public void setLastModificationDate(Instant lastModificationDate) { this.lastModificationDate = lastModificationDate; }
|
||||
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags; }
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
public class ScheduleRequest {
|
||||
|
||||
private String name;
|
||||
private String groupName;
|
||||
private String scheduleExpression;
|
||||
private String scheduleExpressionTimezone;
|
||||
private FlexibleTimeWindow flexibleTimeWindow;
|
||||
private Target target;
|
||||
private String description;
|
||||
private String state;
|
||||
private String actionAfterCompletion;
|
||||
private Instant startDate;
|
||||
private Instant endDate;
|
||||
private String kmsKeyArn;
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getGroupName() { return groupName; }
|
||||
public void setGroupName(String groupName) { this.groupName = groupName; }
|
||||
|
||||
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 FlexibleTimeWindow getFlexibleTimeWindow() { return flexibleTimeWindow; }
|
||||
public void setFlexibleTimeWindow(FlexibleTimeWindow flexibleTimeWindow) { this.flexibleTimeWindow = flexibleTimeWindow; }
|
||||
|
||||
public Target getTarget() { return target; }
|
||||
public void setTarget(Target target) { this.target = target; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public String getState() { return state; }
|
||||
public void setState(String state) { this.state = state; }
|
||||
|
||||
public String getActionAfterCompletion() { return actionAfterCompletion; }
|
||||
public void setActionAfterCompletion(String actionAfterCompletion) { this.actionAfterCompletion = actionAfterCompletion; }
|
||||
|
||||
public Instant getStartDate() { return startDate; }
|
||||
public void setStartDate(Instant startDate) { this.startDate = startDate; }
|
||||
|
||||
public Instant getEndDate() { return endDate; }
|
||||
public void setEndDate(Instant endDate) { this.endDate = endDate; }
|
||||
|
||||
public String getKmsKeyArn() { return kmsKeyArn; }
|
||||
public void setKmsKeyArn(String kmsKeyArn) { this.kmsKeyArn = kmsKeyArn; }
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package io.github.hectorvent.floci.services.scheduler.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Target {
|
||||
|
||||
private String arn;
|
||||
private String roleArn;
|
||||
private String input;
|
||||
private RetryPolicy retryPolicy;
|
||||
private DeadLetterConfig deadLetterConfig;
|
||||
|
||||
public Target() {}
|
||||
|
||||
public Target(String arn, String roleArn, String input, RetryPolicy retryPolicy) {
|
||||
this.arn = arn;
|
||||
this.roleArn = roleArn;
|
||||
this.input = input;
|
||||
this.retryPolicy = retryPolicy;
|
||||
}
|
||||
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
|
||||
public String getRoleArn() { return roleArn; }
|
||||
public void setRoleArn(String roleArn) { this.roleArn = roleArn; }
|
||||
|
||||
public String getInput() { return input; }
|
||||
public void setInput(String input) { this.input = input; }
|
||||
|
||||
public RetryPolicy getRetryPolicy() { return retryPolicy; }
|
||||
public void setRetryPolicy(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; }
|
||||
|
||||
public DeadLetterConfig getDeadLetterConfig() { return deadLetterConfig; }
|
||||
public void setDeadLetterConfig(DeadLetterConfig deadLetterConfig) { this.deadLetterConfig = deadLetterConfig; }
|
||||
}
|
||||
Reference in new issue
Block a user