UNPKG

n8n-nodes-arubacentral

Version:

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

50 lines (42 loc) 1.81 kB
import { IExecuteFunctions, INodeExecutionData, IDataObject } from 'n8n-workflow'; import { apiRequest } from '../../../../helpers/apiRequest'; import { logger } from '../../../../helpers/logger'; import { handleApiError } from '../../../../helpers/errorHandler'; /** * Initiate Client Steering * POST /cm-api/ap/{serial}/client-match/steer * * @param this The n8n execution context * @returns Formatted API response */ export async function initiateClientSteer(this: IExecuteFunctions): Promise<INodeExecutionData[]> { try { // Get parameters const serial = this.getNodeParameter('serial', 0) as string; const clientMac = this.getNodeParameter('client_mac', 0) as string; const targetAp = this.getNodeParameter('target_ap', 0) as string; // Construct request body const body: IDataObject = { client_mac: clientMac, target_ap: targetAp, }; // Construct API endpoint const endpoint = '/cm-api/ap/' + encodeURIComponent(serial) + '/client-match/steer'; logger.debug('monitoring:ap:initiateClientSteer', `Requesting: ${endpoint}`, { body }); // Make API request const responseData = await apiRequest.call(this, 'POST', endpoint, body); // Format and return response return [{ json: responseData }]; } catch (error) { logger.error('monitoring:ap:initiateClientSteer:error', { message: error.message }); // Handle 404 specifically for ClientMatch APIs which may not be available on all clusters if (error.httpCode === 404 || error.message?.includes('404')) { return handleApiError.call( this, error, 'ClientMatch API not available on this cluster or AP does not support ClientMatch. This is an undocumented API that may not be enabled for all devices.', ); } return handleApiError.call(this, error, 'Failed to initiate client steering'); } }