38 lines
926 B
TypeScript
38 lines
926 B
TypeScript
import { request } from './request'
|
|
|
|
export type AlertInfo = {
|
|
id: number
|
|
name: string
|
|
condition: string
|
|
contactPointId: number
|
|
customMessage: string
|
|
customResolvedMessage: string
|
|
triggerInterval: number
|
|
lastStatus: string
|
|
lastStatusAt: string
|
|
}
|
|
|
|
export const getAlerts = () => request<AlertInfo[]>('/api/alerts')
|
|
|
|
export const createAlert = (
|
|
data: Omit<AlertInfo, 'id' | 'lastStatus' | 'lastStatusAt'>
|
|
) =>
|
|
request<AlertInfo>('/api/alerts', {
|
|
method: 'POST',
|
|
headers: { 'content-type': 'application/json' },
|
|
body: JSON.stringify(data),
|
|
})
|
|
|
|
export const updateAlert = ({
|
|
id,
|
|
...body
|
|
}: Omit<AlertInfo, 'lastStatus' | 'lastStatusAt'>) =>
|
|
request<AlertInfo>(`/api/alerts/${id}`, {
|
|
method: 'PUT',
|
|
headers: { 'content-type': 'application/json' },
|
|
body: JSON.stringify(body),
|
|
})
|
|
|
|
export const deleteAlert = (id: number) =>
|
|
request<AlertInfo, 'void'>(`/api/alerts/${id}`, { method: 'DELETE' }, 'void')
|