fix(bedrock-agentcore): allow maxResults up to 1000 (#2487)

This commit is contained in:
Abarnaa Sree N authored and GitHub committed 2026-08-23 15:51:55 -04:00
1 parent c9f456ea7a
commit 97921982d7
3 files changed
+240 -55

No files matched your search

@@ -24,13 +24,21 @@ public final class Pagination {
private Pagination() {}
public static <T> PaginatedResult<T> paginate(List<T> all, Function<T, String> cursorOf,
Integer maxResults, String nextToken,
int maxPage, String errorCode) {
return paginate(all, cursorOf, maxResults, nextToken, maxPage, maxPage, errorCode);
}
public static <T> PaginatedResult<T> paginate(List<T> all, Function<T, String> cursorOf,
Integer maxResults, String nextToken,
int maxPage, String errorCode) {
if (maxResults != null && (maxResults < 1 || maxResults > maxPage)) {
throw new AwsException(errorCode, "maxResults must be between 1 and " + maxPage, 400);
int defaultPageSize, int maxResultsLimit,
String errorCode) {
if (maxResults != null && (maxResults < 1 || maxResults > maxResultsLimit)) {
throw new AwsException(errorCode,
"maxResults must be between 1 and " + maxResultsLimit, 400);
}
int limit = maxResults != null ? maxResults : maxPage;
int limit = maxResults != null ? maxResults : defaultPageSize;
List<T> sorted = all.stream().sorted(Comparator.comparing(cursorOf)).collect(Collectors.toList());
String after = decodeToken(nextToken, errorCode);
@@ -28,7 +28,8 @@ public class BedrockAgentCoreGatewayService {
private static final String STATUS_DELETING = "DELETING";
private static final String LOWER = "abcdefghijklmnopqrstuvwxyz0123456789";
private static final String ALNUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static final int MAX_PAGE = 100;
private static final int DEFAULT_PAGE = 100;
private static final int MAX_PAGE = 1000;
private final StorageBackend<String, Gateway> storage;
private final RegionResolver regionResolver;
@@ -140,7 +141,14 @@ public class BedrockAgentCoreGatewayService {
public PaginatedResult<Gateway> list(Integer maxResults, String nextToken, String region) {
String prefix = keyPrefix(region);
List<Gateway> all = storage.scan(k -> k.startsWith(prefix));
return Pagination.paginate(all, Gateway::getGatewayId, maxResults, nextToken, MAX_PAGE, "ValidationException");
return Pagination.paginate(
all,
Gateway::getGatewayId,
maxResults,
nextToken,
DEFAULT_PAGE,
MAX_PAGE,
"ValidationException");
}
public String gatewayArn(Gateway gateway, String region) {
@@ -199,8 +207,14 @@ public class BedrockAgentCoreGatewayService {
public PaginatedResult<GatewayTarget> listTargets(String gatewayId, Integer maxResults, String nextToken, String region) {
Gateway gateway = get(gatewayId, region);
return Pagination.paginate(gateway.getTargets(), GatewayTarget::getTargetId, maxResults, nextToken,
MAX_PAGE, "ValidationException");
return Pagination.paginate(
gateway.getTargets(),
GatewayTarget::getTargetId,
maxResults,
nextToken,
DEFAULT_PAGE,
MAX_PAGE,
"ValidationException");
}
private GatewayTarget findTarget(Gateway gateway, String targetId) {