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