fix(apigateway): page GetUsagePlans by limit and position (#9125)

* fix(apigateway): page GetUsagePlans by limit and position
* test(apigateway): list every usage plan when a test searches the collection
This commit is contained in:
thejrose1984 authored and GitHub committed 2026-11-21 10:29:21 -04:00
1 parent 93dc80a177
commit e6345cf331
6 files changed
+150 -13

No files matched your search

@@ -911,13 +911,11 @@ public class ApiGatewayController {
@GET
@Path("/usageplans")
public Response getUsagePlans(@Context HttpHeaders headers, @QueryParam("keyId") String keyId) {
public Response getUsagePlans(@Context HttpHeaders headers, @QueryParam("keyId") String keyId,
@QueryParam("limit") String limit, @QueryParam("position") String position) {
String region = regionResolver.resolveRegion(headers);
List<UsagePlan> plans = service.getUsagePlans(region, keyId);
ObjectNode root = objectMapper.createObjectNode();
ArrayNode items = root.putArray("item");
plans.forEach(p -> items.add(toUsagePlanNode(p, false)));
return Response.ok(root.toString()).type(MediaType.APPLICATION_JSON).build();
PaginatedResult<UsagePlan> page = service.getUsagePlanPage(region, keyId, pageLimit(limit), position);
return pageResponse(page, p -> toUsagePlanNode(p, false));
}
@GET
@@ -1774,6 +1774,15 @@ public class ApiGatewayService implements ResourceProvider, Resettable {
.toList();
}
/**
* One {@code GetUsagePlans} page: the {@code keyId}-filtered plans, paged by {@code limit} and
* {@code position} like the other API Gateway collections.
*/
public PaginatedResult<UsagePlan> getUsagePlanPage(String region, String keyId, Integer limit,
String position) {
return pageById(getUsagePlans(region, keyId), UsagePlan::getId, limit, position);
}
/** Its key associations go with it, or a plan recreated with its id would inherit the old keys. */
public void deleteUsagePlan(String region, String usagePlanId) {
synchronized (usagePlanLock) {