UNPKG

n8n-nodes-arubacentralnextgen

Version:

n8n community node for Aruba Central NextGen API integration with modern monitoring and management capabilities

677 lines (676 loc) 25.6 kB
"use strict"; // methods/interfaces/interfaces.methods.ts var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllEthernetInterface = getAllEthernetInterface; exports.getEthernetInterface = getEthernetInterface; exports.createEthernetInterface = createEthernetInterface; exports.updateEthernetInterface = updateEthernetInterface; exports.deleteEthernetInterface = deleteEthernetInterface; exports.getAllPortChannel = getAllPortChannel; exports.getPortChannel = getPortChannel; exports.createPortChannel = createPortChannel; exports.updatePortChannel = updatePortChannel; exports.deletePortChannel = deletePortChannel; exports.getAllLACP = getAllLACP; exports.getLACP = getLACP; exports.createLACP = createLACP; exports.updateLACP = updateLACP; exports.deleteLACP = deleteLACP; exports.getAllLoopback = getAllLoopback; exports.getLoopback = getLoopback; exports.createLoopback = createLoopback; exports.updateLoopback = updateLoopback; exports.deleteLoopback = deleteLoopback; exports.getAllLLDP = getAllLLDP; exports.getLLDP = getLLDP; exports.createLLDP = createLLDP; exports.updateLLDP = updateLLDP; exports.deleteLLDP = deleteLLDP; const apiRequest_1 = require("../../helpers/apiRequest"); const responseFormatter_1 = require("../../helpers/responseFormatter"); const logger = __importStar(require("../../helpers/logger")); /** * Interfaces Methods * API Reference: https://developer.arubanetworks.com/new-central-config/reference * Base Path: /network-config/v1alpha1 * * Resources: * - Ethernet Interface (ethernet-interfaces) * - Port Channel (port-channels) * - LACP (lacp) * - Loopback Interface (loopback-interfaces) * - LLDP (lldp) */ const ETHERNET_INTERFACE_PATH = '/network-config/v1alpha1/ethernet-interfaces'; const PORT_CHANNEL_PATH = '/network-config/v1alpha1/port-channels'; const LACP_PATH = '/network-config/v1alpha1/lacp'; const LOOPBACK_PATH = '/network-config/v1alpha1/loopback-interfaces'; const LLDP_PATH = '/network-config/v1alpha1/lldp'; // ============================================================================ // Helper: build getAll query params from additionalFields // ============================================================================ function buildQueryParams(additionalFields) { const queryParams = {}; if (additionalFields.viewType) { queryParams['view-type'] = additionalFields.viewType; } if (additionalFields.objectType) { queryParams['object-type'] = additionalFields.objectType; } if (additionalFields.scopeId) { queryParams['scope-id'] = additionalFields.scopeId; } if (additionalFields.persona) { queryParams.persona = additionalFields.persona; } if (additionalFields.effective !== undefined) { queryParams.effective = additionalFields.effective; } if (additionalFields.detailed !== undefined) { queryParams.detailed = additionalFields.detailed; } if (additionalFields.limit) { queryParams.limit = additionalFields.limit; } if (additionalFields.offset !== undefined) { queryParams.offset = additionalFields.offset; } return queryParams; } // ============================================================================ // Helper: parse JSON body // ============================================================================ function parseProfileBody(raw) { if (typeof raw === 'string') { try { return JSON.parse(raw); } catch { throw new Error('Invalid JSON in Profile Body'); } } return raw; } // ==================================== // Ethernet Interface Methods // ==================================== /** * Get all ethernet interface profiles */ async function getAllEthernetInterface() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getAllEthernetInterface operation', undefined, this); } try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildQueryParams(additionalFields); if (debugMode) { logger.debug('Query parameters', queryParams, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', ETHERNET_INTERFACE_PATH, {}, queryParams); if (debugMode) { logger.debug(`Retrieved ${((_a = response.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) || 0} ethernet interface profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllEthernetInterface', error); throw error; } } /** * Get a specific ethernet interface profile */ async function getEthernetInterface() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getEthernetInterface operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${ETHERNET_INTERFACE_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getEthernetInterface', error); throw error; } } /** * Create an ethernet interface profile */ async function createEthernetInterface() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting createEthernetInterface operation', undefined, this); } try { const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const response = await apiRequest_1.apiRequest.call(this, 'POST', ETHERNET_INTERFACE_PATH, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createEthernetInterface', error); throw error; } } /** * Update an ethernet interface profile */ async function updateEthernetInterface() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting updateEthernetInterface operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${ETHERNET_INTERFACE_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateEthernetInterface', error); throw error; } } /** * Delete an ethernet interface profile */ async function deleteEthernetInterface() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting deleteEthernetInterface operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${ETHERNET_INTERFACE_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); if (!response || Object.keys(response).length === 0) { return responseFormatter_1.formatResponse.call(this, { success: true, profileName }); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in deleteEthernetInterface', error); throw error; } } // ==================================== // Port Channel Methods // ==================================== /** * Get all port channel profiles */ async function getAllPortChannel() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getAllPortChannel operation', undefined, this); } try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildQueryParams(additionalFields); if (debugMode) { logger.debug('Query parameters', queryParams, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', PORT_CHANNEL_PATH, {}, queryParams); if (debugMode) { logger.debug(`Retrieved ${((_a = response.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) || 0} port channel profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllPortChannel', error); throw error; } } /** * Get a specific port channel profile */ async function getPortChannel() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getPortChannel operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${PORT_CHANNEL_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getPortChannel', error); throw error; } } /** * Create a port channel profile */ async function createPortChannel() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting createPortChannel operation', undefined, this); } try { const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const response = await apiRequest_1.apiRequest.call(this, 'POST', PORT_CHANNEL_PATH, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createPortChannel', error); throw error; } } /** * Update a port channel profile */ async function updatePortChannel() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting updatePortChannel operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${PORT_CHANNEL_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updatePortChannel', error); throw error; } } /** * Delete a port channel profile */ async function deletePortChannel() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting deletePortChannel operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${PORT_CHANNEL_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); if (!response || Object.keys(response).length === 0) { return responseFormatter_1.formatResponse.call(this, { success: true, profileName }); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in deletePortChannel', error); throw error; } } // ==================================== // LACP Methods // ==================================== /** * Get all LACP profiles */ async function getAllLACP() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getAllLACP operation', undefined, this); } try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildQueryParams(additionalFields); if (debugMode) { logger.debug('Query parameters', queryParams, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', LACP_PATH, {}, queryParams); if (debugMode) { logger.debug(`Retrieved ${((_a = response.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) || 0} LACP profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllLACP', error); throw error; } } /** * Get a specific LACP profile */ async function getLACP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getLACP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LACP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getLACP', error); throw error; } } /** * Create a LACP profile */ async function createLACP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting createLACP operation', undefined, this); } try { const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const response = await apiRequest_1.apiRequest.call(this, 'POST', LACP_PATH, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createLACP', error); throw error; } } /** * Update a LACP profile */ async function updateLACP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting updateLACP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${LACP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateLACP', error); throw error; } } /** * Delete a LACP profile */ async function deleteLACP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting deleteLACP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LACP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); if (!response || Object.keys(response).length === 0) { return responseFormatter_1.formatResponse.call(this, { success: true, profileName }); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in deleteLACP', error); throw error; } } // ==================================== // Loopback Interface Methods // ==================================== /** * Get all loopback interface profiles */ async function getAllLoopback() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getAllLoopback operation', undefined, this); } try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildQueryParams(additionalFields); if (debugMode) { logger.debug('Query parameters', queryParams, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', LOOPBACK_PATH, {}, queryParams); if (debugMode) { logger.debug(`Retrieved ${((_a = response.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) || 0} loopback interface profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllLoopback', error); throw error; } } /** * Get a specific loopback interface profile */ async function getLoopback() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getLoopback operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LOOPBACK_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getLoopback', error); throw error; } } /** * Create a loopback interface profile */ async function createLoopback() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting createLoopback operation', undefined, this); } try { const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const response = await apiRequest_1.apiRequest.call(this, 'POST', LOOPBACK_PATH, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createLoopback', error); throw error; } } /** * Update a loopback interface profile */ async function updateLoopback() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting updateLoopback operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${LOOPBACK_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateLoopback', error); throw error; } } /** * Delete a loopback interface profile */ async function deleteLoopback() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting deleteLoopback operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LOOPBACK_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); if (!response || Object.keys(response).length === 0) { return responseFormatter_1.formatResponse.call(this, { success: true, profileName }); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in deleteLoopback', error); throw error; } } // ==================================== // LLDP Methods // ==================================== /** * Get all LLDP profiles */ async function getAllLLDP() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getAllLLDP operation', undefined, this); } try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildQueryParams(additionalFields); if (debugMode) { logger.debug('Query parameters', queryParams, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', LLDP_PATH, {}, queryParams); if (debugMode) { logger.debug(`Retrieved ${((_a = response.items) === null || _a === void 0 ? void 0 : _a.length) || ((_b = response.data) === null || _b === void 0 ? void 0 : _b.length) || 0} LLDP profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllLLDP', error); throw error; } } /** * Get a specific LLDP profile */ async function getLLDP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getLLDP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LLDP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getLLDP', error); throw error; } } /** * Create a LLDP profile */ async function createLLDP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting createLLDP operation', undefined, this); } try { const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const response = await apiRequest_1.apiRequest.call(this, 'POST', LLDP_PATH, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createLLDP', error); throw error; } } /** * Update a LLDP profile */ async function updateLLDP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting updateLLDP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${LLDP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateLLDP', error); throw error; } } /** * Delete a LLDP profile */ async function deleteLLDP() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting deleteLLDP operation', undefined, this); } try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${LLDP_PATH}/${encodeURIComponent(profileName)}`; const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); if (!response || Object.keys(response).length === 0) { return responseFormatter_1.formatResponse.call(this, { success: true, profileName }); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in deleteLLDP', error); throw error; } }