function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var olympusPortal = '/olympus-portal';
var apmServerSl = '/cloudmonitor/apmServer-sl';
export var LOG_CENTER_API = {
  getLogDataSource: "".concat(apmServerSl, "/apmServer-sl/portal/sysAppLog/dropdownSelect"),
  getLogDir: "".concat(apmServerSl, "/apmServer-sl/portal/sysAppLog/logDirs"),
  getLogFiles: "".concat(apmServerSl, "/apmServer-sl/portal/sysAppLog/logFiles"),
  getHistoryLog: "".concat(apmServerSl, "/apmServer-sl/portal/sysAppLog"),
  exportHistoryLog: "".concat(apmServerSl, "/apmServer-sl/portal/sysAppLog/export"),
  getCloudservices: "".concat(olympusPortal, "/apis/v1/cloudservices"),
  getServiceComponents: "".concat(olympusPortal, "/apis/v1/cloudservices/{cloudServiceName}/components"),
  getSvcCompoWorkloads: "".concat(olympusPortal, "/apis/v1/cloudservices/{cloudServiceName}/components/{componentName}/workloads"),
  clusterAddons: "".concat(olympusPortal, "/apis/v1/addons/clusters/{clusterName}/features")
};
function restfulURL(url) {
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  if (url.indexOf('{') === -1) return {
    url: url,
    data: _objectSpread({}, params)
  };
  var data = _objectSpread({}, params);
  var segments = url.split('/').map(function (segment) {
    var _params$key;
    if (segment.indexOf('{') === -1) return segment;
    var key = segment.slice(1, -1);
    delete data[key];
    return (_params$key = params[key]) !== null && _params$key !== void 0 ? _params$key : '';
  });
  return {
    url: segments.join('/'),
    data: data
  };
}
export function createLogCenterServices(request) {
  return {
    getLogDataSource: function getLogDataSource(params) {
      var _restfulURL = restfulURL(LOG_CENTER_API.getLogDataSource, params),
        url = _restfulURL.url,
        data = _restfulURL.data;
      return request.get(url, data);
    },
    getLogDir: function getLogDir(params) {
      var _restfulURL2 = restfulURL(LOG_CENTER_API.getLogDir, params),
        url = _restfulURL2.url,
        data = _restfulURL2.data;
      return request.get(url, data);
    },
    getLogFiles: function getLogFiles(params) {
      var _restfulURL3 = restfulURL(LOG_CENTER_API.getLogFiles, params),
        url = _restfulURL3.url,
        data = _restfulURL3.data;
      return request.get(url, data);
    },
    getHistoryLog: function getHistoryLog(params) {
      var _restfulURL4 = restfulURL(LOG_CENTER_API.getHistoryLog, params),
        url = _restfulURL4.url,
        data = _restfulURL4.data;
      return request.get(url, data);
    },
    exportHistoryLog: function exportHistoryLog(params) {
      var _restfulURL5 = restfulURL(LOG_CENTER_API.exportHistoryLog, params),
        url = _restfulURL5.url,
        data = _restfulURL5.data;
      return request.download(url, data);
    },
    getCloudservices: function getCloudservices() {
      return request.get(LOG_CENTER_API.getCloudservices);
    },
    getServiceComponents: function getServiceComponents(params) {
      var _restfulURL6 = restfulURL(LOG_CENTER_API.getServiceComponents, params),
        url = _restfulURL6.url,
        data = _restfulURL6.data;
      return request.get(url, data);
    },
    getSvcCompoWorkloads: function getSvcCompoWorkloads(params) {
      var _restfulURL7 = restfulURL(LOG_CENTER_API.getSvcCompoWorkloads, params),
        url = _restfulURL7.url,
        data = _restfulURL7.data;
      return request.get(url, data);
    },
    getClusterAddons: function getClusterAddons(params) {
      var _restfulURL8 = restfulURL(LOG_CENTER_API.clusterAddons, params),
        url = _restfulURL8.url,
        data = _restfulURL8.data;
      return request.get(url, data);
    }
  };
}