n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
40 lines (31 loc) • 1.25 kB
text/typescript
// getHealth.methods.ts
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { IHealthStatus } from '../keymanagement.types';
import { KEYMANAGEMENT_BASE_PATH, KEYMANAGEMENT_ENDPOINTS } from '../keymanagement.common';
import { apiRequest } from '../../../helpers/apiRequest';
import { logger } from '../../../helpers/logger';
export async function getHealth(this: IExecuteFunctions): Promise<INodeExecutionData[]> {
logger.info('keymanagement:getHealth', 'Checking Key Management Service health');
const endpoint = `${KEYMANAGEMENT_BASE_PATH}${KEYMANAGEMENT_ENDPOINTS.HEALTH}`;
try {
const response = await apiRequest.call(this, 'GET', endpoint, {}, {});
logger.debug(
'keymanagement:getHealth',
`Health check completed: ${response.status || 'unknown'}`,
);
const healthStatus: IHealthStatus = {
status: response.status || 'DOWN',
timestamp: Date.now(),
details: response,
};
return [{ json: healthStatus }];
} catch (error) {
logger.error('keymanagement:getHealth:error', `Health check failed: ${error.message}`);
const healthStatus: IHealthStatus = {
status: 'DOWN',
timestamp: Date.now(),
details: { error: error.message },
};
return [{ json: healthStatus }];
}
}