import Axios from 'axios'

import {SERVER_ADMQ,SERVER_QUERY,REQUEST_CONFIG, SERVER_UNDER_DEVICES, SERVER_UNDER_DEVICES_NUM} from "../../utils/RequestUrls";

var staticMethods = {
  // 获取所有服务器
  getServerCollection: function(){
    return Axios.get(SERVER_ADMQ);
  },

  // 添加服务器
  postAddServer: function (server) {
    return Axios.post(SERVER_ADMQ,server,REQUEST_CONFIG);
  },

  // 删除服务器
  deleteDeleteServer: function (serverKeyList) {
    return Axios.delete(SERVER_ADMQ,{
      data:serverKeyList,
      headers:{'Content-Type':'application/json','Encoding':'utf-8'}
    });
  },

  // 修改服务器
  putModifyServer: function (server) {
    return Axios.put(SERVER_ADMQ,server,REQUEST_CONFIG);
  },

  // 条件查询服务器
  putConditionQueryServer: function (conditionSet) {
    return Axios.put(SERVER_QUERY,conditionSet,REQUEST_CONFIG);
  },

  // 获取SDNC服务器管辖设备列表
  putDevicesUnderServer: function (serverId) {
    return Axios.put(SERVER_UNDER_DEVICES+serverId,{},REQUEST_CONFIG);
  },

  // 获取所有SDNC服务器管辖设备数量集合
  getDeviceNumUnderServer: function () {
    return Axios.get(SERVER_UNDER_DEVICES_NUM);
  }
};

function ServerAPI (websocketService = null) {

  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}
// inject static methods
Object.assign(ServerAPI, staticMethods);
export default ServerAPI
