UNPKG

n8n-nodes-arubacentralnextgen

Version:

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

159 lines (158 loc) 5.99 kB
"use strict"; 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.listSitesHealthOverview = listSitesHealthOverview; exports.getSiteInformation = getSiteInformation; exports.listSitesDeviceHealth = listSitesDeviceHealth; exports.getDeviceHealthOverview = getDeviceHealthOverview; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); const logger = __importStar(require("../../../helpers/logger")); /** * List sites with health overview */ async function listSitesHealthOverview() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting listSitesHealthOverview operation', undefined, this); } try { const limit = this.getNodeParameter('limit', 0, 100); const offset = this.getNodeParameter('offset', 0, 0); const endpoint = '/network-monitoring/v1alpha1/sites-health'; const queryParams = {}; if (limit !== 100) { queryParams.limit = limit; } if (offset !== 0) { queryParams.offset = offset; } if (debugMode) { logger.debug('Sites health overview API request', { endpoint, queryParams }, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in listSitesHealthOverview', error); throw error; } } /** * Get site information */ async function getSiteInformation() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getSiteInformation operation', undefined, this); } try { const siteId = this.getNodeParameter('siteId', 0); const queryTime = this.getNodeParameter('queryTime', 0, ''); if (!siteId) { throw new Error('Site ID is required'); } const endpoint = `/network-monitoring/v1alpha1/site-health/${siteId}`; const queryParams = {}; if (queryTime) { queryParams['query-time'] = queryTime; } if (debugMode) { logger.debug('Site information API request', { endpoint, siteId, queryParams }, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getSiteInformation', error); throw error; } } /** * List sites with device health */ async function listSitesDeviceHealth() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting listSitesDeviceHealth operation', undefined, this); } try { const limit = this.getNodeParameter('limit', 0, 100); const offset = this.getNodeParameter('offset', 0, 0); const endpoint = '/network-monitoring/v1alpha1/sites-device-health'; const queryParams = {}; if (limit !== 100) { queryParams.limit = limit; } if (offset !== 0) { queryParams.offset = offset; } if (debugMode) { logger.debug('Sites device health API request', { endpoint, queryParams }, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in listSitesDeviceHealth', error); throw error; } } /** * Get device health overview */ async function getDeviceHealthOverview() { const debugMode = logger.isDebugMode(this); if (debugMode) { logger.debug('Starting getDeviceHealthOverview operation', undefined, this); } try { const queryTime = this.getNodeParameter('queryTime', 0, ''); const endpoint = '/network-monitoring/v1alpha1/tenant-device-health'; const queryParams = {}; if (queryTime) { queryParams['query-time'] = queryTime; } if (debugMode) { logger.debug('Device health overview API request', { endpoint, queryParams }, this); } const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, queryParams); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { logger.error('Error in getDeviceHealthOverview', error); throw error; } }