import { PostFile, GetJSON, PostJSON, Post, Get, GetJSONRaw, callFetchRaw } from "../util/axios"
import { ContextPath } from "../util";

export function refreshCatalog() {
  return GetJSON("/pdataservice/pdsCURD/refreshDataServiceCatalog")
}

export function loadDataServiceCatalog() {
  return GetJSON("/pdataservice/pdsCURD/loadDataServiceCatalog");
}

export function loadStateCatalog(payload) {
  return GetJSON("/pdataservice/pdsCURD/loadDataServiceStateCatalog", payload)
}

export function saveCatalog(payload) {
  return PostJSON("/pdataservice/pdsCURD/saveDataServiceCatalog", payload)
}

export function deleteCatalog(payload) {
  return PostJSON("/pdataservice/pdsCURD/deleteDataServiceCatalog", payload)
}

export function upDownCatalog(payload) {
  return GetJSON("/pdataservice/pdsCURD/upDownDataServiceCatalog", payload)
}

export function getServices(payload) {
  return GetJSON("/pdataservice/pdsCURD/getCurrentDataServiceCatalog", payload)
}

export function getGrantedServices(payload) {
  return GetJSON("/pdataservice/pdsCURD/getGrantedDataService", payload)
}

export function getStateServices(payload) {
  return GetJSON("/pdataservice/pdsCURD/getCurrentDataServiceStateCatalog", payload)
}

export function searchService(payload) {
  return GetJSON("/pdataservice/pdsCURD/searchPDSDataServicesByNaming", payload)
}

export function getDataService(payload) {
  return GetJSON("/pdataservice/pdsCURD/getDataService", payload)
}

export function deleteService(payload) {
  return PostJSON("/pdataservice/pdsCURD/deleteDataService", payload);
}

export function recatalogService(payload) {
  return Post("/pdataservice/pdsCURD/recatalogDataService", payload);
}

export function nextState(payload) {
  return GetJSON("/pdataservice/pdsCURD/nextState", payload);
}

export function checkoutService(payload) {
  return PostJSON("/pdataservice/pdsCURD/checkOutDataService", payload)
}

export function getCheckoutService(payload) {
  return GetJSON("/pdataservice/pdsCURD/getCheckoutDataService", payload)
}

export function getServiceDigest(payload) {
  return GetJSON("/pdataservice/pdsCURD/getDataServiceDigest", payload)
}

export function getVersions(payload) {
  return PostJSON("/pdataservice/pdsCURD/getVersions", payload)
}

export function getDataServiceLocation(payload) {
  return GetJSON("/pdataservice/pdsCURD/getDataServiceLocation", payload)
}

export function getSample(payload) {
  return PostJSON("/pdataservice/pdsCURD/getSample", payload)
}

export function enableOData(payload) {
  return Post("/pdataservice/pdsOData/enableOData", payload)
}

export function disableOData(payload) {
  return Post("/pdataservice/pdsOData/disableOData", payload)
}

export function authorize(payload) {
  return PostJSON("/pdataservice/pdsWorkflow/kickoffAuthorize", payload)
}

export function release(payload) {
  return PostJSON("/pdataservice/pdsWorkflow/kickoffRelease", payload)
}

export function offline(payload) {
  return PostJSON("/pdataservice/pdsWorkflow/kickoffOffline", payload)
}

export function getSmartBiUrl(payload) {
  return Get(`/${payload.url}`);
}

export function getOwners() {
  // return GetJSON("/informationmanagement/userData/findAll")
}

export function getDepartments() {
  return GetJSON("/informationmanagement/userData/getAllDepartment")
}

export function saveOwner(payload) {
  return GetJSON("/informationmanagement/userData/getUserDataAndInsert", payload);
}

export function changeOwner(payload) {
  return PostJSON("/pdataservice/pdsCURD/changeOwnerOfDataService", payload)
}

export function saveCols(payload) {
  return PostJSON("/pdataservice/pdsModel/saveVisibleTitle", payload);
}

export function getCols(payload) {
  return GetJSON("/pdataservice/pdsModel/getVisibleTitle", payload);
}

export function getAttrs(payload) {
  return GetJSON("/pdataservice/pdsModel/attrs", payload);
}

export function getJdbcInformation() {
  return GetJSON('/pdataservice/pdsDriver/url');
}

export function subscribe(payload) {
  return callFetchRaw('post', '/pdataservice/pdsSub/subscribeMsg', payload)
}