Initial commit

This commit is contained in:
fawney19
2025-12-10 20:52:44 +08:00
commit f784106826
485 changed files with 110993 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
import client from '../client'
import type {
HealthStatus,
HealthSummary,
EndpointStatusMonitorResponse,
PublicEndpointStatusMonitorResponse
} from './types'
/**
* 获取健康状态摘要
*/
export async function getHealthSummary(): Promise<HealthSummary> {
const response = await client.get('/api/admin/endpoints/health/summary')
return response.data
}
/**
* 获取 Endpoint 健康状态
*/
export async function getEndpointHealth(endpointId: string): Promise<HealthStatus> {
const response = await client.get(`/api/admin/endpoints/health/endpoint/${endpointId}`)
return response.data
}
/**
* 获取 Key 健康状态
*/
export async function getKeyHealth(keyId: string): Promise<HealthStatus> {
const response = await client.get(`/api/admin/endpoints/health/key/${keyId}`)
return response.data
}
/**
* 恢复Key健康状态一键恢复重置健康度 + 关闭熔断器 + 取消自动禁用)
*/
export async function recoverKeyHealth(keyId: string): Promise<{
message: string
details: {
health_score: number
circuit_breaker_open: boolean
is_active: boolean
}
}> {
const response = await client.patch(`/api/admin/endpoints/health/keys/${keyId}`)
return response.data
}
/**
* 批量恢复所有熔断的Key健康状态
*/
export async function recoverAllKeysHealth(): Promise<{
message: string
recovered_count: number
recovered_keys: Array<{
key_id: string
key_name: string
endpoint_id: string
}>
}> {
const response = await client.patch('/api/admin/endpoints/health/keys')
return response.data
}
/**
* 获取按 API 格式聚合的健康监控时间线(管理员版,含 provider/key 数量)
*/
export async function getEndpointStatusMonitor(params?: {
lookback_hours?: number
per_format_limit?: number
}): Promise<EndpointStatusMonitorResponse> {
const response = await client.get('/api/admin/endpoints/health/api-formats', {
params
})
return response.data
}
/**
* 获取按 API 格式聚合的健康监控时间线(公开版,不含敏感信息)
*/
export async function getPublicEndpointStatusMonitor(params?: {
lookback_hours?: number
per_format_limit?: number
}): Promise<PublicEndpointStatusMonitorResponse> {
const response = await client.get('/api/public/health/api-formats', {
params
})
return response.data
}