UNPKG

n8n-nodes-arubacentralnextgen

Version:

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

565 lines (564 loc) 22.8 kB
"use strict"; // methods/routing/routing.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.getAllStaticRoute = getAllStaticRoute; exports.getStaticRoute = getStaticRoute; exports.createStaticRoute = createStaticRoute; exports.updateStaticRoute = updateStaticRoute; exports.deleteStaticRoute = deleteStaticRoute; exports.getAllOSPFv2 = getAllOSPFv2; exports.getOSPFv2 = getOSPFv2; exports.createOSPFv2 = createOSPFv2; exports.updateOSPFv2 = updateOSPFv2; exports.deleteOSPFv2 = deleteOSPFv2; exports.getAllBGP = getAllBGP; exports.getBGP = getBGP; exports.createBGP = createBGP; exports.updateBGP = updateBGP; exports.deleteBGP = deleteBGP; exports.getAllVRF = getAllVRF; exports.getVRF = getVRF; exports.createVRF = createVRF; exports.updateVRF = updateVRF; exports.deleteVRF = deleteVRF; const apiRequest_1 = require("../../helpers/apiRequest"); const responseFormatter_1 = require("../../helpers/responseFormatter"); const logger = __importStar(require("../../helpers/logger")); /** * Routing Domain Methods * API Reference: https://developer.arubanetworks.com/new-central-config/reference * Base Path: /network-config/v1alpha1 * * Resources: * - Static Routes (/static-routes) * - OSPFv2 (/ospfv2) * - BGP (/bgp) * - VRF (/vrf) */ const STATIC_ROUTE_PATH = '/network-config/v1alpha1/static-routes'; const OSPFV2_PATH = '/network-config/v1alpha1/ospfv2'; const BGP_PATH = '/network-config/v1alpha1/bgp'; const VRF_PATH = '/network-config/v1alpha1/vrf'; // ============================================================================ // Shared helpers // ============================================================================ function buildGetAllQueryParams(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; } function parseProfileBody(raw) { if (typeof raw === 'string') { try { return JSON.parse(raw); } catch { throw new Error('Invalid JSON in Profile Body'); } } return raw; } // ============================================================================ // Static Route Methods // ============================================================================ /** * Get all static route profiles */ async function getAllStaticRoute() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getAllStaticRoute operation', undefined, this); try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildGetAllQueryParams(additionalFields); if (debugMode) logger.debug('Query parameters', queryParams, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', STATIC_ROUTE_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} static route profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllStaticRoute', error); throw error; } } /** * Get a specific static route profile */ async function getStaticRoute() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getStaticRoute operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${STATIC_ROUTE_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Fetching static route profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getStaticRoute', error); throw error; } } /** * Create a static route profile */ async function createStaticRoute() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting createStaticRoute operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${STATIC_ROUTE_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Creating static route profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createStaticRoute', error); throw error; } } /** * Update a static route profile */ async function updateStaticRoute() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting updateStaticRoute operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${STATIC_ROUTE_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Updating static route profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateStaticRoute', error); throw error; } } /** * Delete a static route profile */ async function deleteStaticRoute() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting deleteStaticRoute operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${STATIC_ROUTE_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Deleting static route profile', { profileName, endpoint }, this); 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 deleteStaticRoute', error); throw error; } } // ============================================================================ // OSPFv2 Methods // ============================================================================ /** * Get all OSPFv2 profiles */ async function getAllOSPFv2() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getAllOSPFv2 operation', undefined, this); try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildGetAllQueryParams(additionalFields); if (debugMode) logger.debug('Query parameters', queryParams, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', OSPFV2_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} OSPFv2 profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllOSPFv2', error); throw error; } } /** * Get a specific OSPFv2 profile */ async function getOSPFv2() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getOSPFv2 operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${OSPFV2_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Fetching OSPFv2 profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getOSPFv2', error); throw error; } } /** * Create an OSPFv2 profile */ async function createOSPFv2() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting createOSPFv2 operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${OSPFV2_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Creating OSPFv2 profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createOSPFv2', error); throw error; } } /** * Update an OSPFv2 profile */ async function updateOSPFv2() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting updateOSPFv2 operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${OSPFV2_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Updating OSPFv2 profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateOSPFv2', error); throw error; } } /** * Delete an OSPFv2 profile */ async function deleteOSPFv2() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting deleteOSPFv2 operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${OSPFV2_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Deleting OSPFv2 profile', { profileName, endpoint }, this); 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 deleteOSPFv2', error); throw error; } } // ============================================================================ // BGP Methods // ============================================================================ /** * Get all BGP profiles */ async function getAllBGP() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getAllBGP operation', undefined, this); try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildGetAllQueryParams(additionalFields); if (debugMode) logger.debug('Query parameters', queryParams, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', BGP_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} BGP profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllBGP', error); throw error; } } /** * Get a specific BGP profile */ async function getBGP() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getBGP operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${BGP_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Fetching BGP profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getBGP', error); throw error; } } /** * Create a BGP profile */ async function createBGP() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting createBGP operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${BGP_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Creating BGP profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createBGP', error); throw error; } } /** * Update a BGP profile */ async function updateBGP() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting updateBGP operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${BGP_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Updating BGP profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateBGP', error); throw error; } } /** * Delete a BGP profile */ async function deleteBGP() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting deleteBGP operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${BGP_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Deleting BGP profile', { profileName, endpoint }, this); 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 deleteBGP', error); throw error; } } // ============================================================================ // VRF Methods // ============================================================================ /** * Get all VRF profiles */ async function getAllVRF() { var _a, _b; const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getAllVRF operation', undefined, this); try { const additionalFields = this.getNodeParameter('additionalFields', 0, {}); const queryParams = buildGetAllQueryParams(additionalFields); if (debugMode) logger.debug('Query parameters', queryParams, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', VRF_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} VRF profiles`, undefined, this); } return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getAllVRF', error); throw error; } } /** * Get a specific VRF profile */ async function getVRF() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting getVRF operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${VRF_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Fetching VRF profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getVRF', error); throw error; } } /** * Create a VRF profile */ async function createVRF() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting createVRF operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${VRF_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Creating VRF profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in createVRF', error); throw error; } } /** * Update a VRF profile */ async function updateVRF() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting updateVRF operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const profileBodyRaw = this.getNodeParameter('profileBody', 0, '{}'); const profileBody = parseProfileBody(profileBodyRaw); const endpoint = `${VRF_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Updating VRF profile', { profileName, endpoint }, this); const response = await apiRequest_1.apiRequest.call(this, 'PATCH', endpoint, profileBody, {}); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in updateVRF', error); throw error; } } /** * Delete a VRF profile */ async function deleteVRF() { const debugMode = logger.isDebugMode(this); if (debugMode) logger.debug('Starting deleteVRF operation', undefined, this); try { const profileName = this.getNodeParameter('profileName', 0); const endpoint = `${VRF_PATH}/${encodeURIComponent(profileName)}`; if (debugMode) logger.debug('Deleting VRF profile', { profileName, endpoint }, this); 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 deleteVRF', error); throw error; } }