import request from '@/utils/request'
import Request from '@/utils/requestOther'
const instance2 = new Request('/core')
// 获取应用http://localhost:8000/api/v1/ot-apps&pageIndex=0&pageSize=200
export function listApps(query) {
  return request({
    url: '/api/v1/ot-apps',
    method: 'get',
    params: query
  })
}

export function listAppServiceList() {
  return request({
    url: '/api/v1/ot-apps/service/list',
    method: 'get',
  })
}

// 获取单个应用http://localhost:8000/api/v1/ot-apps/{id}
export function singleApps(id) {
  return request({
    url: '/api/v1/ot-apps/' + id,
    method: 'get',
  })
}

//创建应用  /api/v1/ot-apps  post
export function addOtApps(data) {
  return request({
    url: '/api/v1/ot-apps',
    method: 'post',
    data: data
  })
}

//修改应用 /api/v1/ot-apps/{id}
export function updateOtApps(data, id) {
  return request({
    url: '/api/v1/ot-apps/' + id,
    method: 'put',
    data: data
  })
}

// 删除应用 /api/v1/ot-apps   {"ids":[1,2,3,4]}
export function delOtApps(data) {
  return request({
    url: '/api/v1/ot-apps',
    method: 'delete',
    data: data
  })
}

//业务健康评分 /api/v1/apps_score
export function appsScore(data) {
  return request({
    url: '/api/v1/apps_score',
    method: 'post',
    data: data
  })
}

//应用概览，apdex
// /api/v1/app/analyst/{:app_alias}?start_time=xxxxx&end_time=xxxx&percentile=0.99
export function analyst(query, name) {
  return request({
    url: '/api/v1/app/analyst/' + name,
    method: 'get',
    params: query
  })
}

// 获取apdex可用性计算模型数据
export function getApdex(name) {
  return request({
    url: `/api/v1/stats/app/apdex/${name}`,
    method: 'get'
  })
}

// 修改apdex可用性计算模型数据
export function modifyApdex(name, query) {
  return request({
    url: `/api/v1/stats/app/apdex/${name}`,
    method: 'post',
    data: query
  })
}

// 首页- 搜索url
export function searchServiceUrl(query) {
  return request({
    url: `api/v1/url-mapping/match`,
    method: 'get',
    params: query
  })
}
// 首页-业务搜索
export function searchBizName(data) {
  const url = `/v1/biz/search`
  return instance2.get(url, data)
}
