2022-12-16 02:06:14 +00:00
|
|
|
import http from '@/api/http';
|
|
|
|
import { Server, rawDataToServer } from '@/api/admin/servers/getServers';
|
|
|
|
|
|
|
|
export interface Values {
|
|
|
|
externalId: string;
|
|
|
|
name: string;
|
|
|
|
ownerId: number;
|
|
|
|
|
|
|
|
limits: {
|
|
|
|
memory: number;
|
|
|
|
swap: number;
|
|
|
|
disk: number;
|
|
|
|
io: number;
|
|
|
|
cpu: number;
|
|
|
|
threads: string;
|
2023-01-17 18:43:26 +00:00
|
|
|
oomKiller: boolean;
|
2023-01-12 19:31:47 +00:00
|
|
|
};
|
2022-12-16 02:06:14 +00:00
|
|
|
|
|
|
|
featureLimits: {
|
|
|
|
allocations: number;
|
|
|
|
backups: number;
|
|
|
|
databases: number;
|
2023-01-12 19:31:47 +00:00
|
|
|
};
|
2022-12-16 02:06:14 +00:00
|
|
|
|
|
|
|
allocationId: number;
|
|
|
|
addAllocations: number[];
|
|
|
|
removeAllocations: number[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default (id: number, server: Partial<Values>, include: string[] = []): Promise<Server> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.patch(
|
|
|
|
`/api/application/servers/${id}`,
|
|
|
|
{
|
|
|
|
external_id: server.externalId,
|
|
|
|
name: server.name,
|
|
|
|
owner_id: server.ownerId,
|
|
|
|
|
|
|
|
limits: {
|
|
|
|
memory: server.limits?.memory,
|
|
|
|
swap: server.limits?.swap,
|
|
|
|
disk: server.limits?.disk,
|
|
|
|
io: server.limits?.io,
|
|
|
|
cpu: server.limits?.cpu,
|
|
|
|
threads: server.limits?.threads,
|
2023-01-17 18:43:26 +00:00
|
|
|
oom_killer: server.limits?.oomKiller,
|
2022-12-16 02:06:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
feature_limits: {
|
|
|
|
allocations: server.featureLimits?.allocations,
|
|
|
|
backups: server.featureLimits?.backups,
|
|
|
|
databases: server.featureLimits?.databases,
|
|
|
|
},
|
|
|
|
|
|
|
|
allocation_id: server.allocationId,
|
|
|
|
add_allocations: server.addAllocations,
|
|
|
|
remove_allocations: server.removeAllocations,
|
|
|
|
},
|
2023-01-12 19:31:47 +00:00
|
|
|
{ params: { include: include.join(',') } },
|
2022-12-16 02:06:14 +00:00
|
|
|
)
|
|
|
|
.then(({ data }) => resolve(rawDataToServer(data)))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|