From fca8b5b5a76c1c92cb162cde988f6d65fdb709c4 Mon Sep 17 00:00:00 2001 From: Gonzalo Avalos Ribas Date: Fri, 17 Nov 2023 15:26:10 -0300 Subject: [PATCH 1/3] Added pagination --- src/client/index.ts | 48 ++++++++++++++++++++++++------------------- src/steps/profiles.ts | 4 ---- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index 433a692..12cb663 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -152,27 +152,33 @@ export default class AirWatchClient { iteratee: ResourceIteratee, groupUuid: string, ): Promise { - const response = await this.makeRequest( - `/mdm/profiles/search`, - 'POST', - JSON.stringify({ - profileSearchRequestV3Model: { - organization_group_uuid: groupUuid, - }, - }), - '3', - ); - - for (const profile of response.profiles) { - //If we need to add details, for now its not needed. - // const details = await this.makeRequest( - // `/mdm/profiles/${profile.uuid}`, - // 'GET', - // undefined, - // '3', - // ); - await iteratee(profile); - } + let page = 0; + let response: AirwatchProfileResponse; + let accumulated = 0; + do { + response = await this.makeRequest( + `/mdm/profiles/search`, + 'POST', + JSON.stringify({ + profileSearchRequestV3Model: { + organization_group_uuid: groupUuid, + page_number: page, + }, + }), + '3', + ); + accumulated += response.profiles.length ?? 0; + for (const profile of response.profiles) { + //If we need to add details, for now its not needed. + // const details = await this.makeRequest( + // `/mdm/profiles/${profile.uuid}`, + // 'GET', + // undefined, + // '3', + // ); + await iteratee(profile); + } + } while (accumulated < response.total_count); } public async fetchDevicesForProfile( diff --git a/src/steps/profiles.ts b/src/steps/profiles.ts index 916a170..6dc4c2d 100644 --- a/src/steps/profiles.ts +++ b/src/steps/profiles.ts @@ -60,10 +60,6 @@ export async function buildDeviceProfileRelationships({ // we don't have a way to test this - I'm using the model provided by the provider // Let's try logging. for (const device of response.profileAssignedDevices) { - logger.info( - { deviceKeys: Object.keys(device) }, - 'TEMP - Keys of device', - ); if ( device.uuid && profileEntity._key && From 4d90d2a826d2b77d124fa2b5891ca7bd5e00b9e1 Mon Sep 17 00:00:00 2001 From: Gonzalo Avalos Ribas Date: Fri, 17 Nov 2023 15:27:29 -0300 Subject: [PATCH 2/3] Corrected page number --- src/client/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/index.ts b/src/client/index.ts index 12cb663..0919cc6 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -178,6 +178,7 @@ export default class AirWatchClient { // ); await iteratee(profile); } + page++; } while (accumulated < response.total_count); } From 34819f6f1c7eda70e7c870e681b6cc91a4f684b6 Mon Sep 17 00:00:00 2001 From: Gonzalo Avalos Ribas Date: Fri, 17 Nov 2023 15:32:48 -0300 Subject: [PATCH 3/3] v0.6.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7498f16..0d8c355 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jupiterone/graph-airwatch", - "version": "0.6.6", + "version": "0.6.7", "description": "A graph conversion tool for https://www.air-watch.com/.", "repository": { "type": "git",