import { http2 } from '@/utils/request.js'

/**
 * ================================
 * 主控服务管理 API
 * ================================
 */

/** 获取 KVM 主控服务列表 */
export const getKvmServiceList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/list', { params })
}

/** 获取 KVM 主控服务详情 */
export const getKvmServiceDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/detail', { params })
}

/** 创建 KVM 主控服务 */
export const createKvmService = (data) => {
  return http2.post('/api/v1/admin/server/host_service/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改 KVM 主控服务 */
export const updateKvmService = (id, data) => {
  return http2.post(`/api/v1/admin/server/host_service/update?id=${id}`, data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除 KVM 主控服务 */
export const deleteKvmService = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/delete', { params })
}

/**
 * ================================
 * 宿主机组映射管理 API
 * ================================
 */

/** 获取本地主机组列表 */
export const getHostGroupList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/host_group/list', { params })
}

/** 从远程同步主机组到本地 */
export const syncHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/host_group/sync', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 绑定主机组到商品组或商品 */
export const bindHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/host_group/bind', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改本地主机组信息 */
export const updateHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/host_group/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 根据主机组树自动生成 GoodGroup/Goods/Args */
export const generateGoodsByHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/host_group/generate_goods', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除本地主机组 */
export const deleteHostGroup = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/host_group/delete', { params })
}

/**
 * ================================
 * 主控服务接口 - 远程宿主机组管理
 * ================================
 */

/** 获取远程主机组列表 */
export const getRemoteHostGroupList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host_group/list', { params })
}

/** 获取远程主机组详情 */
export const getRemoteHostGroupDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host_group/detail', { params })
}

/** 获取远程主机组树形结构 */
export const getRemoteHostGroupTree = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host_group/tree', { params })
}

/** 获取主机组最优主机配置信息 */
export const getOptimalHostInfo = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host_group/optimal_host', { params })
}

/** 创建远程主机组 */
export const createRemoteHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host_group/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改远程主机组 */
export const updateRemoteHostGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host_group/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除远程主机组 */
export const deleteRemoteHostGroup = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/host_group/delete', { params })
}

/**
 * ================================
 * 主控服务接口 - 宿主机管理
 * ================================
 */

/** 获取宿主机列表 */
export const getRemoteHostList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/list', { params })
}

/** 获取宿主机详情 */
export const getRemoteHostDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/detail', { params })
}

/** 获取宿主机指标数据 */
export const getRemoteHostMetrics = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/metrics', { params })
}

/** 查询历史指标（宿主机或虚拟机） */
export const getMetricsHistory = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/metrics_history', { params })
}

/** 新增宿主机 */
export const addRemoteHost = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host/add', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改宿主机 */
export const updateRemoteHost = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除宿主机 */
export const deleteRemoteHost = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/host/delete', { params })
}

/** 创建宿主机注册令牌 */
export const createHostToken = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host/create_token', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 主控服务接口 - 镜像管理
 * ================================
 */

/** 获取镜像列表 */
export const getImageList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/image/list', { params })
}

/** 获取镜像详情 */
export const getImageDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/image/detail', { params })
}

/** 获取镜像在指定宿主机上的状态 */
export const getImageHostStatus = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/image/host_status', { params })
}

/** 创建镜像 */
export const createImage = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/image/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改镜像 */
export const updateImage = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/image/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除镜像 */
export const deleteImage = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/image/delete', { params })
}

/** 重新下载镜像 */
export const reloadImage = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/image/reload', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 向宿主机同步镜像 */
export const syncImageToHost = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/image/sync', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 指定宿主机重新下载指定镜像 */
export const reloadImageOnHost = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/image/reload_host', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 获取宿主机镜像列表与状态（对比） */
export const getImageCompareHost = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/image/compare_host', { params })
}

/**
 * ================================
 * 主控服务接口 - 网络管理
 * ================================
 */

/** 获取网络列表 */
export const getNetworkList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/network/list', { params })
}

/** 获取网络详情 */
export const getNetworkDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/network/detail', { params })
}

/** 创建网络 */
export const createNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/network/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改网络 */
export const updateNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/network/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 批量创建网络 */
export const batchCreateNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/network/batch_create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除网络 */
export const deleteNetwork = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/network/delete', { params })
}

