UNPKG

n8n-nodes-arubacentral

Version:

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

56 lines (55 loc) 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.executeOperation = executeOperation; const operations_1 = require("../api/operations"); const logger_1 = require("./logger"); /** * Execute the operation selected by the user * * @param this The n8n execution context * @returns Operation result as array of items */ async function executeOperation() { // Get parameters from the node const domain = this.getNodeParameter('domain', 0); const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); // Log the operation details logger_1.logger.debug('executeOperation', `Executing ${domain}.${resource}.${operation}`, { domain, resource, operation, }); // Validate if the domain exists if (!operations_1.operations[domain]) { logger_1.logger.error('executeOperation', `Domain "${domain}" not found`); throw new Error(`Domain "${domain}" not found`); } // Validate if the resource exists if (!operations_1.operations[domain][resource]) { logger_1.logger.error('executeOperation', `Resource "${resource}" not found in domain "${domain}"`); throw new Error(`Resource "${resource}" not found in domain "${domain}"`); } // Check if the operation exists and is a function if (!operations_1.operations[domain][resource][operation]) { logger_1.logger.error('executeOperation', `Operation "${operation}" not found in resource "${resource}" of domain "${domain}"`); throw new Error(`Operation "${operation}" not found in resource "${resource}" of domain "${domain}"`); } if (typeof operations_1.operations[domain][resource][operation] !== 'function') { logger_1.logger.error('executeOperation', `Operation "${operation}" in resource "${resource}" of domain "${domain}" is not a function`); throw new Error(`Operation "${operation}" in resource "${resource}" of domain "${domain}" is not a function`); } // Execute the operation try { logger_1.logger.debug('executeOperation', `Calling ${domain}.${resource}.${operation}`); const result = await operations_1.operations[domain][resource][operation].call(this); logger_1.logger.debug('executeOperation', `Completed ${domain}.${resource}.${operation}`, { resultCount: result.length, }); return result; } catch (error) { logger_1.logger.error('executeOperation:error', error.message, { error }); throw error; } }