import request from '@/utils/request'

// ======== 代理 CRUD ========

export function listProxy(query) {
  return request({ url: '/admin/proxy/list', method: 'get', params: query })
}

export function getProxy(proxyId) {
  return request({ url: `/admin/proxy/${proxyId}`, method: 'get' })
}

export function addProxy(data) {
  return request({ url: '/admin/proxy', method: 'post', data })
}

export function updateProxy(data) {
  return request({ url: '/admin/proxy', method: 'put', data })
}

export function delProxy(proxyIds) {
  return request({ url: `/admin/proxy/${proxyIds}`, method: 'delete' })
}

export function changeProxyStatus(proxyId, status) {
  return request({ url: `/admin/proxy/changeStatus/${proxyId}`, method: 'put', params: { status } })
}

export function allEnabledProxies() {
  return request({ url: '/admin/proxy/allEnabled', method: 'get' })
}

// 重置代理密码
export function resetProxyPwd(proxyId, password) {
  return request({ url: `/admin/proxy/resetPwd/${proxyId}`, method: 'put', data: { password } })
}
