UNPKG

n8n-nodes-arubacentral

Version:

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

46 lines (37 loc) 1.35 kB
// getKeyCache.methods.ts import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import { IKeyCacheRecord } from '../keymanagement.types'; import { KEYMANAGEMENT_BASE_PATH, KEYMANAGEMENT_ENDPOINTS, validateClientMac, } from '../keymanagement.common'; import { apiRequest } from '../../../helpers/apiRequest'; import { logger } from '../../../helpers/logger'; export async function getKeyCache(this: IExecuteFunctions): Promise<INodeExecutionData[]> { const clientMac = this.getNodeParameter('client_mac', 0) as string; logger.info('keymanagement:getKeyCache', `Retrieving key cache for client: ${clientMac}`); validateClientMac(clientMac); const endpoint = `${KEYMANAGEMENT_BASE_PATH}${KEYMANAGEMENT_ENDPOINTS.KEY_CACHE}/${clientMac}`; try { const response = await apiRequest.call(this, 'GET', endpoint, {}, {}); logger.debug( 'keymanagement:getKeyCache', `Retrieved key cache for ${clientMac} - count: ${response.length || 0}`, ); // Ensure response is an array const records = Array.isArray(response) ? response : [response]; return records.map((record: any) => ({ json: { client_mac: clientMac, ...record, }, })); } catch (error) { logger.error( 'keymanagement:getKeyCache:error', `Failed to retrieve key cache for ${clientMac}: ${error.message}`, ); throw error; } }