import request from '@/utils/request'

export function getTrainPackages() {
  return request.get('/train/packages')
}

export function getTrainTasks() {
  return request.get('/train/tasks')
}

export function getTrainTask(taskId) {
  return request.get(`/train/tasks/${taskId}`)
}

export function createTrainTask(payload) {
  return request.post('/train/tasks', payload)
}

export function cancelTrainTask(taskId) {
  return request.post(`/train/tasks/${taskId}/cancel`)
}

export function restartTrainTask(taskId) {
  return request.post(`/train/tasks/${taskId}/restart`)
}

export function deleteTrainTask(taskId) {
  return request.delete(`/train/tasks/${taskId}`)
}

export function saveTrainModel(taskId, payload = {}) {
  return request.post(`/train/tasks/${taskId}/save`, payload)
}

export function getSavedModels() {
  return request.get('/train/models')
}

export function deleteSavedModel(modelId) {
  return request.delete(`/train/models/${modelId}`)
}

export function updateSavedModel(modelId, payload) {
  return request.patch(`/train/models/${modelId}`, payload)
}
