All files / src/api monitors.ts

100% Statements 30/30
100% Branches 5/5
100% Functions 5/5
100% Lines 30/30

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 421x               1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x   1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x   1x 1x 1x  
import apiClient from "./client";
import type {
  MonitorCreate,
  MonitorRead,
  MonitorUpdate,
  MonitorListResponse,
} from "../types/monitor";
 
export async function getMonitors(
  skip: number = 0,
  limit: number = 100,
): Promise<MonitorListResponse> {
  const { data } = await apiClient.get(
    `/monitors/?skip=${skip}&limit=${limit}`,
  );
  return data;
}
 
export async function getMonitor(id: string): Promise<MonitorRead> {
  const { data } = await apiClient.get(`/monitors/${id}`);
  return data;
}
 
export async function createMonitor(
  monitor: MonitorCreate,
): Promise<MonitorRead> {
  const { data } = await apiClient.post("/monitors/", monitor);
  return data;
}
 
export async function updateMonitor(
  id: string,
  monitor: MonitorUpdate,
): Promise<MonitorRead> {
  const { data } = await apiClient.patch(`/monitors/${id}`, monitor);
  return data;
}
 
export async function deleteMonitor(id: string): Promise<void> {
  await apiClient.delete(`/monitors/${id}`);
}