@pelican.ts/sdk 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/index.d.mts +905 -64
- package/dist/index.d.ts +905 -64
- package/dist/index.js +943 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +943 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/api/application/client.ts +40 -0
- package/src/api/application/database_hosts.ts +70 -0
- package/src/api/application/nodes.ts +72 -45
- package/src/api/application/nodes_allocations.ts +4 -6
- package/src/api/application/roles.ts +53 -0
- package/src/api/application/servers.ts +135 -0
- package/src/api/application/servers_databases.ts +49 -0
- package/src/api/application/types/container.ts +1 -3
- package/src/api/application/types/database_host.ts +11 -0
- package/src/api/application/types/node.ts +39 -4
- package/src/api/application/types/role.ts +8 -0
- package/src/api/application/types/server.ts +4 -4
- package/src/api/{common/types/server_allocations.ts → application/types/server_allocation.ts} +3 -2
- package/src/api/application/types/user.ts +4 -4
- package/src/api/application/users.ts +28 -18
- package/src/api/base/request.ts +3 -3
- package/src/api/client/server_allocations.ts +1 -1
- package/src/api/client/server_databases.ts +7 -7
- package/src/api/client/types/server.ts +1 -1
- package/src/api/client/types/server_allocation.ts +11 -0
- package/src/api/common/types/enums.ts +21 -0
- package/src/api/common/types/server_database.ts +1 -1
- package/src/index.ts +4 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
3
|
+
import {DatabaseHost} from "@/api/application/types/database_host";
|
|
4
|
+
import z from "zod";
|
|
5
|
+
|
|
6
|
+
export class DatabaseHosts {
|
|
7
|
+
private readonly r: AxiosInstance
|
|
8
|
+
|
|
9
|
+
constructor(r: AxiosInstance) {
|
|
10
|
+
this.r = r
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
list = async (
|
|
14
|
+
page: number = 1
|
|
15
|
+
): Promise<DatabaseHost[]> => {
|
|
16
|
+
const {data} = await this.r.get<
|
|
17
|
+
GenericListResponse<GenericResponse<DatabaseHost, "database_host">>
|
|
18
|
+
>("/database-hosts", {
|
|
19
|
+
params: {page}
|
|
20
|
+
})
|
|
21
|
+
return data.data.map(d => d.attributes)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
info = async (
|
|
25
|
+
id: string
|
|
26
|
+
): Promise<DatabaseHost> => {
|
|
27
|
+
const {data} = await this.r.get<
|
|
28
|
+
GenericResponse<DatabaseHost, "database_host">
|
|
29
|
+
>(`/database-hosts/${id}`)
|
|
30
|
+
return data.attributes
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// TODO: find out why API returns 500
|
|
34
|
+
create = async (
|
|
35
|
+
opts: z.infer<typeof CreateDBHostSchema>
|
|
36
|
+
): Promise<void> => {
|
|
37
|
+
opts = CreateDBHostSchema.parse(opts)
|
|
38
|
+
await this.r.post<
|
|
39
|
+
GenericResponse<DatabaseHost, "database_host">
|
|
40
|
+
>("/database-hosts", opts).catch(e=>{})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update = async (
|
|
44
|
+
id: string,
|
|
45
|
+
opts: z.infer<typeof CreateDBHostSchema>
|
|
46
|
+
): Promise<DatabaseHost> => {
|
|
47
|
+
opts = CreateDBHostSchema.parse(opts)
|
|
48
|
+
const {data} = await this.r.patch<
|
|
49
|
+
GenericResponse<DatabaseHost, "database_host">
|
|
50
|
+
>(`/database-hosts/${id}`, opts)
|
|
51
|
+
|
|
52
|
+
return data.attributes
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
delete = async (
|
|
56
|
+
id: string
|
|
57
|
+
): Promise<void> => {
|
|
58
|
+
await this.r.delete(`/database-hosts/${id}`)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const CreateDBHostSchema = z.object({
|
|
63
|
+
name: z.string().min(1).max(255),
|
|
64
|
+
host: z.string(),
|
|
65
|
+
port: z.number().min(1).max(65535),
|
|
66
|
+
username: z.string().min(1).max(255),
|
|
67
|
+
password: z.string().optional(),
|
|
68
|
+
node_ids: z.array(z.string()).optional(),
|
|
69
|
+
max_databases: z.number().optional()
|
|
70
|
+
})
|
|
@@ -3,7 +3,7 @@ import {NodesAllocations} from "@/api/application/nodes_allocations";
|
|
|
3
3
|
import {Server} from "@/api/application/types/server";
|
|
4
4
|
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
5
5
|
import z from "zod";
|
|
6
|
-
import {Node} from "@/api/application/types/node";
|
|
6
|
+
import {Node, NodeConfiguration} from "@/api/application/types/node";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export class Nodes {
|
|
@@ -26,42 +26,67 @@ export class Nodes {
|
|
|
26
26
|
return data.data.map(s => s.attributes)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
listDeployable = async (
|
|
30
|
+
filters: {
|
|
31
|
+
disk: number,
|
|
32
|
+
memory: number,
|
|
33
|
+
cpu?: number,
|
|
34
|
+
location_ids?: string[],
|
|
35
|
+
tags?: string[]
|
|
36
|
+
},
|
|
37
|
+
include?: ("allocations" | "location" | "servers")[],
|
|
38
|
+
page: number = 1
|
|
39
|
+
): Promise<Node[]> => {
|
|
40
|
+
z.number().positive().parse(page)
|
|
41
|
+
const {data} = await this.r.get<
|
|
42
|
+
GenericListResponse<GenericResponse<Node, "node">>
|
|
43
|
+
>("/nodes/deployable", {
|
|
44
|
+
params: {
|
|
45
|
+
include: include?.join(","),
|
|
46
|
+
disk: filters.disk,
|
|
47
|
+
memory: filters.memory,
|
|
48
|
+
cpu: filters.cpu,
|
|
49
|
+
location_ids: filters.location_ids,
|
|
50
|
+
tags: filters.tags,
|
|
51
|
+
page: page
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
return data.data.map(s => s.attributes)
|
|
55
|
+
}
|
|
56
|
+
|
|
29
57
|
info = async (
|
|
30
58
|
id: number,
|
|
31
59
|
include?: ("allocations" | "location" | "servers")[],
|
|
32
|
-
|
|
60
|
+
): Promise<Node> => {
|
|
33
61
|
z.number().positive().parse(id)
|
|
34
|
-
const {data} = await this.r.get<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
const {data} = await this.r.get<
|
|
63
|
+
GenericResponse<Node, "node">
|
|
64
|
+
>(`/nodes/${id}`, {
|
|
65
|
+
params: {include: include?.join(",")}
|
|
66
|
+
})
|
|
38
67
|
return data.attributes
|
|
39
68
|
}
|
|
40
69
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const {data} = await this.r.get(`/nodes/${id}/configuration`)
|
|
44
|
-
return data
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
create = async (node: NodeCreate): Promise<NodeUpdated> => {
|
|
70
|
+
create = async (node: z.infer<typeof NodeCreateSchema>): Promise<Node> => {
|
|
71
|
+
node = NodeCreateSchema.parse(node)
|
|
48
72
|
const {data} = await this.r.post<
|
|
49
|
-
GenericResponse<
|
|
50
|
-
>(
|
|
51
|
-
"/nodes",
|
|
52
|
-
node
|
|
53
|
-
)
|
|
73
|
+
GenericResponse<Node, "node">
|
|
74
|
+
>("/nodes", node)
|
|
54
75
|
return data.attributes
|
|
55
76
|
}
|
|
56
77
|
|
|
57
|
-
|
|
78
|
+
get_configuration = async (id: number): Promise<NodeConfiguration> => {
|
|
79
|
+
z.number().positive().parse(id)
|
|
80
|
+
const {data} = await this.r.get<NodeConfiguration>(`/nodes/${id}/configuration`)
|
|
81
|
+
return data
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
update = async (id: number, node: z.infer<typeof NodeCreateSchema>): Promise<Node> => {
|
|
58
85
|
z.number().positive().parse(id)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
node
|
|
64
|
-
)
|
|
86
|
+
node = NodeCreateSchema.parse(node)
|
|
87
|
+
const {data} = await this.r.patch<
|
|
88
|
+
GenericResponse<Node, "node">
|
|
89
|
+
>(`/nodes/${id}`, node)
|
|
65
90
|
return data.attributes
|
|
66
91
|
}
|
|
67
92
|
|
|
@@ -75,23 +100,25 @@ export class Nodes {
|
|
|
75
100
|
)
|
|
76
101
|
}
|
|
77
102
|
|
|
78
|
-
|
|
79
|
-
name: string,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
const NodeCreateSchema = z.object({
|
|
104
|
+
name: z.string().min(1).max(100),
|
|
105
|
+
description: z.string().optional(),
|
|
106
|
+
public: z.boolean().optional(),
|
|
107
|
+
fqdn: z.string().nonempty(),
|
|
108
|
+
scheme: z.enum(["http", "https"]),
|
|
109
|
+
behind_proxy: z.boolean().optional(),
|
|
110
|
+
memory: z.number().min(0),
|
|
111
|
+
memory_overallocate: z.number().min(-1),
|
|
112
|
+
disk: z.number().min(0),
|
|
113
|
+
disk_overallocate: z.number().min(-1),
|
|
114
|
+
cpu: z.number().min(0),
|
|
115
|
+
cpu_overallocate: z.number().min(-1),
|
|
116
|
+
daemon_base: z.string().nonempty().optional(),
|
|
117
|
+
daemon_sftp: z.number().min(1).max(65535),
|
|
118
|
+
daemon_sftp_alias: z.string().optional(),
|
|
119
|
+
daemon_listen: z.number().min(1).max(65535),
|
|
120
|
+
daemon_connect: z.number().min(1).max(65535),
|
|
121
|
+
maintenance_mode: z.boolean().optional(),
|
|
122
|
+
upload_size: z.number().min(1).max(1024),
|
|
123
|
+
tags: z.array(z.string()).optional(),
|
|
124
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {AxiosInstance} from "axios";
|
|
2
|
-
import {Allocation, AllocationRel} from "@/api/
|
|
2
|
+
import {Allocation, AllocationRel} from "@/api/application/types/server_allocation";
|
|
3
3
|
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
4
4
|
import z from "zod";
|
|
5
5
|
|
|
@@ -25,17 +25,15 @@ export class NodesAllocations {
|
|
|
25
25
|
|
|
26
26
|
create = async (
|
|
27
27
|
ip: string,
|
|
28
|
-
ports:
|
|
28
|
+
ports: string[],
|
|
29
29
|
alias?: string
|
|
30
30
|
): Promise<void> => {
|
|
31
31
|
z.ipv4().parse(ip)
|
|
32
|
-
z.ipv4().or(z.url()).optional().parse(alias)
|
|
32
|
+
z.ipv4().or(z.url().max(255)).optional().parse(alias)
|
|
33
33
|
z.array(z.number()).or(z.string().regex(/\d+-\d+/)).parse(ports)
|
|
34
34
|
|
|
35
35
|
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
36
|
-
ip,
|
|
37
|
-
ports,
|
|
38
|
-
alias
|
|
36
|
+
ip, ports, alias
|
|
39
37
|
})
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
3
|
+
import {Role} from "@/api/application/types/role";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// TODO: API is incomplete
|
|
7
|
+
|
|
8
|
+
export class Roles {
|
|
9
|
+
private readonly r: AxiosInstance
|
|
10
|
+
|
|
11
|
+
constructor(r: AxiosInstance) {
|
|
12
|
+
this.r = r
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
list = async (
|
|
16
|
+
page: number = 1
|
|
17
|
+
): Promise<Role[]> => {
|
|
18
|
+
const {data} = await this.r.get<
|
|
19
|
+
GenericListResponse<GenericResponse<Role, "role">>
|
|
20
|
+
>(`/roles`, {
|
|
21
|
+
params: {page}
|
|
22
|
+
})
|
|
23
|
+
return data.data.map(r => r.attributes)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
info = async (
|
|
27
|
+
id: number
|
|
28
|
+
): Promise<Role> => {
|
|
29
|
+
const {data} = await this.r.get<
|
|
30
|
+
GenericResponse<Role, "role">
|
|
31
|
+
>(`/roles/${id}`)
|
|
32
|
+
return data.attributes
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
create = async (
|
|
36
|
+
opts: {name: string}
|
|
37
|
+
): Promise<void> => {
|
|
38
|
+
await this.r.post(`/roles`, opts)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update = async (
|
|
42
|
+
id: number,
|
|
43
|
+
opts: {name: string}
|
|
44
|
+
): Promise<void> => {
|
|
45
|
+
await this.r.patch(`/roles/${id}`, opts)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
delete = async (
|
|
49
|
+
id: number
|
|
50
|
+
): Promise<void> => {
|
|
51
|
+
await this.r.delete(`/roles/${id}`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import {GenericResponse} from "@/api/base/types";
|
|
4
|
+
import {Server} from "@/api/application/types/server";
|
|
5
|
+
import {ServersDatabases} from "@/api/application/servers_databases";
|
|
6
|
+
|
|
7
|
+
export class Servers {
|
|
8
|
+
private readonly r: AxiosInstance
|
|
9
|
+
private readonly id: number
|
|
10
|
+
databases: ServersDatabases
|
|
11
|
+
|
|
12
|
+
constructor(r: AxiosInstance, server_id: number) {
|
|
13
|
+
this.r = r
|
|
14
|
+
this.id = server_id
|
|
15
|
+
|
|
16
|
+
this.databases = new ServersDatabases(this.r, this.id)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
info = async (include?: ("egg" | "subusers")[]): Promise<Server> => {
|
|
20
|
+
const {data} = await this.r.get<GenericResponse<Server, "server">>(`/servers/${this.id}`, {
|
|
21
|
+
params: {include: include?.join(",")}
|
|
22
|
+
})
|
|
23
|
+
return data.attributes
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
delete = async (force: boolean = false) => {
|
|
27
|
+
await this.r.delete(`/servers/${this.id}${force ? "/force" : ""}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
updateDetails = async (opts: z.infer<typeof UpdateDetailsSchema>): Promise<void> => {
|
|
31
|
+
opts = UpdateDetailsSchema.parse(opts)
|
|
32
|
+
await this.r.patch(`/servers/${this.id}/details`, opts)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
updateBuild = async (opts: z.infer<typeof UpdateBuildSchema>): Promise<void> => {
|
|
36
|
+
opts = UpdateBuildSchema.parse(opts)
|
|
37
|
+
await this.r.patch(`/servers/${this.id}/build`, opts)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
updateStartup = async (opts: z.infer<typeof UpdateStartupSchema>): Promise<void> => {
|
|
41
|
+
opts = UpdateStartupSchema.parse(opts)
|
|
42
|
+
await this.r.patch(`/servers/${this.id}/startup`, opts)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
suspend = async (): Promise<void> => {
|
|
46
|
+
await this.r.post(`/servers/${this.id}/suspend`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
unsuspend = async (): Promise<void> => {
|
|
50
|
+
await this.r.post(`/servers/${this.id}/unsuspend`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
reinstall = async (): Promise<void> => {
|
|
54
|
+
await this.r.post(`/servers/${this.id}/reinstall`)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
transferStart = async (
|
|
58
|
+
node_id: number,
|
|
59
|
+
allocation_id: number,
|
|
60
|
+
allocation_additional?: string[]
|
|
61
|
+
): Promise<void> => {
|
|
62
|
+
await this.r.post(`/servers/${this.id}/transfer`, {
|
|
63
|
+
node_id,
|
|
64
|
+
allocation_id,
|
|
65
|
+
allocation_additional
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
transferCancel = async (): Promise<void> => {
|
|
70
|
+
await this.r.post(`/servers/${this.id}/transfer/cancel`)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export const CreateServerSchema = z.object({
|
|
76
|
+
external_id: z.string().min(1).max(255).optional(),
|
|
77
|
+
name: z.string().min(1).max(255),
|
|
78
|
+
description: z.string().optional(),
|
|
79
|
+
user: z.number(),
|
|
80
|
+
egg: z.number(),
|
|
81
|
+
docker_image: z.string().optional(),
|
|
82
|
+
startup: z.string().optional(),
|
|
83
|
+
environment: z.array(z.string()),
|
|
84
|
+
skip_scripts: z.boolean().optional(),
|
|
85
|
+
oom_killer: z.boolean().optional(),
|
|
86
|
+
start_on_completion: z.boolean().optional(),
|
|
87
|
+
limits: z.object({
|
|
88
|
+
memory: z.number().min(0),
|
|
89
|
+
swap: z.number().min(-1),
|
|
90
|
+
disk: z.number().min(0),
|
|
91
|
+
io: z.number().min(0),
|
|
92
|
+
threads: z.string().optional(),
|
|
93
|
+
cpu: z.number().min(0)
|
|
94
|
+
}),
|
|
95
|
+
feature_limits: z.object({
|
|
96
|
+
databases: z.number().min(0),
|
|
97
|
+
allocations: z.number().min(0),
|
|
98
|
+
backups: z.number().min(0)
|
|
99
|
+
}),
|
|
100
|
+
allocation: z.object({
|
|
101
|
+
default: z.string(),
|
|
102
|
+
additional: z.array(z.string()).optional()
|
|
103
|
+
}).optional(),
|
|
104
|
+
deploy: z.object({
|
|
105
|
+
tags: z.array(z.string()).optional(),
|
|
106
|
+
dedicated_ip: z.boolean().optional(),
|
|
107
|
+
port_range: z.array(z.string()).optional()
|
|
108
|
+
}).optional()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const UpdateDetailsSchema = CreateServerSchema.pick({
|
|
112
|
+
external_id: true,
|
|
113
|
+
name: true,
|
|
114
|
+
user: true,
|
|
115
|
+
description: true
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const UpdateBuildSchema = CreateServerSchema.pick({
|
|
119
|
+
oom_killer: true,
|
|
120
|
+
limits: true,
|
|
121
|
+
feature_limits: true,
|
|
122
|
+
}).extend({
|
|
123
|
+
allocation: z.number().optional(),
|
|
124
|
+
add_allocations: z.array(z.string()).optional(),
|
|
125
|
+
remove_allocations: z.array(z.string()).optional(),
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const UpdateStartupSchema = CreateServerSchema.pick({
|
|
129
|
+
startup: true,
|
|
130
|
+
environment: true,
|
|
131
|
+
egg: true,
|
|
132
|
+
skip_scripts: true
|
|
133
|
+
}).extend({
|
|
134
|
+
image: z.string().optional()
|
|
135
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {ServerDatabase} from "@/api/common/types/server_database";
|
|
3
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
4
|
+
import z from "zod";
|
|
5
|
+
|
|
6
|
+
// TODO: Check if database type is valid
|
|
7
|
+
export class ServersDatabases {
|
|
8
|
+
private readonly r: AxiosInstance
|
|
9
|
+
private readonly id: number
|
|
10
|
+
|
|
11
|
+
constructor(r: AxiosInstance, server_id: number) {
|
|
12
|
+
this.r = r
|
|
13
|
+
this.id = server_id
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
list = async (): Promise<ServerDatabase[]> => {
|
|
17
|
+
const {data} = await this.r.get<
|
|
18
|
+
GenericListResponse<GenericResponse<ServerDatabase, "server_database">>
|
|
19
|
+
>(`/servers/${this.id}/databases`)
|
|
20
|
+
return data.data.map(d => d.attributes)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
create = async (
|
|
24
|
+
database: string,
|
|
25
|
+
remote: string,
|
|
26
|
+
host: string
|
|
27
|
+
): Promise<ServerDatabase> => {
|
|
28
|
+
database = z.string().min(1).max(48).parse(database)
|
|
29
|
+
const {data} = await this.r.post<
|
|
30
|
+
GenericResponse<ServerDatabase, "server_database">
|
|
31
|
+
>(`/servers/${this.id}/databases`, {database, remote, host})
|
|
32
|
+
return data.attributes
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
info = async (database_id: number): Promise<ServerDatabase> => {
|
|
36
|
+
const {data} = await this.r.get<
|
|
37
|
+
GenericResponse<ServerDatabase, "server_database">
|
|
38
|
+
>(`/servers/${this.id}/databases/${database_id}`)
|
|
39
|
+
return data.attributes
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
delete = async (database_id: number): Promise<void> => {
|
|
43
|
+
await this.r.delete(`/servers/${this.id}/databases/${database_id}`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
resetPassword = async (database_id: number): Promise<void> => {
|
|
47
|
+
await this.r.post(`/servers/${this.id}/databases/${database_id}/reset-password`)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
2
|
-
import {Allocation} from "@/api/
|
|
2
|
+
import {Allocation} from "@/api/application/types/server_allocation";
|
|
3
3
|
import {Location} from "@/api/application/types/location";
|
|
4
4
|
import {Server} from "@/api/application/types/server";
|
|
5
|
+
import {Nullable} from "@/utils/types";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export type Node = {
|
|
@@ -9,8 +10,7 @@ export type Node = {
|
|
|
9
10
|
uuid: string,
|
|
10
11
|
public: boolean,
|
|
11
12
|
name: string,
|
|
12
|
-
description: string
|
|
13
|
-
location_id: number,
|
|
13
|
+
description: Nullable<string>,
|
|
14
14
|
fqdn: string,
|
|
15
15
|
scheme: "https" | "http",
|
|
16
16
|
behind_proxy: boolean,
|
|
@@ -19,15 +19,50 @@ export type Node = {
|
|
|
19
19
|
memory_overallocate: number,
|
|
20
20
|
disk: number,
|
|
21
21
|
disk_overallocate: number,
|
|
22
|
+
cpu: number,
|
|
23
|
+
cpu_overallocate: number,
|
|
22
24
|
upload_size: number,
|
|
23
25
|
daemon_listen: number,
|
|
24
26
|
daemon_sftp: number,
|
|
27
|
+
daemon_sftp_alias: Nullable<string>,
|
|
25
28
|
daemon_base: string,
|
|
29
|
+
daemon_connect: number,
|
|
26
30
|
created_at: string,
|
|
27
|
-
updated_at: string
|
|
31
|
+
updated_at: Nullable<string>,
|
|
32
|
+
tags: string[],
|
|
33
|
+
allocated_resources: {
|
|
34
|
+
memory: number,
|
|
35
|
+
disk: number,
|
|
36
|
+
cpu: number
|
|
37
|
+
},
|
|
28
38
|
relationships?: {
|
|
29
39
|
allocations?: GenericListResponse<GenericResponse<Allocation, "allocation">>,
|
|
30
40
|
location?: GenericResponse<Location, "location">,
|
|
31
41
|
servers?: GenericListResponse<GenericResponse<Server, "server">>
|
|
32
42
|
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type NodeConfiguration = {
|
|
46
|
+
debug: boolean,
|
|
47
|
+
uuid: string,
|
|
48
|
+
token_id: string,
|
|
49
|
+
token: string,
|
|
50
|
+
api: {
|
|
51
|
+
host: string,
|
|
52
|
+
port: number,
|
|
53
|
+
upload_limit: number,
|
|
54
|
+
ssl: {
|
|
55
|
+
enabled: boolean,
|
|
56
|
+
cert: string,
|
|
57
|
+
key: string
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
system: {
|
|
61
|
+
data: string,
|
|
62
|
+
sftp: {
|
|
63
|
+
bind_port: number,
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
allowed_mounts: string[],
|
|
67
|
+
remote: string
|
|
33
68
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {FeatureLimits, ServerLimits} from "@/api/common/types/server_limits";
|
|
2
2
|
import {Container} from "@/api/application/types/container";
|
|
3
|
+
import {Nullable} from "@/utils/types";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
export type Server = {
|
|
6
7
|
id: number,
|
|
7
|
-
external_id: string
|
|
8
|
+
external_id: Nullable<string>,
|
|
8
9
|
uuid: string,
|
|
9
10
|
identifier: string,
|
|
10
11
|
name: string,
|
|
11
12
|
description: string,
|
|
12
|
-
status:
|
|
13
|
+
status: Nullable<unknown>,
|
|
13
14
|
suspended: boolean,
|
|
14
15
|
limits: ServerLimits,
|
|
15
16
|
feature_limits: FeatureLimits,
|
|
16
17
|
user: number,
|
|
17
18
|
node: number,
|
|
18
19
|
allocation: number,
|
|
19
|
-
nest: number,
|
|
20
20
|
egg: number,
|
|
21
21
|
container: Container,
|
|
22
22
|
created_at: string,
|
|
23
|
-
updated_at: string
|
|
23
|
+
updated_at: Nullable<string>
|
|
24
24
|
}
|
package/src/api/{common/types/server_allocations.ts → application/types/server_allocation.ts}
RENAMED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {GenericResponse} from "@/api/base/types";
|
|
2
2
|
import {Server} from "@/api/application/types/server";
|
|
3
|
+
import {Node} from "@/api/application/types/node";
|
|
3
4
|
import {Nullable} from "@/utils/types";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export type Allocation = {
|
|
7
8
|
id: number,
|
|
8
9
|
ip: string,
|
|
9
|
-
|
|
10
|
+
alias: Nullable<string>,
|
|
10
11
|
port: number,
|
|
11
12
|
notes: Nullable<string>,
|
|
12
|
-
|
|
13
|
+
assigned: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export type AllocationRel = Allocation & {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
2
2
|
import {Server} from "@/api/application/types/server";
|
|
3
|
+
import {Nullable} from "@/utils/types";
|
|
3
4
|
|
|
4
5
|
export type User = {
|
|
5
6
|
id: number,
|
|
6
|
-
external_id: string
|
|
7
|
+
external_id: Nullable<string>,
|
|
7
8
|
uuid: string,
|
|
8
9
|
username: string,
|
|
9
10
|
email: string,
|
|
10
|
-
first_name: string,
|
|
11
|
-
last_name: string,
|
|
12
11
|
language: string,
|
|
13
12
|
root_admin: string,
|
|
13
|
+
"2fa_enabled": boolean,
|
|
14
14
|
"2fa": boolean,
|
|
15
15
|
created_at: string,
|
|
16
|
-
updated_at: string
|
|
16
|
+
updated_at: Nullable<string>,
|
|
17
17
|
relationships?: {
|
|
18
18
|
servers: GenericListResponse<GenericResponse<Server>>
|
|
19
19
|
}
|