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

/**
 * 查询网元版本列表
 * @param query 查询参数
 * @returns object
 */
export function listNeSoftware(query: Record<string, any>) {
  return request({
    url: '/ne/software/list',
    method: 'get',
    params: query,
    timeout: 60_000,
  });
}

/**
 * 查询网元软件包详细
 * @param softwareId 信息ID
 * @returns object
 */
export function getNeSoftware(softwareId: string | number) {
  return request({
    url: `/ne/software/${softwareId}`,
    method: 'get',
  });
}

/**
 * 网元软件包新增
 * @param data 网元对象
 * @returns object
 */
export function addNeSoftware(data: Record<string, any>) {
  return request({
    url: `/ne/software`,
    method: 'post',
    data: data,
    repeatSubmit: false,
  });
}

/**
 * 网元软件包修改
 * @param data 网元对象
 * @returns object
 */
export function updateNeSoftware(data: Record<string, any>) {
  return request({
    url: `/ne/software`,
    method: 'put',
    data: data,
  });
}

/**
 * 网元软件包删除
 * @param id 信息ID
 * @returns object
 */
export function delNeSoftware(softwareIds: string | number) {
  return request({
    url: `/ne/software/${softwareIds}`,
    method: 'delete',
    timeout: 60_000,
  });
}

/**
 * 网元软件包设为网元新版本
 * @param data data { "version": "2.2404.18", "neType": "SMF", "name": "smf-r2.2404.18-ub22.deb"}
 * @returns object
 */
export function newNeVersion(data: Record<string, any>) {
  return request({
    url: `/ne/software/newNeVersion`,
    method: 'post',
    data: data,
  });
}
