fix(codedeploy): honor ListApplications continuation tokens (#6678)

This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-10-26 17:27:41 -04:00
1 parent 9fd0578181
commit 95960f80e8
4 files changed
+153 -4

No files matched your search

@@ -3,6 +3,8 @@ package io.github.hectorvent.floci.services.codedeploy;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
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.services.codedeploy.model.Application;
import io.github.hectorvent.floci.services.codedeploy.model.Deployment;
import io.github.hectorvent.floci.services.codedeploy.model.DeploymentConfig;
@@ -35,7 +37,7 @@ public class CodeDeployJsonHandler {
case "GetApplication" -> getApplication(request, region);
case "UpdateApplication" -> updateApplication(request, region);
case "DeleteApplication" -> deleteApplication(request, region);
case "ListApplications" -> listApplications(region);
case "ListApplications" -> listApplications(request, region);
case "BatchGetApplications" -> batchGetApplications(request, region);
case "CreateDeploymentGroup" -> createDeploymentGroup(request, region);
case "GetDeploymentGroup" -> getDeploymentGroup(request, region);
@@ -97,8 +99,15 @@ public class CodeDeployJsonHandler {
return Response.ok(Map.of()).build();
}
private Response listApplications(String region) {
return Response.ok(Map.of("applications", service.listApplications(region))).build();
private Response listApplications(JsonNode request, String region) {
String token = Pagination.parseNextToken(request, "nextToken", "InvalidNextTokenException");
PaginatedResult<String> page = service.listApplications(region, token);
Map<String, Object> response = new HashMap<>();
response.put("applications", page.items());
if (page.nextToken() != null) {
response.put("nextToken", page.nextToken());
}
return Response.ok(response).build();
}
private Response batchGetApplications(JsonNode req, String region) {
@@ -6,6 +6,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
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.StorageBackedMap;
import io.github.hectorvent.floci.core.storage.StorageFactory;
@@ -389,6 +391,12 @@ public class CodeDeployService {
return new ArrayList<>(applicationsFor(region).keySet());
}
public PaginatedResult<String> listApplications(String region, String nextToken) {
return Pagination.paginate(listApplications(region), name -> name, 100, nextToken,
"codedeploy:ListApplications:" + regionResolver.getAccountId() + ":" + region,
token -> new AwsException("InvalidNextTokenException", "Invalid nextToken.", 400));
}
public List<Application> batchGetApplications(String region, List<String> names) {
Map<String, Application> store = applicationsFor(region);
return names.stream()