UNPKG

n8n-nodes-arubacentral

Version:

n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities

56 lines (55 loc) 2.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDirtyDiff = getDirtyDiff; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); const pagination_1 = require("../../../helpers/pagination"); async function getDirtyDiff() { try { // Get parameters const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0); const returnAll = this.getNodeParameter('returnAll', 0, false); let limit; if (!returnAll) { limit = this.getNodeParameter('limit', 0, 20); } const additionalOptions = this.getNodeParameter('additionalOptions', 0, {}); // Build query parameters const queryParams = {}; // Use additionalOptions only if not using returnAll/limit if (!returnAll && !limit) { if (additionalOptions.limit) { queryParams.limit = Math.min(additionalOptions.limit, 20); // Ensure max 20 } if (additionalOptions.offset) { queryParams.offset = additionalOptions.offset; } } // Log the request console.log('Getting dirty diff with parameters:', { groupNameOrGuidOrSerial, returnAll, limit, additionalOptions, }); // Build the endpoint const endpoint = `/configuration/v1/dirty_diff/${groupNameOrGuidOrSerial}`; if (returnAll || limit) { // Use pagination helper with a custom batch size of 20 return await pagination_1.handlePagination.call(this, endpoint, 'GET', {}, queryParams, { path: ['dirty_diff_list'], fallbackPaths: [['data', 'dirty_diff_list']], }, returnAll, limit, 20); } else { // Make a single API call without pagination const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams); console.log('Received dirty diff'); return responseFormatter_1.formatResponse.call(this, response); } } catch (error) { console.log('ERROR in getDirtyDiff:', error); throw error; } }