n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
57 lines (56 loc) • 2.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDevices = getDevices;
const apiRequest_1 = require("../../../../helpers/apiRequest");
const logger_1 = require("../../../../helpers/logger");
const errorHandler_1 = require("../../../../helpers/errorHandler");
/**
* Retrieves a list of devices with their firmware details
* GET /firmware/v1/devices
*
* @param this The n8n execution context
* @returns List of devices with firmware details
*/
async function getDevices() {
try {
// Get device type - THIS IS REQUIRED
const deviceType = this.getNodeParameter('deviceType', 0);
// Prepare query parameters
const queryParams = {
device_type: deviceType,
};
// Add additional filters if provided
const additionalFields = this.getNodeParameter('additionalFields', 0, {});
if (additionalFields.group) {
queryParams.group = additionalFields.group;
}
// Add pagination parameters
const returnAll = this.getNodeParameter('returnAll', 0, false);
if (!returnAll) {
queryParams.limit = this.getNodeParameter('limit', 0, 20);
}
// Log request details
logger_1.logger.debug('firmware:device:getDevices:request', {
endpoint: '/firmware/v1/devices',
queryParams,
});
// Make the API request
const response = await apiRequest_1.apiRequest.call(this, 'GET', '/firmware/v1/devices', {}, // No body for GET request
queryParams);
// Log response preview
logger_1.logger.debug('firmware:device:getDevices:response', {
responseType: typeof response,
responseIsNull: response === null,
responsePreview: response ? JSON.stringify(response).substring(0, 200) : 'null',
});
// Return the full response
return [{ json: response }];
}
catch (error) {
logger_1.logger.error('firmware:device:getDevices:error', {
message: error.message,
stack: error.stack,
});
return errorHandler_1.handleApiError.call(this, error, 'Failed to retrieve device firmware details');
}
}