n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
42 lines (36 loc) • 1.33 kB
text/typescript
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { apiRequest } from '../../../../helpers/apiRequest';
import { logger } from '../../../../helpers/logger';
import { handleApiError } from '../../../../helpers/errorHandler';
/**
* Get Switch Chassis Details
*
* GET /monitoring/v1/switches/{serial}/chassis_info
*
* @param this The n8n execution context
* @returns Formatted API response
*/
export async function getSwitchChassisDetails(
this: IExecuteFunctions,
): Promise<INodeExecutionData[]> {
try {
// Get parameters
const serial = this.getNodeParameter('serial', 0) as string;
logger.debug(
'monitoring:switch:getSwitchChassisDetails',
`Getting chassis details for switch with serial: ${serial}`,
);
// Make API request
const endpoint = `/monitoring/v1/switches/${encodeURIComponent(serial)}/chassis_info`;
const responseData = await apiRequest.call(this, 'GET', endpoint);
logger.debug(
'monitoring:switch:getSwitchChassisDetails',
'Successfully retrieved switch chassis details',
);
// Return formatted response
return [{ json: responseData }];
} catch (error) {
logger.error('monitoring:switch:getSwitchChassisDetails:error', { message: error.message });
return handleApiError.call(this, error, 'Failed to get switch chassis details');
}
}