You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
1.8 KiB
95 lines
1.8 KiB
import { apiCall } from './util'
|
|
import { getUnixTime, sub } from 'date-fns';
|
|
|
|
export interface Recursor {
|
|
ipAddress: string
|
|
timeoutMs: number
|
|
weight: number
|
|
}
|
|
|
|
export const getRecursors = async () => await apiCall<Recursor>('recursors')
|
|
|
|
|
|
export interface Log {
|
|
Started: string
|
|
Domain: string
|
|
ClientIP: string
|
|
Status: string
|
|
Protocol: string
|
|
Error: string
|
|
RecurseUpstreamIP: string
|
|
RecurseRoundTripTimeMs: number
|
|
TotalTimeMs: number
|
|
};
|
|
|
|
export interface LogSearchOptions {
|
|
start: Date
|
|
end: Date
|
|
page: number
|
|
filter: string
|
|
}
|
|
|
|
export const getLogs = async({
|
|
start = sub(new Date(), { hours: 24 }),
|
|
end = new Date(),
|
|
page = 0,
|
|
filter = ""
|
|
}: LogSearchOptions) => await apiCall<Log>('metrics/log', 'GET', {
|
|
filter,
|
|
page,
|
|
start: getUnixTime(start),
|
|
end: getUnixTime(end),
|
|
});
|
|
|
|
export interface StatsSearchOptions {
|
|
start: Date
|
|
end: Date
|
|
key: StatSearchKey
|
|
interval: number
|
|
}
|
|
|
|
export enum StatSearchKey {
|
|
Domain = "domain",
|
|
ClientIp = "clientIp",
|
|
Status = "status",
|
|
Protocol = "protocol"
|
|
}
|
|
|
|
export interface Stat {
|
|
Header: string
|
|
AverageTotalTime: Number
|
|
Count: number,
|
|
Time: string
|
|
};
|
|
|
|
export const getStats = async ({
|
|
start = sub(new Date(), { hours: 24 }),
|
|
end = new Date(),
|
|
key = StatSearchKey.Domain,
|
|
interval = 30,
|
|
}: StatsSearchOptions) => await apiCall<Stat>('metrics/stats', 'GET', {
|
|
start: getUnixTime(start),
|
|
end: getUnixTime(end),
|
|
key,
|
|
interval
|
|
});
|
|
|
|
|
|
export interface RuleAnswer {
|
|
type: string
|
|
value: string
|
|
}
|
|
|
|
export interface Rule {
|
|
id: number
|
|
weight: number
|
|
enabled: boolean
|
|
created: string
|
|
name: string
|
|
value: string
|
|
answer: RuleAnswer
|
|
ttl: number
|
|
}
|
|
|
|
export const getRules = () => apiCall<Rule>('rules');
|