/** 设置主IP */
export const setNetworkPrimary = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/network/set_primary', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 重置虚拟机MAC地址 */
export const resetVmMac = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/reset_mac', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
}

/** 断开虚拟机外部网络 */
export const disconnectVmNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/disconnect_network', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 恢复虚拟机外部网络 */
export const connectVmNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/connect_network', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 查询虚拟机每小时流量 */
export const getVmTrafficHourly = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/traffic_hourly', { params })
}

/** 获取宿主机额度统计 */
export const getHostQuotaStats = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/quota_stats', { params })
}

/** 获取宿主机 KSM 状态 */
export const getHostKsmStatus = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/host/ksm/status', { params })
}

/** 配置宿主机 KSM */
export const configureHostKsm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/host/ksm/configure', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 主控服务接口 - 数据卷管理
 * ================================
 */

/** 获取数据卷列表 */
export const getVolumeList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/volume/list', { params })
}

/** 获取数据卷详情 */
export const getVolumeDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/volume/detail', { params })
}

/** 创建数据卷 */
export const createVolume = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/volume/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 调整数据卷大小 */
export const resizeVolume = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/volume/resize', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 挂载卷到虚拟机 */
export const mountVolume = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/volume/mount', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 卸载卷 */
export const unmountVolume = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/volume/unmount', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 迁移卷 */
export const transferVolume = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/volume/transfer', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除卷 */
export const deleteVolume = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/volume/delete', { params })
}

/**
 * ================================
 * 主控服务接口 - 虚拟机管理
 * ================================
 */

/** 获取虚拟机列表 */
export const getVmList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/list', { params })
}

/** 获取虚拟机详情 */
export const getVmDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/detail', { params })
}

/** 获取虚拟机状态 */
export const getVmStatus = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/status', { params })
}

/** 获取虚拟机指标数据 */
export const getVmMetrics = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/metrics', { params })
}

/** 创建虚拟机 */
export const createVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改虚拟机 */
export const updateVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 重建虚拟机 */
export const rebuildVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/rebuild', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 重构虚拟机 */
export const refactorVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/refactor', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改虚拟机带宽 */
export const updateVmTraffic = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/update_traffic', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// ========== 流量策略 ==========
// 测试未通过（接口新增，待联调）
/** 获取虚拟机流量策略 */
export const getVmTrafficPolicy = (params) => http2.get('/api/v1/admin/server/host_service/point/vm/traffic_policy', { params })
/** 修改虚拟机流量策略 */
export const updateVmTrafficPolicy = (data) => http2.post('/api/v1/admin/server/host_service/point/vm/traffic_policy/update', data, { headers: { 'Content-Type': 'multipart/form-data' } })
/** 增加虚拟机固定流量上限 */
export const addVmFixedTraffic = (data) => http2.post('/api/v1/admin/server/host_service/point/vm/traffic_policy/add_fixed', data, { headers: { 'Content-Type': 'multipart/form-data' } })
/** 增加虚拟机一次性临时流量 */
export const addVmTemporaryTraffic = (data) => http2.post('/api/v1/admin/server/host_service/point/vm/traffic_policy/add_temporary', data, { headers: { 'Content-Type': 'multipart/form-data' } })

/** 启动虚拟机 */
export const startVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/start', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 停止虚拟机 */
export const stopVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/stop', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 重启虚拟机 */
export const rebootVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/reboot', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 暂停虚拟机 */
export const suspendVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/suspend', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 恢复虚拟机 */
export const resumeVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/resume', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 虚拟机进入救援系统 */
export const rescueVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/rescue', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 虚拟机退出救援系统 */
export const exitRescueVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/exit_rescue', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除虚拟机 */
export const deleteVm = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/vm/delete', { params })
}

/** 迁移虚拟机（更换宿主机） */
export const migrateVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/migrate', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 发起虚拟机数据迁移 */
export const dataMigrateVm = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/data_migrate', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 获取虚拟机数据迁移进度 */
export const getDataMigrateProgress = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vm/data_migrate/progress', { params })
}

/** 中断虚拟机数据迁移 */
export const abortDataMigrate = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vm/data_migrate/abort', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 主控服务接口 - 安全组管理
 * ================================
 */

/** 获取安全组列表 */
export const getSecurityGroupList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/post_group/list', { params })
}

/** 获取安全组详情 */
export const getSecurityGroupDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/post_group/detail', { params })
}

