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.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getArmConfig = getArmConfig; exports.updateArmConfig = updateArmConfig; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); async function getArmConfig() { try { // Get parameters const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0); // Log the request console.log('Getting ARM config with parameters:', { groupNameOrGuidOrSerial }); // Build the endpoint const endpoint = `/configuration/v1/arm/${groupNameOrGuidOrSerial}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); console.log('Received ARM config'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in getArmConfig:', error); throw error; } } async function updateArmConfig() { try { // Get parameters const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0); const armConfigJson = this.getNodeParameter('armConfig', 0); // Parse the ARM Config JSON let armConfig; try { armConfig = JSON.parse(armConfigJson); } catch (parseError) { throw new Error(`Invalid JSON format for ARM config: ${parseError.message}`); } // Log the request console.log('Updating ARM config:', { groupNameOrGuidOrSerial, armConfig }); // Build the endpoint const endpoint = `/configuration/v1/arm/${groupNameOrGuidOrSerial}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, armConfig, {}); console.log('ARM config updated successfully'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in updateArmConfig:', error); throw error; } }