mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): page GetModels with limit and position (#9127)
GetModels ignored limit and returned the whole collection without a position. It now pages through pageById and pageResponse like the other API Gateway list actions: at most limit models (25 by default), a position while more remain, and BadRequestException for an unknown position. Closes #9037
This commit is contained in:
1 parent
c2640aaa22
commit
93dc80a177
3 files changed
+104
-6
No files matched your search
@@ -1197,13 +1197,13 @@ public class ApiGatewayController {
|
||||
|
||||
@GET
|
||||
@Path("/restapis/{apiId}/models")
|
||||
public Response getModels(@Context HttpHeaders headers, @PathParam("apiId") String apiId) {
|
||||
public Response getModels(@Context HttpHeaders headers, @PathParam("apiId") String apiId,
|
||||
@QueryParam("limit") String limit, @QueryParam("position") String position) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<io.floci.aws.services.apigateway.model.Model> models = service.getModels(region, apiId);
|
||||
ObjectNode root = objectMapper.createObjectNode();
|
||||
ArrayNode items = root.putArray("item");
|
||||
models.forEach(m -> items.add(toModelNode(m)));
|
||||
return Response.ok(root.toString()).type(MediaType.APPLICATION_JSON).build();
|
||||
// Model clashes with the imported API Gateway v2 model
|
||||
PaginatedResult<io.floci.aws.services.apigateway.model.Model> page =
|
||||
service.getModelPage(region, apiId, pageLimit(limit), position);
|
||||
return pageResponse(page, this::toModelNode);
|
||||
}
|
||||
|
||||
@GET
|
||||
|
||||
@@ -2501,6 +2501,10 @@ public class ApiGatewayService implements ResourceProvider, Resettable {
|
||||
return modelStore.scan(k -> k.startsWith(prefix));
|
||||
}
|
||||
|
||||
public PaginatedResult<Model> getModelPage(String region, String apiId, Integer limit, String position) {
|
||||
return pageById(getModels(region, apiId), Model::getId, limit, position);
|
||||
}
|
||||
|
||||
public void deleteModel(String region, String apiId, String modelName) {
|
||||
getModel(region, apiId, modelName);
|
||||
modelStore.delete(modelKey(region, apiId, modelName));
|
||||
|
||||
Reference in new issue
Block a user