2023-10-25 10:26:14 +08:00
|
|
|
import type { DataGrid, Pagination } from '@/types/global';
|
|
|
|
|
import type { TableData } from '@arco-design/web-vue/es/table/interface';
|
2023-09-20 12:13:02 +08:00
|
|
|
import axios from 'axios';
|
2024-05-31 16:32:45 +08:00
|
|
|
import qs from 'query-string';
|
2023-09-20 12:13:02 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主机身份创建请求
|
|
|
|
|
*/
|
|
|
|
|
export interface HostIdentityCreateRequest {
|
|
|
|
|
name?: string;
|
2024-04-17 10:11:36 +08:00
|
|
|
type?: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
username?: string;
|
|
|
|
|
password?: string;
|
|
|
|
|
keyId?: number;
|
2025-01-17 09:56:30 +08:00
|
|
|
description?: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主机身份更新请求
|
|
|
|
|
*/
|
|
|
|
|
export interface HostIdentityUpdateRequest extends HostIdentityCreateRequest {
|
2023-09-25 14:36:13 +08:00
|
|
|
id?: number;
|
2023-09-21 13:50:42 +08:00
|
|
|
useNewPassword?: boolean;
|
2023-09-20 12:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主机身份查询请求
|
|
|
|
|
*/
|
|
|
|
|
export interface HostIdentityQueryRequest extends Pagination {
|
2023-10-08 01:05:52 +08:00
|
|
|
searchValue?: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
id?: number;
|
|
|
|
|
name?: string;
|
2024-04-17 10:11:36 +08:00
|
|
|
type?: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
username?: string;
|
|
|
|
|
keyId?: number;
|
2025-01-17 09:56:30 +08:00
|
|
|
description?: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 主机身份查询响应
|
|
|
|
|
*/
|
2023-09-24 22:08:33 +08:00
|
|
|
export interface HostIdentityQueryResponse extends TableData {
|
2023-11-01 18:57:53 +08:00
|
|
|
id: number;
|
|
|
|
|
name: string;
|
2024-04-17 10:11:36 +08:00
|
|
|
type: string;
|
2023-11-01 18:57:53 +08:00
|
|
|
username: string;
|
|
|
|
|
password: string;
|
|
|
|
|
keyId: number;
|
2025-01-17 09:56:30 +08:00
|
|
|
description: string;
|
2023-09-20 12:13:02 +08:00
|
|
|
createTime: number;
|
|
|
|
|
updateTime: number;
|
|
|
|
|
creator: string;
|
|
|
|
|
updater: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function createHostIdentity(request: HostIdentityCreateRequest) {
|
|
|
|
|
return axios.post('/asset/host-identity/create', request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过 id 更新主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function updateHostIdentity(request: HostIdentityUpdateRequest) {
|
|
|
|
|
return axios.put('/asset/host-identity/update', request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过 id 查询主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function getHostIdentity(id: number) {
|
|
|
|
|
return axios.get<HostIdentityQueryResponse>('/asset/host-identity/get', { params: { id } });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询主机身份
|
|
|
|
|
*/
|
2023-09-21 13:50:42 +08:00
|
|
|
export function getHostIdentityList() {
|
2023-09-22 11:50:56 +08:00
|
|
|
return axios.get<Array<HostIdentityQueryResponse>>('/asset/host-identity/list');
|
2023-09-20 12:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function getHostIdentityPage(request: HostIdentityQueryRequest) {
|
|
|
|
|
return axios.post<DataGrid<HostIdentityQueryResponse>>('/asset/host-identity/query', request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过 id 删除主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function deleteHostIdentity(id: number) {
|
|
|
|
|
return axios.delete('/asset/host-identity/delete', { params: { id } });
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-31 16:32:45 +08:00
|
|
|
/**
|
|
|
|
|
* 批量删除主机身份
|
|
|
|
|
*/
|
|
|
|
|
export function batchDeleteHostIdentity(idList: Array<number>) {
|
|
|
|
|
return axios.delete('/asset/host-identity/batch-delete', {
|
|
|
|
|
params: { idList },
|
|
|
|
|
paramsSerializer: params => {
|
|
|
|
|
return qs.stringify(params, { arrayFormat: 'comma' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|