feat(ses): support v2 dedicated IP (IP-level) and scaling/warmup APIs (#3420)

Add the remaining SES v2 dedicated-IP operations on top of pool management:
GetDedicatedIps, GetDedicatedIp, PutDedicatedIpInPool,
PutDedicatedIpWarmupAttributes, PutDedicatedIpPoolScalingAttributes, and
PutAccountDedicatedIpWarmupAttributes.

SES has no API to create a dedicated IP (they are leased out-of-band or
auto-provisioned), so Floci models an account with no dedicated IPs:
GetDedicatedIps is empty and any IP-targeted operation returns NotFoundException
'Could not find dedicated IP <ip> under this account.', matching real AWS for an
account with no leased IPs (verified 2026-06-21). PutDedicatedIpPoolScalingAttributes
updates the pool's scaling mode, and PutAccountDedicatedIpWarmupAttributes stores
the account-level flag now reflected by GetAccount.

Add integration and AWS SDK v2 compatibility tests.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-11 12:01:13 -04:00
1 parent d96516dc70
commit e219ea409f
9 files changed
+604 -3

No files matched your search

@@ -64,6 +64,14 @@ public class SesAccountService {
LOG.infov("Updated account sending enabled for region {0}: {1}", region, enabled);
}
public boolean isDedicatedIpAutoWarmupEnabled(String region) {
return accountSettingsStore.get("dedicatedIpAutoWarmup::" + region).orElse(true);
}
public void setDedicatedIpAutoWarmup(String region, boolean enabled) {
accountSettingsStore.put("dedicatedIpAutoWarmup::" + region, enabled);
}
// VDM (Virtual Deliverability Manager) is opt-in and per region: GetAccount omits VdmAttributes
// entirely until PutAccountVdmAttributes is called for the region, so this returns empty when the
// region was never configured. The whole tuple is stored under one region key so GetAccount never
@@ -1881,6 +1881,36 @@ public class SesController {
return Response.ok(result).build();
}
@PUT
@Path("/dedicated-ip-pools/{poolName}/scaling")
public Response putDedicatedIpPoolScalingAttributes(@Context HttpHeaders headers,
@PathParam("poolName") String poolName,
String body) {
String region = regionResolver.resolveRegion(headers);
try {
JsonNode request = readOptionBody(body);
String scalingMode = parseOptionString(request.path("ScalingMode"), "ScalingMode");
sesService.putDedicatedIpPoolScalingAttributes(poolName, scalingMode, region);
LOG.infov("SES V2 PutDedicatedIpPoolScalingAttributes on {0}", poolName);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
}
}
// ──────────────────────── Dedicated IPs (IP-level) ────────────────────────
@GET
@Path("/dedicated-ips")
public Response getDedicatedIps(@Context HttpHeaders headers) {
regionResolver.resolveRegion(headers);
// Floci does not model leased dedicated IPs, so the account has none.
ObjectNode result = objectMapper.createObjectNode();
result.putArray("DedicatedIps");
result.putNull("NextToken");
return Response.ok(result).build();
}
@GET
@Path("/contact-lists/{contactListName}")
public Response getContactList(@Context HttpHeaders headers,
@@ -2160,6 +2190,59 @@ public class SesController {
return result;
}
@GET
@Path("/dedicated-ips/{ip}")
public Response getDedicatedIp(@Context HttpHeaders headers, @PathParam("ip") String ip) {
String region = regionResolver.resolveRegion(headers);
sesService.getDedicatedIp(ip, region);
return Response.ok(objectMapper.createObjectNode()).build();
}
@PUT
@Path("/dedicated-ips/{ip}/pool")
public Response putDedicatedIpInPool(@Context HttpHeaders headers,
@PathParam("ip") String ip, String body) {
String region = regionResolver.resolveRegion(headers);
try {
JsonNode request = readOptionBody(body);
String destinationPoolName = parseOptionString(
request.path("DestinationPoolName"), "DestinationPoolName");
sesService.putDedicatedIpInPool(ip, destinationPoolName, region);
LOG.infov("SES V2 PutDedicatedIpInPool: {0}", ip);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
}
}
@PUT
@Path("/dedicated-ips/{ip}/warmup")
public Response putDedicatedIpWarmupAttributes(@Context HttpHeaders headers,
@PathParam("ip") String ip, String body) {
String region = regionResolver.resolveRegion(headers);
try {
JsonNode request = readOptionBody(body);
sesService.putDedicatedIpWarmupAttributes(ip,
parseWarmupPercentage(request.path("WarmupPercentage")), region);
LOG.infov("SES V2 PutDedicatedIpWarmupAttributes: {0}", ip);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
}
}
// JSON-layer concern only: a non-integer WarmupPercentage is a SerializationException,
// matching AWS. Required/range validation lives in the service.
private static Integer parseWarmupPercentage(JsonNode node) {
if (node.isMissingNode() || node.isNull()) {
return null;
}
if (!node.isInt()) {
throw new AwsException("SerializationException", null, 400);
}
return node.intValue();
}
// ──────────────────────────── Account ────────────────────────────
@GET
@@ -2171,7 +2254,7 @@ public class SesController {
AccountSuppressionAttributes suppression = sesService.getAccountSuppressionAttributes(region);
ObjectNode result = objectMapper.createObjectNode();
result.put("DedicatedIpAutoWarmupEnabled", false);
result.put("DedicatedIpAutoWarmupEnabled", sesService.isAccountDedicatedIpAutoWarmupEnabled(region));
result.put("EnforcementStatus", "HEALTHY");
result.put("ProductionAccessEnabled", true);
result.put("SendingEnabled", sendingEnabled);
@@ -2373,6 +2456,25 @@ public class SesController {
400);
}
@PUT
@Path("/account/dedicated-ips/warmup")
public Response putAccountDedicatedIpWarmupAttributes(@Context HttpHeaders headers, String body) {
String region = regionResolver.resolveRegion(headers);
try {
JsonNode request = readOptionBody(body);
JsonNode enabledNode = request.path("AutoWarmupEnabled");
// AutoWarmupEnabled has a default of false: the SDK omits it when false, so a missing
// member is treated as false rather than rejected. A present value goes through the
// shared SES v2 boolean coercion (string→true, null/number/container→SerializationException).
boolean enabled = enabledNode.isMissingNode() ? false : coerceBoolean(enabledNode);
sesService.setAccountDedicatedIpAutoWarmup(region, enabled);
LOG.infov("SES V2 PutAccountDedicatedIpWarmupAttributes: {0}", enabled);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
}
}
@PUT
@Path("/account/suppression")
public Response putAccountSuppressionAttributes(@Context HttpHeaders headers, String body) {
@@ -30,8 +30,9 @@ public class SesDedicatedIpService {
private static final Set<String> SCALING_MODES = Set.of("STANDARD", "MANAGED");
private final StorageBackend<String, DedicatedIpPool> dedicatedIpPoolStore;
// Serializes pool check-then-write mutations (create/delete/tag) so concurrent creates for the
// same name can't both succeed and tagging can't resurrect a concurrently deleted pool.
// Serializes pool check-then-write mutations (create/delete/tag/scaling) so concurrent creates
// for the same name can't both succeed and tagging or scaling can't resurrect a concurrently
// deleted pool.
private final Object poolMutationLock = new Object();
@Inject
@@ -141,6 +142,69 @@ public class SesDedicatedIpService {
"No DedicatedIpPool present with name: " + poolName, 404);
}
// ──────────────────────── Dedicated IPs (IP-level) ────────────────────────
//
// SES has no API to create a dedicated IP: they are leased out-of-band
// (STANDARD) or auto-provisioned by AWS (MANAGED). Floci does not model that,
// so an account has no dedicated IPs: GetDedicatedIps is empty and any
// IP-targeted operation reports the IP as not found, matching real AWS for an
// account with no leased IPs (verified 2026-06-21).
private AwsException dedicatedIpNotFound(String ip) {
return new AwsException("NotFoundException",
"Could not find dedicated IP <" + ip + "> under this account.", 404);
}
public void getDedicatedIp(String ip, String region) {
// Unconditional, hence void: the account holds no dedicated IPs (see the section note
// above), so the lookup can only fail, the way real AWS answers with no leased IPs.
throw dedicatedIpNotFound(ip);
}
public void putDedicatedIpInPool(String ip, String destinationPoolName, String region) {
// AWS validates the required DestinationPoolName before it checks the IP.
if (destinationPoolName == null || destinationPoolName.isBlank()) {
throw new AwsException("BadRequestException", "Pool name can't be blank.", 400);
}
// AWS checks the IP before the destination pool.
throw dedicatedIpNotFound(ip);
}
// WarmupPercentage is a required integer in 0..100 (AWS returns -1 only in responses, for
// managed pools). AWS validates it before it looks up the IP; a non-integer value is a
// SerializationException raised at the controller's JSON layer before reaching here.
public void putDedicatedIpWarmupAttributes(String ip, Integer warmupPercentage, String region) {
if (warmupPercentage == null) {
throw new AwsException("BadRequestException", "Warmup Percentage can't be null.", 400);
}
if (warmupPercentage < 0 || warmupPercentage > 100) {
throw new AwsException("BadRequestException",
"Warmup Percentage must be between 0 and 100.", 400);
}
throw dedicatedIpNotFound(ip);
}
public void putDedicatedIpPoolScalingAttributes(String poolName, String scalingMode, String region) {
// AWS validates ScalingMode before it checks that the pool exists.
if (scalingMode == null || !SCALING_MODES.contains(scalingMode)) {
throw new AwsException("BadRequestException", "The ScalingMode parameter is invalid.", 400);
}
String key = dedicatedIpPoolKey(region, poolName);
synchronized (poolMutationLock) {
DedicatedIpPool pool = dedicatedIpPoolStore.get(key)
.orElseThrow(() -> new AwsException("NotFoundException",
"The requested pool <" + poolName + "> does not exist.", 404));
// AWS rejects downgrading a MANAGED pool back to STANDARD.
if ("MANAGED".equals(pool.getScalingMode()) && "STANDARD".equals(scalingMode)) {
throw new AwsException("BadRequestException", "The ScalingMode parameter is invalid.", 400);
}
pool.setScalingMode(scalingMode);
dedicatedIpPoolStore.put(key, pool);
}
LOG.infov("Updated ScalingMode on dedicated IP pool {0} in region {1}: {2}",
poolName, region, scalingMode);
}
private static String dedicatedIpPoolKey(String region, String name) {
return "dedicatedIpPool::" + region + "::" + name;
}
@@ -1338,6 +1338,34 @@ public class SesService {
// Dedicated IPs (IP-level) and pool scaling live in SesDedicatedIpService; the facade forwards.
public void getDedicatedIp(String ip, String region) {
dedicatedIpService.getDedicatedIp(ip, region);
}
public void putDedicatedIpInPool(String ip, String destinationPoolName, String region) {
dedicatedIpService.putDedicatedIpInPool(ip, destinationPoolName, region);
}
public void putDedicatedIpWarmupAttributes(String ip, Integer warmupPercentage, String region) {
dedicatedIpService.putDedicatedIpWarmupAttributes(ip, warmupPercentage, region);
}
public void putDedicatedIpPoolScalingAttributes(String poolName, String scalingMode, String region) {
dedicatedIpService.putDedicatedIpPoolScalingAttributes(poolName, scalingMode, region);
}
// Dedicated-IP auto-warmup is an account-level setting owned by SesAccountService.
public boolean isAccountDedicatedIpAutoWarmupEnabled(String region) {
return accountService.isDedicatedIpAutoWarmupEnabled(region);
}
public void setAccountDedicatedIpAutoWarmup(String region, boolean enabled) {
accountService.setDedicatedIpAutoWarmup(region, enabled);
}
public void createConfigurationSetEventDestination(String configSetName, String eventDestinationName,
EventDestination dest, String region) {
configSetService.createEventDestination(configSetName, eventDestinationName, dest, region);