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

/**
 * 网元配置文件备份记录列表
 * @param query 查询参数
 * @returns object
 */
export function listNeConfigBackup(query: Record<string, any>) {
  return request({
    url: '/ne/config/backup/list',
    method: 'get',
    params: query,
  });
}

/**
 * 网元配置文件备份记录修改
 * @param data 数据 { id, name, remark }
 * @returns object
 */
export function updateNeConfigBackup(data: Record<string, any>) {
  return request({
    url: '/ne/config/backup',
    method: 'put',
    data: data,
  });
}

/**
 * 网元配置文件备份记录下载
 * @param id 记录ID
 * @returns object
 */
export async function downNeConfigBackup(id: string) {
  return await request({
    url: '/ne/config/backup/download',
    method: 'get',
    params: { id },
    responseType: 'blob',
    timeout: 180_000,
  });
}

/**
 * 网元配置文件备份记录删除
 * @param id 记录ID
 * @returns object
 */
export async function delNeConfigBackup(id: string) {
  return request({
    url: '/ne/config/backup',
    method: 'delete',
    params: { id },
  });
}

/**
 * 网元配置文件备份导出
 * @param data 数据 { neType, neId }
 * @returns object
 */
export function exportNeConfigBackup(data: Record<string, any>) {
  return request({
    url: '/ne/config/backup/export',
    method: 'post',
    data: data,
    responseType: 'blob',
    timeout: 180_000,
  });
}

/**
 * 网元配置文件备份导入
 * @param data 数据 { neType, neId, type, path }
 * @returns object
 */
export function importNeConfigBackup(data: Record<string, any>) {
  return request({
    url: '/ne/config/backup/import',
    method: 'post',
    data: data,
  });
}