feat(elbv2): Elastic Load Balancing v2 management API (Phase 1) (#617)

* feat(elbv2): add Elastic Load Balancing v2 management API (Phase 1)
* fix: adding new service to health check test
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-04-27 22:52:52 -05:00
1 parent c7152cef8a
commit d39bdf1c22
24 files changed
+3749 -5

No files matched your search

@@ -269,6 +269,7 @@ public interface EmulatorConfig {
BedrockRuntimeServiceConfig bedrockRuntime();
EksServiceConfig eks();
PipesServiceConfig pipes();
ElbV2ServiceConfig elbv2();
}
interface SsmServiceConfig {
@@ -684,6 +685,11 @@ public interface EmulatorConfig {
boolean enabled();
}
interface ElbV2ServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface EksServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -16,7 +16,8 @@ public final class AwsNamespaces {
public static final String S3 = "http://s3.amazonaws.com/doc/2006-03-01/";
public static final String S3_CONTROL = "http://awss3control.amazonaws.com/doc/2018-08-20/";
public static final String SES = "http://ses.amazonaws.com/doc/2010-12-01/";
public static final String EC2 = "http://ec2.amazonaws.com/doc/2016-11-15/";
public static final String EC2 = "http://ec2.amazonaws.com/doc/2016-11-15/";
public static final String ELB_V2 = "https://elasticloadbalancing.amazonaws.com/doc/2015-12-01/";
private AwsNamespaces() {}
}
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler;
import io.github.hectorvent.floci.services.ec2.Ec2QueryHandler;
import io.github.hectorvent.floci.services.elbv2.ElbV2QueryHandler;
import io.github.hectorvent.floci.services.cloudwatch.metrics.CloudWatchMetricsQueryHandler;
import io.github.hectorvent.floci.services.cognito.CognitoJsonHandler;
import io.github.hectorvent.floci.services.elasticache.ElastiCacheQueryHandler;
@@ -102,6 +103,20 @@ public class AwsQueryController {
"GetAccountSummary", "GetAccountAuthorizationDetails"
);
private static final Set<String> ELB_V2_ACTIONS = Set.of(
"CreateLoadBalancer", "DescribeLoadBalancers", "DeleteLoadBalancer",
"ModifyLoadBalancerAttributes", "DescribeLoadBalancerAttributes",
"SetSecurityGroups", "SetSubnets", "SetIpAddressType",
"CreateTargetGroup", "DescribeTargetGroups", "ModifyTargetGroup", "DeleteTargetGroup",
"ModifyTargetGroupAttributes", "DescribeTargetGroupAttributes",
"RegisterTargets", "DeregisterTargets", "DescribeTargetHealth",
"CreateListener", "DescribeListeners", "ModifyListener", "DeleteListener",
"AddListenerCertificates", "RemoveListenerCertificates", "DescribeListenerCertificates",
"CreateRule", "DescribeRules", "ModifyRule", "DeleteRule", "SetRulePriorities",
"AddTags", "RemoveTags", "DescribeTags",
"DescribeSSLPolicies", "DescribeAccountLimits"
);
private static final Set<String> EC2_ACTIONS = Set.of(
"RunInstances", "DescribeInstances", "TerminateInstances", "StartInstances", "StopInstances",
"RebootInstances", "DescribeInstanceStatus", "DescribeInstanceAttribute", "ModifyInstanceAttribute",
@@ -136,6 +151,7 @@ public class AwsQueryController {
private final CloudWatchMetricsQueryHandler cloudWatchMetricsQueryHandler;
private final CognitoJsonHandler cognitoJsonHandler;
private final Ec2QueryHandler ec2QueryHandler;
private final ElbV2QueryHandler elbV2QueryHandler;
private final ResolvedServiceCatalog catalog;
private final RegionResolver regionResolver;
@@ -149,6 +165,7 @@ public class AwsQueryController {
CloudWatchMetricsQueryHandler cloudWatchMetricsQueryHandler,
CognitoJsonHandler cognitoJsonHandler,
Ec2QueryHandler ec2QueryHandler,
ElbV2QueryHandler elbV2QueryHandler,
ResolvedServiceCatalog catalog,
RegionResolver regionResolver) {
this.cloudFormationQueryHandler = cloudFormationQueryHandler;
@@ -162,6 +179,7 @@ public class AwsQueryController {
this.cloudWatchMetricsQueryHandler = cloudWatchMetricsQueryHandler;
this.cognitoJsonHandler = cognitoJsonHandler;
this.ec2QueryHandler = ec2QueryHandler;
this.elbV2QueryHandler = elbV2QueryHandler;
this.catalog = catalog;
this.regionResolver = regionResolver;
}
@@ -196,6 +214,7 @@ public class AwsQueryController {
case "cloudformation" -> cloudFormationQueryHandler.handle(action, formParams, region);
case "cognito-idp" -> handleCognitoQuery(action, formParams, region);
case "ec2" -> ec2QueryHandler.handle(action, formParams, region);
case "elasticloadbalancing" -> elbV2QueryHandler.handle(action, formParams, region);
default -> xmlErrorResponse("UnknownService",
"Unknown or unsupported service: " + service, 400);
};
@@ -320,6 +339,9 @@ public class AwsQueryController {
if (EC2_ACTIONS.contains(action)) {
return "ec2";
}
if (ELB_V2_ACTIONS.contains(action)) {
return "elasticloadbalancing";
}
// SQS actions are numerous and not enumerated — fall back to sqs only for
// requests that arrived without an Authorization header (raw/test clients)
return "sqs";
@@ -204,7 +204,11 @@ public class ResolvedServiceCatalog {
descriptor("pipes", "pipes", config.services().pipes().enabled(), true,
"pipes", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("pipes"), Set.of(), Set.of(PipesController.class))
Set.of(), Set.of("pipes"), Set.of(), Set.of(PipesController.class)),
descriptor("elasticloadbalancing", "elbv2", config.services().elbv2().enabled(), true,
"elbv2", config.storage().mode(), 5000L, AwsNamespaces.ELB_V2, ServiceProtocol.QUERY,
protocols(ServiceProtocol.QUERY),
Set.of(), Set.of("elasticloadbalancing"), Set.of(), Set.of())
));
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,707 @@
package io.github.hectorvent.floci.services.elbv2;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.services.elbv2.model.*;
import jakarta.enterprise.context.ApplicationScoped;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ApplicationScoped
public class ElbV2Service {
private static final String CANONICAL_HOSTED_ZONE_ID = "Z35SXDOTRQ7X7K";
private static final String DEFAULT_ACCOUNT = "000000000000";
// region → ARN → resource
private final Map<String, Map<String, LoadBalancer>> loadBalancers = new ConcurrentHashMap<>();
private final Map<String, Map<String, TargetGroup>> targetGroups = new ConcurrentHashMap<>();
private final Map<String, Map<String, Listener>> listeners = new ConcurrentHashMap<>();
private final Map<String, Map<String, Rule>> rules = new ConcurrentHashMap<>();
// indexes
private final Map<String, List<String>> lbToListeners = new ConcurrentHashMap<>(); // LB-ARN → listener ARNs
private final Map<String, List<String>> listenerToRules = new ConcurrentHashMap<>(); // Listener-ARN → rule ARNs
private final Map<String, Set<String>> tgToLbs = new ConcurrentHashMap<>(); // TG-ARN → LB-ARNs
// tags: resource-ARN → {key → value}
private final Map<String, Map<String, String>> tags = new ConcurrentHashMap<>();
// ── Load Balancers ────────────────────────────────────────────────────────
public LoadBalancer createLoadBalancer(String region, String name, String scheme,
String type, String ipAddressType,
List<String> subnets, List<String> securityGroups,
Map<String, String> initialTags) {
validateName(name, "load balancer");
Map<String, LoadBalancer> regionLbs = loadBalancers.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
boolean duplicate = regionLbs.values().stream()
.anyMatch(lb -> lb.getLoadBalancerName().equals(name));
if (duplicate) {
throw new AwsException("DuplicateLoadBalancerName",
"A load balancer with name '" + name + "' already exists.", 400);
}
String lbType = type != null ? type : "application";
String lbScheme = scheme != null ? scheme : "internet-facing";
String ipType = ipAddressType != null ? ipAddressType : "ipv4";
String typePrefix = lbTypePrefix(lbType);
String id = randomHex16();
String arn = "arn:aws:elasticloadbalancing:" + region + ":" + DEFAULT_ACCOUNT
+ ":loadbalancer/" + typePrefix + "/" + name + "/" + id;
String dnsName = name + "-" + id + ".elb.localhost";
LoadBalancer lb = new LoadBalancer();
lb.setLoadBalancerArn(arn);
lb.setDnsName(dnsName);
lb.setCanonicalHostedZoneId(CANONICAL_HOSTED_ZONE_ID);
lb.setCreatedTime(Instant.now());
lb.setLoadBalancerName(name);
lb.setScheme(lbScheme);
lb.setVpcId("vpc-00000001");
lb.setState("active");
lb.setType(lbType);
lb.setIpAddressType(ipType);
lb.setRegion(region);
if (subnets != null) lb.setAvailabilityZones(new ArrayList<>(subnets));
if (securityGroups != null) lb.setSecurityGroups(new ArrayList<>(securityGroups));
regionLbs.put(arn, lb);
lbToListeners.put(arn, new ArrayList<>());
if (!initialTags.isEmpty()) {
tags.put(arn, new LinkedHashMap<>(initialTags));
}
return lb;
}
public List<LoadBalancer> describeLoadBalancers(String region, List<String> arns, List<String> names,
String marker, Integer pageSize) {
Map<String, LoadBalancer> regionLbs = loadBalancers.getOrDefault(region, Map.of());
List<LoadBalancer> result = new ArrayList<>(regionLbs.values());
if (arns != null && !arns.isEmpty()) {
Set<String> arnSet = new HashSet<>(arns);
result = result.stream().filter(lb -> arnSet.contains(lb.getLoadBalancerArn())).collect(Collectors.toList());
if (result.isEmpty() && !arns.isEmpty()) {
throw new AwsException("LoadBalancerNotFound",
"One or more load balancers not found.", 400);
}
}
if (names != null && !names.isEmpty()) {
Set<String> nameSet = new HashSet<>(names);
result = result.stream().filter(lb -> nameSet.contains(lb.getLoadBalancerName())).collect(Collectors.toList());
if (result.isEmpty() && !names.isEmpty()) {
throw new AwsException("LoadBalancerNotFound",
"One or more load balancers not found.", 400);
}
}
return result;
}
public void deleteLoadBalancer(String region, String arn) {
Map<String, LoadBalancer> regionLbs = loadBalancers.getOrDefault(region, Map.of());
LoadBalancer lb = regionLbs.remove(arn);
if (lb == null) {
return; // AWS silently ignores non-existent LBs on delete
}
// cascade: listeners → rules
List<String> listenerArns = lbToListeners.remove(arn);
if (listenerArns != null) {
Map<String, Listener> regionListeners = listeners.getOrDefault(region, Map.of());
Map<String, Rule> regionRules = rules.getOrDefault(region, Map.of());
for (String listenerArn : listenerArns) {
regionListeners.remove(listenerArn);
List<String> ruleArns = listenerToRules.remove(listenerArn);
if (ruleArns != null) {
ruleArns.forEach(regionRules::remove);
}
}
}
// remove from TG index
tgToLbs.values().forEach(lbSet -> lbSet.remove(arn));
tags.remove(arn);
}
public Map<String, String> describeLoadBalancerAttributes(String region, String arn) {
LoadBalancer lb = requireLoadBalancer(region, arn);
return new LinkedHashMap<>(lb.getAttributes());
}
public void modifyLoadBalancerAttributes(String region, String arn, Map<String, String> newAttrs) {
LoadBalancer lb = requireLoadBalancer(region, arn);
lb.getAttributes().putAll(newAttrs);
}
public void setSecurityGroups(String region, String arn, List<String> sgIds) {
LoadBalancer lb = requireLoadBalancer(region, arn);
lb.setSecurityGroups(new ArrayList<>(sgIds));
}
public void setSubnets(String region, String arn, List<String> subnets) {
LoadBalancer lb = requireLoadBalancer(region, arn);
lb.setAvailabilityZones(new ArrayList<>(subnets));
}
public void setIpAddressType(String region, String arn, String ipAddressType) {
LoadBalancer lb = requireLoadBalancer(region, arn);
lb.setIpAddressType(ipAddressType);
}
// ── Target Groups ─────────────────────────────────────────────────────────
public TargetGroup createTargetGroup(String region, String name, String protocol, String protocolVersion,
Integer port, String vpcId, String targetType,
String healthCheckProtocol, String healthCheckPort,
Boolean healthCheckEnabled, String healthCheckPath,
Integer healthCheckInterval, Integer healthCheckTimeout,
Integer healthyThreshold, Integer unhealthyThreshold,
String matcher, String ipAddressType,
Map<String, String> initialTags) {
validateName(name, "target group");
Map<String, TargetGroup> regionTgs = targetGroups.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
boolean duplicate = regionTgs.values().stream()
.anyMatch(tg -> tg.getTargetGroupName().equals(name));
if (duplicate) {
throw new AwsException("DuplicateTargetGroupName",
"A target group with name '" + name + "' already exists.", 400);
}
String id = randomHex16();
String arn = "arn:aws:elasticloadbalancing:" + region + ":" + DEFAULT_ACCOUNT
+ ":targetgroup/" + name + "/" + id;
TargetGroup tg = new TargetGroup();
tg.setTargetGroupArn(arn);
tg.setTargetGroupName(name);
tg.setProtocol(protocol != null ? protocol : "HTTP");
tg.setProtocolVersion(protocolVersion != null ? protocolVersion : "HTTP1");
tg.setPort(port);
tg.setVpcId(vpcId);
tg.setTargetType(targetType != null ? targetType : "instance");
tg.setIpAddressType(ipAddressType != null ? ipAddressType : "ipv4");
tg.setRegion(region);
// health check defaults
tg.setHealthCheckEnabled(healthCheckEnabled != null ? healthCheckEnabled : true);
tg.setHealthCheckProtocol(healthCheckProtocol != null ? healthCheckProtocol : "HTTP");
tg.setHealthCheckPort(healthCheckPort != null ? healthCheckPort : "traffic-port");
tg.setHealthCheckPath(healthCheckPath != null ? healthCheckPath : "/");
tg.setHealthCheckIntervalSeconds(healthCheckInterval != null ? healthCheckInterval : 30);
tg.setHealthCheckTimeoutSeconds(healthCheckTimeout != null ? healthCheckTimeout : 5);
tg.setHealthyThresholdCount(healthyThreshold != null ? healthyThreshold : 5);
tg.setUnhealthyThresholdCount(unhealthyThreshold != null ? unhealthyThreshold : 2);
tg.setMatcher(matcher != null ? matcher : "200");
regionTgs.put(arn, tg);
tgToLbs.put(arn, ConcurrentHashMap.newKeySet());
if (!initialTags.isEmpty()) {
tags.put(arn, new LinkedHashMap<>(initialTags));
}
return tg;
}
public List<TargetGroup> describeTargetGroups(String region, String lbArn, List<String> tgArns,
List<String> names) {
Map<String, TargetGroup> regionTgs = targetGroups.getOrDefault(region, Map.of());
List<TargetGroup> result = new ArrayList<>(regionTgs.values());
if (lbArn != null && !lbArn.isEmpty()) {
result = result.stream()
.filter(tg -> tgToLbs.getOrDefault(tg.getTargetGroupArn(), Set.of()).contains(lbArn))
.collect(Collectors.toList());
}
if (tgArns != null && !tgArns.isEmpty()) {
Set<String> arnSet = new HashSet<>(tgArns);
result = result.stream().filter(tg -> arnSet.contains(tg.getTargetGroupArn())).collect(Collectors.toList());
if (result.isEmpty()) {
throw new AwsException("TargetGroupNotFound", "One or more target groups not found.", 400);
}
}
if (names != null && !names.isEmpty()) {
Set<String> nameSet = new HashSet<>(names);
result = result.stream().filter(tg -> nameSet.contains(tg.getTargetGroupName())).collect(Collectors.toList());
}
return result;
}
public void deleteTargetGroup(String region, String arn) {
TargetGroup tg = targetGroups.getOrDefault(region, Map.of()).get(arn);
if (tg == null) {
return;
}
Set<String> lbRefs = tgToLbs.getOrDefault(arn, Set.of());
if (!lbRefs.isEmpty()) {
throw new AwsException("ResourceInUse",
"Target group '" + tg.getTargetGroupName() + "' is currently in use by a listener or rule.", 400);
}
targetGroups.getOrDefault(region, Map.of()).remove(arn);
tgToLbs.remove(arn);
tags.remove(arn);
}
public void modifyTargetGroup(String region, String arn, String healthCheckProtocol,
String healthCheckPort, Boolean healthCheckEnabled,
String healthCheckPath, Integer healthCheckInterval,
Integer healthCheckTimeout, Integer healthyThreshold,
Integer unhealthyThreshold, String matcher) {
TargetGroup tg = requireTargetGroup(region, arn);
if (healthCheckProtocol != null) tg.setHealthCheckProtocol(healthCheckProtocol);
if (healthCheckPort != null) tg.setHealthCheckPort(healthCheckPort);
if (healthCheckEnabled != null) tg.setHealthCheckEnabled(healthCheckEnabled);
if (healthCheckPath != null) tg.setHealthCheckPath(healthCheckPath);
if (healthCheckInterval != null) tg.setHealthCheckIntervalSeconds(healthCheckInterval);
if (healthCheckTimeout != null) tg.setHealthCheckTimeoutSeconds(healthCheckTimeout);
if (healthyThreshold != null) tg.setHealthyThresholdCount(healthyThreshold);
if (unhealthyThreshold != null) tg.setUnhealthyThresholdCount(unhealthyThreshold);
if (matcher != null) tg.setMatcher(matcher);
}
public Map<String, String> describeTargetGroupAttributes(String region, String arn) {
TargetGroup tg = requireTargetGroup(region, arn);
return new LinkedHashMap<>(tg.getAttributes());
}
public void modifyTargetGroupAttributes(String region, String arn, Map<String, String> newAttrs) {
TargetGroup tg = requireTargetGroup(region, arn);
tg.getAttributes().putAll(newAttrs);
}
// ── Listeners ─────────────────────────────────────────────────────────────
public Listener createListener(String region, String lbArn, String protocol, Integer port,
String sslPolicy, List<String> certificates,
List<Action> defaultActions, List<String> alpnPolicy,
Map<String, String> initialTags) {
requireLoadBalancer(region, lbArn);
Map<String, Listener> regionListeners = listeners.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
// check duplicate port on same LB
boolean portExists = regionListeners.values().stream()
.filter(l -> l.getLoadBalancerArn().equals(lbArn))
.anyMatch(l -> Objects.equals(l.getPort(), port));
if (portExists) {
throw new AwsException("DuplicateListener",
"A listener already exists on port " + port + " for this load balancer.", 400);
}
LoadBalancer lb = requireLoadBalancer(region, lbArn);
String lbType = lb.getType() != null ? lb.getType() : "application";
String typePrefix = lbTypePrefix(lbType);
String lbId = arnId(lbArn);
String listenerId = randomHex16();
String listenerArn = "arn:aws:elasticloadbalancing:" + region + ":" + DEFAULT_ACCOUNT
+ ":listener/" + typePrefix + "/" + lb.getLoadBalancerName() + "/" + lbId + "/" + listenerId;
Listener listener = new Listener();
listener.setListenerArn(listenerArn);
listener.setLoadBalancerArn(lbArn);
listener.setPort(port);
listener.setProtocol(protocol != null ? protocol : "HTTP");
listener.setSslPolicy(sslPolicy);
listener.setCertificates(certificates != null ? new ArrayList<>(certificates) : new ArrayList<>());
listener.setDefaultActions(defaultActions != null ? new ArrayList<>(defaultActions) : new ArrayList<>());
listener.setAlpnPolicy(alpnPolicy != null ? new ArrayList<>(alpnPolicy) : new ArrayList<>());
regionListeners.put(listenerArn, listener);
lbToListeners.computeIfAbsent(lbArn, k -> new ArrayList<>()).add(listenerArn);
// auto-create the default rule
Rule defaultRule = buildDefaultRule(region, listenerArn, lb, lbId, listenerId, defaultActions);
rules.computeIfAbsent(region, k -> new ConcurrentHashMap<>()).put(defaultRule.getRuleArn(), defaultRule);
listenerToRules.computeIfAbsent(listenerArn, k -> new ArrayList<>()).add(defaultRule.getRuleArn());
if (!initialTags.isEmpty()) {
tags.put(listenerArn, new LinkedHashMap<>(initialTags));
}
return listener;
}
public List<Listener> describeListeners(String region, String lbArn, List<String> listenerArns) {
Map<String, Listener> regionListeners = listeners.getOrDefault(region, Map.of());
List<Listener> result = new ArrayList<>(regionListeners.values());
if (lbArn != null && !lbArn.isEmpty()) {
result = result.stream()
.filter(l -> l.getLoadBalancerArn().equals(lbArn))
.collect(Collectors.toList());
}
if (listenerArns != null && !listenerArns.isEmpty()) {
Set<String> arnSet = new HashSet<>(listenerArns);
result = result.stream().filter(l -> arnSet.contains(l.getListenerArn())).collect(Collectors.toList());
}
return result;
}
public void deleteListener(String region, String listenerArn) {
Map<String, Listener> regionListeners = listeners.getOrDefault(region, Map.of());
Listener listener = regionListeners.remove(listenerArn);
if (listener == null) {
return;
}
lbToListeners.getOrDefault(listener.getLoadBalancerArn(), List.of()).remove(listenerArn);
Map<String, Rule> regionRules = rules.getOrDefault(region, Map.of());
List<String> ruleArns = listenerToRules.remove(listenerArn);
if (ruleArns != null) {
ruleArns.forEach(regionRules::remove);
}
tags.remove(listenerArn);
}
public Listener modifyListener(String region, String listenerArn, String protocol, Integer port,
String sslPolicy, List<String> certificates,
List<Action> defaultActions, List<String> alpnPolicy) {
Listener listener = requireListener(region, listenerArn);
if (port != null && !Objects.equals(listener.getPort(), port)) {
// check duplicate port on same LB
Map<String, Listener> regionListeners = listeners.getOrDefault(region, Map.of());
boolean portExists = regionListeners.values().stream()
.filter(l -> l.getLoadBalancerArn().equals(listener.getLoadBalancerArn()) && !l.getListenerArn().equals(listenerArn))
.anyMatch(l -> Objects.equals(l.getPort(), port));
if (portExists) {
throw new AwsException("DuplicateListener",
"A listener already exists on port " + port + " for this load balancer.", 400);
}
listener.setPort(port);
}
if (protocol != null) listener.setProtocol(protocol);
if (sslPolicy != null) listener.setSslPolicy(sslPolicy);
if (certificates != null) listener.setCertificates(new ArrayList<>(certificates));
if (alpnPolicy != null) listener.setAlpnPolicy(new ArrayList<>(alpnPolicy));
if (defaultActions != null) {
listener.setDefaultActions(new ArrayList<>(defaultActions));
// update the default rule's actions
listenerToRules.getOrDefault(listenerArn, List.of()).stream()
.map(ra -> rules.getOrDefault(region, Map.of()).get(ra))
.filter(r -> r != null && r.isDefault())
.forEach(r -> r.setActions(new ArrayList<>(defaultActions)));
}
return listener;
}
// ── Rules ─────────────────────────────────────────────────────────────────
public Rule createRule(String region, String listenerArn, List<RuleCondition> conditions,
int priority, List<Action> actions, Map<String, String> initialTags) {
requireListener(region, listenerArn);
if (priority < 1 || priority > 50000) {
throw new AwsException("ValidationError", "Priority must be between 1 and 50000.", 400);
}
Map<String, Rule> regionRules = rules.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
List<String> existingRuleArns = listenerToRules.getOrDefault(listenerArn, List.of());
String priorityStr = String.valueOf(priority);
boolean priorityTaken = existingRuleArns.stream()
.map(regionRules::get)
.filter(Objects::nonNull)
.anyMatch(r -> priorityStr.equals(r.getPriority()));
if (priorityTaken) {
throw new AwsException("PriorityInUse",
"The specified priority is already in use.", 400);
}
Listener listener = requireListener(region, listenerArn);
LoadBalancer lb = requireLoadBalancer(region, listener.getLoadBalancerArn());
String lbType = lb.getType() != null ? lb.getType() : "application";
String typePrefix = lbTypePrefix(lbType);
String lbId = arnId(listener.getLoadBalancerArn());
String listenerId = arnId(listenerArn);
String ruleId = randomHex16();
String ruleArn = "arn:aws:elasticloadbalancing:" + region + ":" + DEFAULT_ACCOUNT
+ ":listener-rule/" + typePrefix + "/" + lb.getLoadBalancerName() + "/" + lbId + "/" + listenerId + "/" + ruleId;
Rule rule = new Rule();
rule.setRuleArn(ruleArn);
rule.setListenerArn(listenerArn);
rule.setPriority(priorityStr);
rule.setConditions(conditions != null ? new ArrayList<>(conditions) : new ArrayList<>());
rule.setActions(actions != null ? new ArrayList<>(actions) : new ArrayList<>());
rule.setDefault(false);
regionRules.put(ruleArn, rule);
listenerToRules.computeIfAbsent(listenerArn, k -> new ArrayList<>()).add(ruleArn);
// update TG → LB index for all target group actions
for (Action a : rule.getActions()) {
linkTgToLb(a, listener.getLoadBalancerArn());
}
if (!initialTags.isEmpty()) {
tags.put(ruleArn, new LinkedHashMap<>(initialTags));
}
return rule;
}
public List<Rule> describeRules(String region, String listenerArn, List<String> ruleArns) {
Map<String, Rule> regionRules = rules.getOrDefault(region, Map.of());
if (ruleArns != null && !ruleArns.isEmpty()) {
return ruleArns.stream()
.map(regionRules::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
if (listenerArn != null && !listenerArn.isEmpty()) {
return listenerToRules.getOrDefault(listenerArn, List.of()).stream()
.map(regionRules::get)
.filter(Objects::nonNull)
.sorted(Comparator.comparing(r -> prioritySortKey(r.getPriority())))
.collect(Collectors.toList());
}
return new ArrayList<>(regionRules.values());
}
public void deleteRule(String region, String ruleArn) {
Map<String, Rule> regionRules = rules.getOrDefault(region, Map.of());
Rule rule = regionRules.get(ruleArn);
if (rule == null) {
return;
}
if (rule.isDefault()) {
throw new AwsException("OperationNotPermitted",
"The default rule for a listener cannot be deleted.", 400);
}
regionRules.remove(ruleArn);
listenerToRules.getOrDefault(rule.getListenerArn(), List.of()).remove(ruleArn);
tags.remove(ruleArn);
}
public Rule modifyRule(String region, String ruleArn, List<RuleCondition> conditions, List<Action> actions) {
Rule rule = requireRule(region, ruleArn);
if (conditions != null) rule.setConditions(new ArrayList<>(conditions));
if (actions != null) rule.setActions(new ArrayList<>(actions));
return rule;
}
public void setRulePriorities(String region, Map<String, Integer> arnToPriority) {
Map<String, Rule> regionRules = rules.getOrDefault(region, Map.of());
// validate all rules exist and are not default before touching anything
for (Map.Entry<String, Integer> e : arnToPriority.entrySet()) {
Rule rule = regionRules.get(e.getKey());
if (rule == null) {
throw new AwsException("RuleNotFound", "Rule not found: " + e.getKey(), 400);
}
if (rule.isDefault()) {
throw new AwsException("OperationNotPermitted", "Cannot change priority of the default rule.", 400);
}
int p = e.getValue();
if (p < 1 || p > 50000) {
throw new AwsException("ValidationError", "Priority must be between 1 and 50000.", 400);
}
}
// check for collisions with rules NOT in the update set
Set<String> updatingArns = arnToPriority.keySet();
Set<Integer> newPriorities = new HashSet<>(arnToPriority.values());
for (Rule existing : regionRules.values()) {
if (!updatingArns.contains(existing.getRuleArn()) && !existing.isDefault()) {
try {
int existingPriority = Integer.parseInt(existing.getPriority());
if (newPriorities.contains(existingPriority)) {
throw new AwsException("PriorityInUse",
"Priority " + existingPriority + " is already in use.", 400);
}
} catch (NumberFormatException ignored) { /* default rule */ }
}
}
// commit
arnToPriority.forEach((arn, priority) -> regionRules.get(arn).setPriority(String.valueOf(priority)));
}
// ── Targets ───────────────────────────────────────────────────────────────
public void registerTargets(String region, String tgArn, List<TargetDescription> targets) {
TargetGroup tg = requireTargetGroup(region, tgArn);
List<TargetDescription> existing = tg.getTargets();
for (TargetDescription t : targets) {
// replace if same id+port already registered
existing.removeIf(e -> e.getId().equals(t.getId()) && Objects.equals(e.getPort(), t.getPort()));
existing.add(t);
}
}
public void deregisterTargets(String region, String tgArn, List<TargetDescription> targets) {
TargetGroup tg = requireTargetGroup(region, tgArn);
for (TargetDescription t : targets) {
tg.getTargets().removeIf(e -> e.getId().equals(t.getId()) && Objects.equals(e.getPort(), t.getPort()));
}
}
public List<TargetHealth> describeTargetHealth(String region, String tgArn,
List<TargetDescription> filterTargets) {
TargetGroup tg = requireTargetGroup(region, tgArn);
List<TargetDescription> candidates = filterTargets != null && !filterTargets.isEmpty()
? filterTargets : tg.getTargets();
return candidates.stream().map(t -> {
TargetHealth th = new TargetHealth();
th.setTarget(t);
th.setHealthCheckPort(tg.getHealthCheckPort() != null ? tg.getHealthCheckPort() : "traffic-port");
th.setState("initial");
th.setReason("Elb.RegistrationInProgress");
th.setDescription("Target registration is in progress");
return th;
}).collect(Collectors.toList());
}
// ── Tags ──────────────────────────────────────────────────────────────────
public void addTags(List<String> resourceArns, Map<String, String> newTags) {
for (String arn : resourceArns) {
tags.computeIfAbsent(arn, k -> new LinkedHashMap<>()).putAll(newTags);
}
}
public void removeTags(List<String> resourceArns, List<String> tagKeys) {
for (String arn : resourceArns) {
Map<String, String> resourceTags = tags.get(arn);
if (resourceTags != null) {
tagKeys.forEach(resourceTags::remove);
}
}
}
public Map<String, Map<String, String>> describeTags(List<String> resourceArns) {
Map<String, Map<String, String>> result = new LinkedHashMap<>();
for (String arn : resourceArns) {
result.put(arn, tags.getOrDefault(arn, Map.of()));
}
return result;
}
// ── Listener Certificates ─────────────────────────────────────────────────
public void addListenerCertificates(String region, String listenerArn, List<String> certArns) {
Listener listener = requireListener(region, listenerArn);
for (String certArn : certArns) {
if (!listener.getCertificates().contains(certArn)) {
listener.getCertificates().add(certArn);
}
}
}
public void removeListenerCertificates(String region, String listenerArn, List<String> certArns) {
Listener listener = requireListener(region, listenerArn);
listener.getCertificates().removeAll(certArns);
}
public List<String> describeListenerCertificates(String region, String listenerArn) {
Listener listener = requireListener(region, listenerArn);
return new ArrayList<>(listener.getCertificates());
}
// ── Helpers ───────────────────────────────────────────────────────────────
private LoadBalancer requireLoadBalancer(String region, String arn) {
LoadBalancer lb = loadBalancers.getOrDefault(region, Map.of()).get(arn);
if (lb == null) {
throw new AwsException("LoadBalancerNotFound",
"One or more load balancers not found.", 400);
}
return lb;
}
private TargetGroup requireTargetGroup(String region, String arn) {
TargetGroup tg = targetGroups.getOrDefault(region, Map.of()).get(arn);
if (tg == null) {
throw new AwsException("TargetGroupNotFound",
"One or more target groups not found.", 400);
}
return tg;
}
private Listener requireListener(String region, String arn) {
Listener l = listeners.getOrDefault(region, Map.of()).get(arn);
if (l == null) {
throw new AwsException("ListenerNotFound",
"One or more listeners not found.", 400);
}
return l;
}
private Rule requireRule(String region, String arn) {
Rule r = rules.getOrDefault(region, Map.of()).get(arn);
if (r == null) {
throw new AwsException("RuleNotFound", "One or more rules not found.", 400);
}
return r;
}
private static void validateName(String name, String resource) {
if (name == null || name.isEmpty()) {
throw new AwsException("ValidationError", "Name is required for " + resource + ".", 400);
}
if (name.length() > 32) {
throw new AwsException("ValidationError",
"Name '" + name + "' exceeds 32 characters.", 400);
}
if (!name.matches("[a-zA-Z0-9-]+")) {
throw new AwsException("ValidationError",
"Name '" + name + "' contains invalid characters. Use alphanumeric characters and hyphens.", 400);
}
if (name.startsWith("-") || name.endsWith("-")) {
throw new AwsException("ValidationError",
"Name '" + name + "' cannot start or end with a hyphen.", 400);
}
}
private static String randomHex16() {
return UUID.randomUUID().toString().replace("-", "").substring(0, 16);
}
private static String lbTypePrefix(String type) {
return switch (type) {
case "network" -> "net";
case "gateway" -> "gwy";
default -> "app";
};
}
// extracts the last path segment of an ARN (the random hex ID)
private static String arnId(String arn) {
int last = arn.lastIndexOf('/');
return last >= 0 ? arn.substring(last + 1) : arn;
}
private static int prioritySortKey(String priority) {
if ("default".equals(priority)) return Integer.MAX_VALUE;
try { return Integer.parseInt(priority); } catch (NumberFormatException e) { return Integer.MAX_VALUE; }
}
private Rule buildDefaultRule(String region, String listenerArn, LoadBalancer lb, String lbId,
String listenerId, List<Action> defaultActions) {
String lbType = lb.getType() != null ? lb.getType() : "application";
String typePrefix = lbTypePrefix(lbType);
String ruleId = randomHex16();
String ruleArn = "arn:aws:elasticloadbalancing:" + region + ":" + DEFAULT_ACCOUNT
+ ":listener-rule/" + typePrefix + "/" + lb.getLoadBalancerName() + "/" + lbId + "/" + listenerId + "/" + ruleId;
Rule rule = new Rule();
rule.setRuleArn(ruleArn);
rule.setListenerArn(listenerArn);
rule.setPriority("default");
rule.setConditions(new ArrayList<>());
rule.setActions(defaultActions != null ? new ArrayList<>(defaultActions) : new ArrayList<>());
rule.setDefault(true);
return rule;
}
private void linkTgToLb(Action action, String lbArn) {
if ("forward".equals(action.getType())) {
if (action.getTargetGroupArn() != null) {
tgToLbs.computeIfAbsent(action.getTargetGroupArn(), k -> ConcurrentHashMap.newKeySet()).add(lbArn);
}
for (Action.TargetGroupTuple t : action.getTargetGroups()) {
if (t.getTargetGroupArn() != null) {
tgToLbs.computeIfAbsent(t.getTargetGroupArn(), k -> ConcurrentHashMap.newKeySet()).add(lbArn);
}
}
}
}
}
@@ -0,0 +1,98 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class Action {
private String type;
private Integer order;
// forward (simple)
private String targetGroupArn;
// forward (weighted)
private List<TargetGroupTuple> targetGroups = new ArrayList<>();
private Boolean stickinessEnabled;
private Integer stickinessDurationSeconds;
// redirect
private String redirectProtocol;
private String redirectPort;
private String redirectHost;
private String redirectPath;
private String redirectQuery;
private String redirectStatusCode;
// fixed-response
private String fixedResponseStatusCode;
private String fixedResponseContentType;
private String fixedResponseMessageBody;
public Action() {}
public String getType() { return type; }
public void setType(String type) { this.type = type; }
public Integer getOrder() { return order; }
public void setOrder(Integer order) { this.order = order; }
public String getTargetGroupArn() { return targetGroupArn; }
public void setTargetGroupArn(String targetGroupArn) { this.targetGroupArn = targetGroupArn; }
public List<TargetGroupTuple> getTargetGroups() { return targetGroups; }
public void setTargetGroups(List<TargetGroupTuple> targetGroups) { this.targetGroups = targetGroups; }
public Boolean getStickinessEnabled() { return stickinessEnabled; }
public void setStickinessEnabled(Boolean stickinessEnabled) { this.stickinessEnabled = stickinessEnabled; }
public Integer getStickinessDurationSeconds() { return stickinessDurationSeconds; }
public void setStickinessDurationSeconds(Integer stickinessDurationSeconds) { this.stickinessDurationSeconds = stickinessDurationSeconds; }
public String getRedirectProtocol() { return redirectProtocol; }
public void setRedirectProtocol(String redirectProtocol) { this.redirectProtocol = redirectProtocol; }
public String getRedirectPort() { return redirectPort; }
public void setRedirectPort(String redirectPort) { this.redirectPort = redirectPort; }
public String getRedirectHost() { return redirectHost; }
public void setRedirectHost(String redirectHost) { this.redirectHost = redirectHost; }
public String getRedirectPath() { return redirectPath; }
public void setRedirectPath(String redirectPath) { this.redirectPath = redirectPath; }
public String getRedirectQuery() { return redirectQuery; }
public void setRedirectQuery(String redirectQuery) { this.redirectQuery = redirectQuery; }
public String getRedirectStatusCode() { return redirectStatusCode; }
public void setRedirectStatusCode(String redirectStatusCode) { this.redirectStatusCode = redirectStatusCode; }
public String getFixedResponseStatusCode() { return fixedResponseStatusCode; }
public void setFixedResponseStatusCode(String fixedResponseStatusCode) { this.fixedResponseStatusCode = fixedResponseStatusCode; }
public String getFixedResponseContentType() { return fixedResponseContentType; }
public void setFixedResponseContentType(String fixedResponseContentType) { this.fixedResponseContentType = fixedResponseContentType; }
public String getFixedResponseMessageBody() { return fixedResponseMessageBody; }
public void setFixedResponseMessageBody(String fixedResponseMessageBody) { this.fixedResponseMessageBody = fixedResponseMessageBody; }
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public static class TargetGroupTuple {
private String targetGroupArn;
private Integer weight;
public TargetGroupTuple() {}
public String getTargetGroupArn() { return targetGroupArn; }
public void setTargetGroupArn(String targetGroupArn) { this.targetGroupArn = targetGroupArn; }
public Integer getWeight() { return weight; }
public void setWeight(Integer weight) { this.weight = weight; }
}
}
@@ -0,0 +1,53 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class Listener {
private String listenerArn;
private String loadBalancerArn;
private Integer port;
private String protocol;
private List<String> certificates = new ArrayList<>();
private String sslPolicy;
private List<Action> defaultActions = new ArrayList<>();
private List<String> alpnPolicy = new ArrayList<>();
private Map<String, String> attributes = new LinkedHashMap<>();
public Listener() {}
public String getListenerArn() { return listenerArn; }
public void setListenerArn(String listenerArn) { this.listenerArn = listenerArn; }
public String getLoadBalancerArn() { return loadBalancerArn; }
public void setLoadBalancerArn(String loadBalancerArn) { this.loadBalancerArn = loadBalancerArn; }
public Integer getPort() { return port; }
public void setPort(Integer port) { this.port = port; }
public String getProtocol() { return protocol; }
public void setProtocol(String protocol) { this.protocol = protocol; }
public List<String> getCertificates() { return certificates; }
public void setCertificates(List<String> certificates) { this.certificates = certificates; }
public String getSslPolicy() { return sslPolicy; }
public void setSslPolicy(String sslPolicy) { this.sslPolicy = sslPolicy; }
public List<Action> getDefaultActions() { return defaultActions; }
public void setDefaultActions(List<Action> defaultActions) { this.defaultActions = defaultActions; }
public List<String> getAlpnPolicy() { return alpnPolicy; }
public void setAlpnPolicy(List<String> alpnPolicy) { this.alpnPolicy = alpnPolicy; }
public Map<String, String> getAttributes() { return attributes; }
public void setAttributes(Map<String, String> attributes) { this.attributes = attributes; }
}
@@ -0,0 +1,74 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class LoadBalancer {
private String loadBalancerArn;
private String dnsName;
private String canonicalHostedZoneId;
private Instant createdTime;
private String loadBalancerName;
private String scheme;
private String vpcId;
private String state;
private String type;
private List<String> availabilityZones = new ArrayList<>();
private List<String> securityGroups = new ArrayList<>();
private String ipAddressType;
private String region;
private Map<String, String> attributes = new LinkedHashMap<>();
public LoadBalancer() {}
public String getLoadBalancerArn() { return loadBalancerArn; }
public void setLoadBalancerArn(String loadBalancerArn) { this.loadBalancerArn = loadBalancerArn; }
public String getDnsName() { return dnsName; }
public void setDnsName(String dnsName) { this.dnsName = dnsName; }
public String getCanonicalHostedZoneId() { return canonicalHostedZoneId; }
public void setCanonicalHostedZoneId(String canonicalHostedZoneId) { this.canonicalHostedZoneId = canonicalHostedZoneId; }
public Instant getCreatedTime() { return createdTime; }
public void setCreatedTime(Instant createdTime) { this.createdTime = createdTime; }
public String getLoadBalancerName() { return loadBalancerName; }
public void setLoadBalancerName(String loadBalancerName) { this.loadBalancerName = loadBalancerName; }
public String getScheme() { return scheme; }
public void setScheme(String scheme) { this.scheme = scheme; }
public String getVpcId() { return vpcId; }
public void setVpcId(String vpcId) { this.vpcId = vpcId; }
public String getState() { return state; }
public void setState(String state) { this.state = state; }
public String getType() { return type; }
public void setType(String type) { this.type = type; }
public List<String> getAvailabilityZones() { return availabilityZones; }
public void setAvailabilityZones(List<String> availabilityZones) { this.availabilityZones = availabilityZones; }
public List<String> getSecurityGroups() { return securityGroups; }
public void setSecurityGroups(List<String> securityGroups) { this.securityGroups = securityGroups; }
public String getIpAddressType() { return ipAddressType; }
public void setIpAddressType(String ipAddressType) { this.ipAddressType = ipAddressType; }
public String getRegion() { return region; }
public void setRegion(String region) { this.region = region; }
public Map<String, String> getAttributes() { return attributes; }
public void setAttributes(Map<String, String> attributes) { this.attributes = attributes; }
}
@@ -0,0 +1,39 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class Rule {
private String ruleArn;
private String listenerArn;
private String priority;
private List<RuleCondition> conditions = new ArrayList<>();
private List<Action> actions = new ArrayList<>();
private boolean isDefault;
public Rule() {}
public String getRuleArn() { return ruleArn; }
public void setRuleArn(String ruleArn) { this.ruleArn = ruleArn; }
public String getListenerArn() { return listenerArn; }
public void setListenerArn(String listenerArn) { this.listenerArn = listenerArn; }
public String getPriority() { return priority; }
public void setPriority(String priority) { this.priority = priority; }
public List<RuleCondition> getConditions() { return conditions; }
public void setConditions(List<RuleCondition> conditions) { this.conditions = conditions; }
public List<Action> getActions() { return actions; }
public void setActions(List<Action> actions) { this.actions = actions; }
public boolean isDefault() { return isDefault; }
public void setDefault(boolean aDefault) { isDefault = aDefault; }
}
@@ -0,0 +1,68 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.List;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class RuleCondition {
private String field;
private List<String> values = new ArrayList<>();
// typed configs
private List<String> hostHeaderValues = new ArrayList<>();
private List<String> pathPatternValues = new ArrayList<>();
private String httpHeaderName;
private List<String> httpHeaderValues = new ArrayList<>();
private List<String> httpMethodValues = new ArrayList<>();
private List<String> sourceIpValues = new ArrayList<>();
private List<QueryStringPair> queryStringValues = new ArrayList<>();
public RuleCondition() {}
public String getField() { return field; }
public void setField(String field) { this.field = field; }
public List<String> getValues() { return values; }
public void setValues(List<String> values) { this.values = values; }
public List<String> getHostHeaderValues() { return hostHeaderValues; }
public void setHostHeaderValues(List<String> hostHeaderValues) { this.hostHeaderValues = hostHeaderValues; }
public List<String> getPathPatternValues() { return pathPatternValues; }
public void setPathPatternValues(List<String> pathPatternValues) { this.pathPatternValues = pathPatternValues; }
public String getHttpHeaderName() { return httpHeaderName; }
public void setHttpHeaderName(String httpHeaderName) { this.httpHeaderName = httpHeaderName; }
public List<String> getHttpHeaderValues() { return httpHeaderValues; }
public void setHttpHeaderValues(List<String> httpHeaderValues) { this.httpHeaderValues = httpHeaderValues; }
public List<String> getHttpMethodValues() { return httpMethodValues; }
public void setHttpMethodValues(List<String> httpMethodValues) { this.httpMethodValues = httpMethodValues; }
public List<String> getSourceIpValues() { return sourceIpValues; }
public void setSourceIpValues(List<String> sourceIpValues) { this.sourceIpValues = sourceIpValues; }
public List<QueryStringPair> getQueryStringValues() { return queryStringValues; }
public void setQueryStringValues(List<QueryStringPair> queryStringValues) { this.queryStringValues = queryStringValues; }
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public static class QueryStringPair {
private String key;
private String value;
public QueryStringPair() {}
public String getKey() { return key; }
public void setKey(String key) { this.key = key; }
public String getValue() { return value; }
public void setValue(String value) { this.value = value; }
}
}
@@ -0,0 +1,24 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class TargetDescription {
private String id;
private Integer port;
private String availabilityZone;
public TargetDescription() {}
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public Integer getPort() { return port; }
public void setPort(Integer port) { this.port = port; }
public String getAvailabilityZone() { return availabilityZone; }
public void setAvailabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; }
}
@@ -0,0 +1,101 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class TargetGroup {
private String targetGroupArn;
private String targetGroupName;
private String protocol;
private String protocolVersion;
private Integer port;
private String vpcId;
private String healthCheckProtocol;
private String healthCheckPort;
private Boolean healthCheckEnabled;
private Integer healthCheckIntervalSeconds;
private Integer healthCheckTimeoutSeconds;
private Integer healthyThresholdCount;
private Integer unhealthyThresholdCount;
private String healthCheckPath;
private String matcher;
private List<String> loadBalancerArns = new ArrayList<>();
private String targetType;
private String ipAddressType;
private String region;
private Map<String, String> attributes = new LinkedHashMap<>();
private List<TargetDescription> targets = new ArrayList<>();
public TargetGroup() {}
public String getTargetGroupArn() { return targetGroupArn; }
public void setTargetGroupArn(String targetGroupArn) { this.targetGroupArn = targetGroupArn; }
public String getTargetGroupName() { return targetGroupName; }
public void setTargetGroupName(String targetGroupName) { this.targetGroupName = targetGroupName; }
public String getProtocol() { return protocol; }
public void setProtocol(String protocol) { this.protocol = protocol; }
public String getProtocolVersion() { return protocolVersion; }
public void setProtocolVersion(String protocolVersion) { this.protocolVersion = protocolVersion; }
public Integer getPort() { return port; }
public void setPort(Integer port) { this.port = port; }
public String getVpcId() { return vpcId; }
public void setVpcId(String vpcId) { this.vpcId = vpcId; }
public String getHealthCheckProtocol() { return healthCheckProtocol; }
public void setHealthCheckProtocol(String healthCheckProtocol) { this.healthCheckProtocol = healthCheckProtocol; }
public String getHealthCheckPort() { return healthCheckPort; }
public void setHealthCheckPort(String healthCheckPort) { this.healthCheckPort = healthCheckPort; }
public Boolean getHealthCheckEnabled() { return healthCheckEnabled; }
public void setHealthCheckEnabled(Boolean healthCheckEnabled) { this.healthCheckEnabled = healthCheckEnabled; }
public Integer getHealthCheckIntervalSeconds() { return healthCheckIntervalSeconds; }
public void setHealthCheckIntervalSeconds(Integer healthCheckIntervalSeconds) { this.healthCheckIntervalSeconds = healthCheckIntervalSeconds; }
public Integer getHealthCheckTimeoutSeconds() { return healthCheckTimeoutSeconds; }
public void setHealthCheckTimeoutSeconds(Integer healthCheckTimeoutSeconds) { this.healthCheckTimeoutSeconds = healthCheckTimeoutSeconds; }
public Integer getHealthyThresholdCount() { return healthyThresholdCount; }
public void setHealthyThresholdCount(Integer healthyThresholdCount) { this.healthyThresholdCount = healthyThresholdCount; }
public Integer getUnhealthyThresholdCount() { return unhealthyThresholdCount; }
public void setUnhealthyThresholdCount(Integer unhealthyThresholdCount) { this.unhealthyThresholdCount = unhealthyThresholdCount; }
public String getHealthCheckPath() { return healthCheckPath; }
public void setHealthCheckPath(String healthCheckPath) { this.healthCheckPath = healthCheckPath; }
public String getMatcher() { return matcher; }
public void setMatcher(String matcher) { this.matcher = matcher; }
public List<String> getLoadBalancerArns() { return loadBalancerArns; }
public void setLoadBalancerArns(List<String> loadBalancerArns) { this.loadBalancerArns = loadBalancerArns; }
public String getTargetType() { return targetType; }
public void setTargetType(String targetType) { this.targetType = targetType; }
public String getIpAddressType() { return ipAddressType; }
public void setIpAddressType(String ipAddressType) { this.ipAddressType = ipAddressType; }
public String getRegion() { return region; }
public void setRegion(String region) { this.region = region; }
public Map<String, String> getAttributes() { return attributes; }
public void setAttributes(Map<String, String> attributes) { this.attributes = attributes; }
public List<TargetDescription> getTargets() { return targets; }
public void setTargets(List<TargetDescription> targets) { this.targets = targets; }
}
@@ -0,0 +1,32 @@
package io.github.hectorvent.floci.services.elbv2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class TargetHealth {
private TargetDescription target;
private String healthCheckPort;
private String state;
private String reason;
private String description;
public TargetHealth() {}
public TargetDescription getTarget() { return target; }
public void setTarget(TargetDescription target) { this.target = target; }
public String getHealthCheckPort() { return healthCheckPort; }
public void setHealthCheckPort(String healthCheckPort) { this.healthCheckPort = healthCheckPort; }
public String getState() { return state; }
public void setState(String state) { this.state = state; }
public String getReason() { return reason; }
public void setReason(String reason) { this.reason = reason; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
}