From 35c5058ba938c741a77f8da0de92b879b854ddea Mon Sep 17 00:00:00 2001 From: amazon-meaisiah Date: Fri, 15 May 2020 11:54:28 -0700 Subject: [PATCH] Fix unintended limitation with fetching APIs --- .../backend/routes/admin/catalog/visibility.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lambdas/backend/routes/admin/catalog/visibility.js b/lambdas/backend/routes/admin/catalog/visibility.js index e36d53e1e..1c7ad0af2 100644 --- a/lambdas/backend/routes/admin/catalog/visibility.js +++ b/lambdas/backend/routes/admin/catalog/visibility.js @@ -6,12 +6,26 @@ const util = require('../../../util') const inspect = o => JSON.stringify(o, null, 2) +// Let's try to minimize how many calls we make here. +const MAX_REST_API_LIMIT = 500 + exports.get = async (req, res) => { console.log(`GET /admin/catalog/visibility for Cognito ID: ${util.getCognitoIdentityId(req)}`) try { const visibility = { apiGateway: [] } const catalogObject = await util.catalog() - const apis = (await util.apigateway.getRestApis().promise()).items + let restApiResult = await util.apigateway.getRestApis({ + limit: MAX_REST_API_LIMIT + }).promise() + const apis = restApiResult.items + + while (restApiResult.position != null) { + restApiResult = await util.apigateway.getRestApis({ + limit: MAX_REST_API_LIMIT, + position: restApiResult.position + }).promise() + for (const api of restApiResult.apis) apis.push(api) + } console.log(`apis: ${inspect(apis)}`)