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

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

/**
 * 查询网元授权详细
 * @param licenseId 信息ID
 * @returns object
 */
export function getNeLicense(licenseId: string | number) {
  return request({
    url: `/ne/license/${licenseId}`,
    method: 'GET',
  });
}

/**
 * 网元neType和neID查询
 * @param neType 网元类型
 * @param neId 网元ID
 * @returns object
 */
export function getNeLicenseByTypeAndID(neType: string, neId: string) {
  return request({
    url: `/ne/license/byTypeAndID`,
    method: 'GET',
    params: { neType, neId },
  });
}

/**
 * 网元授权激活授权申请码
 * @param neType 网元类型
 * @param neId 网元id
 * @returns object
 */
export function codeNeLicense(neType: string, neId: string) {
  return request({
    url: `/ne/license/code`,
    method: 'GET',
    params: { neType, neId },
  });
}

/**
 * 网元授权激活授权文件替换
 * @param data 网元对象 {"neType": "", "neId": "", "licensePath": "", "reload": true}
 * @returns object
 */
export function changeNeLicense(data: Record<string, any>) {
  return request({
    url: `/ne/license/change`,
    method: 'POST',
    data: data,
    timeout: 180_000,
  });
}

/**
 * 网元授权激活状态
 * @param neType 网元类型
 * @param neId 网元id
 * @returns object
 */
export function stateNeLicense(neType: string, neId: string) {
  return request({
    url: `/ne/license/state`,
    method: 'GET',
    params: { neType, neId },
  });
}
