feat(globalaccelerator): add the Global Accelerator management plane (#3378)

* feat(globalaccelerator): add the Global Accelerator management plane

Emulates the AWS Global Accelerator management plane over JSON 1.1 under the
GlobalAccelerator_V20180706 target prefix, signing name globalaccelerator:
accelerators, listeners, endpoint groups, accelerator attributes and resource
tags, 22 actions in all.

Global Accelerator is a global service, so ARNs carry an empty region segment
and listener and endpoint group ARNs extend the accelerator ARN. Nothing is
keyed by the signing region, so a caller that signs outside us-west-2 sees the
same accelerators. Accelerators report DEPLOYED and endpoints HEALTHY from the
first read, so SDK and Terraform waiters complete on their first poll.

Enum and range members are validated against the API model, and
UpdateAcceleratorAttributes rejects an update that would leave FlowLogsEnabled
true with no destination bucket.

* fix(globalaccelerator): enforce the list caps and HealthCheckPath format from the API model

The scalar ranges were already checked against globalaccelerator/2018-08-08, but the
array-count caps were not. PortRanges, EndpointConfigurations and PortOverrides each
declare max 10, and IpAddresses declares max 2 for the BYOIP case. All four were
unbounded. HealthCheckPath declares max 255 and the pattern
^/[-a-zA-Z0-9@:%_\+.~#?&/=]*$, which was not checked at all.

The new failures reuse InvalidArgumentException and the message shape the existing
scalar validations already use, so they are indistinguishable in kind from those.

* test(globalaccelerator): add the SDK compatibility test

Adds the globalaccelerator SDK module, a TestFixtures client factory and a
GlobalAcceleratorTest that drives accelerator, listener and endpoint group
lifecycles through the AWS SDK v2 client, including the new PortRanges cap.

---------

Co-authored-by: lex00 <artigues.dev@gmail.com>
This commit is contained in:
lex00andlex00 authored and GitHub committed 2026-09-11 16:53:22 -04:00
1 parent a91d7becd1
commit 2e79f5c766
26 files changed
+3084 -1

No files matched your search

@@ -740,6 +740,7 @@ public interface EmulatorConfig {
ControlTowerServiceConfig controltower();
ConnectServiceConfig connect();
CognitoIdentityServiceConfig cognitoidentity();
GlobalAcceleratorServiceConfig globalaccelerator();
ApsServiceConfig aps();
@@ -759,6 +760,11 @@ public interface EmulatorConfig {
boolean enabled();
}
interface GlobalAcceleratorServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface SsoAdminServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -51,6 +51,7 @@ import io.github.hectorvent.floci.services.kms.KmsJsonHandler;
import io.github.hectorvent.floci.services.secretsmanager.SecretsManagerJsonHandler;
import io.github.hectorvent.floci.services.organizations.OrganizationsJsonHandler;
import io.github.hectorvent.floci.services.cognitoidentity.CognitoIdentityJsonHandler;
import io.github.hectorvent.floci.services.globalaccelerator.GlobalAcceleratorJsonHandler;
import io.github.hectorvent.floci.services.route53resolver.Route53ResolverJsonHandler;
import io.github.hectorvent.floci.services.networkfirewall.NetworkFirewallJsonHandler;
import io.github.hectorvent.floci.services.servicecatalog.ServiceCatalogJsonHandler;
@@ -123,6 +124,7 @@ public class AwsJson11Controller {
private final LightsailJsonHandler lightsailJsonHandler;
private final Route53ResolverJsonHandler route53ResolverJsonHandler;
private final CognitoIdentityJsonHandler cognitoIdentityJsonHandler;
private final GlobalAcceleratorJsonHandler globalAcceleratorJsonHandler;
private final NetworkFirewallJsonHandler networkFirewallJsonHandler;
private final ServiceCatalogJsonHandler serviceCatalogJsonHandler;
private final CloudControlJsonHandler cloudControlJsonHandler;
@@ -175,6 +177,7 @@ public class AwsJson11Controller {
LightsailJsonHandler lightsailJsonHandler,
Route53ResolverJsonHandler route53ResolverJsonHandler,
CognitoIdentityJsonHandler cognitoIdentityJsonHandler,
GlobalAcceleratorJsonHandler globalAcceleratorJsonHandler,
NetworkFirewallJsonHandler networkFirewallJsonHandler,
ServiceCatalogJsonHandler serviceCatalogJsonHandler,
CloudControlJsonHandler cloudControlJsonHandler,
@@ -231,6 +234,7 @@ public class AwsJson11Controller {
this.lightsailJsonHandler = lightsailJsonHandler;
this.route53ResolverJsonHandler = route53ResolverJsonHandler;
this.cognitoIdentityJsonHandler = cognitoIdentityJsonHandler;
this.globalAcceleratorJsonHandler = globalAcceleratorJsonHandler;
this.networkFirewallJsonHandler = networkFirewallJsonHandler;
this.serviceCatalogJsonHandler = serviceCatalogJsonHandler;
this.cloudControlJsonHandler = cloudControlJsonHandler;
@@ -319,6 +323,10 @@ public class AwsJson11Controller {
case "lightsail" -> lightsailJsonHandler.handle(action, request, region);
case "route53resolver" -> route53ResolverJsonHandler.handle(action, request, region, regionResolver.getAccountId());
case "cognito-identity" -> cognitoIdentityJsonHandler.handle(action, request, region);
// Global Accelerator is a global service: its resources carry an empty ARN region
// segment and are never partitioned by the region the caller signed with, so the
// handler takes no region.
case "globalaccelerator" -> globalAcceleratorJsonHandler.handle(action, request);
case "network-firewall" -> networkFirewallJsonHandler.handle(
action, request, region, regionResolver.getAccountId());
case "servicecatalog" -> serviceCatalogJsonHandler.handle(
@@ -612,6 +612,11 @@ public class ResolvedServiceCatalog {
"cognitoidentity", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("AWSCognitoIdentityService."), Set.of("cognito-identity"), Set.of(), Set.of()),
descriptor("globalaccelerator", "globalaccelerator",
config.services().globalaccelerator().enabled(), true,
"globalaccelerator", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("GlobalAccelerator_V20180706."), Set.of("globalaccelerator"), Set.of(), Set.of()),
descriptor("network-firewall", "networkfirewall", config.services().networkfirewall().enabled(), true,
"networkfirewall", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
@@ -0,0 +1,229 @@
package io.github.hectorvent.floci.services.globalaccelerator;
import com.fasterxml.jackson.core.type.TypeReference;
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.services.globalaccelerator.model.EndpointGroup;
import io.github.hectorvent.floci.services.globalaccelerator.model.PortOverride;
import io.github.hectorvent.floci.services.globalaccelerator.model.PortRange;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Global Accelerator management plane, JSON 1.1 under the
* {@code GlobalAccelerator_V20180706} target prefix.
*
* <p>An operation that is not implemented falls through to {@code UnknownOperationException}
* rather than a stub success, so a caller fails fast instead of stranding a waiter.
*/
@ApplicationScoped
public class GlobalAcceleratorJsonHandler {
private final GlobalAcceleratorService service;
private final ObjectMapper mapper;
@Inject
public GlobalAcceleratorJsonHandler(GlobalAcceleratorService service, ObjectMapper mapper) {
this.service = service;
this.mapper = mapper;
}
public Response handle(String action, JsonNode request) {
return switch (action) {
case "CreateAccelerator" -> Response.ok(Map.of("Accelerator", service.createAccelerator(
text(request, "Name"),
text(request, "IpAddressType"),
stringList(request.path("IpAddresses")),
bool(request, "Enabled"),
tagMap(request.path("Tags"))))).build();
case "DescribeAccelerator" -> Response.ok(Map.of("Accelerator",
service.describeAccelerator(text(request, "AcceleratorArn")))).build();
case "UpdateAccelerator" -> Response.ok(Map.of("Accelerator", service.updateAccelerator(
text(request, "AcceleratorArn"),
text(request, "Name"),
text(request, "IpAddressType"),
stringList(request.path("IpAddresses")),
bool(request, "Enabled")))).build();
case "DeleteAccelerator" -> {
service.deleteAccelerator(text(request, "AcceleratorArn"));
yield Response.ok(Map.of()).build();
}
case "ListAccelerators" -> Response.ok(Map.of("Accelerators", service.listAccelerators())).build();
case "DescribeAcceleratorAttributes" -> Response.ok(Map.of("AcceleratorAttributes",
service.describeAcceleratorAttributes(text(request, "AcceleratorArn")))).build();
case "UpdateAcceleratorAttributes" -> Response.ok(Map.of("AcceleratorAttributes",
service.updateAcceleratorAttributes(
text(request, "AcceleratorArn"),
bool(request, "FlowLogsEnabled"),
text(request, "FlowLogsS3Bucket"),
text(request, "FlowLogsS3Prefix")))).build();
case "CreateListener" -> Response.ok(Map.of("Listener", service.createListener(
text(request, "AcceleratorArn"),
portRanges(request.path("PortRanges")),
text(request, "Protocol"),
text(request, "ClientAffinity")))).build();
case "DescribeListener" -> Response.ok(Map.of("Listener",
service.describeListener(text(request, "ListenerArn")))).build();
case "UpdateListener" -> Response.ok(Map.of("Listener", service.updateListener(
text(request, "ListenerArn"),
portRanges(request.path("PortRanges")),
text(request, "Protocol"),
text(request, "ClientAffinity")))).build();
case "DeleteListener" -> {
service.deleteListener(text(request, "ListenerArn"));
yield Response.ok(Map.of()).build();
}
case "ListListeners" -> Response.ok(Map.of("Listeners",
service.listListeners(text(request, "AcceleratorArn")))).build();
case "CreateEndpointGroup" -> Response.ok(Map.of("EndpointGroup", service.createEndpointGroup(
text(request, "ListenerArn"),
text(request, "EndpointGroupRegion"),
nodeOrNull(request, "EndpointConfigurations"),
floatValue(request, "TrafficDialPercentage"),
integer(request, "HealthCheckPort"),
text(request, "HealthCheckProtocol"),
text(request, "HealthCheckPath"),
integer(request, "HealthCheckIntervalSeconds"),
integer(request, "ThresholdCount"),
portOverrides(request.path("PortOverrides"))))).build();
case "DescribeEndpointGroup" -> Response.ok(Map.of("EndpointGroup",
service.describeEndpointGroup(text(request, "EndpointGroupArn")))).build();
case "UpdateEndpointGroup" -> Response.ok(Map.of("EndpointGroup", service.updateEndpointGroup(
text(request, "EndpointGroupArn"),
nodeOrNull(request, "EndpointConfigurations"),
floatValue(request, "TrafficDialPercentage"),
integer(request, "HealthCheckPort"),
text(request, "HealthCheckProtocol"),
text(request, "HealthCheckPath"),
integer(request, "HealthCheckIntervalSeconds"),
integer(request, "ThresholdCount"),
portOverrides(request.path("PortOverrides"))))).build();
case "DeleteEndpointGroup" -> {
service.deleteEndpointGroup(text(request, "EndpointGroupArn"));
yield Response.ok(Map.of()).build();
}
case "ListEndpointGroups" -> Response.ok(Map.of("EndpointGroups",
service.listEndpointGroups(text(request, "ListenerArn")))).build();
case "AddEndpoints" -> {
String endpointGroupArn = text(request, "EndpointGroupArn");
EndpointGroup group = service.addEndpoints(endpointGroupArn,
nodeOrNull(request, "EndpointConfigurations"));
yield Response.ok(Map.of(
"EndpointDescriptions", group.getEndpointDescriptions(),
"EndpointGroupArn", endpointGroupArn)).build();
}
case "RemoveEndpoints" -> {
service.removeEndpoints(text(request, "EndpointGroupArn"),
endpointIdentifiers(request.path("EndpointIdentifiers")));
yield Response.ok(Map.of()).build();
}
case "TagResource" -> {
service.tagResource(text(request, "ResourceArn"), tagMap(request.path("Tags")));
yield Response.ok(Map.of()).build();
}
case "UntagResource" -> {
service.untagResource(text(request, "ResourceArn"), stringList(request.path("TagKeys")));
yield Response.ok(Map.of()).build();
}
case "ListTagsForResource" -> Response.ok(Map.of("Tags",
tagList(service.listTagsForResource(text(request, "ResourceArn"))))).build();
default -> throw new AwsException("UnknownOperationException",
"Operation " + action + " is not supported by floci", 400);
};
}
private static String text(JsonNode request, String field) {
JsonNode node = request.path(field);
return node.isMissingNode() || node.isNull() ? null : node.asText();
}
private static Boolean bool(JsonNode request, String field) {
JsonNode node = request.path(field);
return node.isMissingNode() || node.isNull() ? null : node.asBoolean();
}
private static Integer integer(JsonNode request, String field) {
JsonNode node = request.path(field);
return node.isMissingNode() || node.isNull() ? null : node.asInt();
}
private static Float floatValue(JsonNode request, String field) {
JsonNode node = request.path(field);
return node.isMissingNode() || node.isNull() ? null : (float) node.asDouble();
}
private static JsonNode nodeOrNull(JsonNode request, String field) {
JsonNode node = request.path(field);
return node.isMissingNode() || node.isNull() ? null : node;
}
private static List<String> stringList(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
List<String> values = new ArrayList<>();
node.forEach(element -> values.add(element.asText()));
return values;
}
private static List<String> endpointIdentifiers(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
List<String> endpointIds = new ArrayList<>();
node.forEach(element -> endpointIds.add(element.path("EndpointId").asText()));
return endpointIds;
}
private List<PortRange> portRanges(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
return mapper.convertValue(node, new TypeReference<List<PortRange>>() {});
}
private List<PortOverride> portOverrides(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
return mapper.convertValue(node, new TypeReference<List<PortOverride>>() {});
}
private static Map<String, String> tagMap(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
Map<String, String> tags = new LinkedHashMap<>();
for (JsonNode tag : node) {
String key = tag.path("Key").asText(null);
if (key == null) {
throw new AwsException("InvalidArgumentException", "Every tag must carry a Key.", 400);
}
tags.put(key, tag.path("Value").asText(""));
}
return tags;
}
private ArrayNode tagList(Map<String, String> tags) {
ArrayNode list = mapper.createArrayNode();
tags.forEach((key, value) -> {
ObjectNode tag = list.addObject();
tag.put("Key", key);
tag.put("Value", value);
});
return list;
}
}
@@ -0,0 +1,672 @@
package io.github.hectorvent.floci.services.globalaccelerator;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.globalaccelerator.model.Accelerator;
import io.github.hectorvent.floci.services.globalaccelerator.model.AcceleratorAttributes;
import io.github.hectorvent.floci.services.globalaccelerator.model.EndpointDescription;
import io.github.hectorvent.floci.services.globalaccelerator.model.EndpointGroup;
import io.github.hectorvent.floci.services.globalaccelerator.model.IpSet;
import io.github.hectorvent.floci.services.globalaccelerator.model.Listener;
import io.github.hectorvent.floci.services.globalaccelerator.model.PortOverride;
import io.github.hectorvent.floci.services.globalaccelerator.model.PortRange;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
/**
* AWS Global Accelerator management plane.
*
* <p>Global Accelerator is a global service. Its ARNs carry an empty region segment
* ({@code arn:aws:globalaccelerator::<account>:accelerator/<id>}) and listener and endpoint
* group ARNs extend the accelerator ARN, which is how the real service expresses the
* parent/child relationship. Parent lookups therefore need no back-reference field: an
* accelerator's listeners are the stored ARNs prefixed by it. Nothing is keyed by region,
* so the signing region the SDK happens to use does not partition the state.
*
* <p>Accelerators are {@code DEPLOYED} and endpoints are {@code HEALTHY} as soon as a create
* returns, so provider waiters complete on their first poll. The static IP addresses come
* from the address ranges Global Accelerator advertises but route no traffic.
*/
@ApplicationScoped
public class GlobalAcceleratorService {
private static final Logger LOG = Logger.getLogger(GlobalAcceleratorService.class);
private static final String ID_ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
private static final String HEX = "0123456789abcdef";
private static final String STATUS_DEPLOYED = "DEPLOYED";
private static final String HEALTH_STATE_HEALTHY = "HEALTHY";
private static final String LISTENER_SEGMENT = "/listener/";
private static final String ENDPOINT_GROUP_SEGMENT = "/endpoint-group/";
private static final String DNS_SUFFIX = ".awsglobalaccelerator.com";
private static final String DUAL_STACK_DNS_SUFFIX = ".dualstack.awsglobalaccelerator.com";
private static final Set<String> IP_ADDRESS_TYPES = Set.of("IPV4", "DUAL_STACK");
private static final Set<String> PROTOCOLS = Set.of("TCP", "UDP");
private static final Set<String> CLIENT_AFFINITIES = Set.of("NONE", "SOURCE_IP");
private static final Set<String> HEALTH_CHECK_PROTOCOLS = Set.of("TCP", "HTTP", "HTTPS");
private static final int MAX_PORT_RANGES = 10;
private static final int MAX_ENDPOINT_CONFIGURATIONS = 10;
private static final int MAX_PORT_OVERRIDES = 10;
private static final int MAX_IP_ADDRESSES = 2;
private static final int MAX_HEALTH_CHECK_PATH_LENGTH = 255;
private static final Pattern HEALTH_CHECK_PATH_PATTERN =
Pattern.compile("^/[-a-zA-Z0-9@:%_\\+.~#?&/=]*$");
private final StorageBackend<String, Accelerator> accelerators;
private final StorageBackend<String, AcceleratorAttributes> acceleratorAttributes;
private final StorageBackend<String, Listener> listeners;
private final StorageBackend<String, EndpointGroup> endpointGroups;
private final StorageBackend<String, Map<String, String>> tags;
private final RegionResolver regionResolver;
@Inject
public GlobalAcceleratorService(StorageFactory storageFactory, RegionResolver regionResolver) {
this.accelerators = storageFactory.create("globalaccelerator", "globalaccelerator-accelerators.json",
new TypeReference<Map<String, Accelerator>>() {});
this.acceleratorAttributes = storageFactory.create("globalaccelerator",
"globalaccelerator-accelerator-attributes.json",
new TypeReference<Map<String, AcceleratorAttributes>>() {});
this.listeners = storageFactory.create("globalaccelerator", "globalaccelerator-listeners.json",
new TypeReference<Map<String, Listener>>() {});
this.endpointGroups = storageFactory.create("globalaccelerator", "globalaccelerator-endpoint-groups.json",
new TypeReference<Map<String, EndpointGroup>>() {});
this.tags = storageFactory.create("globalaccelerator", "globalaccelerator-tags.json",
new TypeReference<Map<String, Map<String, String>>>() {});
this.regionResolver = regionResolver;
}
public Accelerator createAccelerator(String name, String ipAddressType, List<String> ipAddresses,
Boolean enabled, Map<String, String> requestTags) {
requireArgument(name, "Name");
String resolvedIpAddressType = ipAddressType != null ? ipAddressType : "IPV4";
requireIpAddressType(resolvedIpAddressType);
validateIpAddresses(ipAddresses);
long now = Instant.now().getEpochSecond();
String dnsPrefix = "a" + randomHex(16);
Accelerator accelerator = new Accelerator();
accelerator.setAcceleratorArn(regionResolver.buildArn("globalaccelerator", "",
"accelerator/" + UUID.randomUUID()));
accelerator.setName(name);
accelerator.setIpAddressType(resolvedIpAddressType);
accelerator.setEnabled(enabled == null || enabled);
accelerator.setIpSets(buildIpSets(resolvedIpAddressType, ipAddresses));
accelerator.setDnsName(dnsPrefix + DNS_SUFFIX);
if ("DUAL_STACK".equals(resolvedIpAddressType)) {
accelerator.setDualStackDnsName(dnsPrefix + DUAL_STACK_DNS_SUFFIX);
}
accelerator.setStatus(STATUS_DEPLOYED);
accelerator.setCreatedTime(now);
accelerator.setLastModifiedTime(now);
accelerators.put(accelerator.getAcceleratorArn(), accelerator);
acceleratorAttributes.put(accelerator.getAcceleratorArn(), defaultAttributes());
tags.put(accelerator.getAcceleratorArn(),
requestTags != null ? new LinkedHashMap<>(requestTags) : new LinkedHashMap<>());
LOG.infov("Created Global Accelerator accelerator: {0}", accelerator.getAcceleratorArn());
return accelerator;
}
public Accelerator describeAccelerator(String acceleratorArn) {
requireArgument(acceleratorArn, "AcceleratorArn");
return accelerators.get(acceleratorArn)
.orElseThrow(() -> new AwsException("AcceleratorNotFoundException",
"Accelerator " + acceleratorArn + " does not exist.", 400));
}
public Accelerator updateAccelerator(String acceleratorArn, String name, String ipAddressType,
List<String> ipAddresses, Boolean enabled) {
Accelerator accelerator = describeAccelerator(acceleratorArn);
if (ipAddressType != null) {
requireIpAddressType(ipAddressType);
}
validateIpAddresses(ipAddresses);
if (name != null) {
accelerator.setName(name);
}
if (ipAddressType != null) {
accelerator.setIpAddressType(ipAddressType);
accelerator.setIpSets(buildIpSets(ipAddressType, ipAddresses != null
? ipAddresses
: firstIpv4Addresses(accelerator)));
if ("DUAL_STACK".equals(ipAddressType)) {
if (accelerator.getDualStackDnsName() == null) {
accelerator.setDualStackDnsName(
accelerator.getDnsName().replace(DNS_SUFFIX, DUAL_STACK_DNS_SUFFIX));
}
} else {
accelerator.setDualStackDnsName(null);
}
} else if (ipAddresses != null && !ipAddresses.isEmpty()) {
accelerator.setIpSets(buildIpSets(accelerator.getIpAddressType(), ipAddresses));
}
if (enabled != null) {
accelerator.setEnabled(enabled);
}
accelerator.setStatus(STATUS_DEPLOYED);
accelerator.setLastModifiedTime(Instant.now().getEpochSecond());
accelerators.put(acceleratorArn, accelerator);
return accelerator;
}
public void deleteAccelerator(String acceleratorArn) {
Accelerator accelerator = describeAccelerator(acceleratorArn);
if (Boolean.TRUE.equals(accelerator.getEnabled())) {
throw new AwsException("AcceleratorNotDisabledException",
"The accelerator must be disabled before it can be deleted.", 400);
}
if (!listenersOf(acceleratorArn).isEmpty()) {
throw new AwsException("AssociatedListenerFoundException",
"The accelerator has associated listeners and cannot be deleted.", 400);
}
accelerators.delete(acceleratorArn);
acceleratorAttributes.delete(acceleratorArn);
tags.delete(acceleratorArn);
LOG.infov("Deleted Global Accelerator accelerator: {0}", acceleratorArn);
}
public List<Accelerator> listAccelerators() {
return accelerators.scan(key -> true);
}
public AcceleratorAttributes describeAcceleratorAttributes(String acceleratorArn) {
describeAccelerator(acceleratorArn);
return acceleratorAttributes.get(acceleratorArn).orElseGet(GlobalAcceleratorService::defaultAttributes);
}
/**
* Flow logs need a destination bucket. AWS rejects an update that leaves
* {@code FlowLogsEnabled} true with no {@code FlowLogsS3Bucket}, so the emulator does too:
* accepting it would persist an attribute set the real service cannot produce.
*/
public AcceleratorAttributes updateAcceleratorAttributes(String acceleratorArn, Boolean flowLogsEnabled,
String flowLogsS3Bucket, String flowLogsS3Prefix) {
AcceleratorAttributes stored = describeAcceleratorAttributes(acceleratorArn);
AcceleratorAttributes updated = new AcceleratorAttributes();
updated.setFlowLogsEnabled(flowLogsEnabled != null ? flowLogsEnabled : stored.getFlowLogsEnabled());
updated.setFlowLogsS3Bucket(flowLogsS3Bucket != null ? flowLogsS3Bucket : stored.getFlowLogsS3Bucket());
updated.setFlowLogsS3Prefix(flowLogsS3Prefix != null ? flowLogsS3Prefix : stored.getFlowLogsS3Prefix());
if (Boolean.TRUE.equals(updated.getFlowLogsEnabled())
&& (updated.getFlowLogsS3Bucket() == null || updated.getFlowLogsS3Bucket().isBlank())) {
throw new AwsException("InvalidArgumentException",
"FlowLogsS3Bucket is required when FlowLogsEnabled is true.", 400);
}
acceleratorAttributes.put(acceleratorArn, updated);
return updated;
}
public Listener createListener(String acceleratorArn, List<PortRange> portRanges, String protocol,
String clientAffinity) {
describeAccelerator(acceleratorArn);
validatePortRanges(portRanges);
requireArgument(protocol, "Protocol");
requireProtocol(protocol);
requireClientAffinity(clientAffinity);
Listener listener = new Listener();
listener.setListenerArn(acceleratorArn + LISTENER_SEGMENT + randomId(8));
listener.setPortRanges(portRanges);
listener.setProtocol(protocol);
listener.setClientAffinity(clientAffinity != null ? clientAffinity : "NONE");
listeners.put(listener.getListenerArn(), listener);
LOG.infov("Created Global Accelerator listener: {0}", listener.getListenerArn());
return listener;
}
public Listener describeListener(String listenerArn) {
requireArgument(listenerArn, "ListenerArn");
return listeners.get(listenerArn)
.orElseThrow(() -> new AwsException("ListenerNotFoundException",
"Listener " + listenerArn + " does not exist.", 400));
}
public Listener updateListener(String listenerArn, List<PortRange> portRanges, String protocol,
String clientAffinity) {
Listener listener = describeListener(listenerArn);
if (portRanges != null && !portRanges.isEmpty()) {
validatePortRanges(portRanges);
listener.setPortRanges(portRanges);
}
if (protocol != null) {
requireProtocol(protocol);
listener.setProtocol(protocol);
}
if (clientAffinity != null) {
requireClientAffinity(clientAffinity);
listener.setClientAffinity(clientAffinity);
}
listeners.put(listenerArn, listener);
return listener;
}
public void deleteListener(String listenerArn) {
describeListener(listenerArn);
if (!endpointGroupsOf(listenerArn).isEmpty()) {
throw new AwsException("AssociatedEndpointGroupFoundException",
"The listener has associated endpoint groups and cannot be deleted.", 400);
}
listeners.delete(listenerArn);
tags.delete(listenerArn);
LOG.infov("Deleted Global Accelerator listener: {0}", listenerArn);
}
public List<Listener> listListeners(String acceleratorArn) {
describeAccelerator(acceleratorArn);
return listenersOf(acceleratorArn);
}
public EndpointGroup createEndpointGroup(String listenerArn, String endpointGroupRegion,
JsonNode endpointConfigurations, Float trafficDialPercentage,
Integer healthCheckPort, String healthCheckProtocol,
String healthCheckPath, Integer healthCheckIntervalSeconds,
Integer thresholdCount, List<PortOverride> portOverrides) {
Listener listener = describeListener(listenerArn);
requireArgument(endpointGroupRegion, "EndpointGroupRegion");
validateHealthCheck(healthCheckProtocol, healthCheckPort, healthCheckIntervalSeconds, thresholdCount);
validateHealthCheckPath(healthCheckPath);
validateTrafficDial(trafficDialPercentage);
validatePortOverrides(portOverrides);
boolean regionTaken = endpointGroupsOf(listenerArn).stream()
.anyMatch(group -> endpointGroupRegion.equals(group.getEndpointGroupRegion()));
if (regionTaken) {
throw new AwsException("EndpointGroupAlreadyExistsException",
"An endpoint group for Region " + endpointGroupRegion + " already exists on this listener.", 400);
}
EndpointGroup group = new EndpointGroup();
group.setEndpointGroupArn(listenerArn + ENDPOINT_GROUP_SEGMENT + randomId(12));
group.setEndpointGroupRegion(endpointGroupRegion);
group.setEndpointDescriptions(toEndpointDescriptions(endpointConfigurations));
group.setTrafficDialPercentage(trafficDialPercentage != null ? trafficDialPercentage : 100.0f);
group.setHealthCheckPort(healthCheckPort != null ? healthCheckPort : defaultHealthCheckPort(listener));
group.setHealthCheckProtocol(healthCheckProtocol != null ? healthCheckProtocol : "TCP");
group.setHealthCheckPath(healthCheckPath != null ? healthCheckPath : "/");
group.setHealthCheckIntervalSeconds(healthCheckIntervalSeconds != null ? healthCheckIntervalSeconds : 30);
group.setThresholdCount(thresholdCount != null ? thresholdCount : 3);
group.setPortOverrides(portOverrides != null ? portOverrides : new ArrayList<>());
endpointGroups.put(group.getEndpointGroupArn(), group);
LOG.infov("Created Global Accelerator endpoint group: {0}", group.getEndpointGroupArn());
return group;
}
public EndpointGroup describeEndpointGroup(String endpointGroupArn) {
requireArgument(endpointGroupArn, "EndpointGroupArn");
return endpointGroups.get(endpointGroupArn)
.orElseThrow(() -> new AwsException("EndpointGroupNotFoundException",
"Endpoint group " + endpointGroupArn + " does not exist.", 400));
}
public EndpointGroup updateEndpointGroup(String endpointGroupArn, JsonNode endpointConfigurations,
Float trafficDialPercentage, Integer healthCheckPort,
String healthCheckProtocol, String healthCheckPath,
Integer healthCheckIntervalSeconds, Integer thresholdCount,
List<PortOverride> portOverrides) {
EndpointGroup group = describeEndpointGroup(endpointGroupArn);
validateHealthCheck(healthCheckProtocol, healthCheckPort, healthCheckIntervalSeconds, thresholdCount);
validateHealthCheckPath(healthCheckPath);
validateTrafficDial(trafficDialPercentage);
validatePortOverrides(portOverrides);
if (endpointConfigurations != null && endpointConfigurations.isArray()) {
group.setEndpointDescriptions(toEndpointDescriptions(endpointConfigurations));
}
if (trafficDialPercentage != null) {
group.setTrafficDialPercentage(trafficDialPercentage);
}
if (healthCheckPort != null) {
group.setHealthCheckPort(healthCheckPort);
}
if (healthCheckProtocol != null) {
group.setHealthCheckProtocol(healthCheckProtocol);
}
if (healthCheckPath != null) {
group.setHealthCheckPath(healthCheckPath);
}
if (healthCheckIntervalSeconds != null) {
group.setHealthCheckIntervalSeconds(healthCheckIntervalSeconds);
}
if (thresholdCount != null) {
group.setThresholdCount(thresholdCount);
}
if (portOverrides != null) {
group.setPortOverrides(portOverrides);
}
endpointGroups.put(endpointGroupArn, group);
return group;
}
public void deleteEndpointGroup(String endpointGroupArn) {
describeEndpointGroup(endpointGroupArn);
endpointGroups.delete(endpointGroupArn);
tags.delete(endpointGroupArn);
LOG.infov("Deleted Global Accelerator endpoint group: {0}", endpointGroupArn);
}
public List<EndpointGroup> listEndpointGroups(String listenerArn) {
describeListener(listenerArn);
return endpointGroupsOf(listenerArn);
}
public EndpointGroup addEndpoints(String endpointGroupArn, JsonNode endpointConfigurations) {
EndpointGroup group = describeEndpointGroup(endpointGroupArn);
if (endpointConfigurations == null || !endpointConfigurations.isArray()) {
throw new AwsException("InvalidArgumentException", "EndpointConfigurations is required.", 400);
}
List<EndpointDescription> merged = new ArrayList<>(group.getEndpointDescriptions());
for (EndpointDescription added : toEndpointDescriptions(endpointConfigurations)) {
merged.removeIf(existing -> existing.getEndpointId() != null
&& existing.getEndpointId().equals(added.getEndpointId()));
merged.add(added);
}
group.setEndpointDescriptions(merged);
endpointGroups.put(endpointGroupArn, group);
return group;
}
public void removeEndpoints(String endpointGroupArn, List<String> endpointIds) {
EndpointGroup group = describeEndpointGroup(endpointGroupArn);
if (endpointIds == null || endpointIds.isEmpty()) {
throw new AwsException("InvalidArgumentException", "EndpointIdentifiers is required.", 400);
}
List<EndpointDescription> remaining = new ArrayList<>(group.getEndpointDescriptions());
remaining.removeIf(endpoint -> endpointIds.contains(endpoint.getEndpointId()));
group.setEndpointDescriptions(remaining);
endpointGroups.put(endpointGroupArn, group);
}
public Map<String, String> listTagsForResource(String resourceArn) {
requireResourceExists(resourceArn);
return tags.get(resourceArn).orElseGet(LinkedHashMap::new);
}
public void tagResource(String resourceArn, Map<String, String> newTags) {
requireResourceExists(resourceArn);
if (newTags == null || newTags.isEmpty()) {
throw new AwsException("InvalidArgumentException", "Tags is required.", 400);
}
Map<String, String> existing = new LinkedHashMap<>(tags.get(resourceArn).orElseGet(LinkedHashMap::new));
existing.putAll(newTags);
tags.put(resourceArn, existing);
}
public void untagResource(String resourceArn, List<String> tagKeys) {
requireResourceExists(resourceArn);
if (tagKeys == null || tagKeys.isEmpty()) {
throw new AwsException("InvalidArgumentException", "TagKeys is required.", 400);
}
Map<String, String> existing = new LinkedHashMap<>(tags.get(resourceArn).orElseGet(LinkedHashMap::new));
tagKeys.forEach(existing::remove);
tags.put(resourceArn, existing);
}
private List<Listener> listenersOf(String acceleratorArn) {
return listeners.scan(key -> key.startsWith(acceleratorArn + LISTENER_SEGMENT));
}
private List<EndpointGroup> endpointGroupsOf(String listenerArn) {
return endpointGroups.scan(key -> key.startsWith(listenerArn + ENDPOINT_GROUP_SEGMENT));
}
private void requireResourceExists(String resourceArn) {
requireArgument(resourceArn, "ResourceArn");
if (resourceArn.contains(ENDPOINT_GROUP_SEGMENT)) {
describeEndpointGroup(resourceArn);
} else if (resourceArn.contains(LISTENER_SEGMENT)) {
describeListener(resourceArn);
} else {
describeAccelerator(resourceArn);
}
}
private static Integer defaultHealthCheckPort(Listener listener) {
for (PortRange range : listener.getPortRanges()) {
if (range.getFromPort() != null) {
return range.getFromPort();
}
}
return null;
}
private List<EndpointDescription> toEndpointDescriptions(JsonNode endpointConfigurations) {
List<EndpointDescription> descriptions = new ArrayList<>();
if (endpointConfigurations == null || !endpointConfigurations.isArray()) {
return descriptions;
}
requireAtMost(endpointConfigurations.size(), MAX_ENDPOINT_CONFIGURATIONS, "EndpointConfigurations");
for (JsonNode configuration : endpointConfigurations) {
EndpointDescription description = new EndpointDescription();
String endpointId = configuration.path("EndpointId").asText(null);
if (endpointId == null || endpointId.isBlank()) {
throw new AwsException("InvalidArgumentException",
"EndpointId is required on every endpoint configuration.", 400);
}
description.setEndpointId(endpointId);
description.setWeight(configuration.has("Weight")
? requireWeight(configuration.get("Weight").asInt())
: 128);
description.setClientIpPreservationEnabled(configuration.has("ClientIPPreservationEnabled")
? configuration.get("ClientIPPreservationEnabled").asBoolean()
: endpointId.contains(":loadbalancer/app/"));
description.setHealthState(HEALTH_STATE_HEALTHY);
descriptions.add(description);
}
return descriptions;
}
private static int requireWeight(int weight) {
if (weight < 0 || weight > 255) {
throw new AwsException("InvalidArgumentException", "Weight must be between 0 and 255.", 400);
}
return weight;
}
private static void validatePortRanges(List<PortRange> portRanges) {
if (portRanges == null || portRanges.isEmpty()) {
throw new AwsException("InvalidArgumentException", "PortRanges is required.", 400);
}
requireAtMost(portRanges.size(), MAX_PORT_RANGES, "PortRanges");
for (PortRange range : portRanges) {
Integer from = range.getFromPort();
Integer to = range.getToPort();
if (from == null || to == null || from < 1 || to > 65535 || from > to) {
throw new AwsException("InvalidPortRangeException",
"The port range is not valid. FromPort must be between 1 and ToPort, "
+ "and ToPort must not exceed 65535.", 400);
}
}
}
private static void validatePortOverrides(List<PortOverride> portOverrides) {
if (portOverrides == null) {
return;
}
requireAtMost(portOverrides.size(), MAX_PORT_OVERRIDES, "PortOverrides");
for (PortOverride override : portOverrides) {
if (!isPort(override.getListenerPort()) || !isPort(override.getEndpointPort())) {
throw new AwsException("InvalidPortRangeException",
"A port override must carry a ListenerPort and an EndpointPort between 1 and 65535.", 400);
}
}
}
private static boolean isPort(Integer port) {
return port != null && port >= 1 && port <= 65535;
}
private static void validateHealthCheck(String healthCheckProtocol, Integer healthCheckPort,
Integer healthCheckIntervalSeconds, Integer thresholdCount) {
if (healthCheckProtocol != null && !HEALTH_CHECK_PROTOCOLS.contains(healthCheckProtocol)) {
throw new AwsException("InvalidArgumentException",
"HealthCheckProtocol must be TCP, HTTP or HTTPS.", 400);
}
if (healthCheckPort != null && !isPort(healthCheckPort)) {
throw new AwsException("InvalidArgumentException",
"HealthCheckPort must be between 1 and 65535.", 400);
}
if (healthCheckIntervalSeconds != null
&& (healthCheckIntervalSeconds < 10 || healthCheckIntervalSeconds > 30)) {
throw new AwsException("InvalidArgumentException",
"HealthCheckIntervalSeconds must be between 10 and 30.", 400);
}
if (thresholdCount != null && (thresholdCount < 1 || thresholdCount > 10)) {
throw new AwsException("InvalidArgumentException",
"ThresholdCount must be between 1 and 10.", 400);
}
}
private static void validateHealthCheckPath(String healthCheckPath) {
if (healthCheckPath == null) {
return;
}
if (healthCheckPath.length() > MAX_HEALTH_CHECK_PATH_LENGTH) {
throw new AwsException("InvalidArgumentException",
"HealthCheckPath must not exceed " + MAX_HEALTH_CHECK_PATH_LENGTH + " characters.", 400);
}
if (!HEALTH_CHECK_PATH_PATTERN.matcher(healthCheckPath).matches()) {
throw new AwsException("InvalidArgumentException",
"HealthCheckPath must begin with / and contain only URL path characters.", 400);
}
}
private static void validateIpAddresses(List<String> ipAddresses) {
if (ipAddresses == null) {
return;
}
requireAtMost(ipAddresses.size(), MAX_IP_ADDRESSES, "IpAddresses");
}
private static void requireAtMost(int size, int max, String field) {
if (size > max) {
throw new AwsException("InvalidArgumentException",
field + " must not contain more than " + max + " members.", 400);
}
}
private static void validateTrafficDial(Float trafficDialPercentage) {
if (trafficDialPercentage != null && (trafficDialPercentage < 0f || trafficDialPercentage > 100f)) {
throw new AwsException("InvalidArgumentException",
"TrafficDialPercentage must be between 0 and 100.", 400);
}
}
private static void requireIpAddressType(String ipAddressType) {
if (!IP_ADDRESS_TYPES.contains(ipAddressType)) {
throw new AwsException("InvalidArgumentException", "IpAddressType must be IPV4 or DUAL_STACK.", 400);
}
}
private static void requireProtocol(String protocol) {
if (!PROTOCOLS.contains(protocol)) {
throw new AwsException("InvalidArgumentException", "Protocol must be TCP or UDP.", 400);
}
}
private static void requireClientAffinity(String clientAffinity) {
if (clientAffinity != null && !CLIENT_AFFINITIES.contains(clientAffinity)) {
throw new AwsException("InvalidArgumentException", "ClientAffinity must be NONE or SOURCE_IP.", 400);
}
}
private static List<IpSet> buildIpSets(String ipAddressType, List<String> requestedIpv4Addresses) {
List<IpSet> ipSets = new ArrayList<>();
IpSet ipv4 = new IpSet();
ipv4.setIpFamily("IPv4");
ipv4.setIpAddressFamily("IPv4");
ipv4.setIpAddresses(staticIpv4Addresses(requestedIpv4Addresses));
ipSets.add(ipv4);
if ("DUAL_STACK".equals(ipAddressType)) {
IpSet ipv6 = new IpSet();
ipv6.setIpFamily("IPv6");
ipv6.setIpAddressFamily("IPv6");
ipv6.setIpAddresses(List.of(randomIpv6(), randomIpv6()));
ipSets.add(ipv6);
}
return ipSets;
}
private static List<String> firstIpv4Addresses(Accelerator accelerator) {
return accelerator.getIpSets().stream()
.filter(set -> "IPv4".equals(set.getIpAddressFamily()))
.findFirst()
.map(IpSet::getIpAddresses)
.orElseGet(ArrayList::new);
}
/**
* Global Accelerator assigns two static IPv4 addresses per accelerator, drawn from the
* ranges it advertises. A caller that brought its own address pool (BYOIP) may pin one or
* both, in which case the request wins and any shortfall is filled from the service pool.
*/
private static List<String> staticIpv4Addresses(List<String> requested) {
List<String> addresses = new ArrayList<>();
if (requested != null) {
requested.stream().filter(address -> address != null && !address.isBlank()).forEach(addresses::add);
}
String[] pools = {"75.2", "99.83"};
int poolIndex = 0;
while (addresses.size() < 2) {
addresses.add(pools[poolIndex % pools.length] + "."
+ ThreadLocalRandom.current().nextInt(256) + "."
+ ThreadLocalRandom.current().nextInt(256));
poolIndex++;
}
return addresses;
}
private static String randomIpv6() {
StringBuilder address = new StringBuilder("2600:9000:a400");
for (int group = 0; group < 5; group++) {
address.append(':').append(randomHex(4));
}
return address.toString();
}
private static AcceleratorAttributes defaultAttributes() {
AcceleratorAttributes attributes = new AcceleratorAttributes();
attributes.setFlowLogsEnabled(false);
return attributes;
}
private static void requireArgument(String value, String field) {
if (value == null || value.isBlank()) {
throw new AwsException("InvalidArgumentException", field + " is required.", 400);
}
}
private static String randomId(int length) {
StringBuilder id = new StringBuilder(length);
for (int i = 0; i < length; i++) {
id.append(ID_ALPHABET.charAt(ThreadLocalRandom.current().nextInt(ID_ALPHABET.length())));
}
return id.toString();
}
private static String randomHex(int length) {
StringBuilder hex = new StringBuilder(length);
for (int i = 0; i < length; i++) {
hex.append(HEX.charAt(ThreadLocalRandom.current().nextInt(HEX.length())));
}
return hex.toString().toLowerCase(Locale.ROOT);
}
}
@@ -0,0 +1,85 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Accelerator {
@JsonProperty("AcceleratorArn")
private String acceleratorArn;
@JsonProperty("Name")
private String name;
@JsonProperty("IpAddressType")
private String ipAddressType;
@JsonProperty("Enabled")
private Boolean enabled;
@JsonProperty("IpSets")
private List<IpSet> ipSets = new ArrayList<>();
@JsonProperty("DnsName")
private String dnsName;
@JsonProperty("DualStackDnsName")
private String dualStackDnsName;
@JsonProperty("Status")
private String status;
@JsonProperty("CreatedTime")
private Long createdTime;
@JsonProperty("LastModifiedTime")
private Long lastModifiedTime;
@JsonProperty("Events")
private List<AcceleratorEvent> events = new ArrayList<>();
public Accelerator() {}
public String getAcceleratorArn() { return acceleratorArn; }
public void setAcceleratorArn(String acceleratorArn) { this.acceleratorArn = acceleratorArn; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getIpAddressType() { return ipAddressType; }
public void setIpAddressType(String ipAddressType) { this.ipAddressType = ipAddressType; }
public Boolean getEnabled() { return enabled; }
public void setEnabled(Boolean enabled) { this.enabled = enabled; }
public List<IpSet> getIpSets() { return ipSets; }
public void setIpSets(List<IpSet> ipSets) { this.ipSets = ipSets != null ? ipSets : new ArrayList<>(); }
public String getDnsName() { return dnsName; }
public void setDnsName(String dnsName) { this.dnsName = dnsName; }
public String getDualStackDnsName() { return dualStackDnsName; }
public void setDualStackDnsName(String dualStackDnsName) { this.dualStackDnsName = dualStackDnsName; }
public String getStatus() { return status; }
public void setStatus(String status) { this.status = status; }
public Long getCreatedTime() { return createdTime; }
public void setCreatedTime(Long createdTime) { this.createdTime = createdTime; }
public Long getLastModifiedTime() { return lastModifiedTime; }
public void setLastModifiedTime(Long lastModifiedTime) { this.lastModifiedTime = lastModifiedTime; }
public List<AcceleratorEvent> getEvents() { return events; }
public void setEvents(List<AcceleratorEvent> events) {
this.events = events != null ? events : new ArrayList<>();
}
}
@@ -0,0 +1,32 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AcceleratorAttributes {
@JsonProperty("FlowLogsEnabled")
private Boolean flowLogsEnabled;
@JsonProperty("FlowLogsS3Bucket")
private String flowLogsS3Bucket;
@JsonProperty("FlowLogsS3Prefix")
private String flowLogsS3Prefix;
public AcceleratorAttributes() {}
public Boolean getFlowLogsEnabled() { return flowLogsEnabled; }
public void setFlowLogsEnabled(Boolean flowLogsEnabled) { this.flowLogsEnabled = flowLogsEnabled; }
public String getFlowLogsS3Bucket() { return flowLogsS3Bucket; }
public void setFlowLogsS3Bucket(String flowLogsS3Bucket) { this.flowLogsS3Bucket = flowLogsS3Bucket; }
public String getFlowLogsS3Prefix() { return flowLogsS3Prefix; }
public void setFlowLogsS3Prefix(String flowLogsS3Prefix) { this.flowLogsS3Prefix = flowLogsS3Prefix; }
}
@@ -0,0 +1,26 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AcceleratorEvent {
@JsonProperty("Message")
private String message;
@JsonProperty("Timestamp")
private Long timestamp;
public AcceleratorEvent() {}
public String getMessage() { return message; }
public void setMessage(String message) { this.message = message; }
public Long getTimestamp() { return timestamp; }
public void setTimestamp(Long timestamp) { this.timestamp = timestamp; }
}
@@ -0,0 +1,40 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EndpointDescription {
@JsonProperty("EndpointId")
private String endpointId;
@JsonProperty("Weight")
private Integer weight;
@JsonProperty("HealthState")
private String healthState;
@JsonProperty("ClientIPPreservationEnabled")
private Boolean clientIpPreservationEnabled;
public EndpointDescription() {}
public String getEndpointId() { return endpointId; }
public void setEndpointId(String endpointId) { this.endpointId = endpointId; }
public Integer getWeight() { return weight; }
public void setWeight(Integer weight) { this.weight = weight; }
public String getHealthState() { return healthState; }
public void setHealthState(String healthState) { this.healthState = healthState; }
public Boolean getClientIpPreservationEnabled() { return clientIpPreservationEnabled; }
public void setClientIpPreservationEnabled(Boolean clientIpPreservationEnabled) {
this.clientIpPreservationEnabled = clientIpPreservationEnabled;
}
}
@@ -0,0 +1,83 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class EndpointGroup {
@JsonProperty("EndpointGroupArn")
private String endpointGroupArn;
@JsonProperty("EndpointGroupRegion")
private String endpointGroupRegion;
@JsonProperty("EndpointDescriptions")
private List<EndpointDescription> endpointDescriptions = new ArrayList<>();
@JsonProperty("TrafficDialPercentage")
private Float trafficDialPercentage;
@JsonProperty("HealthCheckPort")
private Integer healthCheckPort;
@JsonProperty("HealthCheckProtocol")
private String healthCheckProtocol;
@JsonProperty("HealthCheckPath")
private String healthCheckPath;
@JsonProperty("HealthCheckIntervalSeconds")
private Integer healthCheckIntervalSeconds;
@JsonProperty("ThresholdCount")
private Integer thresholdCount;
@JsonProperty("PortOverrides")
private List<PortOverride> portOverrides = new ArrayList<>();
public EndpointGroup() {}
public String getEndpointGroupArn() { return endpointGroupArn; }
public void setEndpointGroupArn(String endpointGroupArn) { this.endpointGroupArn = endpointGroupArn; }
public String getEndpointGroupRegion() { return endpointGroupRegion; }
public void setEndpointGroupRegion(String endpointGroupRegion) { this.endpointGroupRegion = endpointGroupRegion; }
public List<EndpointDescription> getEndpointDescriptions() { return endpointDescriptions; }
public void setEndpointDescriptions(List<EndpointDescription> endpointDescriptions) {
this.endpointDescriptions = endpointDescriptions != null ? endpointDescriptions : new ArrayList<>();
}
public Float getTrafficDialPercentage() { return trafficDialPercentage; }
public void setTrafficDialPercentage(Float trafficDialPercentage) { this.trafficDialPercentage = trafficDialPercentage; }
public Integer getHealthCheckPort() { return healthCheckPort; }
public void setHealthCheckPort(Integer healthCheckPort) { this.healthCheckPort = healthCheckPort; }
public String getHealthCheckProtocol() { return healthCheckProtocol; }
public void setHealthCheckProtocol(String healthCheckProtocol) { this.healthCheckProtocol = healthCheckProtocol; }
public String getHealthCheckPath() { return healthCheckPath; }
public void setHealthCheckPath(String healthCheckPath) { this.healthCheckPath = healthCheckPath; }
public Integer getHealthCheckIntervalSeconds() { return healthCheckIntervalSeconds; }
public void setHealthCheckIntervalSeconds(Integer healthCheckIntervalSeconds) {
this.healthCheckIntervalSeconds = healthCheckIntervalSeconds;
}
public Integer getThresholdCount() { return thresholdCount; }
public void setThresholdCount(Integer thresholdCount) { this.thresholdCount = thresholdCount; }
public List<PortOverride> getPortOverrides() { return portOverrides; }
public void setPortOverrides(List<PortOverride> portOverrides) {
this.portOverrides = portOverrides != null ? portOverrides : new ArrayList<>();
}
}
@@ -0,0 +1,37 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class IpSet {
@JsonProperty("IpFamily")
private String ipFamily;
@JsonProperty("IpAddresses")
private List<String> ipAddresses = new ArrayList<>();
@JsonProperty("IpAddressFamily")
private String ipAddressFamily;
public IpSet() {}
public String getIpFamily() { return ipFamily; }
public void setIpFamily(String ipFamily) { this.ipFamily = ipFamily; }
public List<String> getIpAddresses() { return ipAddresses; }
public void setIpAddresses(List<String> ipAddresses) {
this.ipAddresses = ipAddresses != null ? ipAddresses : new ArrayList<>();
}
public String getIpAddressFamily() { return ipAddressFamily; }
public void setIpAddressFamily(String ipAddressFamily) { this.ipAddressFamily = ipAddressFamily; }
}
@@ -0,0 +1,43 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Listener {
@JsonProperty("ListenerArn")
private String listenerArn;
@JsonProperty("PortRanges")
private List<PortRange> portRanges = new ArrayList<>();
@JsonProperty("Protocol")
private String protocol;
@JsonProperty("ClientAffinity")
private String clientAffinity;
public Listener() {}
public String getListenerArn() { return listenerArn; }
public void setListenerArn(String listenerArn) { this.listenerArn = listenerArn; }
public List<PortRange> getPortRanges() { return portRanges; }
public void setPortRanges(List<PortRange> portRanges) {
this.portRanges = portRanges != null ? portRanges : new ArrayList<>();
}
public String getProtocol() { return protocol; }
public void setProtocol(String protocol) { this.protocol = protocol; }
public String getClientAffinity() { return clientAffinity; }
public void setClientAffinity(String clientAffinity) { this.clientAffinity = clientAffinity; }
}
@@ -0,0 +1,26 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PortOverride {
@JsonProperty("ListenerPort")
private Integer listenerPort;
@JsonProperty("EndpointPort")
private Integer endpointPort;
public PortOverride() {}
public Integer getListenerPort() { return listenerPort; }
public void setListenerPort(Integer listenerPort) { this.listenerPort = listenerPort; }
public Integer getEndpointPort() { return endpointPort; }
public void setEndpointPort(Integer endpointPort) { this.endpointPort = endpointPort; }
}
@@ -0,0 +1,26 @@
package io.github.hectorvent.floci.services.globalaccelerator.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PortRange {
@JsonProperty("FromPort")
private Integer fromPort;
@JsonProperty("ToPort")
private Integer toPort;
public PortRange() {}
public Integer getFromPort() { return fromPort; }
public void setFromPort(Integer fromPort) { this.fromPort = fromPort; }
public Integer getToPort() { return toPort; }
public void setToPort(Integer toPort) { this.toPort = toPort; }
}