// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 告警规则 */
export async function getAlarmRules(
  params: API.SearchAlarmRulesParams,
  options?: { [key: string]: any },
) {
  return request<API.Response & { data?: API.PageResult; msg?: string }>(
    `/api/warning_rule/`,
    {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
      params: {
        ...params,
      },
      ...(options || {}),
    },
  );
}

/** 更新告警规则 */
export async function postAlarmRules(
    body: API.UpdateAlarmRulesParams,
    options?: { [key: string]: any },
  ) {
    return request<API.Response & { data?: API.PageResult; msg?: string }>(
      `/api/warning_rule/`,
      {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        data: body,
        ...(options || {}),
      },
    );
}

/** 离线告警规则 */
export async function getOfflineAlarmRules(
  params: API.SearchAlarmRulesParams,
  options?: { [key: string]: any },
) {
  return request<API.Response & { data?: API.PageResult; msg?: string }>(
    `/api/upload_warning_rule/`,
    {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
      },
      params: {
        ...params,
      },
      ...(options || {}),
    },
  );
}

/** 离线更新告警规则 */
export async function postOfflineAlarmRules(
  body: API.UpdateAlarmRulesParams,
  options?: { [key: string]: any },
) {
  return request<API.Response & { data?: API.PageResult; msg?: string }>(
    `/api/upload_warning_rule/`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    },
  );
}
