n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
46 lines (37 loc) • 1.36 kB
text/typescript
// getRoamCache.methods.ts
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { IRoamCacheRecord } 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 getRoamCache(this: IExecuteFunctions): Promise<INodeExecutionData[]> {
const clientMac = this.getNodeParameter('client_mac', 0) as string;
logger.info('keymanagement:getRoamCache', `Retrieving roam cache for client: ${clientMac}`);
validateClientMac(clientMac);
const endpoint = `${KEYMANAGEMENT_BASE_PATH}${KEYMANAGEMENT_ENDPOINTS.ROAM_CACHE}/${clientMac}`;
try {
const response = await apiRequest.call(this, 'GET', endpoint, {}, {});
logger.debug(
'keymanagement:getRoamCache',
`Retrieved roam 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:getRoamCache:error',
`Failed to retrieve roam cache for ${clientMac}: ${error.message}`,
);
throw error;
}
}