alert_notify_config.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import axios from 'axios';
  2. import { AlertNotifyConfig } from "../../share/monitorTypes.ts";
  3. // 告警通知配置相关响应类型
  4. interface AlertNotifyConfigDataResponse {
  5. data: AlertNotifyConfig[];
  6. total: number;
  7. page: number;
  8. pageSize: number;
  9. }
  10. interface AlertNotifyConfigResponse {
  11. data: AlertNotifyConfig;
  12. message?: string;
  13. }
  14. // 告警通知配置API接口定义
  15. export const AlertNotifyConfigAPI = {
  16. // 获取告警通知配置
  17. getAlertNotifyConfig: async (params?: {
  18. page?: number,
  19. limit?: number,
  20. device_id?: number,
  21. alert_level?: string
  22. }): Promise<AlertNotifyConfigDataResponse> => {
  23. try {
  24. const response = await axios.get(`/alert-notify-configs`, { params });
  25. return response.data;
  26. } catch (error) {
  27. throw error;
  28. }
  29. },
  30. // 创建告警通知配置
  31. createAlertNotifyConfig: async (data: Partial<AlertNotifyConfig>): Promise<AlertNotifyConfigResponse> => {
  32. try {
  33. const response = await axios.post(`/alert-notify-configs`, data);
  34. return response.data;
  35. } catch (error) {
  36. throw error;
  37. }
  38. },
  39. // 更新告警通知配置
  40. updateAlertNotifyConfig: async (id: number, data: Partial<AlertNotifyConfig>): Promise<AlertNotifyConfigResponse> => {
  41. try {
  42. const response = await axios.put(`/alert-notify-configs/${id}`, data);
  43. return response.data;
  44. } catch (error) {
  45. throw error;
  46. }
  47. },
  48. // 删除告警通知配置
  49. deleteAlertNotifyConfig: async (id: number): Promise<AlertNotifyConfigResponse> => {
  50. try {
  51. const response = await axios.delete(`/alert-notify-configs/${id}`);
  52. return response.data;
  53. } catch (error) {
  54. throw error;
  55. }
  56. }
  57. };