mcsmapi 0.1.5b1__tar.gz → 0.1.6__tar.gz
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.
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/PKG-INFO +12 -2
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/README.md +11 -1
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/daemon.py +28 -1
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/file.py +5 -2
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/instance.py +1 -1
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/models/daemon.py +48 -0
- mcsmapi-0.1.6/mcsmapi/models/file.py +228 -0
- mcsmapi-0.1.6/mcsmapi/models/image.py +207 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/models/instance.py +88 -6
- mcsmapi-0.1.6/mcsmapi/models/overview.py +112 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/models/user.py +36 -2
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi.egg-info/PKG-INFO +12 -2
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/pyproject.toml +1 -1
- mcsmapi-0.1.5b1/mcsmapi/models/file.py +0 -108
- mcsmapi-0.1.5b1/mcsmapi/models/image.py +0 -112
- mcsmapi-0.1.5b1/mcsmapi/models/overview.py +0 -63
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/LICENSE +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/__init__.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/__init__.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/image.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/overview.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/apis/user.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/exceptions.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/models/__init__.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/pool.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi/request.py +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi.egg-info/SOURCES.txt +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi.egg-info/dependency_links.txt +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi.egg-info/requires.txt +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/mcsmapi.egg-info/top_level.txt +0 -0
- {mcsmapi-0.1.5b1 → mcsmapi-0.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcsmapi
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
4
4
|
Summary: Shortcut the pypi package of MCSM./快捷操作MCSM的pypi包
|
5
5
|
Author-email: molanp <molanpp@outlook.com>
|
6
6
|
License-Expression: MIT
|
@@ -17,6 +17,7 @@ Dynamic: license-file
|
|
17
17
|

|
18
18
|

|
19
19
|

|
20
|
+
[](https://deepwiki.com/molanp/mcsmapi)
|
20
21
|
|
21
22
|
English|[Chinese Simplified](README_zh-cn.md)
|
22
23
|
|
@@ -25,7 +26,13 @@ English|[Chinese Simplified](README_zh-cn.md)
|
|
25
26
|
|
26
27
|
## Documentation
|
27
28
|
|
28
|
-
The documentation is not yet complete, if you need it, please visit [
|
29
|
+
The documentation is not yet complete, if you need it, please visit [deepwiki-mcsmapi](https://deepwiki.com/molanp/mcsmapi)
|
30
|
+
|
31
|
+
You can also find:
|
32
|
+
|
33
|
+
📄 Work-in-progress docs: [docs](docs)
|
34
|
+
|
35
|
+
💡 Example: [example](example)
|
29
36
|
|
30
37
|
## Introduction
|
31
38
|
|
@@ -41,6 +48,9 @@ You can install `mcsmapi` using `pip`:
|
|
41
48
|
pip install mcsmapi
|
42
49
|
```
|
43
50
|
|
51
|
+
If you need the latest build files (untested), please visit
|
52
|
+
[Actions](https://github.com/molanp/mcsmapi/actions/workflows/auto-build.yml)
|
53
|
+
|
44
54
|
## Supported Features
|
45
55
|
|
46
56
|
- [x] Dashboard data (`Overview`)
|
@@ -3,6 +3,7 @@
|
|
3
3
|

|
4
4
|

|
5
5
|

|
6
|
+
[](https://deepwiki.com/molanp/mcsmapi)
|
6
7
|
|
7
8
|
English|[Chinese Simplified](README_zh-cn.md)
|
8
9
|
|
@@ -11,7 +12,13 @@ English|[Chinese Simplified](README_zh-cn.md)
|
|
11
12
|
|
12
13
|
## Documentation
|
13
14
|
|
14
|
-
The documentation is not yet complete, if you need it, please visit [
|
15
|
+
The documentation is not yet complete, if you need it, please visit [deepwiki-mcsmapi](https://deepwiki.com/molanp/mcsmapi)
|
16
|
+
|
17
|
+
You can also find:
|
18
|
+
|
19
|
+
📄 Work-in-progress docs: [docs](docs)
|
20
|
+
|
21
|
+
💡 Example: [example](example)
|
15
22
|
|
16
23
|
## Introduction
|
17
24
|
|
@@ -27,6 +34,9 @@ You can install `mcsmapi` using `pip`:
|
|
27
34
|
pip install mcsmapi
|
28
35
|
```
|
29
36
|
|
37
|
+
If you need the latest build files (untested), please visit
|
38
|
+
[Actions](https://github.com/molanp/mcsmapi/actions/workflows/auto-build.yml)
|
39
|
+
|
30
40
|
## Supported Features
|
31
41
|
|
32
42
|
- [x] Dashboard data (`Overview`)
|
@@ -1,10 +1,37 @@
|
|
1
1
|
from typing import Any
|
2
2
|
from mcsmapi.pool import ApiPool
|
3
3
|
from mcsmapi.request import send
|
4
|
-
from mcsmapi.models.daemon import DaemonConfig
|
4
|
+
from mcsmapi.models.daemon import DaemonConfig, DaemonModel
|
5
|
+
from mcsmapi.models.daemon.instance import InstanceDetail
|
5
6
|
|
6
7
|
|
7
8
|
class Daemon:
|
9
|
+
def show(self) -> list[DaemonConfig]:
|
10
|
+
"""
|
11
|
+
获取全部节点配置信息
|
12
|
+
|
13
|
+
返回:
|
14
|
+
- List[DaemonConfig]: 节点的配置信息列表
|
15
|
+
"""
|
16
|
+
daemons = send(
|
17
|
+
"GET",
|
18
|
+
f"{ApiPool.SERVICE}/remote_services_list",
|
19
|
+
)
|
20
|
+
return [DaemonConfig(**daemon) for daemon in daemons]
|
21
|
+
|
22
|
+
def system(self) -> list[DaemonModel]:
|
23
|
+
"""
|
24
|
+
获取全部节点的系统信息
|
25
|
+
|
26
|
+
返回:
|
27
|
+
- List[DaemonModel]: 节点系统信息列表
|
28
|
+
"""
|
29
|
+
daemons = send(
|
30
|
+
"GET",
|
31
|
+
f"{ApiPool.SERVICE}/remote_services_system",
|
32
|
+
)
|
33
|
+
return [DaemonModel(**daemon) for daemon in daemons]
|
34
|
+
|
8
35
|
def add(self, config: dict[str, Any]) -> str:
|
9
36
|
"""
|
10
37
|
新增一个节点。
|
@@ -13,6 +13,7 @@ class File:
|
|
13
13
|
target: str = "",
|
14
14
|
page: int = 0,
|
15
15
|
page_size: int = 100,
|
16
|
+
file_name: str = ""
|
16
17
|
) -> FileList:
|
17
18
|
"""
|
18
19
|
获取文件列表
|
@@ -23,6 +24,7 @@ class File:
|
|
23
24
|
- target (str, 可选): 用于文件过滤的目标路径。默认为空字符串,表示不按路径过滤。
|
24
25
|
- page (int, 可选): 指定分页的页码。默认为0。
|
25
26
|
- page_size (int, 可选): 指定每页的文件数量。默认为100。
|
27
|
+
- file_name (str, 可选): 用于在文件列表中过滤出名称包含指定字符串的文件或文件夹
|
26
28
|
|
27
29
|
**返回:**
|
28
30
|
- FileList: 包含文件列表信息和分页详情的FileList模型。
|
@@ -36,6 +38,7 @@ class File:
|
|
36
38
|
"target": target,
|
37
39
|
"page": page,
|
38
40
|
"page_size": page_size,
|
41
|
+
"file_name": file_name,
|
39
42
|
},
|
40
43
|
)
|
41
44
|
return FileList(**result, daemonId=daemonId, uuid=uuid)
|
@@ -223,8 +226,8 @@ class File:
|
|
223
226
|
**参数:**
|
224
227
|
- daemonId (str): 守护进程的唯一标识符。
|
225
228
|
- uuid (str): 实例的唯一标识符。
|
226
|
-
- source (str):
|
227
|
-
- targets (list):
|
229
|
+
- source (str): 需要压缩的文件路径。
|
230
|
+
- targets (list): 要压缩到的目标文件的路径。
|
228
231
|
|
229
232
|
**返回:**
|
230
233
|
- bool: 压缩成功后返回True。
|
@@ -4,48 +4,89 @@ from mcsmapi.models.instance import InstanceCreateResult
|
|
4
4
|
|
5
5
|
|
6
6
|
class CpuMemChart(BaseModel):
|
7
|
+
"""节点资源使用率信息"""
|
8
|
+
|
9
|
+
"""cpu使用率"""
|
7
10
|
cpu: float = 0
|
11
|
+
"""内存使用率"""
|
8
12
|
mem: float = 0
|
9
13
|
|
10
14
|
|
11
15
|
class ProcessInfo(BaseModel):
|
16
|
+
"""节点进程详细信息"""
|
17
|
+
|
18
|
+
"""远程节点使用的cpu资源(单位: byte)"""
|
12
19
|
cpu: int = 0
|
20
|
+
"""远程节点使用的内存资源(单位: byte)"""
|
13
21
|
memory: int = 0
|
22
|
+
"""远程节点的工作路径"""
|
14
23
|
cwd: str = ""
|
15
24
|
|
16
25
|
|
17
26
|
class InstanceInfo(BaseModel):
|
27
|
+
"""实例统计信息"""
|
28
|
+
|
29
|
+
"""运行中实例数量"""
|
18
30
|
running: int = 0
|
31
|
+
"""全部实例数量"""
|
19
32
|
total: int = 0
|
20
33
|
|
21
34
|
|
22
35
|
class SystemInfo(BaseModel):
|
36
|
+
"""节点系统信息"""
|
37
|
+
|
38
|
+
"""系统类型"""
|
23
39
|
type: str = ""
|
40
|
+
"""主机名"""
|
24
41
|
hostname: str = ""
|
42
|
+
"""平台架构"""
|
25
43
|
platform: str = ""
|
44
|
+
"""系统版本"""
|
26
45
|
release: str = ""
|
46
|
+
"""系统运行时间(单位: sec)"""
|
27
47
|
uptime: float = 0
|
48
|
+
"""远程节点运行路径"""
|
28
49
|
cwd: str = ""
|
50
|
+
"""系统负载平均值(仅适用于 Linux 和 macOS),表示过去 **1 分钟、5 分钟、15 分钟** 内的 CPU 负载情况"""
|
29
51
|
loadavg: List[float] = []
|
52
|
+
"""可用内存(单位: byte)"""
|
30
53
|
freemem: int = 0
|
54
|
+
"""cpu使用率"""
|
31
55
|
cpuUsage: float = 0
|
56
|
+
"""内存使用率"""
|
32
57
|
memUsage: float = 0
|
58
|
+
"""内存总量(单位: byte)"""
|
33
59
|
totalmem: int = 0
|
60
|
+
"""未知,在MCSM代码中始终为0"""
|
34
61
|
processCpu: int = 0
|
62
|
+
"""未知,在MCSM代码中始终为0"""
|
35
63
|
processMem: int = 0
|
36
64
|
|
37
65
|
|
38
66
|
class DaemonModel(BaseModel):
|
67
|
+
"""节点详细信息"""
|
68
|
+
|
69
|
+
"""远程节点版本"""
|
39
70
|
version: str = ""
|
71
|
+
"""远程节点的基本信息"""
|
40
72
|
process: ProcessInfo = ProcessInfo()
|
73
|
+
"""远程节点实例基本信息"""
|
41
74
|
instance: InstanceInfo = InstanceInfo()
|
75
|
+
"""远程节点系统信息"""
|
42
76
|
system: SystemInfo = SystemInfo()
|
77
|
+
"""cpu和内存使用趋势"""
|
43
78
|
cpuMemChart: List[CpuMemChart] = []
|
79
|
+
"""远程节点的uuid"""
|
44
80
|
uuid: str = ""
|
81
|
+
"""远程节点的ip"""
|
45
82
|
ip: str = ""
|
83
|
+
"""远程节点的端口"""
|
46
84
|
port: int = 24444
|
85
|
+
"""远程节点的路径前缀"""
|
47
86
|
prefix: str = ""
|
87
|
+
"""远程节点的可用状态"""
|
48
88
|
available: bool = False
|
89
|
+
"""远程节点的备注"""
|
49
90
|
remarks: str = ""
|
50
91
|
|
51
92
|
def delete(self) -> bool:
|
@@ -127,8 +168,15 @@ class DaemonModel(BaseModel):
|
|
127
168
|
|
128
169
|
|
129
170
|
class DaemonConfig(BaseModel):
|
171
|
+
"""节点配置信息"""
|
172
|
+
|
173
|
+
"""远程节点的ip"""
|
130
174
|
ip: str = "localhost"
|
175
|
+
"""远程节点的端口"""
|
131
176
|
port: int = 24444
|
177
|
+
"""远程节点的路径前缀"""
|
132
178
|
prefix: str = ""
|
179
|
+
"""远程节点的备注"""
|
133
180
|
remarks: str = "New Daemon"
|
181
|
+
"""远程节点的可用状态"""
|
134
182
|
available: bool = True
|
@@ -0,0 +1,228 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from typing import List
|
3
|
+
import os
|
4
|
+
|
5
|
+
|
6
|
+
class FileItem(BaseModel):
|
7
|
+
"""文件信息"""
|
8
|
+
|
9
|
+
"""文件名称"""
|
10
|
+
name: str = ""
|
11
|
+
"""文件大小(单位: byte)"""
|
12
|
+
size: int = 0 # byte
|
13
|
+
"""文件修改时间"""
|
14
|
+
time: str = ""
|
15
|
+
"""文件操作权限(仅适用于Linux)"""
|
16
|
+
mode: int = 777 # Linux file permission
|
17
|
+
"""文件类型,`0`为文件夹,`1`为文件"""
|
18
|
+
type: int = 0 # 0 = Folder, 1 = File
|
19
|
+
"""远程节点uuid"""
|
20
|
+
daemonId: str = ""
|
21
|
+
"""实例的uiid"""
|
22
|
+
uuid: str = ""
|
23
|
+
"""文件所在路径"""
|
24
|
+
target: str = ""
|
25
|
+
"""当前文件列表过滤条件"""
|
26
|
+
file_name: str = ""
|
27
|
+
|
28
|
+
def rename(self, newName: str) -> bool:
|
29
|
+
"""
|
30
|
+
重命名该文件或文件夹。
|
31
|
+
|
32
|
+
**参数:**
|
33
|
+
- new_name (str): 源文件或文件夹的新名字。
|
34
|
+
|
35
|
+
**返回:**
|
36
|
+
- bool: 重命名成功后返回True。
|
37
|
+
"""
|
38
|
+
from mcsmapi.apis.file import File
|
39
|
+
|
40
|
+
return File().rename(
|
41
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), newName
|
42
|
+
)
|
43
|
+
|
44
|
+
def delete(self) -> bool:
|
45
|
+
"""
|
46
|
+
删除该文件或文件夹。
|
47
|
+
|
48
|
+
**返回:**
|
49
|
+
- bool: 重命名成功后返回True。
|
50
|
+
"""
|
51
|
+
from mcsmapi.apis.file import File
|
52
|
+
|
53
|
+
return File().delete(
|
54
|
+
self.daemonId, self.uuid, [os.path.join(self.target, self.name)]
|
55
|
+
)
|
56
|
+
|
57
|
+
def copy(self, target: str) -> bool:
|
58
|
+
from mcsmapi.apis.file import File
|
59
|
+
|
60
|
+
return File().copyOne(
|
61
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), target
|
62
|
+
)
|
63
|
+
|
64
|
+
def move(self, target: str) -> bool:
|
65
|
+
"""
|
66
|
+
移动该文件或文件夹到目标路径。
|
67
|
+
|
68
|
+
**参数:**
|
69
|
+
- target (str): 目标文件或文件夹的路径。
|
70
|
+
|
71
|
+
**返回:**
|
72
|
+
- bool: 移动成功后返回True。
|
73
|
+
"""
|
74
|
+
from mcsmapi.apis.file import File
|
75
|
+
|
76
|
+
return File().moveOne(
|
77
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), target
|
78
|
+
)
|
79
|
+
|
80
|
+
def content(self):
|
81
|
+
"""
|
82
|
+
获取文件内容。
|
83
|
+
**返回:**
|
84
|
+
- str | bytes: 文件内容。
|
85
|
+
"""
|
86
|
+
from mcsmapi.apis.file import File
|
87
|
+
|
88
|
+
return File().content(
|
89
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name)
|
90
|
+
)
|
91
|
+
|
92
|
+
def zip(self, targets: list[str]) -> bool:
|
93
|
+
"""
|
94
|
+
压缩多个文件或文件夹到指定位置。
|
95
|
+
|
96
|
+
**参数:**
|
97
|
+
- targets (list): 要压缩到的目标文件的路径。
|
98
|
+
|
99
|
+
**返回:**
|
100
|
+
- bool: 压缩成功后返回True。
|
101
|
+
"""
|
102
|
+
from mcsmapi.apis.file import File
|
103
|
+
|
104
|
+
return File().zip(
|
105
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), targets
|
106
|
+
)
|
107
|
+
|
108
|
+
def unzip(self, target: str, code: str = "utf-8") -> bool:
|
109
|
+
"""
|
110
|
+
解压缩该 zip 文件到目标位置。
|
111
|
+
|
112
|
+
**参数:**
|
113
|
+
- target (str): 解压到的目标路径。
|
114
|
+
- code (str, optional): 压缩文件的编码方式,默认为"utf-8"。
|
115
|
+
可选值: utf-8, gbk, big5
|
116
|
+
|
117
|
+
**返回:**
|
118
|
+
- bool: 解压成功后返回True。
|
119
|
+
"""
|
120
|
+
from mcsmapi.apis.file import File
|
121
|
+
|
122
|
+
return File().unzip(
|
123
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), target, code
|
124
|
+
)
|
125
|
+
|
126
|
+
def update(self, text: str) -> bool:
|
127
|
+
"""
|
128
|
+
更新该文件内容。
|
129
|
+
**参数:**
|
130
|
+
- text (str): 文件内容。
|
131
|
+
**返回:**
|
132
|
+
- bool: 更新成功后返回True。
|
133
|
+
"""
|
134
|
+
from mcsmapi.apis.file import File
|
135
|
+
|
136
|
+
return File().update(
|
137
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name), text
|
138
|
+
)
|
139
|
+
|
140
|
+
def download(self) -> str:
|
141
|
+
"""
|
142
|
+
下载该文件。
|
143
|
+
**返回:**
|
144
|
+
- str: 文件下载的URL。
|
145
|
+
"""
|
146
|
+
from mcsmapi.apis.file import File
|
147
|
+
|
148
|
+
return File().download(
|
149
|
+
self.daemonId, self.uuid, os.path.join(self.target, self.name)
|
150
|
+
)
|
151
|
+
|
152
|
+
|
153
|
+
class FileList(BaseModel):
|
154
|
+
"""文件列表"""
|
155
|
+
|
156
|
+
"""文件信息列表"""
|
157
|
+
items: List[FileItem]
|
158
|
+
"""当前页数"""
|
159
|
+
page: int = 0
|
160
|
+
"""文件列表单页大小"""
|
161
|
+
pageSize: int = 100
|
162
|
+
"""总页数"""
|
163
|
+
total: int = 0
|
164
|
+
"""当前路径在远程节点的绝对路径"""
|
165
|
+
absolutePath: str = "\\"
|
166
|
+
"""远程节点uuid"""
|
167
|
+
daemonId: str = ""
|
168
|
+
"""实例uuid"""
|
169
|
+
uuid: str = ""
|
170
|
+
"""文件(名称或目录)路径"""
|
171
|
+
target: str = ""
|
172
|
+
|
173
|
+
def __init__(self, **data: str):
|
174
|
+
super().__init__(**data)
|
175
|
+
for item in self.items:
|
176
|
+
item.daemonId = self.daemonId
|
177
|
+
item.uuid = self.uuid
|
178
|
+
item.target = self.target
|
179
|
+
|
180
|
+
async def upload(self, file: bytes, upload_dir: str) -> bool:
|
181
|
+
"""
|
182
|
+
上传文件到实例。
|
183
|
+
|
184
|
+
**参数:**
|
185
|
+
- file (bytes): 要上传的文件内容。
|
186
|
+
- upload_dir (str): 上传文件的目标目录(包含文件名)。
|
187
|
+
|
188
|
+
**返回:**
|
189
|
+
- bool: 返回操作结果,成功时返回True。
|
190
|
+
"""
|
191
|
+
from mcsmapi.apis.file import File
|
192
|
+
|
193
|
+
return await File().upload(self.daemonId, self.uuid, file, upload_dir)
|
194
|
+
|
195
|
+
def createFile(self, target: str) -> bool:
|
196
|
+
"""
|
197
|
+
创建文件。
|
198
|
+
|
199
|
+
**参数:**
|
200
|
+
- target (str): 目标文件的路径,包含文件名。
|
201
|
+
|
202
|
+
**返回:**
|
203
|
+
- bool: 创建成功后返回True。
|
204
|
+
"""
|
205
|
+
from mcsmapi.apis.file import File
|
206
|
+
|
207
|
+
return File().createFile(self.daemonId, self.uuid, target)
|
208
|
+
|
209
|
+
def createFloder(self, target: str) -> bool:
|
210
|
+
"""
|
211
|
+
创建文件夹
|
212
|
+
|
213
|
+
**参数:**
|
214
|
+
- target (str): 目标文件夹的路径。
|
215
|
+
|
216
|
+
**返回:**
|
217
|
+
- bool: 创建成功后返回True。
|
218
|
+
"""
|
219
|
+
from mcsmapi.apis.file import File
|
220
|
+
|
221
|
+
return File().createFloder(self.daemonId, self.uuid, target)
|
222
|
+
|
223
|
+
|
224
|
+
class CommonConfig(BaseModel):
|
225
|
+
"""文件下载密码"""
|
226
|
+
password: str = ""
|
227
|
+
"""文件下载地址"""
|
228
|
+
addr: str = ""
|
@@ -0,0 +1,207 @@
|
|
1
|
+
from typing import List, Optional, Union
|
2
|
+
from pydantic import BaseModel
|
3
|
+
|
4
|
+
|
5
|
+
class DockerConfig(BaseModel):
|
6
|
+
"""容器配置"""
|
7
|
+
|
8
|
+
"""容器名称"""
|
9
|
+
containerName: str = ""
|
10
|
+
"""镜像名称"""
|
11
|
+
image: str = ""
|
12
|
+
"""容器分配内存(单位: MB)"""
|
13
|
+
memory: int = 0 # in MB
|
14
|
+
"""容器端口映射"""
|
15
|
+
ports: List[str] = [] # ["25565:25565/tcp"]
|
16
|
+
"""额外挂载卷路径"""
|
17
|
+
extraVolumes: List[str] = []
|
18
|
+
"""容器可使用的最大磁盘空间(单位: MB)"""
|
19
|
+
maxSpace: Optional[int] = None
|
20
|
+
"""网络配置,可以是网络名称或ID"""
|
21
|
+
network: Optional[Union[str, int]] = None
|
22
|
+
"""容器的 IO 限制"""
|
23
|
+
io: Optional[Union[str, int]] = None
|
24
|
+
"""网络模式(例如: bridge, host)"""
|
25
|
+
networkMode: str = "bridge"
|
26
|
+
"""网络别名列表"""
|
27
|
+
networkAliases: List[str] = []
|
28
|
+
"""绑定的 CPU 核心"""
|
29
|
+
cpusetCpus: str = "" # 例如 `0,1`
|
30
|
+
"""CPU 使用率(单位: %)"""
|
31
|
+
cpuUsage: int = 100
|
32
|
+
"""工作目录"""
|
33
|
+
workingDir: str = ""
|
34
|
+
"""环境变量设置"""
|
35
|
+
env: List[str] = []
|
36
|
+
|
37
|
+
|
38
|
+
class DockerImageItem(BaseModel):
|
39
|
+
"""Docker 镜像信息"""
|
40
|
+
|
41
|
+
"""镜像唯一 ID"""
|
42
|
+
Id: str = ""
|
43
|
+
"""父镜像 ID"""
|
44
|
+
ParentId: str = ""
|
45
|
+
"""镜像仓库标签"""
|
46
|
+
RepoTags: List[str] = [] # 例如 ["ubuntu:latest"]
|
47
|
+
"""镜像摘要"""
|
48
|
+
RepoDigests: List[str] = []
|
49
|
+
"""镜像创建时间(Unix 时间戳)"""
|
50
|
+
Created: int = 0
|
51
|
+
"""镜像大小(单位: 字节)"""
|
52
|
+
Size: int = 0
|
53
|
+
"""镜像的虚拟大小"""
|
54
|
+
VirtualSize: int = 0
|
55
|
+
"""共享存储空间大小"""
|
56
|
+
SharedSize: int = 0
|
57
|
+
"""镜像标签"""
|
58
|
+
Labels: dict[str, str] = {}
|
59
|
+
"""依赖该镜像运行的容器数量"""
|
60
|
+
Containers: int = 0
|
61
|
+
|
62
|
+
|
63
|
+
class DockerContainerItemPort(BaseModel):
|
64
|
+
"""Docker 容器端口映射"""
|
65
|
+
|
66
|
+
"""容器内部端口"""
|
67
|
+
PrivatePort: int = 0
|
68
|
+
"""映射到宿主机的端口"""
|
69
|
+
PublicPort: Optional[int] = None
|
70
|
+
"""端口类型(tcp/udp)"""
|
71
|
+
Type: str = ""
|
72
|
+
|
73
|
+
|
74
|
+
class DockerContainerItemNetworkSettingsNetwork(BaseModel):
|
75
|
+
"""Docker 容器网络设置信息"""
|
76
|
+
|
77
|
+
"""网络 ID"""
|
78
|
+
NetworkID: str = ""
|
79
|
+
"""网络端点 ID"""
|
80
|
+
EndpointID: str = ""
|
81
|
+
"""网关地址"""
|
82
|
+
Gateway: str = ""
|
83
|
+
"""分配的 IP 地址"""
|
84
|
+
IPAddress: str = ""
|
85
|
+
"""IP 地址前缀长度"""
|
86
|
+
IPPrefixLen: int = 0
|
87
|
+
"""IPv6 网关地址"""
|
88
|
+
IPv6Gateway: str = ""
|
89
|
+
"""IPv6 地址"""
|
90
|
+
GlobalIPv6Address: str = ""
|
91
|
+
"""IPv6 地址前缀长度"""
|
92
|
+
GlobalIPv6PrefixLen: int = 0
|
93
|
+
"""MAC 地址"""
|
94
|
+
MacAddress: str = ""
|
95
|
+
|
96
|
+
|
97
|
+
class DockerContainerItemNetworkSettings(BaseModel):
|
98
|
+
"""Docker 容器的网络配置信息"""
|
99
|
+
|
100
|
+
"""容器连接的所有网络"""
|
101
|
+
Networks: dict[str, DockerContainerItemNetworkSettingsNetwork] = {}
|
102
|
+
|
103
|
+
|
104
|
+
class DockerContainerItemMount(BaseModel):
|
105
|
+
"""容器挂载点信息"""
|
106
|
+
|
107
|
+
"""挂载名称"""
|
108
|
+
Name: str = ""
|
109
|
+
"""源路径"""
|
110
|
+
Source: str = ""
|
111
|
+
"""目标路径"""
|
112
|
+
Destination: str = ""
|
113
|
+
"""驱动类型"""
|
114
|
+
Driver: str = ""
|
115
|
+
"""挂载模式"""
|
116
|
+
Mode: str = ""
|
117
|
+
"""是否允许读写"""
|
118
|
+
RW: bool = False
|
119
|
+
"""传播模式"""
|
120
|
+
Propagation: str = ""
|
121
|
+
|
122
|
+
|
123
|
+
class DockerContainerItemHostConfig(BaseModel):
|
124
|
+
"""Docker 宿主机配置"""
|
125
|
+
|
126
|
+
"""网络模式"""
|
127
|
+
NetworkMode: str = ""
|
128
|
+
|
129
|
+
|
130
|
+
class DockerContainerItem(BaseModel):
|
131
|
+
"""Docker 容器详细信息"""
|
132
|
+
|
133
|
+
"""容器 ID"""
|
134
|
+
Id: str = ""
|
135
|
+
"""容器名称列表"""
|
136
|
+
Names: List[str] = []
|
137
|
+
"""运行的镜像名称"""
|
138
|
+
Image: str = ""
|
139
|
+
"""镜像 ID"""
|
140
|
+
ImageID: str = ""
|
141
|
+
"""容器启动命令"""
|
142
|
+
Command: str = ""
|
143
|
+
"""容器创建时间(Unix 时间戳)"""
|
144
|
+
Created: int = 0
|
145
|
+
"""容器状态"""
|
146
|
+
State: str = ""
|
147
|
+
"""容器运行状态描述"""
|
148
|
+
Status: str = ""
|
149
|
+
"""端口映射信息"""
|
150
|
+
Ports: List[DockerContainerItemPort] = []
|
151
|
+
"""容器标签信息"""
|
152
|
+
Labels: dict[str, str] = {}
|
153
|
+
"""读写层大小(单位: 字节)"""
|
154
|
+
SizeRw: int = 0
|
155
|
+
"""根文件系统大小(单位: 字节)"""
|
156
|
+
SizeRootFs: int = 0
|
157
|
+
"""宿主机配置"""
|
158
|
+
HostConfig: DockerContainerItemHostConfig = DockerContainerItemHostConfig()
|
159
|
+
"""容器网络配置"""
|
160
|
+
NetworkSettings: DockerContainerItemNetworkSettings = DockerContainerItemNetworkSettings()
|
161
|
+
"""容器挂载信息"""
|
162
|
+
Mounts: List[DockerContainerItemMount] = []
|
163
|
+
|
164
|
+
|
165
|
+
class DockerNetworkItemIPAMConfig(BaseModel):
|
166
|
+
"""Docker 网络 IPAM 配置信息"""
|
167
|
+
|
168
|
+
"""子网地址"""
|
169
|
+
Subnet: str = ""
|
170
|
+
|
171
|
+
|
172
|
+
class DockerNetworkItemIPAM(BaseModel):
|
173
|
+
"""Docker 网络的 IP 地址管理"""
|
174
|
+
|
175
|
+
"""驱动类型"""
|
176
|
+
Driver: str = ""
|
177
|
+
"""IPAM 配置"""
|
178
|
+
Config: List[DockerNetworkItemIPAMConfig] = []
|
179
|
+
|
180
|
+
|
181
|
+
class DockerNetworkItem(BaseModel):
|
182
|
+
"""Docker 网络详细信息"""
|
183
|
+
|
184
|
+
"""网络名称"""
|
185
|
+
Name: str = ""
|
186
|
+
"""网络 ID"""
|
187
|
+
Id: str = ""
|
188
|
+
"""网络创建时间"""
|
189
|
+
Created: str = ""
|
190
|
+
"""网络作用范围(local/global)"""
|
191
|
+
Scope: str = ""
|
192
|
+
"""网络驱动类型"""
|
193
|
+
Driver: str = ""
|
194
|
+
"""是否启用 IPv6"""
|
195
|
+
EnableIPv6: bool = False
|
196
|
+
"""是否为内部网络"""
|
197
|
+
Internal: bool = False
|
198
|
+
"""是否可附加"""
|
199
|
+
Attachable: bool = False
|
200
|
+
"""是否为入口网络"""
|
201
|
+
Ingress: bool = False
|
202
|
+
"""IPAM 配置信息"""
|
203
|
+
IPAM: DockerNetworkItemIPAM = DockerNetworkItemIPAM()
|
204
|
+
"""网络选项"""
|
205
|
+
Options: dict[str, str] = {}
|
206
|
+
"""连接到此网络的容器信息"""
|
207
|
+
Containers: Optional[dict[str, dict]] = {}
|