mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
refactor(ses): split the suppression-list and tag endpoints out of SesController (#3786)
The four /v2/email/suppression/addresses endpoints move byte-for-byte into SesSuppressionController and the three /v2/email/tags endpoints into SesTagController. Both keep calling the SesService facade: an optional TenantName routes each suppression operation to that tenant's own list across the suppression and tenant domains, and tagging parses the resource ARN and dispatches to whichever of the seven taggable domains owns it, so the facade loses nothing and both moves are pure size splits in the shape of LambdaTagController. Both classes are registered on the SES descriptor. No wire behavior changes.
This commit is contained in:
1 parent
d9abefb83f
commit
f83341e013
4 files changed
+268
-159
No files matched your search
@@ -38,6 +38,8 @@ import io.github.hectorvent.floci.services.ses.SesContactController;
|
||||
import io.github.hectorvent.floci.services.ses.SesController;
|
||||
import io.github.hectorvent.floci.services.ses.SesCvetController;
|
||||
import io.github.hectorvent.floci.services.ses.SesDedicatedIpController;
|
||||
import io.github.hectorvent.floci.services.ses.SesSuppressionController;
|
||||
import io.github.hectorvent.floci.services.ses.SesTagController;
|
||||
import io.github.hectorvent.floci.services.ses.SesTemplateController;
|
||||
import io.github.hectorvent.floci.services.appsync.AppSyncController;
|
||||
import io.github.hectorvent.floci.services.rdsdata.RdsDataController;
|
||||
@@ -293,7 +295,8 @@ public class ResolvedServiceCatalog {
|
||||
Set.of(), Set.of("email", "ses", "sesv2"), Set.of(),
|
||||
Set.of(SesController.class, SesAccountController.class,
|
||||
SesContactController.class, SesCvetController.class,
|
||||
SesDedicatedIpController.class, SesTemplateController.class)),
|
||||
SesDedicatedIpController.class, SesSuppressionController.class,
|
||||
SesTagController.class, SesTemplateController.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,
|
||||
|
||||
@@ -15,7 +15,6 @@ 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.SuppressedDestination;
|
||||
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.Tenant;
|
||||
@@ -35,7 +34,6 @@ import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
@@ -53,7 +51,6 @@ import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSendingEnab
|
||||
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.readRequiredStringField;
|
||||
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;
|
||||
@@ -1509,161 +1506,6 @@ public class SesController {
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────── Suppression list ───────────────────────────
|
||||
|
||||
@PUT
|
||||
@Path("/suppression/addresses")
|
||||
public Response putSuppressedDestination(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
if (body == null || body.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "Request body is required.", 400);
|
||||
}
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
requireJsonObject(request);
|
||||
String emailAddress = readRequiredStringField(request, "EmailAddress");
|
||||
String reason = readRequiredStringField(request, "Reason");
|
||||
String tenantName = stringMemberOrAbsent(request, "TenantName");
|
||||
sesService.putSuppressedDestination(region, emailAddress, reason, tenantName);
|
||||
LOG.infov("SES V2 PutSuppressedDestination: {0} ({1})", emailAddress, reason);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/suppression/addresses/{emailAddress}")
|
||||
public Response getSuppressedDestination(@Context HttpHeaders headers,
|
||||
@PathParam("emailAddress") String emailAddress,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
SuppressedDestination suppressed =
|
||||
sesService.getSuppressedDestination(region, emailAddress, tenantName);
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ObjectNode entry = result.putObject("SuppressedDestination");
|
||||
entry.put("EmailAddress", suppressed.getEmailAddress());
|
||||
entry.put("Reason", suppressed.getReason());
|
||||
if (suppressed.getLastUpdateTime() != null) {
|
||||
entry.put("LastUpdateTime", suppressed.getLastUpdateTime().getEpochSecond());
|
||||
}
|
||||
// AWS renders TenantName on every entry — an explicit null for account-level ones.
|
||||
entry.put("TenantName", suppressed.getTenantName());
|
||||
return Response.ok(result).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/suppression/addresses/{emailAddress}")
|
||||
public Response deleteSuppressedDestination(@Context HttpHeaders headers,
|
||||
@PathParam("emailAddress") String emailAddress,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
sesService.deleteSuppressedDestination(region, emailAddress, tenantName);
|
||||
LOG.infov("SES V2 DeleteSuppressedDestination: {0}", emailAddress);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/suppression/addresses")
|
||||
public Response listSuppressedDestinations(@Context HttpHeaders headers,
|
||||
@QueryParam("Reason") List<String> reasons,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<SuppressedDestination> entries;
|
||||
try {
|
||||
entries = sesService.listSuppressedDestinations(region, reasons, tenantName);
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ArrayNode summaries = result.putArray("SuppressedDestinationSummaries");
|
||||
for (SuppressedDestination s : entries) {
|
||||
ObjectNode item = objectMapper.createObjectNode();
|
||||
item.put("EmailAddress", s.getEmailAddress());
|
||||
item.put("Reason", s.getReason());
|
||||
if (s.getLastUpdateTime() != null) {
|
||||
item.put("LastUpdateTime", s.getLastUpdateTime().getEpochSecond());
|
||||
}
|
||||
summaries.add(item);
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
|
||||
// ──────────────────────────── Tags ───────────────────────────────
|
||||
|
||||
@POST
|
||||
@Path("/tags")
|
||||
public Response tagResource(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
if (body == null || body.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "Request body is required.", 400);
|
||||
}
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
if (arn == null || arn.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "ResourceArn is required.", 400);
|
||||
}
|
||||
List<Tag> tags = parseTagsArray(request.path("Tags"));
|
||||
if (tags == null) {
|
||||
throw new AwsException("BadRequestException", "Tags must be an array.", 400);
|
||||
}
|
||||
sesService.tagResource(arn, region, tags);
|
||||
LOG.infov("SES V2 TagResource: {0}", arn);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/tags")
|
||||
public Response untagResource(@Context HttpHeaders headers,
|
||||
@QueryParam("ResourceArn") String arn,
|
||||
@QueryParam("TagKeys") List<String> tagKeys) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
sesService.untagResource(arn, region, tagKeys);
|
||||
LOG.infov("SES V2 UntagResource: {0}", arn);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/tags")
|
||||
public Response listTagsForResource(@Context HttpHeaders headers,
|
||||
@QueryParam("ResourceArn") String arn) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
List<Tag> tags = sesService.listResourceTags(arn, region);
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ArrayNode arr = result.putArray("Tags");
|
||||
for (Tag t : tags) {
|
||||
ObjectNode tagNode = objectMapper.createObjectNode();
|
||||
tagNode.put("Key", t.key());
|
||||
tagNode.put("Value", t.value());
|
||||
arr.add(tagNode);
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
// ──────────────────────────── Helpers ────────────────────────────
|
||||
|
||||
private ObjectNode buildFullIdentityResponse(Identity identity, String region) {
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
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.SuppressedDestination;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readRequiredStringField;
|
||||
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.stringMemberOrAbsent;
|
||||
|
||||
/**
|
||||
* SES V2 suppression-list endpoints ({@code /v2/email/suppression/addresses}), split out of
|
||||
* {@link SesController}. Every operation keeps going through the {@link SesService} facade,
|
||||
* because an optional {@code TenantName} routes it to that tenant's own list, which spans the
|
||||
* suppression and tenant domains; the account-level suppression attributes live under
|
||||
* {@code /account}.
|
||||
*/
|
||||
@Path("/v2/email")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class SesSuppressionController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SesSuppressionController.class);
|
||||
|
||||
private final SesService sesService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public SesSuppressionController(SesService sesService, RegionResolver regionResolver,
|
||||
ObjectMapper objectMapper) {
|
||||
this.sesService = sesService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/suppression/addresses")
|
||||
public Response putSuppressedDestination(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
if (body == null || body.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "Request body is required.", 400);
|
||||
}
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
requireJsonObject(request);
|
||||
String emailAddress = readRequiredStringField(request, "EmailAddress");
|
||||
String reason = readRequiredStringField(request, "Reason");
|
||||
String tenantName = stringMemberOrAbsent(request, "TenantName");
|
||||
sesService.putSuppressedDestination(region, emailAddress, reason, tenantName);
|
||||
LOG.infov("SES V2 PutSuppressedDestination: {0} ({1})", emailAddress, reason);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new AwsException("BadRequestException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/suppression/addresses/{emailAddress}")
|
||||
public Response getSuppressedDestination(@Context HttpHeaders headers,
|
||||
@PathParam("emailAddress") String emailAddress,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
SuppressedDestination suppressed =
|
||||
sesService.getSuppressedDestination(region, emailAddress, tenantName);
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ObjectNode entry = result.putObject("SuppressedDestination");
|
||||
entry.put("EmailAddress", suppressed.getEmailAddress());
|
||||
entry.put("Reason", suppressed.getReason());
|
||||
if (suppressed.getLastUpdateTime() != null) {
|
||||
entry.put("LastUpdateTime", suppressed.getLastUpdateTime().getEpochSecond());
|
||||
}
|
||||
// AWS renders TenantName on every entry: an explicit null for account-level ones.
|
||||
entry.put("TenantName", suppressed.getTenantName());
|
||||
return Response.ok(result).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/suppression/addresses/{emailAddress}")
|
||||
public Response deleteSuppressedDestination(@Context HttpHeaders headers,
|
||||
@PathParam("emailAddress") String emailAddress,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
sesService.deleteSuppressedDestination(region, emailAddress, tenantName);
|
||||
LOG.infov("SES V2 DeleteSuppressedDestination: {0}", emailAddress);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/suppression/addresses")
|
||||
public Response listSuppressedDestinations(@Context HttpHeaders headers,
|
||||
@QueryParam("Reason") List<String> reasons,
|
||||
@QueryParam("TenantName") String tenantName) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<SuppressedDestination> entries;
|
||||
try {
|
||||
entries = sesService.listSuppressedDestinations(region, reasons, tenantName);
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ArrayNode summaries = result.putArray("SuppressedDestinationSummaries");
|
||||
for (SuppressedDestination s : entries) {
|
||||
ObjectNode item = objectMapper.createObjectNode();
|
||||
item.put("EmailAddress", s.getEmailAddress());
|
||||
item.put("Reason", s.getReason());
|
||||
if (s.getLastUpdateTime() != null) {
|
||||
item.put("LastUpdateTime", s.getLastUpdateTime().getEpochSecond());
|
||||
}
|
||||
summaries.add(item);
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
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.Tag;
|
||||
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.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;
|
||||
|
||||
/**
|
||||
* SES V2 resource-tag endpoints ({@code /v2/email/tags}), split out of {@link SesController}.
|
||||
* Every operation keeps going through the {@link SesService} facade, which parses the resource
|
||||
* ARN and dispatches to whichever of the seven taggable domains owns it; that cross-domain
|
||||
* dispatch is the facade's job by the survival rule, so this class is a pure size split like
|
||||
* {@code LambdaTagController}.
|
||||
*/
|
||||
@Path("/v2/email")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class SesTagController {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(SesTagController.class);
|
||||
|
||||
private final SesService sesService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public SesTagController(SesService sesService, RegionResolver regionResolver,
|
||||
ObjectMapper objectMapper) {
|
||||
this.sesService = sesService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/tags")
|
||||
public Response tagResource(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
if (body == null || body.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "Request body is required.", 400);
|
||||
}
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
String arn = request.path("ResourceArn").asText(null);
|
||||
if (arn == null || arn.isBlank()) {
|
||||
throw new AwsException("BadRequestException", "ResourceArn is required.", 400);
|
||||
}
|
||||
List<Tag> tags = parseTagsArray(request.path("Tags"));
|
||||
if (tags == null) {
|
||||
throw new AwsException("BadRequestException", "Tags must be an array.", 400);
|
||||
}
|
||||
sesService.tagResource(arn, region, tags);
|
||||
LOG.infov("SES V2 TagResource: {0}", arn);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new AwsException("BadRequestException", e.getMessage(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/tags")
|
||||
public Response untagResource(@Context HttpHeaders headers,
|
||||
@QueryParam("ResourceArn") String arn,
|
||||
@QueryParam("TagKeys") List<String> tagKeys) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
sesService.untagResource(arn, region, tagKeys);
|
||||
LOG.infov("SES V2 UntagResource: {0}", arn);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/tags")
|
||||
public Response listTagsForResource(@Context HttpHeaders headers,
|
||||
@QueryParam("ResourceArn") String arn) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
List<Tag> tags = sesService.listResourceTags(arn, region);
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
ArrayNode arr = result.putArray("Tags");
|
||||
for (Tag t : tags) {
|
||||
ObjectNode tagNode = objectMapper.createObjectNode();
|
||||
tagNode.put("Key", t.key());
|
||||
tagNode.put("Value", t.value());
|
||||
arr.add(tagNode);
|
||||
}
|
||||
return Response.ok(result).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user