import request from "@/utils/request";
//获取任务列表
const tasks = (data) => {
  return request({
    url: '/tasks',
    method: 'get',
    params:data
  })
}
//获取可用的设备状态
const availableDevices = (data) => {
  return request({
    url: '/tasks/available_devices',
    method: 'get',
    params: data
  })
}
//获取正在执行的任务
const running = () => {
  return request({
    url: '/tasks/running',
    method: 'get'
  })
}
//创建推理任务
const addTask = (data) => {
  return request({
    url: '/tasks',
    method: 'post',
    data: data
  })
}

//创建推理任务
const deleteTask = (id) => {
  return request({
    url: '/tasks/'+id,
    method: 'delete'
  })
}


//创建推理任务
const stopTask = (id) => {
  return request({
    url: `/tasks/${id}/stop`,
    method: 'post',
    data: {
      operation_id:0
    }
  })
}
const taskDetail=id=>{
  return request({
    url: '/tasks/'+id,
    method: 'get'
  })
}
const taskResults=id=>{
  return request({
    url: '/tasks/'+id+'/results',
    method: 'get'
  })
}

const taskImage=(id,fileName)=>{
  return request({
    url: '/tasks/'+id+'/results/'+fileName,
    method: 'get'
  })
}
export default {
  tasks,
  availableDevices,
  running,
  addTask,
  stopTask,
  taskDetail,
  taskResults,
  deleteTask,
  taskImage
}
