n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
52 lines (51 loc) • 2.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSystemConfig = getSystemConfig;
exports.updateSystemConfig = updateSystemConfig;
const apiRequest_1 = require("../../../helpers/apiRequest");
const responseFormatter_1 = require("../../../helpers/responseFormatter");
async function getSystemConfig() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
// Log the request
console.log('Getting system config with parameters:', { groupNameOrGuidOrSerial });
// Build the endpoint
const endpoint = `/configuration/v1/system_config/${groupNameOrGuidOrSerial}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {});
console.log('Received system config');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in getSystemConfig:', error);
throw error;
}
}
async function updateSystemConfig() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const systemConfigJson = this.getNodeParameter('systemConfig', 0);
// Parse the System Config JSON
let systemConfig;
try {
systemConfig = JSON.parse(systemConfigJson);
}
catch (parseError) {
throw new Error(`Invalid JSON format for system config: ${parseError.message}`);
}
// Log the request
console.log('Updating system config:', { groupNameOrGuidOrSerial, systemConfig });
// Build the endpoint
const endpoint = `/configuration/v1/system_config/${groupNameOrGuidOrSerial}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, systemConfig, {});
console.log('System config updated successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in updateSystemConfig:', error);
throw error;
}
}