2020-09-01 10:34:11 +08:00
|
|
|
import Api from '@/common/Api';
|
2023-08-31 21:49:20 +08:00
|
|
|
import config from '@/common/config';
|
2023-10-18 15:24:29 +08:00
|
|
|
import { joinClientParams } from '@/common/utils/storage';
|
2020-09-01 10:34:11 +08:00
|
|
|
|
|
|
|
|
export const machineApi = {
|
|
|
|
|
// 获取权限列表
|
2023-07-06 20:59:22 +08:00
|
|
|
list: Api.newGet('/machines'),
|
2023-07-20 22:41:13 +08:00
|
|
|
tagList: Api.newGet('/machines/tags'),
|
2023-07-06 20:59:22 +08:00
|
|
|
getMachinePwd: Api.newGet('/machines/{id}/pwd'),
|
|
|
|
|
info: Api.newGet('/machines/{id}/sysinfo'),
|
|
|
|
|
stats: Api.newGet('/machines/{id}/stats'),
|
|
|
|
|
process: Api.newGet('/machines/{id}/process'),
|
2022-01-16 21:45:00 +08:00
|
|
|
// 终止进程
|
2023-07-06 20:59:22 +08:00
|
|
|
killProcess: Api.newDelete('/machines/{id}/process'),
|
|
|
|
|
closeCli: Api.newDelete('/machines/{id}/close-cli'),
|
|
|
|
|
testConn: Api.newPost('/machines/test-conn'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 保存按钮
|
2023-07-06 20:59:22 +08:00
|
|
|
saveMachine: Api.newPost('/machines'),
|
2022-04-27 10:59:02 +08:00
|
|
|
// 调整状态
|
2023-07-06 20:59:22 +08:00
|
|
|
changeStatus: Api.newPut('/machines/{id}/{status}'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 删除机器
|
2023-07-06 20:59:22 +08:00
|
|
|
del: Api.newDelete('/machines/{id}'),
|
|
|
|
|
scripts: Api.newGet('/machines/{machineId}/scripts'),
|
|
|
|
|
runScript: Api.newGet('/machines/{machineId}/scripts/{scriptId}/run'),
|
|
|
|
|
saveScript: Api.newPost('/machines/{machineId}/scripts'),
|
|
|
|
|
deleteScript: Api.newDelete('/machines/{machineId}/scripts/{scriptId}'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 获取配置文件列表
|
2023-07-06 20:59:22 +08:00
|
|
|
files: Api.newGet('/machines/{id}/files'),
|
|
|
|
|
lsFile: Api.newGet('/machines/{machineId}/files/{fileId}/read-dir'),
|
|
|
|
|
dirSize: Api.newGet('/machines/{machineId}/files/{fileId}/dir-size'),
|
|
|
|
|
fileStat: Api.newGet('/machines/{machineId}/files/{fileId}/file-stat'),
|
2023-09-07 16:33:53 +08:00
|
|
|
rmFile: Api.newPost('/machines/{machineId}/files/{fileId}/remove'),
|
|
|
|
|
cpFile: Api.newPost('/machines/{machineId}/files/{fileId}/cp'),
|
|
|
|
|
renameFile: Api.newPost('/machines/{machineId}/files/{fileId}/rename'),
|
|
|
|
|
mvFile: Api.newPost('/machines/{machineId}/files/{fileId}/mv'),
|
2023-10-18 15:24:29 +08:00
|
|
|
uploadFile: Api.newPost('/machines/{machineId}/files/{fileId}/upload?' + joinClientParams()),
|
2023-07-06 20:59:22 +08:00
|
|
|
fileContent: Api.newGet('/machines/{machineId}/files/{fileId}/read'),
|
|
|
|
|
createFile: Api.newPost('/machines/{machineId}/files/{id}/create-file'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 修改文件内容
|
2023-07-06 20:59:22 +08:00
|
|
|
updateFileContent: Api.newPost('/machines/{machineId}/files/{id}/write'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 添加文件or目录
|
2023-07-06 20:59:22 +08:00
|
|
|
addConf: Api.newPost('/machines/{machineId}/files'),
|
2020-09-01 10:34:11 +08:00
|
|
|
// 删除配置的文件or目录
|
2023-07-06 20:59:22 +08:00
|
|
|
delConf: Api.newDelete('/machines/{machineId}/files/{id}'),
|
|
|
|
|
terminal: Api.newGet('/api/machines/{id}/terminal'),
|
|
|
|
|
recDirNames: Api.newGet('/machines/rec/names'),
|
|
|
|
|
};
|
2023-03-06 16:59:57 +08:00
|
|
|
|
|
|
|
|
export const authCertApi = {
|
2023-07-06 20:59:22 +08:00
|
|
|
baseList: Api.newGet('/sys/authcerts/base'),
|
|
|
|
|
list: Api.newGet('/sys/authcerts'),
|
|
|
|
|
save: Api.newPost('/sys/authcerts'),
|
|
|
|
|
delete: Api.newDelete('/sys/authcerts/{id}'),
|
|
|
|
|
};
|
2023-07-20 22:41:13 +08:00
|
|
|
|
|
|
|
|
export const cronJobApi = {
|
|
|
|
|
list: Api.newGet('/machine-cronjobs'),
|
|
|
|
|
relateMachineIds: Api.newGet('/machine-cronjobs/machine-ids'),
|
|
|
|
|
relateCronJobIds: Api.newGet('/machine-cronjobs/cronjob-ids'),
|
|
|
|
|
save: Api.newPost('/machine-cronjobs'),
|
|
|
|
|
delete: Api.newDelete('/machine-cronjobs/{id}'),
|
|
|
|
|
execList: Api.newGet('/machine-cronjobs/execs'),
|
|
|
|
|
};
|
2023-08-31 21:49:20 +08:00
|
|
|
|
|
|
|
|
export function getMachineTerminalSocketUrl(machineId: any) {
|
2023-10-18 15:24:29 +08:00
|
|
|
return `${config.baseWsUrl}/machines/${machineId}/terminal?${joinClientParams()}`;
|
2023-08-31 21:49:20 +08:00
|
|
|
}
|