UNPKG

n8n-nodes-arubacentral

Version:

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

49 lines (41 loc) 1.7 kB
import { IExecuteFunctions, INodeExecutionData, IDataObject } from 'n8n-workflow'; import { apiRequest } from '../../../../helpers/apiRequest'; import { logger } from '../../../../helpers/logger'; import { handleApiError } from '../../../../helpers/errorHandler'; /** * Get Switch Port PoE Info * * GET /monitoring/v1/switches/{serial}/poe_detail * * @param this The n8n execution context * @returns Formatted API response */ export async function getSwitchPortPoeInfo(this: IExecuteFunctions): Promise<INodeExecutionData[]> { try { // Get parameters const serial = this.getNodeParameter('serial', 0) as string; const additionalFields = this.getNodeParameter('additionalFields', 0, {}) as IDataObject; // Construct query parameters const qs: IDataObject = {}; // Add port parameter if provided if (additionalFields.port !== undefined && additionalFields.port !== '') { qs.port = additionalFields.port; } logger.debug( 'monitoring:switch:getSwitchPortPoeInfo', `Getting port PoE info for switch with serial: ${serial}${additionalFields.port ? ', port: ' + additionalFields.port : ''}`, ); // Make API request const endpoint = `/monitoring/v1/switches/${encodeURIComponent(serial)}/poe_detail`; const responseData = await apiRequest.call(this, 'GET', endpoint, {}, qs); logger.debug( 'monitoring:switch:getSwitchPortPoeInfo', 'Successfully retrieved switch port PoE info', ); // Return formatted response return [{ json: responseData }]; } catch (error) { logger.error('monitoring:switch:getSwitchPortPoeInfo:error', { message: error.message }); return handleApiError.call(this, error, 'Failed to get switch port PoE info'); } }