import { defHttp } from '@jdlinker/func';
/**
 * 查询规则编排分页列表
 */
export const queryList = (data: any) => {
  const params = { ...data };
  return defHttp.post({ url: '/rule-engine/instance/list', data, params }, { isTransformResponse: false });
};

/**
 * 新增规则
 */
export const saveRule = (data: any) => defHttp.post({ url: '/rule-editor/flows/_create', data });

/**
 * 修改规则
 */
export const modify = (id: any, data: any) => {
  delete data.state;
  return defHttp.put({ url: `/rule-engine/instance/${id}`, data });
};

/**
 * 启动规则
 */
export const startRule = (id: string) =>
  defHttp.post({ url: `/rule-engine/instance/${id}/_start` }, { isTransformResponse: false });

/**
 * 禁用规则
 */
export const stopRule = (id: string) =>
  defHttp.post({ url: `/rule-engine/instance/${id}/_stop` }, { isTransformResponse: false });

/**
 * 删除规则
 */
export const deleteRule = (id: string) =>
  defHttp.delete({ url: `/rule-engine/instance/${id}` }, { isTransformResponse: false });
