From 75c358148c7d9ec6df77c1f5a43323566d74ca2f Mon Sep 17 00:00:00 2001 From: Cathal Garvey Date: Wed, 5 Oct 2022 09:11:37 +0100 Subject: [PATCH] fix(manager): specify a higher per_page for DigitalOcean API call (#1113) * Fixes #999. Specify a higher per_page for DigitalOcean API call to get droplets. * Review feedback: Add TODOs for proper pagination, extend other 'droplets' DO API call to use 100 as well. 100 is the tested limit, and a sane default until proper pagination --- src/server_manager/cloud/digitalocean_api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server_manager/cloud/digitalocean_api.ts b/src/server_manager/cloud/digitalocean_api.ts index 68099068b..aa38288fa 100644 --- a/src/server_manager/cloud/digitalocean_api.ts +++ b/src/server_manager/cloud/digitalocean_api.ts @@ -198,9 +198,10 @@ export class RestApiSession implements DigitalOceanSession { public getDropletsByTag(tag: string): Promise { console.info('Requesting droplet by tag'); + // TODO Add proper pagination support. Going with 100 for now to extend the default of 20, and confirm UI works return this.request<{droplets: DropletInfo[]}>( 'GET', - `droplets?tag_name=${encodeURI(tag)}` + `droplets?per_page=100&tag_name=${encodeURI(tag)}` ).then((response) => { return response.droplets; }); @@ -208,7 +209,8 @@ export class RestApiSession implements DigitalOceanSession { public getDroplets(): Promise { console.info('Requesting droplets'); - return this.request<{droplets: DropletInfo[]}>('GET', 'droplets').then((response) => { + // TODO Add proper pagination support. Going with 100 for now to extend the default of 20, and confirm UI works + return this.request<{droplets: DropletInfo[]}>('GET', 'droplets?per_page=100').then((response) => { return response.droplets; }); }