diff --git a/docs/services/glue.md b/docs/services/glue.md
index 9b058277ac..4a39e5b675 100644
--- a/docs/services/glue.md
+++ b/docs/services/glue.md
@@ -31,7 +31,7 @@ descriptor keeps the `AdditionalLocations`, `BucketColumns`, `SortColumns`, `Ske
|--------|-------------|
| CreateDatabase | Creates a database in the local Glue Data Catalog. |
| GetDatabase | Returns a stored Data Catalog database. |
-| GetDatabases | Lists databases in the local Glue Data Catalog. |
+| GetDatabases | Lists databases in pages using `MaxResults` and `NextToken`. |
| DeleteDatabase | Deletes a database from the local Glue Data Catalog. |
#### Tables
@@ -40,11 +40,11 @@ descriptor keeps the `AdditionalLocations`, `BucketColumns`, `SortColumns`, `Ske
|--------|-------------|
| CreateTable | Creates a table definition in the local Glue Data Catalog. |
| GetTable | Returns a stored table definition and resolves schema references when possible. |
-| GetTables | Lists table definitions for a database. |
+| GetTables | Lists table definitions for a database in pages using `MaxResults` and `NextToken`. |
| UpdateTable | Replaces a table definition; the previous version is archived unless `SkipArchive` is set. |
| DeleteTable | Deletes a table definition from a database. |
| BatchDeleteTable | Deletes several tables of a database, reporting the missing ones in `Errors`. |
-| GetTableVersions | Lists the current and archived versions of a table, newest first. |
+| GetTableVersions | Lists the current and archived versions of a table, newest first, in pages using `MaxResults` and `NextToken`. |
| GetTableVersion | Returns one version by `VersionId`, or the current version when none is given. |
| DeleteTableVersion | Deletes an archived version; the current version cannot be deleted, as on AWS. |
| BatchDeleteTableVersion | Deletes several archived versions, reporting the ones not deleted in `Errors`. |
@@ -55,7 +55,7 @@ descriptor keeps the `AdditionalLocations`, `BucketColumns`, `SortColumns`, `Ske
| Action | Description |
|--------|-------------|
| CreatePartition | Creates a partition for a Data Catalog table. |
-| GetPartitions | Lists partitions stored for a Data Catalog table. With a `Segment`, returns that segment's share of them: each partition is in exactly one of `TotalSegments` (1 to 10) segments; a `Segment` member that is not an integer is a `SerializationException`. AWS documents `SegmentNumber` values from 0 through `TotalSegments` minus 1 and not what a larger one returns, so a `SegmentNumber` of `TotalSegments` or more returning no partitions is Floci's reading. |
+| GetPartitions | Lists partitions stored for a Data Catalog table in pages using `MaxResults` and `NextToken`. With a `Segment`, returns that segment's share of them: each partition is in exactly one of `TotalSegments` (1 to 10) segments; a `Segment` member that is not an integer is a `SerializationException`. AWS documents `SegmentNumber` values from 0 through `TotalSegments` minus 1 and not what a larger one returns, so a `SegmentNumber` of `TotalSegments` or more returning no partitions is Floci's reading. |
| BatchDeletePartition | Deletes up to 25 partitions, reporting the ones not found in `Errors`. |
| CreatePartitionIndex | Registers a partition index on a table. Keys must name partition columns, and a table holds at most 3 indexes. The index reports `CREATING` before `ACTIVE`. |
| GetPartitionIndexes | Lists a table's partition indexes, each with its keys resolved to name and type. |
@@ -437,3 +437,5 @@ aws glue list-schema-versions \
--schema-id RegistryName=local-registry,SchemaName=orders \
--endpoint-url $AWS_ENDPOINT_URL
```
+
+Catalog pagination for GetDatabases, GetTables, GetPartitions and GetTableVersions uses opaque continuation cursors ordered by database name, table name, partition values and descending version number respectively. Removing the last returned item or inserting items before its cursor does not invalidate continuation. Table schema references are resolved for the selected page.
diff --git a/src/main/java/io/floci/aws/services/glue/GlueJsonHandler.java b/src/main/java/io/floci/aws/services/glue/GlueJsonHandler.java
index d315087af7..f323c7dafa 100644
--- a/src/main/java/io/floci/aws/services/glue/GlueJsonHandler.java
+++ b/src/main/java/io/floci/aws/services/glue/GlueJsonHandler.java
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.AwsJsonTimestamp;
import io.floci.aws.core.common.EpochSeconds;
+import io.floci.aws.core.common.Pagination;
import io.floci.aws.services.glue.model.*;
import io.floci.aws.services.glue.schemaregistry.GlueSchemaRegistryService;
import io.floci.aws.services.glue.schemaregistry.model.Registry;
@@ -90,9 +91,7 @@ public class GlueJsonHandler {
Database db = glueService.getDatabase(name);
yield Response.ok(Map.of("Database", db)).build();
}
- case "GetDatabases" -> {
- yield Response.ok(Map.of("DatabaseList", glueService.getDatabases())).build();
- }
+ case "GetDatabases" -> handleGetDatabases(request);
case "DeleteDatabase" -> {
String name = request.get("Name").asText();
glueService.deleteDatabase(name, region);
@@ -141,9 +140,13 @@ public class GlueJsonHandler {
glueService.getPartitionIndexes(dbName, tableName))).build();
}
case "GetTables" -> {
+ Integer maxResults = Pagination.parseMaxResults(request, "MaxResults", "InvalidInputException");
+ String nextToken = Pagination.parseNextToken(request, "NextToken", "InvalidInputException");
String dbName = request.get("DatabaseName").asText();
- List
tables = glueService.getTables(dbName).stream().map(GlueService::withReadDefaults).toList();
- yield Response.ok(Map.of("TableList", tables)).build();
+ GlueService.Page page = glueService.getTables(
+ dbName, maxResults, nextToken);
+ List tables = page.items().stream().map(GlueService::withReadDefaults).toList();
+ yield Response.ok(pageResponse("TableList", tables, page.nextToken())).build();
}
case "UpdateTable" -> {
String dbName = request.get("DatabaseName").asText();
@@ -153,9 +156,13 @@ public class GlueJsonHandler {
yield Response.ok().build();
}
case "GetTableVersions" -> {
+ Integer maxResults = Pagination.parseMaxResults(request, "MaxResults", "InvalidInputException");
+ String nextToken = Pagination.parseNextToken(request, "NextToken", "InvalidInputException");
String dbName = request.get("DatabaseName").asText();
String tableName = request.get("TableName").asText();
- yield Response.ok(Map.of("TableVersions", glueService.getTableVersions(dbName, tableName))).build();
+ GlueService.Page