import Axios from 'axios'
import {
  SNAPSHOT_CMD,
  SNAPSHOT_ADMQ,
  SNAPSHOT_QUERY,
  SNAPSHOT_CREATE,
  SNAPSHOT_RECOVER,
  CABINET_ADMQ,
  CABINET_UPLOAD,
  CABINET_DOWNLOAD,
  REQUEST_CONFIG,
  FIRMWARE_QUERY,
} from "../../utils/RequestUrls";

var staticMethods = {

  // 获取快照
  getSnapshotCollection: function () {
    return Axios.get(SNAPSHOT_CMD)
  },

  // 删除快照
  deleteDeleteSnapshot: function (snapshotKey) {
    return Axios.delete(SNAPSHOT_ADMQ, {
      data: snapshotKey,
      REQUEST_CONFIG
    })
  },

  // 条件查询快照
  putConditionQuerySnapshot: function (conditionSet) {
    return Axios.put(SNAPSHOT_QUERY, conditionSet, REQUEST_CONFIG);
  },
  // 创建快照
  postAddSnapshot: function (snapshot, options) {
    return Axios.post(SNAPSHOT_CREATE + options, snapshot)
  },

  // 回退快照
  getRecoverSnapshot: function (snapshotKey) {
    return Axios.get(SNAPSHOT_RECOVER + snapshotKey)
  }
}

function CabinetAPI (websocketService = null) {

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