n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
61 lines (60 loc) • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getApCliConfig = getApCliConfig;
exports.replaceApCliConfig = replaceApCliConfig;
const apiRequest_1 = require("../../../helpers/apiRequest");
const responseFormatter_1 = require("../../../helpers/responseFormatter");
async function getApCliConfig() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const version = this.getNodeParameter('version', 0, '');
// Build query parameters
const queryParams = {};
if (version) {
queryParams.version = version;
}
// Log the request
console.log('Getting AP CLI configuration with parameters:', {
groupNameOrGuidOrSerial,
version,
});
// Build the endpoint
const endpoint = `/configuration/v1/ap_cli/${groupNameOrGuidOrSerial}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams);
console.log('Received AP CLI configuration');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in getApCliConfig:', error);
throw error;
}
}
async function replaceApCliConfig() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const cliCommandsJson = this.getNodeParameter('cliCommands', 0);
// Parse the CLI commands JSON
let cliCommands;
try {
cliCommands = JSON.parse(cliCommandsJson);
}
catch (parseError) {
throw new Error(`Invalid JSON format for CLI commands: ${parseError.message}`);
}
// Log the request
console.log('Replacing AP CLI configuration:', { groupNameOrGuidOrSerial, cliCommands });
// Build the endpoint
const endpoint = `/configuration/v1/ap_cli/${groupNameOrGuidOrSerial}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, cliCommands, {});
console.log('AP CLI configuration replaced successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in replaceApCliConfig:', error);
throw error;
}
}