forked from onlyLTY/dockerCopilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockercopilot.api
More file actions
428 lines (333 loc) · 9.45 KB
/
dockercopilot.api
File metadata and controls
428 lines (333 loc) · 9.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
syntax = "v1"
type DoLoginReq {
SecretKey string `form:"secret_key,optional"`
}
type LoginReq {
SecretKey string `form:"secretKey,optional"`
}
type VerifyJwtReq {
Jwt string `form:"jwt,optional"`
}
type GetProgressReq {
TaskId string `path:"taskid"`
}
type ContainerLogsReq {
Id string `path:"id"`
Token string `form:"token,optional"`
Tail string `form:"tail,default=100"`
}
type StartContainerReq {
Name string `json:"name"`
}
type StopContainerReq {
Name string `json:"name"`
}
type RenameContainerReq {
OldName string `json:"oldName"`
NewName string `json:"newName"`
}
type CreateContainerReq {
OldName string `json:"old_name"`
NewName string `json:"new_name"`
ImageNameAndTag string `json:"image_name_and_tag"`
}
type RemoveContainerReq {
IdReq
Force bool `form:"force,default=false"`
DeleteImage bool `form:"deleteImage,default=false"`
DeleteRelatedContainers bool `form:"deleteRelatedContainers,default=false"`
}
type getNewImageReq {
ImageNameAndTag string `json:"image_name_and_tag"`
}
type MsgResp {
Status string `json:"status"`
Msg string `json:"msg"`
}
type Resp {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
type IdReq {
Id string `path:"id"`
}
type ContainerRestoreReq {
Filename string `json:"filename"`
}
type DelContainerBackupReq {
Filename string `form:"filename"`
}
type ContainerRenameReq {
IdReq
NewName string `form:"newName"`
}
type RemoveImageReq {
IdReq
Force bool `form:"force,default=false"`
}
type UpdateImageSourceReq {
IdReq
SourceType string `json:"sourceType"` // remote, local, private
RegistryHost string `json:"registryHost,optional"` // 私有 Registry 主机
}
type UpdateImageTagReq {
IdReq
NewTag string `json:"newTag"` // 新的镜像标签
}
type ContainerUpdateReq {
IdReq
ImageNameAndTag string `form:"imageNameAndTag"`
ContainerName string `form:"containerName"`
}
type VersionMsgResp {
Version string `json:"version"`
BuildDate string `json:"build_date"`
}
type VersionReq {
Type string `form:"type"`
}
// ======== 群组管理类型定义 ========
type GroupCreateReq {
Name string `json:"name"`
GroupType string `json:"groupType,optional,default=container"`
CronExpr string `json:"cronExpr,optional"`
AutoUpdate bool `json:"autoUpdate,optional"`
CheckUpdate bool `json:"checkUpdate,default=true"`
Priority int `json:"priority,default=100"`
Enabled bool `json:"enabled,default=true"`
RestartAfterUpdate bool `json:"restartAfterUpdate,optional"` // 更新后重启容器
StartContainers bool `json:"startContainers,optional"` // 启动停止的容器
StopContainers bool `json:"stopContainers,optional"` // 关闭运行中的容器
}
type GroupUpdateReq {
Id int64 `path:"id"`
Name string `json:"name,optional"`
GroupType string `json:"groupType,optional"`
CronExpr string `json:"cronExpr,optional"`
AutoUpdate bool `json:"autoUpdate,optional"`
CheckUpdate bool `json:"checkUpdate,optional"`
Priority int `json:"priority,optional"`
Enabled bool `json:"enabled,optional"`
RestartAfterUpdate bool `json:"restartAfterUpdate,optional"` // 更新后重启容器
StartContainers bool `json:"startContainers,optional"` // 启动停止的容器
StopContainers bool `json:"stopContainers,optional"` // 关闭运行中的容器
}
type GroupIdReq {
Id int64 `path:"id"`
}
type RuleCreateReq {
GroupId int64 `json:"groupId"`
RuleType string `json:"ruleType"`
Pattern string `json:"pattern"`
}
type RuleIdReq {
Id int64 `path:"id"`
}
type ContainerAssignReq {
GroupId int64 `json:"groupId"`
ContainerId string `json:"containerId"`
ContainerName string `json:"containerName"`
}
type ContainerAssignIdReq {
Id int64 `path:"id"`
}
type RulePreviewReq {
RuleType string `form:"ruleType"`
Pattern string `form:"pattern"`
}
type HistoryListReq {
Page int `form:"page,default=1"`
Size int `form:"size,default=20"`
GroupId int64 `form:"groupId,optional"`
}
service dockerCopilot {
@handler webindex
get /
}
@server(
prefix: /api
group: auth
)
service dockerCopilot {
@handler Login
post /auth (LoginReq) returns (Resp)
}
@server(
prefix: /api
group: progress
)
service dockerCopilot {
@handler GetProgress
get /progress/:taskid (GetProgressReq) returns (Resp)
@handler ContainerLogs
get /container/:id/logs (ContainerLogsReq) returns (Resp)
}
@server(
prefix: /api
group: container
jwt: Auth
)
service dockerCopilot {
@handler containersList
get /containers returns (Resp)
@handler start
post /container/:id/start (IdReq) returns (Resp)
@handler stop
post /container/:id/stop (IdReq) returns (Resp)
@handler restart
post /container/:id/restart (IdReq) returns (Resp)
@handler rename
post /container/:id/rename (ContainerRenameReq) returns (Resp)
@handler update
post /container/:id/update (ContainerUpdateReq) returns (Resp)
@handler remove
delete /container/:id (RemoveContainerReq) returns (Resp)
@handler imageDependency
get /container/:id/image-dependency (IdReq) returns (Resp)
@handler backup
get /container/backup returns (Resp)
@handler backup2compose
get /container/backup2compose returns (Resp)
@handler listBackups
get /container/listBackups returns (Resp)
@handler restore
post /container/backups/restore (ContainerRestoreReq) returns (Resp)
@handler delRestore
delete /container/backups (DelContainerBackupReq) returns (Resp)
}
@server(
prefix: /api
group: image
jwt: Auth
)
service dockerCopilot {
@handler imagesList
get /images returns (Resp)
@handler remove
delete /image/:id (RemoveImageReq) returns (Resp)
@handler updateSource
put /image/:id/source (UpdateImageSourceReq) returns (Resp)
@handler updateTag
put /image/:id/tag (UpdateImageTagReq) returns (Resp)
@handler pull
post /image/:id/pull (IdReq) returns (Resp)
}
@server(
prefix: /api
group: version
jwt: Auth
)
service dockerCopilot {
@handler version
get /version (VersionReq) returns (Resp)
@handler updateProgram
put /program returns (Resp)
}
// ======== 群组管理路由 ========
@server(
prefix: /api
group: group
jwt: Auth
)
service dockerCopilot {
@handler groupList
get /groups returns (Resp)
@handler groupGet
get /group/:id (GroupIdReq) returns (Resp)
@handler groupCreate
post /group (GroupCreateReq) returns (Resp)
@handler groupUpdate
put /group/:id (GroupUpdateReq) returns (Resp)
@handler groupDelete
delete /group/:id (GroupIdReq) returns (Resp)
@handler ruleCreate
post /group/rule (RuleCreateReq) returns (Resp)
@handler ruleDelete
delete /group/rule/:id (RuleIdReq) returns (Resp)
@handler rulePreview
get /group/rule/preview (RulePreviewReq) returns (Resp)
@handler containerAssign
post /group/container (ContainerAssignReq) returns (Resp)
@handler containerUnassign
delete /group/container/:id (ContainerAssignIdReq) returns (Resp)
@handler containerAssignments
get /containers/assignments returns (Resp)
@handler groupCheck
post /group/:id/check (GroupIdReq) returns (Resp)
@handler groupUpdate2
post /group/:id/update (GroupIdReq) returns (Resp)
@handler historyList
get /group/history (HistoryListReq) returns (Resp)
// 群组容器批量操作
@handler groupRestart
post /group/:id/restart (GroupIdReq) returns (Resp)
@handler groupStart
post /group/:id/start (GroupIdReq) returns (Resp)
@handler groupStop
post /group/:id/stop (GroupIdReq) returns (Resp)
}
// ======== 环境管理类型定义 ========
type EnvironmentCreateReq {
Name string `json:"name"`
Description string `json:"description,optional"`
EnvType string `json:"envType,default=remote"`
URL string `json:"url,optional"`
SecretKey string `json:"secretKey,optional"`
}
type EnvironmentUpdateReq {
Id int64 `path:"id"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
URL string `json:"url,optional"`
SecretKey string `json:"secretKey,optional"`
}
type EnvironmentIdReq {
Id int64 `path:"id"`
}
type EnvironmentTestReq {
URL string `json:"url"`
SecretKey string `json:"secretKey"`
}
// ======== 环境管理路由 ========
@server(
prefix: /api
group: environment
jwt: Auth
)
service dockerCopilot {
@handler environmentList
get /environments returns (Resp)
@handler environmentGet
get /environment/:id (EnvironmentIdReq) returns (Resp)
@handler environmentCreate
post /environment (EnvironmentCreateReq) returns (Resp)
@handler environmentUpdate
put /environment/:id (EnvironmentUpdateReq) returns (Resp)
@handler environmentDelete
delete /environment/:id (EnvironmentIdReq) returns (Resp)
@handler environmentTest
post /environment/test (EnvironmentTestReq) returns (Resp)
@handler environmentConnect
post /environment/:id/connect (EnvironmentIdReq) returns (Resp)
@handler environmentSetDefault
post /environment/:id/default (EnvironmentIdReq) returns (Resp)
@handler environmentRefresh
post /environment/:id/refresh (EnvironmentIdReq) returns (Resp)
@handler environmentCurrent
get /environment/current returns (Resp)
@handler environmentRestart
post /environment/:id/restart (EnvironmentIdReq) returns (Resp)
}
// 系统信息
@server(
prefix: /api
group: system
jwt: Auth
)
service dockerCopilot {
@handler systemInfo
get /system/info returns (Resp)
@handler systemRestart
post /system/restart returns (Resp)
}