UNPKG

n8n-nodes-arubacentral

Version:

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

43 lines (42 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getInsightDetailsClient = getInsightDetailsClient; const apiRequest_1 = require("../../../../helpers/apiRequest"); const logger_1 = require("../../../../helpers/logger"); const errorHandler_1 = require("../../../../helpers/errorHandler"); /** * AI Insight Details for a Client * * GET /aiops/v2/insights/client/{sta_mac}/id/{insight_id}/export * * @param this The n8n execution context * @returns Formatted API response */ async function getInsightDetailsClient() { try { // Get parameters const staMac = this.getNodeParameter('sta_mac', 0); const insightId = this.getNodeParameter('insight_id', 0); const fromDate = new Date(this.getNodeParameter('from', 0)); const toDate = new Date(this.getNodeParameter('to', 0)); // Convert dates to epoch milliseconds for API const fromMs = fromDate.getTime(); const toMs = toDate.getTime(); logger_1.logger.debug('aiops:insightDetails:getInsightDetailsClient', `Getting details for client=${staMac}, insight=${insightId}, from=${fromMs}, to=${toMs}`); // Construct query parameters const qs = { from: fromMs, to: toMs, }; // Make API request const endpoint = `/aiops/v2/insights/client/${encodeURIComponent(staMac)}/id/${insightId}/export`; const responseData = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, qs); logger_1.logger.debug('aiops:insightDetails:getInsightDetailsClient', 'Successfully retrieved client insight details'); // Return formatted response return [{ json: responseData }]; } catch (error) { logger_1.logger.error('aiops:insightDetails:getInsightDetailsClient:error', { message: error.message }); return errorHandler_1.handleApiError.call(this, error, 'Failed to get AI insight details for client'); } }