import { service, request } from './network_services'
let url = `ustb-oai.com`

export function SET_URL (data = {}) {
  // 接口请求
  url="202.204.54.185"
}
export function GET_URL (data = {}) {
  // 接口请求
  return url
}

/**
 * @description 获取MAC_Stats
 * @param {Object} data NONE
 */
 export function GET_MAC_STATS (data = {}) {
    // 接口请求
    return request({
      url: `http://${url}:8110/api/stats`,
      method: `get`,
      data
    })
  }
  /**
 * @description 启动eNB
 * @param {Object} data NONE
 */
 export function START_ENB (data = {}) {
  // 接口请求
  return request({
    url: `http://${url}:8110/api/startenb`,
    method: `get`,
    data
  })
}
  /**
 * @description 启动eNBl2
 * @param {Object} data NONE
 */
   export function START_ENB_L2 (data = {}) {
    // 接口请求
    return request({
      url: `http://${url}:8110/api/startenbl2`,
      method: `post`,
      data
    })
  }
  /**
 * @description Add_UE
 * @param {Object} data NONE
 */
   export function ADD_UE (data = {}) {
    // 接口请求
    return request({
      url: `http://${url}:8110/api/startue`,
      method: `post`,
      data
    })
  }
  /**
   * @description 获取IPV4
   * @param {Object} data {"imsi":"208920100001105"}
   */
  export function GET_IPV4_IMSI (data = {}) {
    // 接口请求
    return request({
      url: `http://${url}:8110/api/getip`,
      method: `post`,
      data
    })
  }
  /**
   * @description 获取IPV4
   * @param {Object} data {"host":"172.16.0.8"}
   */
  export function SEND_PING (data = {}) {
    // 接口请求
    return request({
      url: `http://${url}:8110/api/pingapp`,
      method: `post`,
      data
    })
  }
  /**
   * @description Enables the ElasticMon logging framework. Note that this might notably fail because the endpoint is not configured properly or because logging is already active.
   * @param {Object} data NONE
   */
  export function ENABLE_ELASTIC (data = {}) {
    // 接口请求
    return request({
      url: `/elasticmon/enable`,
      method: `post`,
      data
    })
  }
  
  /**
   * @description This API endpoint changes the cell configuration of the eNodeB in the underlying agent, effectively resulting in soft-restart of the base station (only L1/L2/L3 will be restarted). The parameters are specified as a JSON file with the format of the cellConfig as contained in the agent configuration, but only the parametrs dlBandwidth, ulBandwidth, dlFreq, ulFreq end eutraBand are accepted.
   * @param {Object} data  {"dlBandwidth": 50,"ulBandwidth": 50, "dlFreq": 2650,"ulFreq": 2530, "eutraBand": 7};
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function CHANGE_CELL_CONF (data = {}, ENB_ID) {
    // 接口请求
    return request({
      url: `/conf/enb/` + ENB_ID,
      method: `post`,
      data
    })
  }
  
  /**
   * @description This API endpoint triggers the base station to connect to a new MME (and therefore, to a new core network). The list of PLMNs should be configured such that the PLMN(s) served by this new CN are present in the RAN (either through eNB configuration, or dynamically through the corresponding north-bound call). Note that a registration with a subset of the PLMNs (e.g., to hide a PLMN from the CN) is not possible.
   * @param {Object} data  {
      "mme": [
          {
              "s1Ip": "192.168.12.4"
          }
      ]
  }
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function ADD_NEW_MME (data = {}, ENB_ID) {
    // 接口请求
    return request({
      url: `/mme/enb/` + ENB_ID,
      method: `post`,
      data
    })
  }
  
  /**
   * @description This API saves a list of IMSIs or regular expressions matching on IMSIs in order to auto-associate those to a particular slice when they connect. It is checked that the base station has a slice with the given slice ID. Whenever a UE whose IMSI is known (this might not always be the case, go to flight mode and exit to get it reliably) is not in the slice it was associated to, it will automatically be associated to this slice. When associating a new list to a slice which already has an association list, that list will be removed.
   * @param {Object} data  [
      "^20895"
  ]
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function AUTO_SLICE_ASSOC (data = {}, ENB_ID, SLICE_ID) {
    // 接口请求
    return request({
      url: `/auto_ue_slice_assoc/enb/` + ENB_ID + ` /slice/` + SLICE_ID + `/dl`, 
      method: `post`,
      data
    })
  }
  
  /**
   * @description This API endpoint changes the association of a UE in an underlying agent, specified as a JSON file with the format of the ueConfig as contained in the agent configuration. It can be used to changed the association of UEs using their current RNTI or IMSI. In the request, a slice ID and RNTI or IMSI must be present. The stats call should always be used after triggering this endpoint and sufficient time to verify the actions have been taken.
   * @param {Object} data  {
      "ueConfig": [
          {
              "imsi": 208940100001115,
              "dlSliceId": 3,
              "ulSliceId": 3
          }
      ]
  }
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function CHANGE_SLICE_ASSOC (data = {}, ENB_ID) {
    // 接口请求
    return request({
      url: `http://${url}:9999/ue_slice_assoc/enb/` + ENB_ID, 
      method: `post`,
      data
    })
  }
  
  /**
   * @description This API endpoint deletes slices as specified in the JSON data in the body specified as a JSON file with the format of the sliceConfig as contained in the cellConfig of a agent configuration for a given agent. A valid slice ID must present. Slice 0 can not be removed. To remove the slice algorithm, consider posting the None slice algorithm instead.
   * @param {Object} data  {
    "dl": {
      "slices": [
        {
          "id": 3,
        }
      ]
    }
  }
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function DELETE_SLICE (data = {}, ENB_ID) {
    // 接口请求
    return request({
      url: `/slice/enb/` + ENB_ID, 
      method: `delete`,
      data
    })
  }
  
  /**
   * @description This API endpoint posts a new slice configuration to an underlying agent, specified as a JSON file with the format of the sliceConfig as contained in the cellConfig of an agent configuration (for a description of the parameters, see below), or the scheduler to use if no slicing algorithm is chosen (None). It can be used to create arbitrary slices with an arbitrary ID or to change slices by specifying an ID for an existing slice. In the request, a slice ID must be present, as well as the slice parameters. The label is optional, and if no scheduler is given, the scheduler that was active when enabling slicing will be used. The stats call should always be used after triggering this endpoint and sufficient time to verify the actions have been taken. Note that the scheduler (within dl/ul) and the slices parameters are mutually exclusive, since the first only applies for no slicing algorithm (None), whereas the latter only applies if a slicing algorithm has been chosen.This API call has changed as of July 2020. For a description of how the old parameters can be reproduced in the new call, see Deprecated Slice ConfigurationRemarks on the Static slicing algorithm: this algorithm does not provide any sharing. Note that posLow/posHigh are in terms of resource block groups (RBG) in DL and resource blocks (RB) in UL. Furthermore, it is not checked that the channel bandwidth can actually accommodate this slice (posLow=100 and posHigh=110 are a valid entry, but they will never work, since LTE has a maximum bandwidth of 100RBs). Please refer to the stats call to check the amount of resource blocks as well as the resource block group size which will tell the applicable RB/RBG settings. Please also note that OAI reserves the first and last 1, 2, or 3 RBs (for bandwidths 25, 50, or 100RBs, respectively) for PUCCH, meaning that these first/last RBs should be spared out/they won`t be given to the slice. Also, the minimum RB size in UL is 3!
   * @param {Object} data  {"dl":{"algorithm":"SCN19","slices":[
  {"id":0,"scn19":{"typeid":1,"type":"static","posLow":0,"posHigh":8}},
  {"id":2,"scn19":{"typeid":2,"type":"dynamic","kpsRequired":100,"kpsReference":1200}},
  {"id":3,"scn19":{"typeid":2,"type":"dynamic","kpsRequired":1200,"kpsReference":1200}},
  {"id":4,"scn19":{"typeid":2,"type":"dynamic","kpsRequired":500,"kpsReference":1200}}]}}
   * @param {Object}  ENB_ID Default -1 for eNB 0
  */
  export function ADD_SLICE (data = {}, ENB_ID) {
    // 接口请求
    return request({
      url: `http://${url}:9999/slice/enb/` + ENB_ID, 
      method: `post`,
      data
    })
  }

  /**
   * @description 探测网络环境
  */
  export function DETECT (data = {}) {
    // 接口请求
    return request({
      url: `http://pv.sohu.com/cityjson?ie=utf-8`, 
      method: `get`,
      data
    })
  }

  /**
   * @description 获取归属地
  */
     export function DETECT_LOCAL (data = {},ip) {
      // 接口请求
      return request({
        url: `https://www.svlik.com/t/ipapi/ip.php?ip=${ip}&type=0`, 
        method: `get`,
        data
      })
    }