n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
43 lines (42 loc) • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initiateClientSteer = initiateClientSteer;
const apiRequest_1 = require("../../../../helpers/apiRequest");
const logger_1 = require("../../../../helpers/logger");
const errorHandler_1 = require("../../../../helpers/errorHandler");
/**
* Initiate Client Steering
* POST /cm-api/ap/{serial}/client-match/steer
*
* @param this The n8n execution context
* @returns Formatted API response
*/
async function initiateClientSteer() {
var _a;
try {
// Get parameters
const serial = this.getNodeParameter('serial', 0);
const clientMac = this.getNodeParameter('client_mac', 0);
const targetAp = this.getNodeParameter('target_ap', 0);
// Construct request body
const body = {
client_mac: clientMac,
target_ap: targetAp,
};
// Construct API endpoint
const endpoint = '/cm-api/ap/' + encodeURIComponent(serial) + '/client-match/steer';
logger_1.logger.debug('monitoring:ap:initiateClientSteer', `Requesting: ${endpoint}`, { body });
// Make API request
const responseData = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, body);
// Format and return response
return [{ json: responseData }];
}
catch (error) {
logger_1.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 || ((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('404'))) {
return errorHandler_1.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 errorHandler_1.handleApiError.call(this, error, 'Failed to initiate client steering');
}
}