import { request } from '@/plugins/http-fetch';

/**
 * 信令跟踪网卡设备列表
 * @returns
 */
export function packetDevices() {
  return request({
    url: '/trace/packet/devices',
    method: 'GET',
  });
}

/**
 * 信令跟踪开始
 * @param data 对象
 * @returns
 */
export function packetStart(data: Record<string, any>) {
  return request({
    url: '/trace/packet/start',
    method: 'POST',
    data: data,
  });
}

/**
 * 信令跟踪结束
 * @param data 对象
 * @returns
 */
export function packetStop(taskNo: string) {
  return request({
    url: '/trace/packet/stop',
    method: 'POST',
    data: { taskNo },
  });
}

/**
 * 信令跟踪过滤
 * @param data 对象
 * @returns
 */
export function packetFilter(taskNo: string, expr: string) {
  return request({
    url: '/trace/packet/filter',
    method: 'PUT',
    data: { taskNo, expr },
  });
}

/**
 * 信令跟踪续期保活
 * @param data 对象
 * @returns
 */
export function packetKeep(taskNo: string, duration: number = 120) {
  return request({
    url: '/trace/packet/keep-alive',
    method: 'PUT',
    data: { taskNo, duration },
  });
}

/**
 * 信令跟踪文件
 * @param taskNo 对象
 * @returns object
 */
export function packetPCAPFile(taskNo: string) {
  return request({
    url: '/trace/packet/filePull',
    method: 'GET',
    params: { taskNo },
    responseType: 'blob',
    timeout: 180_000,
  });
}
