fix(kinesisanalytics): paginate ListApplicationSnapshots (#7185)

* fix(kinesisanalytics): paginate ListApplicationSnapshots

* test(kinesisanalytics): cover ListApplicationSnapshots pagination and bounds

* test(kinesisanalytics): pin the snapshot cursor contract in tests

Assert the delete in the resume-after-deletion test, and the surviving list
length, so a no-op delete cannot let the case pass vacuously. Accept a token
purely as a cursor up to the modeled 512 characters, since this NextToken
declares no pattern. Reuse the issued token instead of retyping the expected
cursor, and assert the page-size message on the wire.
This commit is contained in:
Rashen Anupama authored and GitHub committed 2026-11-01 08:09:38 -04:00
1 parent d2d9ed6ca2
commit 6b3f482510
4 files changed
+211 -1

No files matched your search

@@ -214,11 +214,17 @@ public class KinesisAnalyticsV2JsonHandler {
private Response handleListApplicationSnapshots(JsonNode request, String region) {
String applicationName = request.path("ApplicationName").asText(null);
Integer limit = Pagination.parseMaxResults(request, "Limit", "InvalidArgumentException");
String nextToken = Pagination.parseNextToken(request, "NextToken", "InvalidArgumentException");
PaginatedResult<Snapshot> page = service.listApplicationSnapshots(applicationName, region, limit, nextToken);
ObjectNode response = objectMapper.createObjectNode();
ArrayNode summaries = response.putArray("SnapshotSummaries");
for (Snapshot snapshot : service.listApplicationSnapshots(applicationName, region)) {
for (Snapshot snapshot : page.items()) {
summaries.add(snapshotDetailNode(snapshot));
}
if (page.nextToken() != null) {
response.put("NextToken", page.nextToken());
}
return Response.ok(response).build();
}
@@ -561,6 +561,14 @@ public class KinesisAnalyticsV2Service {
return List.copyOf(describeApplication(applicationName, region).getSnapshots().values());
}
public PaginatedResult<Snapshot> listApplicationSnapshots(String applicationName, String region,
Integer limit, String nextToken) {
// AWS: ListSnapshotsInputLimit is 1 to 50 and NextToken is 1 to 512 with no pattern, so
// unlike ListApplications the token is not checked against a resource name here.
return Pagination.paginateUnencoded(listApplicationSnapshots(applicationName, region),
Snapshot::getSnapshotName, limit, nextToken, 50, 50, 512, "InvalidArgumentException");
}
public void deleteApplicationSnapshot(String applicationName, String snapshotName,
Instant snapshotCreationTimestamp) {
deleteApplicationSnapshot(applicationName, snapshotName, snapshotCreationTimestamp,