diff --git a/docs/services/globalaccelerator.md b/docs/services/globalaccelerator.md
index 64642fd5df..27310074a9 100644
--- a/docs/services/globalaccelerator.md
+++ b/docs/services/globalaccelerator.md
@@ -125,12 +125,14 @@ These operations return `UnknownOperationException` rather than a stub success:
list, so a BYOIP address can be pinned without provisioning a pool.
- Cross-account attachments (`CreateCrossAccountAttachment` and friends)
-Two more gaps are worth calling out:
+`ListAccelerators` supports `MaxResults` (1–100, default 10) and `NextToken`.
+
+Other gaps are worth calling out:
- `IdempotencyToken` is accepted but not deduplicated, so repeating a create produces a
second resource.
-- The list operations ignore `MaxResults` and return every resource in one page with no
- `NextToken`. A paginator terminates after the first call.
+- The other list operations ignore `MaxResults` and return every resource in one page
+ with no `NextToken`.
- `AddEndpoints` returns the endpoint group's whole endpoint list rather than only the
endpoints the call added.
diff --git a/pom.xml b/pom.xml
index a59b4b9818..649f06ea9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -348,6 +348,12 @@
${aws.sdk.version}
test
+
+ software.amazon.awssdk
+ globalaccelerator
+ ${aws.sdk.version}
+ test
+
software.amazon.awssdk
batch
diff --git a/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorJsonHandler.java
index 1d69c7967e..3a96ccc340 100644
--- a/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorJsonHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorJsonHandler.java
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.PaginatedResult;
+import io.github.hectorvent.floci.services.globalaccelerator.model.Accelerator;
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;
@@ -57,7 +59,25 @@ public class GlobalAcceleratorJsonHandler {
service.deleteAccelerator(text(request, "AcceleratorArn"));
yield Response.ok(Map.of()).build();
}
- case "ListAccelerators" -> Response.ok(Map.of("Accelerators", service.listAccelerators())).build();
+ case "ListAccelerators" -> {
+ JsonNode maxResults = request.get("MaxResults");
+ if (maxResults != null && !maxResults.isNull()
+ && (!maxResults.isIntegralNumber() || !maxResults.canConvertToInt())) {
+ throw new AwsException("InvalidArgumentException", "MaxResults must be between 1 and 100", 400);
+ }
+ JsonNode nextToken = request.get("NextToken");
+ if (nextToken != null && !nextToken.isNull() && !nextToken.isTextual()) {
+ throw new AwsException("InvalidNextTokenException", "Invalid NextToken", 400);
+ }
+ PaginatedResult page = service.listAccelerators(
+ integer(request, "MaxResults"), text(request, "NextToken"));
+ Map result = new LinkedHashMap<>();
+ result.put("Accelerators", page.items());
+ if (page.nextToken() != null) {
+ result.put("NextToken", page.nextToken());
+ }
+ yield Response.ok(result).build();
+ }
case "DescribeAcceleratorAttributes" -> Response.ok(Map.of("AcceleratorAttributes",
service.describeAcceleratorAttributes(text(request, "AcceleratorArn")))).build();
case "UpdateAcceleratorAttributes" -> Response.ok(Map.of("AcceleratorAttributes",
diff --git a/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorService.java b/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorService.java
index 7fd0a2c81a..c168858d25 100644
--- a/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorService.java
@@ -3,6 +3,8 @@ 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.PaginatedResult;
+import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
@@ -188,6 +190,19 @@ public class GlobalAcceleratorService {
return accelerators.scan(key -> true);
}
+ public PaginatedResult listAccelerators(Integer maxResults, String nextToken) {
+ int limit = maxResults != null ? maxResults : 10;
+ if (limit < 1 || limit > 100) {
+ throw new AwsException("InvalidArgumentException", "MaxResults must be between 1 and 100", 400);
+ }
+ if (nextToken != null && nextToken.length() > 255) {
+ throw new AwsException("InvalidNextTokenException", "Invalid NextToken", 400);
+ }
+ String namespace = "ListAccelerators:" + regionResolver.getPartition() + ":" + regionResolver.getAccountId();
+ return Pagination.paginate(listAccelerators(), Accelerator::getAcceleratorArn, limit, nextToken, namespace,
+ token -> new AwsException("InvalidNextTokenException", "Invalid NextToken", 400));
+ }
+
public AcceleratorAttributes describeAcceleratorAttributes(String acceleratorArn) {
describeAccelerator(acceleratorArn);
return acceleratorAttributes.get(acceleratorArn).orElseGet(GlobalAcceleratorService::defaultAttributes);
diff --git a/src/test/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorPaginationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorPaginationIntegrationTest.java
new file mode 100644
index 0000000000..231e4b1f55
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/globalaccelerator/GlobalAcceleratorPaginationIntegrationTest.java
@@ -0,0 +1,212 @@
+package io.github.hectorvent.floci.services.globalaccelerator;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.core.common.AwsArnUtils;
+import io.github.hectorvent.floci.core.common.AwsRegions;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.globalaccelerator.model.Accelerator;
+import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import jakarta.inject.Inject;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.globalaccelerator.GlobalAcceleratorClient;
+import software.amazon.awssdk.services.globalaccelerator.model.InvalidArgumentException;
+import software.amazon.awssdk.services.globalaccelerator.model.InvalidNextTokenException;
+import software.amazon.awssdk.services.globalaccelerator.model.ListAcceleratorsResponse;
+
+import java.net.URI;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class GlobalAcceleratorPaginationIntegrationTest {
+
+ private static final String ACCOUNT = "741649500001";
+ private static final String OTHER_ACCOUNT = "741649500002";
+ private static final Region REGION = Region.US_WEST_2;
+
+ @Inject
+ StorageFactory storageFactory;
+
+ private AccountAwareStorageBackend accelerators;
+ private final List seeded = new ArrayList<>();
+
+ @BeforeAll
+ static void configureRestAssured() {
+ RestAssuredJsonUtils.configureAwsContentTypes();
+ }
+
+ @BeforeEach
+ void setUp() {
+ accelerators = storageFactory.create("globalaccelerator", "globalaccelerator-accelerators.json",
+ new TypeReference