import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClusterNodesVO, ClusterNodesForm, ClusterNodesQuery } from '@/api/manage/clusterNodes/types';

/**
 * 查询集群配置列表
 * @param query
 * @returns {*}
 */

export const listClusterNodes = (query?: ClusterNodesQuery): AxiosPromise<ClusterNodesVO[]> => {
  return request({
    url: '/manage/clusterNodes/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询集群配置详细
 * @param nodeId
 */
export const getClusterNodes = (nodeId: string | number): AxiosPromise<ClusterNodesVO> => {
  return request({
    url: '/manage/clusterNodes/' + nodeId,
    method: 'get'
  });
};

/**
 * 新增集群配置
 * @param data
 */
export const addClusterNodes = (data: ClusterNodesForm) => {
  return request({
    url: '/manage/clusterNodes',
    method: 'post',
    data: data
  });
};

/**
 * 修改集群配置
 * @param data
 */
export const updateClusterNodes = (data: ClusterNodesForm) => {
  return request({
    url: '/manage/clusterNodes',
    method: 'put',
    data: data
  });
};

/**
 * 删除集群配置
 * @param nodeId
 */
export const delClusterNodes = (nodeId: string | number | Array<string | number>) => {
  return request({
    url: '/manage/clusterNodes/' + nodeId,
    method: 'delete'
  });
};
