From 265dd878d509b37919a08b6cd59654e5f12925f1 Mon Sep 17 00:00:00 2001 From: Jinesh Varia Date: Wed, 24 Jun 2020 17:03:04 -0700 Subject: [PATCH] Updating apis to overcome the 25 limit. Currently, due to default limit of 25, getRestAPis is getting only 25 APIs and even with usagePlan fix #257 does not show all the apis in the portal because usageplan APIs are filtered with apis list. Hence add this will help query a larger limit. --- lambdas/backend/routes/admin/catalog/visibility.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lambdas/backend/routes/admin/catalog/visibility.js b/lambdas/backend/routes/admin/catalog/visibility.js index ae7c23b69..2e8353a4b 100644 --- a/lambdas/backend/routes/admin/catalog/visibility.js +++ b/lambdas/backend/routes/admin/catalog/visibility.js @@ -9,7 +9,19 @@ exports.get = async (req, res) => { try { const visibility = { apiGateway: [] } const catalogObject = await util.catalog() - const apis = (await util.apigateway.getRestApis().promise()).items + + const defaultParams = { limit: 500 }; + let response = await util.apigateway.getRestApis(defaultParams).promise(); + const apis = response.items; + + while (response.position) { + console.log( + `Fetching next page of api, at position=[${response.position}]` + ); + const nextParams = { ...defaultParams, position: response.position }; + response = await util.apiGateway.getRestApis(nextParams).promise(); + apis.push(...response.items); + } console.log(`network request: ${JSON.stringify(apis, null, 4)}`) console.log(`apis: ${JSON.stringify(apis, null, 4)}`)