feat(rum): add CloudWatch RUM app-monitor service (#1797)

* feat(rum): add CloudWatch RUM app-monitor service

Adds a minimal CloudWatch RUM service (restJson1) covering the app-monitor
lifecycle — CreateAppMonitor, GetAppMonitor, UpdateAppMonitor, DeleteAppMonitor,
ListAppMonitors — backed by an in-memory store.

Previously restJson1 RUM requests (e.g. POST /appmonitor) fell through to the S3
path-style catch-all (@Path("/{bucket}")) and returned an XML error that
restJson1 SDKs (and the CDK AwsCustomResource used for RUM AppMonitor custom
resources) cannot parse. Literal /appmonitor and /appmonitors paths take JAX-RS
precedence over S3's /{bucket} template (the same mechanism eks/mq use), so the
routes win with no extra routing wiring.

Verified with aws-cli 2.33.18 against a dev-mode emulator: CreateAppMonitor
returns an Id, GetAppMonitor/ListAppMonitors round-trip, DeleteAppMonitor then
GetAppMonitor returns ResourceNotFoundException.

* fix(rum): make monitor updates atomic

* fix(rum): align app monitor lifecycle with AWS

* chore: retry flaky Node compatibility check

* fix(rum): address app-monitor review feedback

---------

Co-authored-by: abanna <abanna@users.noreply.github.com>
This commit is contained in:
Alex Bannaandabanna authored and GitHub committed 2026-08-01 15:28:54 -05:00
1 parent 04873bfd09
commit aadc93e306
16 files changed
+1544 -4

No files matched your search

@@ -280,6 +280,7 @@ public interface EmulatorConfig {
TaggingStorageConfig tagging();
ElasticBeanstalkStorageConfig elasticbeanstalk();
CloudTrailStorageConfig cloudtrail();
RumStorageConfig rum();
}
interface SsmStorageConfig {
@@ -488,6 +489,13 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
interface RumStorageConfig {
Optional<String> mode();
@WithDefault("5000")
long flushIntervalMs();
}
interface CodeDeployStorageConfig {
Optional<String> mode();
@@ -585,6 +593,7 @@ public interface EmulatorConfig {
S3VectorsServiceConfig s3vectors();
IotServiceConfig iot();
IotDataServiceConfig iotdata();
RumServiceConfig rum();
}
interface IotServiceConfig {
@@ -613,6 +622,11 @@ public interface EmulatorConfig {
boolean enabled();
}
interface RumServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface LightsailServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -19,6 +19,7 @@ import io.github.hectorvent.floci.services.route53.Route53Controller;
import io.github.hectorvent.floci.services.ses.SesController;
import io.github.hectorvent.floci.services.appsync.AppSyncController;
import io.github.hectorvent.floci.services.rdsdata.RdsDataController;
import io.github.hectorvent.floci.services.rum.RumController;
import io.github.hectorvent.floci.services.s3vectors.S3VectorsController;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -393,7 +394,12 @@ public class ResolvedServiceCatalog {
descriptor("iotdata", "iotdata", config.services().iotdata().enabled(), true,
"iot", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("iotdata"), Set.of(), Set.of(IotDataController.class))
Set.of(), Set.of("iotdata"), Set.of(), Set.of(IotDataController.class)),
descriptor("rum", "rum", config.services().rum().enabled(), true,
"rum", storageMode(config.storage().services().rum().mode(), config.storage().mode()),
config.storage().services().rum().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("rum"), Set.of(), Set.of(RumController.class))
));
}
@@ -0,0 +1,129 @@
package io.github.hectorvent.floci.services.rum;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.services.rum.model.AppMonitor;
import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.POST;
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;
/**
* CloudWatch RUM (Smithy restJson1) — minimal app-monitor lifecycle.
*
* <p>Exists so the CDK RUM AppMonitor custom resource ({@code Custom::AWS} / AwsCustomResource) —
* which calls {@code rum:createAppMonitor}/{@code updateAppMonitor}/{@code deleteAppMonitor} — gets a
* JSON response. Without a {@code rum} service these requests fell through to the S3 catch-all
* ({@code @Path("/{bucket}")}) and returned an XML error, which the restJson1 SDK could not parse.
*
* <p>The literal {@code /appmonitor} paths take JAX-RS precedence over S3's {@code /{bucket}} and
* {@code /{bucket}/{key}} template routes, so these routes win with no extra routing wiring.
*/
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class RumController {
private final RumService service;
private final ObjectMapper objectMapper;
private final RegionResolver regionResolver;
@Inject
public RumController(RumService service, ObjectMapper objectMapper, RegionResolver regionResolver) {
this.service = service;
this.objectMapper = objectMapper;
this.regionResolver = regionResolver;
}
private JsonNode parse(String body) {
if (body == null || body.isBlank()) {
return objectMapper.createObjectNode();
}
try {
JsonNode request = objectMapper.readTree(body);
if (request == null || !request.isObject()) {
throw new AwsException("ValidationException", "Request body must be a JSON object.", 400);
}
return request;
} catch (AwsException e) {
throw e;
} catch (Exception e) {
throw new AwsException("ValidationException", "Request body is not valid JSON.", 400);
}
}
@POST
@Path("/appmonitor")
public Response createAppMonitor(@Context HttpHeaders headers, String body) {
JsonNode request = parse(body);
AppMonitor monitor = service.createAppMonitor(regionResolver.resolveRegion(headers), request);
ObjectNode response = objectMapper.createObjectNode();
response.put("Id", monitor.getId());
return Response.ok(response).build();
}
@GET
@Path("/appmonitor/{name}")
public Response getAppMonitor(@Context HttpHeaders headers, @PathParam("name") String name) {
AppMonitor monitor = service.getAppMonitor(regionResolver.resolveRegion(headers), name);
ObjectNode response = objectMapper.createObjectNode();
response.set("AppMonitor", objectMapper.valueToTree(monitor));
return Response.ok(response).build();
}
@PATCH
@Path("/appmonitor/{name}")
public Response updateAppMonitor(
@Context HttpHeaders headers, @PathParam("name") String name, String body) {
JsonNode request = parse(body);
service.updateAppMonitor(regionResolver.resolveRegion(headers), name, request);
return Response.ok().build();
}
@DELETE
@Path("/appmonitor/{name}")
public Response deleteAppMonitor(@Context HttpHeaders headers, @PathParam("name") String name) {
service.deleteAppMonitor(regionResolver.resolveRegion(headers), name);
return Response.ok().build();
}
@POST
@Path("/appmonitors")
@Consumes(MediaType.WILDCARD)
public Response listAppMonitors(
@Context HttpHeaders headers,
@QueryParam("maxResults") String maxResults,
@QueryParam("nextToken") String nextToken) {
RumService.Page page = service.listAppMonitors(
regionResolver.resolveRegion(headers), maxResults, nextToken);
ObjectNode response = objectMapper.createObjectNode();
var summaries = response.putArray("AppMonitorSummaries");
for (AppMonitor monitor : page.monitors()) {
ObjectNode summary = objectMapper.createObjectNode();
summary.put("Created", monitor.getCreated());
summary.put("Id", monitor.getId());
summary.put("LastModified", monitor.getLastModified());
summary.put("Name", monitor.getName());
summary.put("Platform", monitor.getPlatform());
summary.put("State", monitor.getState());
summaries.add(summary);
}
if (page.nextToken() != null) {
response.put("NextToken", page.nextToken());
}
return Response.ok(response).build();
}
}
@@ -0,0 +1,472 @@
package io.github.hectorvent.floci.services.rum;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.rum.model.AppMonitor;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/** CloudWatch RUM app-monitor lifecycle backed by the configured Floci storage mode. */
@ApplicationScoped
public class RumService {
private static final int DEFAULT_MAX_RESULTS = 50;
private static final int MAX_RESULTS = 100;
private static final String TOKEN_PREFIX = "rum:v1:";
private static final DateTimeFormatter TIMESTAMP_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss").withZone(ZoneOffset.UTC);
private static final Pattern NAME_PATTERN = Pattern.compile("(?!\\.)[.\\-_#A-Za-z0-9]+");
private static final Pattern DOMAIN_PATTERN = Pattern.compile(
"(localhost)$|^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
+ "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|"
+ "(?=^[a-zA-Z0-9.\\*-]{4,253}$)(?!.*\\.-)(?!.*-\\.)(?!.*\\.\\.)"
+ "(?!.*[^.]{64,})^(\\*\\.)?(?![-.\\*])[^\\*]{1,}\\."
+ "(\\*|(?!.*--)(?=.*[a-zA-Z])[^\\*]{1,}[^\\*-])$");
private static final Pattern TAG_KEY_PATTERN = Pattern.compile("(?!aws:)[a-zA-Z+-=._:/]+");
private static final Pattern S3_URI_PATTERN = Pattern.compile(
"s3://[a-z0-9][-.a-z0-9]{1,62}(?:/[-!_*'().a-z0-9A-Z]+(?:/[-!_*'().a-z0-9A-Z]+)*)?/?");
private static final Set<String> TELEMETRIES = Set.of("errors", "performance", "http");
private static final Set<String> ENABLED_DISABLED = Set.of("ENABLED", "DISABLED");
private static final Set<String> PLATFORMS = Set.of("Web", "Android", "iOS");
private final StorageBackend<String, AppMonitor> monitorStore;
@Inject
public RumService(StorageFactory storageFactory) {
this(storageFactory.create(
"rum",
"rum-app-monitors.json",
new TypeReference<Map<String, AppMonitor>>() {
}));
}
RumService(StorageBackend<String, AppMonitor> monitorStore) {
this.monitorStore = monitorStore;
}
public synchronized AppMonitor createAppMonitor(String region, JsonNode request) {
requireObject(request, "Request body");
String name = requireText(request, "Name");
validateName(name);
DomainSelection domains = readDomains(request);
JsonNode configuration = readConfiguration(request);
JsonNode customEvents = readCustomEvents(request);
JsonNode deobfuscation = readDeobfuscationConfiguration(request);
boolean cwLogEnabled = request.has("CwLogEnabled")
? requireBoolean(request, "CwLogEnabled")
: false;
Map<String, String> tags = readTags(request);
String platform = readPlatform(request);
String key = storageKey(region, name);
if (monitorStore.get(key).isPresent()) {
throw resourceConflict(name);
}
String now = timestamp();
AppMonitor monitor = new AppMonitor(
UUID.randomUUID().toString(),
name,
domains.domain(),
domains.domainList(),
"CREATED",
platform,
now,
now,
tags,
configuration,
dataStorage(cwLogEnabled),
customEvents,
deobfuscation);
monitorStore.put(key, monitor);
return monitor;
}
public AppMonitor getAppMonitor(String region, String name) {
validateName(name);
return monitorStore.get(storageKey(region, name)).orElseThrow(() -> resourceNotFound(name));
}
public synchronized void updateAppMonitor(String region, String name, JsonNode request) {
validateName(name);
requireObject(request, "Request body");
String key = storageKey(region, name);
AppMonitor current = monitorStore.get(key).orElseThrow(() -> resourceNotFound(name));
boolean domainChanged = request.has("Domain") || request.has("DomainList");
DomainSelection domains = domainChanged
? readDomains(request)
: new DomainSelection(current.getDomain(), current.getDomainList());
JsonNode configuration = request.has("AppMonitorConfiguration")
? mergeObjects(current.getAppMonitorConfiguration(), readConfiguration(request))
: current.getAppMonitorConfiguration();
JsonNode customEvents = request.has("CustomEvents")
? mergeObjects(current.getCustomEvents(), readCustomEvents(request))
: current.getCustomEvents();
JsonNode deobfuscation = request.has("DeobfuscationConfiguration")
? mergeObjects(current.getDeobfuscationConfiguration(), readDeobfuscationConfiguration(request))
: current.getDeobfuscationConfiguration();
JsonNode storage = request.has("CwLogEnabled")
? dataStorage(requireBoolean(request, "CwLogEnabled"))
: current.getDataStorage();
boolean changed = domainChanged
|| request.has("AppMonitorConfiguration")
|| request.has("CustomEvents")
|| request.has("DeobfuscationConfiguration")
|| request.has("CwLogEnabled");
if (!changed) {
return;
}
AppMonitor updated = new AppMonitor(
current.getId(),
current.getName(),
domains.domain(),
domains.domainList(),
current.getState(),
current.getPlatform(),
current.getCreated(),
timestamp(),
current.getTags(),
configuration,
storage,
customEvents,
deobfuscation);
monitorStore.put(key, updated);
}
public synchronized void deleteAppMonitor(String region, String name) {
validateName(name);
String key = storageKey(region, name);
if (monitorStore.get(key).isEmpty()) {
throw resourceNotFound(name);
}
monitorStore.delete(key);
}
public Page listAppMonitors(String region, String maxResultsValue, String nextToken) {
int maxResults = parseMaxResults(maxResultsValue);
List<AppMonitor> monitors = monitorStore.scan(key -> key.startsWith(region + "::"));
monitors.sort(Comparator.comparing(AppMonitor::getName));
int offset = decodeOffset(nextToken, monitors.size());
int end = Math.min(offset + maxResults, monitors.size());
String responseToken = end < monitors.size() ? encodeOffset(end) : null;
return new Page(monitors.subList(offset, end), responseToken);
}
private static String storageKey(String region, String name) {
return region + "::" + name;
}
private static String timestamp() {
return TIMESTAMP_FORMATTER.format(Instant.now());
}
private static DomainSelection readDomains(JsonNode request) {
boolean hasDomain = request.has("Domain");
boolean hasDomainList = request.has("DomainList");
if (hasDomain == hasDomainList) {
throw validation("Specify exactly one of Domain or DomainList.");
}
if (hasDomain) {
String domain = requireText(request, "Domain");
validateDomain(domain, "Domain");
return new DomainSelection(domain, null);
}
JsonNode node = request.get("DomainList");
if (node == null || !node.isArray() || node.size() < 1 || node.size() > 5) {
throw validation("DomainList must contain between 1 and 5 domains.");
}
List<String> domains = new ArrayList<>(node.size());
for (int i = 0; i < node.size(); i++) {
JsonNode domainNode = node.get(i);
if (!domainNode.isTextual()) {
throw validation("DomainList members must be strings.");
}
String domain = domainNode.textValue();
validateDomain(domain, "DomainList");
domains.add(domain);
}
return new DomainSelection(null, domains);
}
private static void validateName(String name) {
if (name == null || name.length() < 1 || name.length() > 255 || !NAME_PATTERN.matcher(name).matches()) {
throw validation("Name must match (?!\\.)[.\\-_#A-Za-z0-9]+ and contain at most 255 characters.");
}
}
private static void validateDomain(String domain, String field) {
if (domain == null || domain.length() < 1 || domain.length() > 253
|| !DOMAIN_PATTERN.matcher(domain).matches()) {
throw validation(field + " contains an invalid domain.");
}
}
private static JsonNode readConfiguration(JsonNode request) {
JsonNode configuration = optionalObject(request, "AppMonitorConfiguration");
if (configuration == null) {
return null;
}
requireOptionalBoolean(configuration, "AllowCookies");
requireOptionalBoolean(configuration, "EnableXRay");
requireOptionalText(configuration, "GuestRoleArn");
requireOptionalText(configuration, "IdentityPoolId");
if (configuration.has("SessionSampleRate")) {
JsonNode rate = configuration.get("SessionSampleRate");
if (!rate.isNumber() || rate.doubleValue() < 0 || rate.doubleValue() > 1) {
throw validation("SessionSampleRate must be between 0 and 1.");
}
}
if (configuration.has("ExcludedPages") && configuration.has("IncludedPages")) {
throw validation("ExcludedPages and IncludedPages cannot both be specified.");
}
validateStringArray(configuration, "ExcludedPages", 50, null);
validateStringArray(configuration, "IncludedPages", 50, null);
validateStringArray(configuration, "FavoritePages", 50, null);
validateStringArray(configuration, "Telemetries", Integer.MAX_VALUE, TELEMETRIES);
return configuration.deepCopy();
}
private static JsonNode readCustomEvents(JsonNode request) {
JsonNode customEvents = optionalObject(request, "CustomEvents");
if (customEvents == null) {
return null;
}
if (customEvents.has("Status")) {
String status = requireText(customEvents, "Status");
if (!ENABLED_DISABLED.contains(status)) {
throw validation("CustomEvents.Status must be ENABLED or DISABLED.");
}
}
return customEvents.deepCopy();
}
private static JsonNode readDeobfuscationConfiguration(JsonNode request) {
JsonNode configuration = optionalObject(request, "DeobfuscationConfiguration");
if (configuration == null) {
return null;
}
if (configuration.has("JavaScriptSourceMaps")) {
JsonNode sourceMaps = configuration.get("JavaScriptSourceMaps");
requireObject(sourceMaps, "JavaScriptSourceMaps");
String status = requireText(sourceMaps, "Status");
if (!ENABLED_DISABLED.contains(status)) {
throw validation("JavaScriptSourceMaps.Status must be ENABLED or DISABLED.");
}
if (sourceMaps.has("S3Uri")) {
String s3Uri = requireText(sourceMaps, "S3Uri");
if (s3Uri.length() > 1024 || !S3_URI_PATTERN.matcher(s3Uri).matches()) {
throw validation("JavaScriptSourceMaps.S3Uri is invalid.");
}
} else if ("ENABLED".equals(status)) {
throw validation("JavaScriptSourceMaps.S3Uri is required when Status is ENABLED.");
}
}
return configuration.deepCopy();
}
private static String readPlatform(JsonNode request) {
if (!request.has("Platform")) {
return "Web";
}
String platform = requireText(request, "Platform");
if (!PLATFORMS.contains(platform)) {
throw validation("Platform must be Web, Android, or iOS.");
}
return platform;
}
private static JsonNode mergeObjects(JsonNode current, JsonNode update) {
ObjectNode merged = current != null && current.isObject()
? (ObjectNode) current.deepCopy()
: JsonNodeFactory.instance.objectNode();
update.fields().forEachRemaining(entry -> {
JsonNode existingValue = merged.get(entry.getKey());
JsonNode updateValue = entry.getValue();
if (existingValue != null && existingValue.isObject() && updateValue.isObject()) {
merged.set(entry.getKey(), mergeObjects(existingValue, updateValue));
} else {
merged.set(entry.getKey(), updateValue.deepCopy());
}
});
return merged;
}
private static Map<String, String> readTags(JsonNode request) {
if (!request.has("Tags")) {
return null;
}
JsonNode tagsNode = request.get("Tags");
if (tagsNode == null || !tagsNode.isObject() || tagsNode.size() > 50) {
throw validation("Tags must be an object with at most 50 entries.");
}
Map<String, String> tags = new LinkedHashMap<>();
tagsNode.fields().forEachRemaining(entry -> {
String key = entry.getKey();
JsonNode valueNode = entry.getValue();
if (key.length() < 1 || key.length() > 128 || !TAG_KEY_PATTERN.matcher(key).matches()
|| !valueNode.isTextual() || valueNode.textValue().length() > 256) {
throw validation("Tags contains an invalid key or value.");
}
tags.put(key, valueNode.textValue());
});
return tags;
}
private static ObjectNode dataStorage(boolean enabled) {
ObjectNode cwLog = JsonNodeFactory.instance.objectNode();
cwLog.put("CwLogEnabled", enabled);
ObjectNode dataStorage = JsonNodeFactory.instance.objectNode();
dataStorage.set("CwLog", cwLog);
return dataStorage;
}
private static JsonNode optionalObject(JsonNode parent, String field) {
if (!parent.has(field)) {
return null;
}
JsonNode value = parent.get(field);
requireObject(value, field);
return value;
}
private static void requireObject(JsonNode value, String field) {
if (value == null || !value.isObject()) {
throw validation(field + " must be a JSON object.");
}
}
private static String requireText(JsonNode parent, String field) {
JsonNode value = parent.get(field);
if (value == null || !value.isTextual()) {
throw validation(field + " must be a string.");
}
return value.textValue();
}
private static boolean requireBoolean(JsonNode parent, String field) {
JsonNode value = parent.get(field);
if (value == null || !value.isBoolean()) {
throw validation(field + " must be a boolean.");
}
return value.booleanValue();
}
private static void requireOptionalBoolean(JsonNode parent, String field) {
if (parent.has(field)) {
requireBoolean(parent, field);
}
}
private static void requireOptionalText(JsonNode parent, String field) {
if (parent.has(field)) {
requireText(parent, field);
}
}
private static void validateStringArray(JsonNode parent, String field, int maxSize, Set<String> values) {
if (!parent.has(field)) {
return;
}
JsonNode array = parent.get(field);
if (!array.isArray() || array.size() > maxSize) {
throw validation(field + " must be an array with at most " + maxSize + " entries.");
}
for (JsonNode value : array) {
if (!value.isTextual() || (values != null && !values.contains(value.textValue()))) {
throw validation(field + " contains an invalid value.");
}
}
}
private static int parseMaxResults(String value) {
if (value == null) {
return DEFAULT_MAX_RESULTS;
}
try {
int parsed = Integer.parseInt(value);
if (parsed < 1 || parsed > MAX_RESULTS) {
throw validation("maxResults must be between 1 and 100.");
}
return parsed;
} catch (NumberFormatException e) {
throw validation("maxResults must be an integer between 1 and 100.");
}
}
private static int decodeOffset(String token, int resultSize) {
if (token == null) {
return 0;
}
try {
String decoded = new String(Base64.getUrlDecoder().decode(token), StandardCharsets.UTF_8);
if (!decoded.startsWith(TOKEN_PREFIX)) {
throw validation("nextToken is invalid.");
}
int offset = Integer.parseInt(decoded.substring(TOKEN_PREFIX.length()));
if (offset < 1 || offset >= resultSize) {
throw validation("nextToken is invalid.");
}
return offset;
} catch (IllegalArgumentException e) {
throw validation("nextToken is invalid.");
}
}
private static String encodeOffset(int offset) {
return Base64.getUrlEncoder().withoutPadding()
.encodeToString((TOKEN_PREFIX + offset).getBytes(StandardCharsets.UTF_8));
}
private static AwsException resourceConflict(String name) {
return new AwsException(
"ConflictException",
"App monitor " + name + " already exists.",
409,
Map.of("resourceName", name, "resourceType", "AppMonitor"));
}
private static AwsException resourceNotFound(String name) {
return new AwsException(
"ResourceNotFoundException",
"App monitor " + name + " does not exist.",
404,
Map.of("resourceName", name, "resourceType", "AppMonitor"));
}
private static AwsException validation(String message) {
return new AwsException("ValidationException", message, 400);
}
public record Page(List<AppMonitor> monitors, String nextToken) {
public Page {
monitors = List.copyOf(monitors);
}
}
private record DomainSelection(String domain, List<String> domainList) {
}
}
@@ -0,0 +1,170 @@
package io.github.hectorvent.floci.services.rum.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.List;
import java.util.Map;
/** A CloudWatch RUM app monitor. Serialized with AWS's UpperCamelCase member names. */
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class)
public class AppMonitor {
private String id;
private String name;
private String domain;
private List<String> domainList;
private String state;
private String platform;
private String created;
private String lastModified;
private Map<String, String> tags;
private JsonNode appMonitorConfiguration;
private JsonNode dataStorage;
private JsonNode customEvents;
private JsonNode deobfuscationConfiguration;
public AppMonitor() {
}
public AppMonitor(
String id,
String name,
String domain,
List<String> domainList,
String state,
String platform,
String created,
String lastModified,
Map<String, String> tags,
JsonNode appMonitorConfiguration,
JsonNode dataStorage,
JsonNode customEvents,
JsonNode deobfuscationConfiguration) {
this.id = id;
this.name = name;
this.domain = domain;
setDomainList(domainList);
this.state = state;
this.platform = platform;
this.created = created;
this.lastModified = lastModified;
setTags(tags);
setAppMonitorConfiguration(appMonitorConfiguration);
setDataStorage(dataStorage);
setCustomEvents(customEvents);
setDeobfuscationConfiguration(deobfuscationConfiguration);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public List<String> getDomainList() {
return domainList;
}
public void setDomainList(List<String> domainList) {
this.domainList = domainList == null ? null : List.copyOf(domainList);
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getLastModified() {
return lastModified;
}
public void setLastModified(String lastModified) {
this.lastModified = lastModified;
}
public Map<String, String> getTags() {
return tags;
}
public void setTags(Map<String, String> tags) {
this.tags = tags == null ? null : Map.copyOf(tags);
}
public JsonNode getAppMonitorConfiguration() {
return copy(appMonitorConfiguration);
}
public void setAppMonitorConfiguration(JsonNode appMonitorConfiguration) {
this.appMonitorConfiguration = copy(appMonitorConfiguration);
}
public JsonNode getDataStorage() {
return copy(dataStorage);
}
public void setDataStorage(JsonNode dataStorage) {
this.dataStorage = copy(dataStorage);
}
public JsonNode getCustomEvents() {
return copy(customEvents);
}
public void setCustomEvents(JsonNode customEvents) {
this.customEvents = copy(customEvents);
}
public JsonNode getDeobfuscationConfiguration() {
return copy(deobfuscationConfiguration);
}
public void setDeobfuscationConfiguration(JsonNode deobfuscationConfiguration) {
this.deobfuscationConfiguration = copy(deobfuscationConfiguration);
}
private static JsonNode copy(JsonNode value) {
return value == null ? null : value.deepCopy();
}
}