/** 创建安全组 */
export const createSecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改安全组 */
export const updateSecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 同步安全组 */
export const syncSecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/sync', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 绑定安全组到虚拟机 */
export const bindSecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/bind', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 解绑安全组 */
export const unbindSecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/unbind', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除安全组 */
export const deleteSecurityGroup = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/post_group/delete', { params })
}

/** 开启安全组白名单 */
export const enableSecurityGroupWhitelist = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/enable_whitelist', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 关闭安全组白名单 */
export const disableSecurityGroupWhitelist = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/disable_whitelist', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 新增安全组规则 */
export const createSecurityGroupRule = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/create_rule', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改安全组规则 */
export const updateSecurityGroupRule = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/update_rule', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除安全组规则 */
export const deleteSecurityGroupRule = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/post_group/delete_rule', { params })
}

/** 应用安全组 */
export const applySecurityGroup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/apply', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 主控服务接口 - VNC 节点管理
 * ================================
 */

/** 获取 VNC 节点列表 */
export const getVncNodeList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vnc/list', { params })
}

/** 获取虚拟机 VNC 连接信息 */
export const getVmVnc = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/vnc/vm_vnc', { params })
}

/** 新增 VNC 节点 */
export const addVncNode = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vnc/add', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 测试 VNC 节点连接 */
export const testVncNode = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vnc/test', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 修改 VNC 节点 */
export const updateVncNode = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/vnc/update', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除 VNC 节点 */
export const deleteVncNode = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/vnc/delete', { params })
}

/** 设置安全组共享状态 */
export const setSecurityGroupShared = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/post_group/set_shared', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// ========== 快照管理 ==========
/** 获取快照列表 */
export const getSnapshotList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/snapshot/list', { params })
}

/** 获取快照任务进度 */
export const getSnapshotProgress = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/snapshot/progress', { params })
}

/** 创建快照 */
export const createSnapshot = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/snapshot/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 恢复快照 */
export const restoreSnapshot = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/snapshot/restore', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除快照 */
export const deleteSnapshot = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/snapshot/delete', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// ========== 备份管理 ==========
/** 获取备份列表 */
export const getBackupList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/backup/list', { params })
}

/** 获取备份任务进度 */
export const getBackupProgress = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/backup/progress', { params })
}

/** 创建备份 */
export const createBackup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/backup/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 恢复备份 */
export const restoreBackup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/backup/restore', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除备份 */
export const deleteBackup = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/backup/delete', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 获取快照数量与上限 */
export const getSnapshotCount = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/snapshot/count', { params })
}

/** 设置快照数量上限 */
export const setSnapshotLimit = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/snapshot/set_limit', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 获取备份数量与上限 */
export const getBackupCount = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/backup/count', { params })
}

/** 设置备份数量上限 */
export const setBackupLimit = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/backup/set_limit', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 用户组网管理 (UserNetworking)
 * ================================
 */

/** 获取组网列表 */
export const getUserNetworkingList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/networking/list', { params })
}

/** 获取组网详情 */
export const getUserNetworkingDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/networking/detail', { params })
}

/** 创建用户组网 */
export const createUserNetworking = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/networking/create', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 为虚拟机分配组网 IP */
export const assignUserNetworking = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/networking/assign', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 删除组网 */
export const deleteUserNetworking = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/networking/delete', { params })
}

/** 删除组网下的指定网络 */
export const removeUserNetworkingNetwork = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/networking/remove_network', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * ================================
 * 回收站管理 API
 * ================================
 */

/** 获取回收站列表 */
export const getRecycleBinList = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/recycle_bin/list', { params })
}

/** 获取回收站记录详情 */
export const getRecycleBinDetail = (params) => {
  return http2.get('/api/v1/admin/server/host_service/point/recycle_bin/detail', { params })
}

/** 从回收站恢复虚拟机 */
export const restoreRecycleBin = (data) => {
  return http2.post('/api/v1/admin/server/host_service/point/recycle_bin/restore', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/** 永久删除回收站记录 */
export const deleteRecycleBin = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/recycle_bin/delete', { params })
}

/** 清空回收站（all=true 全部清空，all=false 仅清理到期） */
export const cleanRecycleBin = (params) => {
  return http2.delete('/api/v1/admin/server/host_service/point/recycle_bin/clean', { params })
}
