import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';

/**
 * 查询跟踪任务列表
 * @param query 查询参数
 * @returns object
 */
export async function listTraceTask(query: Record<string, any>) {
  return request({
    url: '/trace/task/list',
    method: 'GET',
    params: query,
  });
}

/**
 * 查询跟踪任务信息
 * @param id 网元ID
 * @returns object
 */
export async function getTraceTask(id: string | number) {
  return request({
    url: `/trace/task/${id}`,
    method: 'GET',
  });
}

/**
 * 新增任务
 * @param data 网元对象
 * @returns object
 */
export function addTraceTask(data: Record<string, any>) {
  return request({
    url: `/trace/task`,
    method: 'POST',
    data: data,
  });
}

/**
 * 修改任务
 * @param data 网元对象
 * @returns object
 */
export function updateTraceTask(data: Record<string, any>) {
  return request({
    url: `/trace/task`,
    method: 'PUT',
    data: data,
  });
}

/**
 * 跟踪任务删除
 * @param ids ID多个逗号分隔
 * @returns object
 */
export async function delTraceTask(ids: string) {
  return request({
    url: `/trace/task/${ids}`,
    method: 'DELETE',
  });
}

/**
 * 跟踪任务文件
 * @param query 对象
 * @returns object
 */
export function filePullTask(traceId: string) {
  return request({
    url: '/trace/task/filePull',
    method: 'GET',
    params: { traceId },
    responseType: 'blob',
    timeout: 180_000,
  });
}

/**
 * 跟踪任务数据列表
 * @param query 查询参数
 * @returns object
 */
export async function listTraceData(query: Record<string, any>) {
  return request({
    url: '/trace/data/list',
    method: 'GET',
    params: query,
  });
}

/**
 * 查询跟踪任务数据信息
 * @param id ID
 * @returns object
 */
export async function getTraceData(id: string | number) {
  return request({
    url: `/trace/data/${id}`,
    method: 'GET',
  });
}
