UNPKG

n8n-nodes-arubacentral

Version:

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

54 lines (53 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCxSwitchPortsErrors = getCxSwitchPortsErrors; const apiRequest_1 = require("../../../../helpers/apiRequest"); const logger_1 = require("../../../../helpers/logger"); const errorHandler_1 = require("../../../../helpers/errorHandler"); /** * Get CX Switch Ports Errors * * GET /monitoring/v1/cx_switches/{serial}/ports/errors * * @param this The n8n execution context * @returns Formatted API response */ async function getCxSwitchPortsErrors() { try { // Get parameters const serial = this.getNodeParameter('serial', 0); const fromTimestamp = this.getNodeParameter('from_timestamp', 0, ''); const toTimestamp = this.getNodeParameter('to_timestamp', 0, ''); const additionalFields = this.getNodeParameter('additionalFields', 0, {}); // Construct query parameters const qs = {}; // Add time range parameters if (fromTimestamp) { const fromDate = new Date(fromTimestamp); qs.from_timestamp = Math.floor(fromDate.getTime() / 1000); } if (toTimestamp) { const toDate = new Date(toTimestamp); qs.to_timestamp = Math.floor(toDate.getTime() / 1000); } // Add port parameter if provided if (additionalFields.port !== undefined && additionalFields.port !== '') { qs.port = additionalFields.port; } // Add error parameter if provided if (additionalFields.error !== undefined && additionalFields.error !== '') { qs.error = additionalFields.error; } logger_1.logger.debug('monitoring:switch:getCxSwitchPortsErrors', `Getting ports errors for CX switch with serial: ${serial}`); // Make API request const endpoint = `/monitoring/v1/cx_switches/${encodeURIComponent(serial)}/ports/errors`; const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, qs); logger_1.logger.debug('monitoring:switch:getCxSwitchPortsErrors', 'Successfully retrieved CX switch ports errors'); // Return formatted response return [{ json: responseData }]; } catch (error) { logger_1.logger.error('monitoring:switch:getCxSwitchPortsErrors:error', { message: error.message }); return errorHandler_1.handleApiError.call(this, error, 'Failed to get CX switch ports errors'); } }