Light, fluffy, and always free - The AWS Local Emulator alternative
refactor(ses): split the configuration-set endpoints into SesConfigurationSetController (#3795)
Kenshin Okinakad0d787d8a3bf
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.javaindex e623b00e60..5d798189c6 100644--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java@@ -34,6 +34,7 @@ import io.github.hectorvent.floci.services.cloudfront.CloudFrontController;import io.github.hectorvent.floci.services.cloudfront.CloudFrontServingController;import io.github.hectorvent.floci.services.route53.Route53Controller;import io.github.hectorvent.floci.services.ses.SesAccountController;+import io.github.hectorvent.floci.services.ses.SesConfigurationSetController;import io.github.hectorvent.floci.services.ses.SesContactController;import io.github.hectorvent.floci.services.ses.SesController;import io.github.hectorvent.floci.services.ses.SesCvetController;@@ -295,10 +296,10 @@ public class ResolvedServiceCatalog {protocols(ServiceProtocol.REST_JSON, ServiceProtocol.QUERY),Set.of(), Set.of("email", "ses", "sesv2"), Set.of(),Set.of(SesController.class, SesAccountController.class,- SesContactController.class, SesCvetController.class,- SesDedicatedIpController.class, SesSuppressionController.class,- SesTagController.class, SesTemplateController.class,- SesTenantController.class)),+ SesConfigurationSetController.class, SesContactController.class,+ SesCvetController.class, SesDedicatedIpController.class,+ SesSuppressionController.class, SesTagController.class,+ SesTemplateController.class, SesTenantController.class)),descriptor("es", "opensearch", config.services().opensearch().enabled(), true,"opensearch", storageMode(config.storage().services().opensearch().mode(), config.storage().mode()),config.storage().services().opensearch().flushIntervalMs(), null, ServiceProtocol.REST_JSON,diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.javanew file mode 100644index 0000000000..b1fad82285--- /dev/null+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetController.java@@ -0,0 +1,529 @@+package io.github.hectorvent.floci.services.ses;++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 io.github.hectorvent.floci.core.common.AwsException;+import io.github.hectorvent.floci.core.common.RegionResolver;+import io.github.hectorvent.floci.services.ses.model.ArchivingOptions;+import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;+import io.github.hectorvent.floci.services.ses.model.DashboardOptions;+import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;+import io.github.hectorvent.floci.services.ses.model.EventDestination;+import io.github.hectorvent.floci.services.ses.model.GuardianOptions;+import io.github.hectorvent.floci.services.ses.model.SuppressionOptions;+import io.github.hectorvent.floci.services.ses.model.Tag;+import io.github.hectorvent.floci.services.ses.model.TrackingOptions;+import io.github.hectorvent.floci.services.ses.model.VdmOptions;+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.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.util.List;++import static io.github.hectorvent.floci.services.ses.SesV2Json.parseOptionString;+import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSendingEnabled;+import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSuppressedReasons;+import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;+import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;+import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;+import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObject;++/**+ * SES V2 configuration-set endpoints ({@code /v2/email/configuration-sets}), including the event+ * destinations, split out of {@link SesController}. Most operations call+ * {@link SesConfigurationSetService} directly; create, the tracking and delivery option setters+ * and delete go through the {@link SesService} facade, which supplies the verified-domain and+ * dedicated-pool probes those validations need and guards the delete against tenant associations.+ */+@Path("/v2/email")+@Produces(MediaType.APPLICATION_JSON)+@Consumes(MediaType.APPLICATION_JSON)+public class SesConfigurationSetController {++ private static final Logger LOG = Logger.getLogger(SesConfigurationSetController.class);++ private final SesConfigurationSetService configSetService;+ private final SesService sesService;+ private final RegionResolver regionResolver;+ private final ObjectMapper objectMapper;++ @Inject+ public SesConfigurationSetController(SesConfigurationSetService configSetService,+ SesService sesService, RegionResolver regionResolver,+ ObjectMapper objectMapper) {+ this.configSetService = configSetService;+ this.sesService = sesService;+ this.regionResolver = regionResolver;+ this.objectMapper = objectMapper;+ }++ @POST+ @Path("/configuration-sets")+ public Response createConfigurationSet(@Context HttpHeaders headers, String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = objectMapper.readTree(body);+ String name = request.path("ConfigurationSetName").asText(null);+ if (name == null || name.isBlank()) {+ throw new AwsException("BadRequestException", "ConfigurationSetName is required.", 400);+ }+ ConfigurationSet cs = new ConfigurationSet(name);+ List<Tag> parsedTags = parseTagsArray(request.path("Tags"));+ if (parsedTags != null) {+ cs.setTags(parsedTags);+ }+ JsonNode suppressionNode = request.path("SuppressionOptions");+ if (!suppressionNode.isMissingNode() && !suppressionNode.isNull()) {+ if (!suppressionNode.isObject()) {+ throw new AwsException("SerializationException", "Expected null", 400);+ }+ JsonNode reasonsNode = suppressionNode.path("SuppressedReasons");+ if (reasonsNode.isMissingNode() || reasonsNode.isNull()) {+ throw new AwsException("InternalFailure",+ "An internal failure has occurred.", 500);+ }+ SuppressionOptions options = new SuppressionOptions();+ options.setSuppressedReasons(parseSuppressedReasons(reasonsNode));+ cs.setSuppressionOptions(options);+ }+ JsonNode sendingNode = request.path("SendingOptions");+ if (!sendingNode.isMissingNode() && !sendingNode.isNull()) {+ if (!sendingNode.isObject()) {+ throw new AwsException("SerializationException", "Expected null", 400);+ }+ cs.setSendingEnabled(parseSendingEnabled(sendingNode.path("SendingEnabled")));+ }+ JsonNode reputationNode = request.path("ReputationOptions");+ if (!reputationNode.isMissingNode() && !reputationNode.isNull()) {+ requireOptionObject(reputationNode);+ Boolean rme = parseReputationMetricsEnabled(reputationNode.path("ReputationMetricsEnabled"));+ if (rme != null) {+ cs.setReputationMetricsEnabled(rme);+ }+ }+ JsonNode trackingNode = request.path("TrackingOptions");+ if (!trackingNode.isMissingNode() && !trackingNode.isNull()) {+ cs.setTrackingOptions(parseTrackingOptions(trackingNode));+ }+ JsonNode deliveryNode = request.path("DeliveryOptions");+ if (!deliveryNode.isMissingNode() && !deliveryNode.isNull()) {+ cs.setDeliveryOptions(parseDeliveryOptions(deliveryNode));+ }+ JsonNode archivingNode = request.path("ArchivingOptions");+ if (!archivingNode.isMissingNode() && !archivingNode.isNull()) {+ cs.setArchivingOptions(parseArchivingOptions(archivingNode));+ }+ JsonNode vdmNode = request.path("VdmOptions");+ if (!vdmNode.isMissingNode() && !vdmNode.isNull()) {+ cs.setVdmOptions(parseVdmOptions(vdmNode));+ }+ sesService.createConfigurationSet(cs, region);+ LOG.infov("SES V2 CreateConfigurationSet: {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (Exception e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @GET+ @Path("/configuration-sets")+ public Response listConfigurationSets(@Context HttpHeaders headers) {+ String region = regionResolver.resolveRegion(headers);+ List<ConfigurationSet> all = configSetService.list(region);+ ObjectNode result = objectMapper.createObjectNode();+ ArrayNode arr = result.putArray("ConfigurationSets");+ for (ConfigurationSet cs : all) {+ arr.add(cs.getName());+ }+ return Response.ok(result).build();+ }++ @GET+ @Path("/configuration-sets/{configurationSetName}")+ public Response getConfigurationSet(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name) {+ String region = regionResolver.resolveRegion(headers);+ try {+ ConfigurationSet cs = configSetService.get(name, region);+ ObjectNode result = objectMapper.createObjectNode();+ result.put("ConfigurationSetName", cs.getName());+ ArrayNode tags = result.putArray("Tags");+ for (Tag t : cs.getTags()) {+ ObjectNode tagNode = objectMapper.createObjectNode();+ tagNode.put("Key", t.key());+ tagNode.put("Value", t.value());+ tags.add(tagNode);+ }+ if (cs.getSuppressionOptions() != null) {+ ObjectNode suppressionNode = result.putObject("SuppressionOptions");+ ArrayNode reasons = suppressionNode.putArray("SuppressedReasons");+ for (String r : cs.getSuppressionOptions().getSuppressedReasons()) {+ reasons.add(r);+ }+ }+ ObjectNode sendingNode = result.putObject("SendingOptions");+ sendingNode.put("SendingEnabled", cs.isSendingEnabledEffective());+ // AWS always returns ReputationOptions (true by default), like SendingOptions.+ ObjectNode reputationNode = result.putObject("ReputationOptions");+ reputationNode.put("ReputationMetricsEnabled", cs.isReputationMetricsEnabledEffective());+ // The option models carry @JsonProperty/@JsonInclude(NON_NULL), so let+ // Jackson shape the response and omit unset members.+ if (cs.getTrackingOptions() != null) {+ result.set("TrackingOptions", objectMapper.valueToTree(cs.getTrackingOptions()));+ }+ if (cs.getDeliveryOptions() != null) {+ result.set("DeliveryOptions", objectMapper.valueToTree(cs.getDeliveryOptions()));+ }+ if (cs.getArchivingOptions() != null) {+ result.set("ArchivingOptions", objectMapper.valueToTree(cs.getArchivingOptions()));+ }+ if (cs.getVdmOptions() != null) {+ result.set("VdmOptions", objectMapper.valueToTree(cs.getVdmOptions()));+ }+ return Response.ok(result).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/suppression-options")+ public Response putConfigurationSetSuppressionOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = (body == null || body.isBlank())+ ? objectMapper.createObjectNode()+ : objectMapper.readTree(body);+ requireJsonObject(request);+ List<String> reasons = parseSuppressedReasons(request.path("SuppressedReasons"));+ configSetService.putSuppressionOptions(name, reasons, region);+ LOG.infov("SES V2 PutConfigurationSetSuppressionOptions: {0} on {1}", reasons, name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (JsonProcessingException e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/sending")+ public Response putConfigurationSetSendingOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ // Reuse the AWS-aligned SendingEnabled deserialization shared with CreateConfigurationSet:+ // absent -> false, string -> true, null/number -> SerializationException. An empty body+ // / {} therefore disables sending (200). Verified against real AWS.+ boolean enabled = parseSendingEnabled(+ readOptionBody(objectMapper, body).path("SendingEnabled"));+ configSetService.setSendingEnabled(name, enabled, region);+ LOG.infov("SES V2 PutConfigurationSetSendingOptions: {0} on {1}", enabled, name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/reputation-options")+ public Response putConfigurationSetReputationOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = readOptionBody(objectMapper, body);+ Boolean enabled = parseReputationMetricsEnabled(request.path("ReputationMetricsEnabled"));+ boolean effectiveEnabled = enabled != null && enabled;+ configSetService.setReputationMetricsEnabled(name, effectiveEnabled, region);+ LOG.infov("SES V2 PutConfigurationSetReputationOptions: {0} on {1}", effectiveEnabled, name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/tracking-options")+ public Response putConfigurationSetTrackingOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = readOptionBody(objectMapper, body);+ sesService.setConfigurationSetTrackingOptions(name, parseTrackingOptions(request), region);+ LOG.infov("SES V2 PutConfigurationSetTrackingOptions on {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/delivery-options")+ public Response putConfigurationSetDeliveryOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = readOptionBody(objectMapper, body);+ sesService.setConfigurationSetDeliveryOptions(name, parseDeliveryOptions(request), region);+ LOG.infov("SES V2 PutConfigurationSetDeliveryOptions on {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/archiving-options")+ public Response putConfigurationSetArchivingOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = readOptionBody(objectMapper, body);+ configSetService.setArchivingOptions(name, parseArchivingOptions(request), region);+ LOG.infov("SES V2 PutConfigurationSetArchivingOptions on {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/vdm-options")+ public Response putConfigurationSetVdmOptions(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = readOptionBody(objectMapper, body);+ JsonNode vdmNode = request.path("VdmOptions");+ VdmOptions options = (vdmNode.isMissingNode() || vdmNode.isNull())+ ? null : parseVdmOptions(vdmNode);+ configSetService.setVdmOptions(name, options, region);+ LOG.infov("SES V2 PutConfigurationSetVdmOptions on {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ /** Reject a non-object option block, mirroring the AWS deserialization layer. */+ private static void requireOptionObject(JsonNode node) {+ if (!node.isObject()) {+ throw new AwsException("SerializationException", "Expected null", 400);+ }+ }++ private static Boolean parseReputationMetricsEnabled(JsonNode node) {+ if (node.isMissingNode() || node.isNull()) {+ return null;+ }+ if (!node.isBoolean()) {+ throw new AwsException("BadRequestException",+ "ReputationMetricsEnabled must be a boolean.", 400);+ }+ return node.booleanValue();+ }++ private static TrackingOptions parseTrackingOptions(JsonNode node) {+ requireOptionObject(node);+ TrackingOptions t = new TrackingOptions();+ t.setCustomRedirectDomain(parseOptionString(node.path("CustomRedirectDomain"), "CustomRedirectDomain"));+ t.setHttpsPolicy(parseOptionString(node.path("HttpsPolicy"), "HttpsPolicy"));+ // An all-null block (e.g. an empty PUT body) clears the options rather+ // than persisting an empty object that GetConfigurationSet would echo.+ if (t.getCustomRedirectDomain() == null && t.getHttpsPolicy() == null) {+ return null;+ }+ return t;+ }++ private static DeliveryOptions parseDeliveryOptions(JsonNode node) {+ requireOptionObject(node);+ DeliveryOptions d = new DeliveryOptions();+ d.setTlsPolicy(parseOptionString(node.path("TlsPolicy"), "TlsPolicy"));+ d.setSendingPoolName(parseOptionString(node.path("SendingPoolName"), "SendingPoolName"));+ JsonNode max = node.path("MaxDeliverySeconds");+ if (!max.isMissingNode() && !max.isNull()) {+ if (!max.isNumber()) {+ throw new AwsException("BadRequestException",+ "MaxDeliverySeconds must be a number.", 400);+ }+ if (!max.isIntegralNumber()) {+ throw new AwsException("BadRequestException",+ "MaxDeliverySeconds must be an integer.", 400);+ }+ d.setMaxDeliverySeconds(max.asLong());+ }+ if (d.getTlsPolicy() == null && d.getSendingPoolName() == null && d.getMaxDeliverySeconds() == null) {+ return null;+ }+ return d;+ }++ private static ArchivingOptions parseArchivingOptions(JsonNode node) {+ requireOptionObject(node);+ ArchivingOptions a = new ArchivingOptions();+ a.setArchiveArn(parseOptionString(node.path("ArchiveArn"), "ArchiveArn"));+ if (a.getArchiveArn() == null) {+ return null;+ }+ return a;+ }++ private static VdmOptions parseVdmOptions(JsonNode node) {+ requireOptionObject(node);+ VdmOptions v = new VdmOptions();+ JsonNode dashboard = node.path("DashboardOptions");+ if (!dashboard.isMissingNode() && !dashboard.isNull()) {+ requireOptionObject(dashboard);+ String engagementMetrics = parseOptionString(dashboard.path("EngagementMetrics"), "EngagementMetrics");+ if (engagementMetrics != null) {+ DashboardOptions d = new DashboardOptions();+ d.setEngagementMetrics(engagementMetrics);+ v.setDashboardOptions(d);+ }+ }+ JsonNode guardian = node.path("GuardianOptions");+ if (!guardian.isMissingNode() && !guardian.isNull()) {+ requireOptionObject(guardian);+ String optimized = parseOptionString(guardian.path("OptimizedSharedDelivery"), "OptimizedSharedDelivery");+ if (optimized != null) {+ GuardianOptions g = new GuardianOptions();+ g.setOptimizedSharedDelivery(optimized);+ v.setGuardianOptions(g);+ }+ }+ // An all-null block (e.g. an empty PUT body) clears the options rather+ // than persisting an empty object that GetConfigurationSet would echo.+ if (v.getDashboardOptions() == null && v.getGuardianOptions() == null) {+ return null;+ }+ return v;+ }++ @DELETE+ @Path("/configuration-sets/{configurationSetName}")+ public Response deleteConfigurationSet(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String name) {+ String region = regionResolver.resolveRegion(headers);+ try {+ sesService.deleteConfigurationSet(name, region);+ LOG.infov("SES V2 DeleteConfigurationSet: {0}", name);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @POST+ @Path("/configuration-sets/{configurationSetName}/event-destinations")+ public Response createConfigurationSetEventDestination(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String configurationSetName,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = objectMapper.readTree(body);+ String edName = request.path("EventDestinationName").asText(null);+ if (edName == null || edName.isBlank()) {+ throw new AwsException("BadRequestException", "EventDestinationName is required.", 400);+ }+ JsonNode edNode = request.path("EventDestination");+ if (!edNode.isObject()) {+ throw new AwsException("BadRequestException", "EventDestination is required.", 400);+ }+ EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);+ configSetService.createEventDestination(configurationSetName, edName, dest, region);+ LOG.infov("SES V2 CreateConfigurationSetEventDestination: {0} on {1}", edName, configurationSetName);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (Exception e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @GET+ @Path("/configuration-sets/{configurationSetName}/event-destinations")+ public Response getConfigurationSetEventDestinations(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String configurationSetName) {+ String region = regionResolver.resolveRegion(headers);+ try {+ List<EventDestination> dests =+ configSetService.getEventDestinations(configurationSetName, region);+ ObjectNode result = objectMapper.createObjectNode();+ ArrayNode arr = result.putArray("EventDestinations");+ for (EventDestination ed : dests) {+ arr.add(objectMapper.valueToTree(ed));+ }+ return Response.ok(result).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }++ @PUT+ @Path("/configuration-sets/{configurationSetName}/event-destinations/{eventDestinationName}")+ public Response updateConfigurationSetEventDestination(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String configurationSetName,+ @PathParam("eventDestinationName") String eventDestinationName,+ String body) {+ String region = regionResolver.resolveRegion(headers);+ try {+ JsonNode request = objectMapper.readTree(body);+ JsonNode edNode = request.path("EventDestination");+ if (!edNode.isObject()) {+ throw new AwsException("BadRequestException", "EventDestination is required.", 400);+ }+ EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);+ configSetService.updateEventDestination(configurationSetName, eventDestinationName,+ dest, region);+ LOG.infov("SES V2 UpdateConfigurationSetEventDestination: {0} on {1}",+ eventDestinationName, configurationSetName);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ } catch (Exception e) {+ throw new AwsException("BadRequestException", e.getMessage(), 400);+ }+ }++ @DELETE+ @Path("/configuration-sets/{configurationSetName}/event-destinations/{eventDestinationName}")+ public Response deleteConfigurationSetEventDestination(@Context HttpHeaders headers,+ @PathParam("configurationSetName") String configurationSetName,+ @PathParam("eventDestinationName") String eventDestinationName) {+ String region = regionResolver.resolveRegion(headers);+ try {+ configSetService.deleteEventDestination(configurationSetName, eventDestinationName,+ region);+ LOG.infov("SES V2 DeleteConfigurationSetEventDestination: {0} on {1}",+ eventDestinationName, configurationSetName);+ return Response.ok(objectMapper.createObjectNode()).build();+ } catch (AwsException e) {+ throw remapV1Exception(e);+ }+ }+}diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.javaindex f2b7d7b84d..fd45008820 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java@@ -2,23 +2,14 @@ package io.github.hectorvent.floci.services.ses;import io.github.hectorvent.floci.core.common.AwsException;import io.github.hectorvent.floci.core.common.RegionResolver;-import io.github.hectorvent.floci.services.ses.model.ArchivingOptions;-import io.github.hectorvent.floci.services.ses.model.DashboardOptions;-import io.github.hectorvent.floci.services.ses.model.GuardianOptions;import io.github.hectorvent.floci.services.ses.model.BulkEmailEntry;import io.github.hectorvent.floci.services.ses.model.BulkEmailEntryResult;-import io.github.hectorvent.floci.services.ses.model.ConfigurationSet;-import io.github.hectorvent.floci.services.ses.model.DeliveryOptions;import io.github.hectorvent.floci.services.ses.model.EmailTemplate;-import io.github.hectorvent.floci.services.ses.model.EventDestination;import io.github.hectorvent.floci.services.ses.model.Identity;import io.github.hectorvent.floci.services.ses.model.ListManagementOptions;import io.github.hectorvent.floci.services.ses.model.MessageHeader;import io.github.hectorvent.floci.services.ses.model.MessageTag;-import io.github.hectorvent.floci.services.ses.model.SuppressionOptions;import io.github.hectorvent.floci.services.ses.model.Tag;-import io.github.hectorvent.floci.services.ses.model.TrackingOptions;-import io.github.hectorvent.floci.services.ses.model.VdmOptions;import com.fasterxml.jackson.databind.JsonNode;import com.fasterxml.jackson.databind.ObjectMapper;import com.fasterxml.jackson.databind.node.ArrayNode;@@ -43,11 +34,7 @@ import java.util.Collections;import java.util.List;import java.util.Map;-import static io.github.hectorvent.floci.services.ses.SesV2Json.parseOptionString;-import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSendingEnabled;-import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSuppressedReasons;import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;-import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObject;import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrAbsent;@@ -763,464 +750,6 @@ public class SesController {}}- // ──────────────────────── Configuration Sets ───────────────────────-- @POST- @Path("/configuration-sets")- public Response createConfigurationSet(@Context HttpHeaders headers, String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = objectMapper.readTree(body);- String name = request.path("ConfigurationSetName").asText(null);- if (name == null || name.isBlank()) {- throw new AwsException("BadRequestException", "ConfigurationSetName is required.", 400);- }- ConfigurationSet cs = new ConfigurationSet(name);- List<Tag> parsedTags = parseTagsArray(request.path("Tags"));- if (parsedTags != null) {- cs.setTags(parsedTags);- }- JsonNode suppressionNode = request.path("SuppressionOptions");- if (!suppressionNode.isMissingNode() && !suppressionNode.isNull()) {- if (!suppressionNode.isObject()) {- throw new AwsException("SerializationException", "Expected null", 400);- }- JsonNode reasonsNode = suppressionNode.path("SuppressedReasons");- if (reasonsNode.isMissingNode() || reasonsNode.isNull()) {- throw new AwsException("InternalFailure",- "An internal failure has occurred.", 500);- }- SuppressionOptions options = new SuppressionOptions();- options.setSuppressedReasons(parseSuppressedReasons(reasonsNode));- cs.setSuppressionOptions(options);- }- JsonNode sendingNode = request.path("SendingOptions");- if (!sendingNode.isMissingNode() && !sendingNode.isNull()) {- if (!sendingNode.isObject()) {- throw new AwsException("SerializationException", "Expected null", 400);- }- cs.setSendingEnabled(parseSendingEnabled(sendingNode.path("SendingEnabled")));- }- JsonNode reputationNode = request.path("ReputationOptions");- if (!reputationNode.isMissingNode() && !reputationNode.isNull()) {- requireOptionObject(reputationNode);- Boolean rme = parseReputationMetricsEnabled(reputationNode.path("ReputationMetricsEnabled"));- if (rme != null) {- cs.setReputationMetricsEnabled(rme);- }- }- JsonNode trackingNode = request.path("TrackingOptions");- if (!trackingNode.isMissingNode() && !trackingNode.isNull()) {- cs.setTrackingOptions(parseTrackingOptions(trackingNode));- }- JsonNode deliveryNode = request.path("DeliveryOptions");- if (!deliveryNode.isMissingNode() && !deliveryNode.isNull()) {- cs.setDeliveryOptions(parseDeliveryOptions(deliveryNode));- }- JsonNode archivingNode = request.path("ArchivingOptions");- if (!archivingNode.isMissingNode() && !archivingNode.isNull()) {- cs.setArchivingOptions(parseArchivingOptions(archivingNode));- }- JsonNode vdmNode = request.path("VdmOptions");- if (!vdmNode.isMissingNode() && !vdmNode.isNull()) {- cs.setVdmOptions(parseVdmOptions(vdmNode));- }- sesService.createConfigurationSet(cs, region);- LOG.infov("SES V2 CreateConfigurationSet: {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- } catch (Exception e) {- throw new AwsException("BadRequestException", e.getMessage(), 400);- }- }-- @GET- @Path("/configuration-sets")- public Response listConfigurationSets(@Context HttpHeaders headers) {- String region = regionResolver.resolveRegion(headers);- List<ConfigurationSet> all = sesService.listConfigurationSets(region);- ObjectNode result = objectMapper.createObjectNode();- ArrayNode arr = result.putArray("ConfigurationSets");- for (ConfigurationSet cs : all) {- arr.add(cs.getName());- }- return Response.ok(result).build();- }-- @GET- @Path("/configuration-sets/{configurationSetName}")- public Response getConfigurationSet(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name) {- String region = regionResolver.resolveRegion(headers);- try {- ConfigurationSet cs = sesService.getConfigurationSet(name, region);- ObjectNode result = objectMapper.createObjectNode();- result.put("ConfigurationSetName", cs.getName());- ArrayNode tags = result.putArray("Tags");- for (Tag t : cs.getTags()) {- ObjectNode tagNode = objectMapper.createObjectNode();- tagNode.put("Key", t.key());- tagNode.put("Value", t.value());- tags.add(tagNode);- }- if (cs.getSuppressionOptions() != null) {- ObjectNode suppressionNode = result.putObject("SuppressionOptions");- ArrayNode reasons = suppressionNode.putArray("SuppressedReasons");- for (String r : cs.getSuppressionOptions().getSuppressedReasons()) {- reasons.add(r);- }- }- ObjectNode sendingNode = result.putObject("SendingOptions");- sendingNode.put("SendingEnabled", cs.isSendingEnabledEffective());- // AWS always returns ReputationOptions (true by default), like SendingOptions.- ObjectNode reputationNode = result.putObject("ReputationOptions");- reputationNode.put("ReputationMetricsEnabled", cs.isReputationMetricsEnabledEffective());- // The option models carry @JsonProperty/@JsonInclude(NON_NULL), so let- // Jackson shape the response and omit unset members.- if (cs.getTrackingOptions() != null) {- result.set("TrackingOptions", objectMapper.valueToTree(cs.getTrackingOptions()));- }- if (cs.getDeliveryOptions() != null) {- result.set("DeliveryOptions", objectMapper.valueToTree(cs.getDeliveryOptions()));- }- if (cs.getArchivingOptions() != null) {- result.set("ArchivingOptions", objectMapper.valueToTree(cs.getArchivingOptions()));- }- if (cs.getVdmOptions() != null) {- result.set("VdmOptions", objectMapper.valueToTree(cs.getVdmOptions()));- }- return Response.ok(result).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/suppression-options")- public Response putConfigurationSetSuppressionOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = (body == null || body.isBlank())- ? objectMapper.createObjectNode()- : objectMapper.readTree(body);- requireJsonObject(request);- List<String> reasons = parseSuppressedReasons(request.path("SuppressedReasons"));- sesService.putConfigurationSetSuppressionOptions(name, reasons, region);- LOG.infov("SES V2 PutConfigurationSetSuppressionOptions: {0} on {1}", reasons, name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- } catch (com.fasterxml.jackson.core.JsonProcessingException e) {- throw new AwsException("BadRequestException", e.getMessage(), 400);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/sending")- public Response putConfigurationSetSendingOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- // Reuse the AWS-aligned SendingEnabled deserialization shared with CreateConfigurationSet:- // absent -> false, string -> true, null/number -> SerializationException. An empty body- // / {} therefore disables sending (200). Verified against real AWS.- boolean enabled = parseSendingEnabled(- readOptionBody(objectMapper, body).path("SendingEnabled"));- sesService.setConfigurationSetSendingEnabled(name, enabled, region);- LOG.infov("SES V2 PutConfigurationSetSendingOptions: {0} on {1}", enabled, name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/reputation-options")- public Response putConfigurationSetReputationOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = readOptionBody(objectMapper, body);- Boolean enabled = parseReputationMetricsEnabled(request.path("ReputationMetricsEnabled"));- boolean effectiveEnabled = enabled != null && enabled;- sesService.setConfigurationSetReputationOptions(name, effectiveEnabled, region);- LOG.infov("SES V2 PutConfigurationSetReputationOptions: {0} on {1}", effectiveEnabled, name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/tracking-options")- public Response putConfigurationSetTrackingOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = readOptionBody(objectMapper, body);- sesService.setConfigurationSetTrackingOptions(name, parseTrackingOptions(request), region);- LOG.infov("SES V2 PutConfigurationSetTrackingOptions on {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/delivery-options")- public Response putConfigurationSetDeliveryOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = readOptionBody(objectMapper, body);- sesService.setConfigurationSetDeliveryOptions(name, parseDeliveryOptions(request), region);- LOG.infov("SES V2 PutConfigurationSetDeliveryOptions on {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/archiving-options")- public Response putConfigurationSetArchivingOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = readOptionBody(objectMapper, body);- sesService.setConfigurationSetArchivingOptions(name, parseArchivingOptions(request), region);- LOG.infov("SES V2 PutConfigurationSetArchivingOptions on {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/vdm-options")- public Response putConfigurationSetVdmOptions(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = readOptionBody(objectMapper, body);- JsonNode vdmNode = request.path("VdmOptions");- VdmOptions options = (vdmNode.isMissingNode() || vdmNode.isNull())- ? null : parseVdmOptions(vdmNode);- sesService.setConfigurationSetVdmOptions(name, options, region);- LOG.infov("SES V2 PutConfigurationSetVdmOptions on {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- /** Reject a non-object option block, mirroring the AWS deserialization layer. */- private static void requireOptionObject(JsonNode node) {- if (!node.isObject()) {- throw new AwsException("SerializationException", "Expected null", 400);- }- }-- private static Boolean parseReputationMetricsEnabled(JsonNode node) {- if (node.isMissingNode() || node.isNull()) {- return null;- }- if (!node.isBoolean()) {- throw new AwsException("BadRequestException",- "ReputationMetricsEnabled must be a boolean.", 400);- }- return node.booleanValue();- }-- private static TrackingOptions parseTrackingOptions(JsonNode node) {- requireOptionObject(node);- TrackingOptions t = new TrackingOptions();- t.setCustomRedirectDomain(parseOptionString(node.path("CustomRedirectDomain"), "CustomRedirectDomain"));- t.setHttpsPolicy(parseOptionString(node.path("HttpsPolicy"), "HttpsPolicy"));- // An all-null block (e.g. an empty PUT body) clears the options rather- // than persisting an empty object that GetConfigurationSet would echo.- if (t.getCustomRedirectDomain() == null && t.getHttpsPolicy() == null) {- return null;- }- return t;- }-- private static DeliveryOptions parseDeliveryOptions(JsonNode node) {- requireOptionObject(node);- DeliveryOptions d = new DeliveryOptions();- d.setTlsPolicy(parseOptionString(node.path("TlsPolicy"), "TlsPolicy"));- d.setSendingPoolName(parseOptionString(node.path("SendingPoolName"), "SendingPoolName"));- JsonNode max = node.path("MaxDeliverySeconds");- if (!max.isMissingNode() && !max.isNull()) {- if (!max.isNumber()) {- throw new AwsException("BadRequestException",- "MaxDeliverySeconds must be a number.", 400);- }- if (!max.isIntegralNumber()) {- throw new AwsException("BadRequestException",- "MaxDeliverySeconds must be an integer.", 400);- }- d.setMaxDeliverySeconds(max.asLong());- }- if (d.getTlsPolicy() == null && d.getSendingPoolName() == null && d.getMaxDeliverySeconds() == null) {- return null;- }- return d;- }-- private static ArchivingOptions parseArchivingOptions(JsonNode node) {- requireOptionObject(node);- ArchivingOptions a = new ArchivingOptions();- a.setArchiveArn(parseOptionString(node.path("ArchiveArn"), "ArchiveArn"));- if (a.getArchiveArn() == null) {- return null;- }- return a;- }-- private static VdmOptions parseVdmOptions(JsonNode node) {- requireOptionObject(node);- VdmOptions v = new VdmOptions();- JsonNode dashboard = node.path("DashboardOptions");- if (!dashboard.isMissingNode() && !dashboard.isNull()) {- requireOptionObject(dashboard);- String engagementMetrics = parseOptionString(dashboard.path("EngagementMetrics"), "EngagementMetrics");- if (engagementMetrics != null) {- DashboardOptions d = new DashboardOptions();- d.setEngagementMetrics(engagementMetrics);- v.setDashboardOptions(d);- }- }- JsonNode guardian = node.path("GuardianOptions");- if (!guardian.isMissingNode() && !guardian.isNull()) {- requireOptionObject(guardian);- String optimized = parseOptionString(guardian.path("OptimizedSharedDelivery"), "OptimizedSharedDelivery");- if (optimized != null) {- GuardianOptions g = new GuardianOptions();- g.setOptimizedSharedDelivery(optimized);- v.setGuardianOptions(g);- }- }- // An all-null block (e.g. an empty PUT body) clears the options rather- // than persisting an empty object that GetConfigurationSet would echo.- if (v.getDashboardOptions() == null && v.getGuardianOptions() == null) {- return null;- }- return v;- }-- @DELETE- @Path("/configuration-sets/{configurationSetName}")- public Response deleteConfigurationSet(@Context HttpHeaders headers,- @PathParam("configurationSetName") String name) {- String region = regionResolver.resolveRegion(headers);- try {- sesService.deleteConfigurationSet(name, region);- LOG.infov("SES V2 DeleteConfigurationSet: {0}", name);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- // ──────────────── Configuration Set Event Destinations ────────────────-- @POST- @Path("/configuration-sets/{configurationSetName}/event-destinations")- public Response createConfigurationSetEventDestination(@Context HttpHeaders headers,- @PathParam("configurationSetName") String configurationSetName,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = objectMapper.readTree(body);- String edName = request.path("EventDestinationName").asText(null);- if (edName == null || edName.isBlank()) {- throw new AwsException("BadRequestException", "EventDestinationName is required.", 400);- }- JsonNode edNode = request.path("EventDestination");- if (!edNode.isObject()) {- throw new AwsException("BadRequestException", "EventDestination is required.", 400);- }- EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);- sesService.createConfigurationSetEventDestination(configurationSetName, edName, dest, region);- LOG.infov("SES V2 CreateConfigurationSetEventDestination: {0} on {1}", edName, configurationSetName);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- } catch (Exception e) {- throw new AwsException("BadRequestException", e.getMessage(), 400);- }- }-- @GET- @Path("/configuration-sets/{configurationSetName}/event-destinations")- public Response getConfigurationSetEventDestinations(@Context HttpHeaders headers,- @PathParam("configurationSetName") String configurationSetName) {- String region = regionResolver.resolveRegion(headers);- try {- List<EventDestination> dests =- sesService.getConfigurationSetEventDestinations(configurationSetName, region);- ObjectNode result = objectMapper.createObjectNode();- ArrayNode arr = result.putArray("EventDestinations");- for (EventDestination ed : dests) {- arr.add(objectMapper.valueToTree(ed));- }- return Response.ok(result).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-- @PUT- @Path("/configuration-sets/{configurationSetName}/event-destinations/{eventDestinationName}")- public Response updateConfigurationSetEventDestination(@Context HttpHeaders headers,- @PathParam("configurationSetName") String configurationSetName,- @PathParam("eventDestinationName") String eventDestinationName,- String body) {- String region = regionResolver.resolveRegion(headers);- try {- JsonNode request = objectMapper.readTree(body);- JsonNode edNode = request.path("EventDestination");- if (!edNode.isObject()) {- throw new AwsException("BadRequestException", "EventDestination is required.", 400);- }- EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);- sesService.updateConfigurationSetEventDestination(configurationSetName, eventDestinationName, dest, region);- LOG.infov("SES V2 UpdateConfigurationSetEventDestination: {0} on {1}",- eventDestinationName, configurationSetName);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- } catch (Exception e) {- throw new AwsException("BadRequestException", e.getMessage(), 400);- }- }-- @DELETE- @Path("/configuration-sets/{configurationSetName}/event-destinations/{eventDestinationName}")- public Response deleteConfigurationSetEventDestination(@Context HttpHeaders headers,- @PathParam("configurationSetName") String configurationSetName,- @PathParam("eventDestinationName") String eventDestinationName) {- String region = regionResolver.resolveRegion(headers);- try {- sesService.deleteConfigurationSetEventDestination(configurationSetName, eventDestinationName, region);- LOG.infov("SES V2 DeleteConfigurationSetEventDestination: {0} on {1}",- eventDestinationName, configurationSetName);- return Response.ok(objectMapper.createObjectNode()).build();- } catch (AwsException e) {- throw remapV1Exception(e);- }- }-// ──────────────────────────── Helpers ────────────────────────────private ObjectNode buildFullIdentityResponse(Identity identity, String region) {diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.javaindex 8bf3926c87..ccf21f3675 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesQueryHandler.java@@ -50,6 +50,7 @@ public class SesQueryHandler {private final SesTemplateService templateService;private final SesCvetService cvetService;private final SesAccountService accountService;+ private final SesConfigurationSetService configSetService;private final SesSentEmailService sentEmailService;private final ObjectMapper objectMapper;@@ -57,6 +58,7 @@ public class SesQueryHandler {public SesQueryHandler(SesService sesService, SesReceiptRuleService receiptRuleService,SesIdentityService identityService, SesTemplateService templateService,SesCvetService cvetService, SesAccountService accountService,+ SesConfigurationSetService configSetService,SesSentEmailService sentEmailService, ObjectMapper objectMapper) {this.sesService = sesService;this.receiptRuleService = receiptRuleService;@@ -64,6 +66,7 @@ public class SesQueryHandler {this.templateService = templateService;this.cvetService = cvetService;this.accountService = accountService;+ this.configSetService = configSetService;this.sentEmailService = sentEmailService;this.objectMapper = objectMapper;}@@ -774,7 +777,7 @@ public class SesQueryHandler {if (name == null || name.isBlank()) {throw new AwsException("InvalidParameterValue", "ConfigurationSetName is required.", 400);}- ConfigurationSet cs = sesService.getConfigurationSet(name, region);+ ConfigurationSet cs = configSetService.get(name, region);List<String> attrs = extractMembers(params, "ConfigurationSetAttributeNames");XmlBuilder xml = new XmlBuilder().start("ConfigurationSet")@@ -874,7 +877,7 @@ public class SesQueryHandler {}private Response handleListConfigurationSets(String region) {- List<ConfigurationSet> all = sesService.listConfigurationSets(region);+ List<ConfigurationSet> all = configSetService.list(region);XmlBuilder xml = new XmlBuilder().start("ConfigurationSets");for (ConfigurationSet cs : all) {xml.start("member").elem("Name", cs.getName()).end("member");@@ -897,7 +900,7 @@ public class SesQueryHandler {String configSet = requireParam(params, "ConfigurationSetName");String edName = requireParam(params, "EventDestination.Name");EventDestination dest = readEventDestination(params, "EventDestination");- sesService.createConfigurationSetEventDestination(configSet, edName, dest, region);+ configSetService.createEventDestination(configSet, edName, dest, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("CreateConfigurationSetEventDestination", AwsNamespaces.SES)).build();}@@ -907,7 +910,7 @@ public class SesQueryHandler {String configSet = requireParam(params, "ConfigurationSetName");String edName = requireParam(params, "EventDestination.Name");EventDestination dest = readEventDestination(params, "EventDestination");- sesService.updateConfigurationSetEventDestination(configSet, edName, dest, region);+ configSetService.updateEventDestination(configSet, edName, dest, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("UpdateConfigurationSetEventDestination", AwsNamespaces.SES)).build();}@@ -916,7 +919,7 @@ public class SesQueryHandler {String region) {String configSet = requireParam(params, "ConfigurationSetName");String edName = requireParam(params, "EventDestinationName");- sesService.deleteConfigurationSetEventDestination(configSet, edName, region);+ configSetService.deleteEventDestination(configSet, edName, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("DeleteConfigurationSetEventDestination", AwsNamespaces.SES)).build();}@@ -925,7 +928,7 @@ public class SesQueryHandler {String region) {String configSet = requireParam(params, "ConfigurationSetName");boolean enabled = parseXsdBoolean(params, "Enabled");- sesService.setConfigurationSetSendingEnabled(configSet, enabled, region);+ configSetService.setSendingEnabled(configSet, enabled, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("UpdateConfigurationSetSendingEnabled", AwsNamespaces.SES)).build();}@@ -951,7 +954,7 @@ public class SesQueryHandler {private Response handleDeleteConfigurationSetTrackingOptions(MultivaluedMap<String, String> params,String region) {String configSet = requireParam(params, "ConfigurationSetName");- sesService.deleteConfigurationSetTrackingOptions(configSet, region);+ configSetService.deleteTrackingOptions(configSet, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("DeleteConfigurationSetTrackingOptions", AwsNamespaces.SES)).build();}@@ -960,7 +963,7 @@ public class SesQueryHandler {String region) {String configSet = requireParam(params, "ConfigurationSetName");boolean enabled = parseXsdBoolean(params, "Enabled");- sesService.setConfigurationSetReputationOptions(configSet, enabled, region);+ configSetService.setReputationMetricsEnabled(configSet, enabled, region);return Response.ok(AwsQueryResponse.envelopeEmptyResult("UpdateConfigurationSetReputationMetricsEnabled", AwsNamespaces.SES)).build();}diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.javaindex 9392d0f757..dd1ca99f4f 100644--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java@@ -66,9 +66,10 @@ public class SesService {// Email templates extracted to SesTemplateService. The facade delegates; the templated-send path// reads via it, and ARN-dispatched tagging reads/writes via its find/save.private final SesTemplateService templateService;- // Configuration sets extracted to SesConfigurationSetService. The facade delegates; the- // cross-domain option validation (tracking's verified domain, delivery's dedicated pool), the- // send-path reads, and the ARN-dispatched tagging go through its get/find/save.+ // Configuration sets live in SesConfigurationSetService, which the v2 controller and the v1+ // handler call directly; the facade keeps the cross-domain option validation (tracking's+ // verified domain, delivery's dedicated pool), the tenant-guarded delete, the send-path reads,+ // and the ARN-dispatched tagging.private final SesConfigurationSetService configSetService;// Account suppression attributes + the per-address suppression list (two stores) extracted to// SesSuppressionService. The facade delegates; its send filters read via it.@@ -168,7 +169,7 @@ public class SesService {public Identity createEmailIdentity(String emailIdentity, String configurationSetName,List<Tag> tags, String region) {Runnable configurationSetExistsCheck = configurationSetName == null ? null- : () -> getConfigurationSet(configurationSetName, region);+ : () -> configSetService.get(configurationSetName, region);return identityService.createEmailIdentity(emailIdentity, configurationSetName, tags, region,configurationSetExistsCheck);}@@ -578,7 +579,7 @@ public class SesService {"Identity <" + identityValue + "> does not exist.", 404));boolean clearing = configurationSetName == null || configurationSetName.isEmpty();if (!clearing) {- getConfigurationSet(configurationSetName, region);+ configSetService.get(configurationSetName, region);}identity.setConfigurationSetName(clearing ? null : configurationSetName);identityService.save(identity, region);@@ -663,10 +664,6 @@ public class SesService {sentEmailService.clear();}- public void setConfigurationSetSendingEnabled(String configSetName, boolean enabled, String region) {- configSetService.setSendingEnabled(configSetName, enabled, region);- }-// ──────────────────────────── Templates ────────────────────────────// Email templates live in SesTemplateService, which the v2 controller and the v1 handler call@@ -735,7 +732,7 @@ public class SesService {+ region.toUpperCase(Locale.ROOT) + ": " + template.getFromEmailAddress(), 400);}if (configurationSetName != null && !configurationSetName.isBlank()) {- getConfigurationSet(configurationSetName, region);+ configSetService.get(configurationSetName, region);}// AWS registers the recipient as a pending-verification identity as part of sending the@@ -856,10 +853,6 @@ public class SesService {pool -> dedicatedIpService.dedicatedIpPoolExists(pool, region));}- public void setConfigurationSetReputationOptions(String configSetName, boolean metricsEnabled, String region) {- configSetService.setReputationMetricsEnabled(configSetName, metricsEnabled, region);- }-private boolean isVerifiedDomainIdentity(String domain, String region) {Identity identity = getIdentityVerificationAttributes(domain, region);return identity != null && "Success".equals(identity.getVerificationStatus())@@ -878,26 +871,6 @@ public class SesService {domain -> isVerifiedDomainIdentity(domain, region));}- public void deleteConfigurationSetTrackingOptions(String configSetName, String region) {- configSetService.deleteTrackingOptions(configSetName, region);- }-- public void setConfigurationSetArchivingOptions(String configSetName, ArchivingOptions options, String region) {- configSetService.setArchivingOptions(configSetName, options, region);- }-- public void setConfigurationSetVdmOptions(String configSetName, VdmOptions options, String region) {- configSetService.setVdmOptions(configSetName, options, region);- }-- public ConfigurationSet getConfigurationSet(String name, String region) {- return configSetService.get(name, region);- }-- public List<ConfigurationSet> listConfigurationSets(String region) {- return configSetService.list(region);- }-public void deleteConfigurationSet(String name, String region) {configSetService.get(name, region);tenantService.deleteBackingResource(SesTenantService.RESOURCE_TYPE_CONFIGURATION_SET, name,@@ -1123,30 +1096,6 @@ public class SesService {}}- public void createConfigurationSetEventDestination(String configSetName, String eventDestinationName,- EventDestination dest, String region) {- configSetService.createEventDestination(configSetName, eventDestinationName, dest, region);- }-- public List<EventDestination> getConfigurationSetEventDestinations(String configSetName, String region) {- return configSetService.getEventDestinations(configSetName, region);- }-- public void updateConfigurationSetEventDestination(String configSetName, String eventDestinationName,- EventDestination dest, String region) {- configSetService.updateEventDestination(configSetName, eventDestinationName, dest, region);- }-- public void deleteConfigurationSetEventDestination(String configSetName, String eventDestinationName,- String region) {- configSetService.deleteEventDestination(configSetName, eventDestinationName, region);- }-- public void putConfigurationSetSuppressionOptions(String configSetName,- List<String> reasons, String region) {- configSetService.putSuppressionOptions(configSetName, reasons, region);- }-/*** Returns the effective suppression reasons for a send that is using* {@code configurationSetName}. Per the AWS V2 contract, a configuration@@ -1159,7 +1108,7 @@ public class SesService {*/public List<String> getEffectiveSuppressedReasons(String configurationSetName, String region) {if (configurationSetName != null && !configurationSetName.isBlank()) {- ConfigurationSet cs = getConfigurationSet(configurationSetName, region);+ ConfigurationSet cs = configSetService.get(configurationSetName, region);SuppressionOptions options = cs.getSuppressionOptions();if (options != null) {return List.copyOf(options.getSuppressedReasons());diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.javaindex 6c0900bcc3..91d30fd67c 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java@@ -40,6 +40,9 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {@InjectSesSuppressionService suppressionService;+ @Inject+ SesConfigurationSetService configSetService;+@Test@Order(1)void createConfigurationSet() {@@ -234,7 +237,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {.then().statusCode(200);- sesService.putConfigurationSetSuppressionOptions(csBounceOnly, List.of("BOUNCE"), REGION);+ configSetService.putSuppressionOptions(csBounceOnly, List.of("BOUNCE"), REGION);List<String> effective = sesService.getEffectiveSuppressedReasons(csBounceOnly, REGION);assertEquals(List.of("BOUNCE"), effective);@@ -253,7 +256,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {.then().statusCode(200);- sesService.putConfigurationSetSuppressionOptions(csEmpty, List.of(), REGION);+ configSetService.putSuppressionOptions(csEmpty, List.of(), REGION);List<String> effective = sesService.getEffectiveSuppressedReasons(csEmpty, REGION);assertTrue(effective.isEmpty(),diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.javaindex 5a6f36f543..a69f7701ee 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceSmtpTest.java@@ -22,6 +22,7 @@ class SesServiceSmtpTest {@Mock SmtpRelay smtpRelay;private SesService service;+ private SesConfigurationSetService configSets;private InMemoryStorage<String, SentEmail> emailStore;@BeforeEach@@ -29,6 +30,7 @@ class SesServiceSmtpTest {SesServiceTestBuilder builder = SesServiceTestBuilder.create().smtpRelay(smtpRelay);emailStore = builder.emailStore();service = builder.build();+ configSets = builder.configSetService();}private SentEmail storedEmail(String messageId) {@@ -233,7 +235,7 @@ class SesServiceSmtpTest {// suppression list with reason=BOUNCE should still reach the SMTP relay.service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");service.createConfigurationSet(new ConfigurationSet("cs-no-suppression"), "us-east-1");- service.putConfigurationSetSuppressionOptions("cs-no-suppression", List.of(), "us-east-1");+ configSets.putSuppressionOptions("cs-no-suppression", List.of(), "us-east-1");service.sendEmail("[email protected]",List.of("[email protected]"), null, null, null, null,@@ -249,7 +251,7 @@ class SesServiceSmtpTest {// suppressed for COMPLAINT is NOT filtered when sending through this CS.service.putSuppressedDestination("us-east-1", "[email protected]", "COMPLAINT");service.createConfigurationSet(new ConfigurationSet("cs-bounce-only"), "us-east-1");- service.putConfigurationSetSuppressionOptions("cs-bounce-only", List.of("BOUNCE"), "us-east-1");+ configSets.putSuppressionOptions("cs-bounce-only", List.of("BOUNCE"), "us-east-1");service.sendEmail("[email protected]",List.of("[email protected]"), null, null, null, null,@@ -277,7 +279,7 @@ class SesServiceSmtpTest {void sendRawEmail_csOverridesAccountToEmptyList_suppressionListIsIgnored() {service.putSuppressedDestination("us-east-1", "[email protected]", "BOUNCE");service.createConfigurationSet(new ConfigurationSet("cs-no-suppression-raw"), "us-east-1");- service.putConfigurationSetSuppressionOptions("cs-no-suppression-raw", List.of(), "us-east-1");+ configSets.putSuppressionOptions("cs-no-suppression-raw", List.of(), "us-east-1");service.sendRawEmail("[email protected]",List.of("[email protected]"), "raw MIME", null, "cs-no-suppression-raw", List.of(), null,diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceTestBuilder.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceTestBuilder.javaindex 7525ff889b..799104d80d 100644--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceTestBuilder.java+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesServiceTestBuilder.java@@ -52,10 +52,11 @@ final class SesServiceTestBuilder {private Route53Service route53Service = null;private ObjectMapper objectMapper = new ObjectMapper();private Clock clock = Clock.systemUTC();- // Built by build(); exposed so tests can seed contacts and account suppression through the domain- // services now that the facade no longer forwards those operations.+ // Built by build(); exposed so tests can seed contacts, account suppression and configuration-set+ // options through the domain services now that the facade no longer forwards those operations.private SesContactService contactService;private SesSuppressionService suppressionService;+ private SesConfigurationSetService configSetService;static SesServiceTestBuilder create() {return new SesServiceTestBuilder();@@ -125,15 +126,23 @@ final class SesServiceTestBuilder {return suppressionService;}+ SesConfigurationSetService configSetService() {+ if (configSetService == null) {+ throw new IllegalStateException("call build() first");+ }+ return configSetService;+ }+SesService build() {contactService = new SesContactService(contactListStore, contactStore, clock);suppressionService = new SesSuppressionService(suppressionStore, accountSuppressionStore,new InMemoryStorage<>());+ configSetService = new SesConfigurationSetService(configSetStore);return new SesService(new SesIdentityService(identityStore, route53Service, clock),new SesSentEmailService(emailStore),new SesTemplateService(templateStore, objectMapper, new SecureRandom()),- new SesConfigurationSetService(configSetStore),+ configSetService,suppressionService,new SesDedicatedIpService(dedicatedIpPoolStore),contactService,