UNPKG

n8n-nodes-arubacentral

Version:

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

52 lines (51 loc) 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getApSettings = getApSettings; exports.replaceApSettings = replaceApSettings; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); async function getApSettings() { try { // Get parameters const serialNumber = this.getNodeParameter('serialNumber', 0); // Log the request console.log('Getting per-AP settings with parameters:', { serialNumber }); // Build the endpoint const endpoint = `/configuration/v1/ap_settings_cli/${serialNumber}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); console.log('Received per-AP settings'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in getApSettings:', error); throw error; } } async function replaceApSettings() { try { // Get parameters const serialNumber = this.getNodeParameter('serialNumber', 0); const apSettingsJson = this.getNodeParameter('apSettings', 0); // Parse the AP Settings JSON let apSettings; try { apSettings = JSON.parse(apSettingsJson); } catch (parseError) { throw new Error(`Invalid JSON format for AP settings: ${parseError.message}`); } // Log the request console.log('Replacing per-AP settings:', { serialNumber, apSettings }); // Build the endpoint const endpoint = `/configuration/v1/ap_settings_cli/${serialNumber}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, apSettings, {}); console.log('Per-AP settings replaced successfully'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in replaceApSettings:', error); throw error; } }