mcsmapi 0.1.6__tar.gz → 0.1.8b1__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.
Files changed (39) hide show
  1. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/PKG-INFO +6 -3
  2. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/README.md +2 -1
  3. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/__init__.py +3 -4
  4. mcsmapi-0.1.8b1/mcsmapi/apis/daemon.py +92 -0
  5. mcsmapi-0.1.8b1/mcsmapi/apis/file.py +308 -0
  6. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/apis/image.py +28 -29
  7. mcsmapi-0.1.8b1/mcsmapi/apis/instance.py +281 -0
  8. mcsmapi-0.1.8b1/mcsmapi/apis/overview.py +21 -0
  9. mcsmapi-0.1.8b1/mcsmapi/apis/user.py +82 -0
  10. mcsmapi-0.1.8b1/mcsmapi/models/common.py +30 -0
  11. mcsmapi-0.1.8b1/mcsmapi/models/daemon.py +146 -0
  12. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/models/file.py +89 -78
  13. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/models/image.py +93 -85
  14. mcsmapi-0.1.8b1/mcsmapi/models/instance.py +325 -0
  15. mcsmapi-0.1.8b1/mcsmapi/models/overview.py +203 -0
  16. mcsmapi-0.1.8b1/mcsmapi/models/user.py +133 -0
  17. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/pool.py +1 -0
  18. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/request.py +20 -14
  19. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi.egg-info/PKG-INFO +6 -3
  20. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi.egg-info/SOURCES.txt +1 -0
  21. mcsmapi-0.1.8b1/mcsmapi.egg-info/requires.txt +2 -0
  22. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/pyproject.toml +4 -2
  23. mcsmapi-0.1.6/mcsmapi/apis/daemon.py +0 -97
  24. mcsmapi-0.1.6/mcsmapi/apis/file.py +0 -321
  25. mcsmapi-0.1.6/mcsmapi/apis/instance.py +0 -300
  26. mcsmapi-0.1.6/mcsmapi/apis/overview.py +0 -17
  27. mcsmapi-0.1.6/mcsmapi/apis/user.py +0 -82
  28. mcsmapi-0.1.6/mcsmapi/models/daemon.py +0 -182
  29. mcsmapi-0.1.6/mcsmapi/models/instance.py +0 -303
  30. mcsmapi-0.1.6/mcsmapi/models/overview.py +0 -112
  31. mcsmapi-0.1.6/mcsmapi/models/user.py +0 -110
  32. mcsmapi-0.1.6/mcsmapi.egg-info/requires.txt +0 -2
  33. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/LICENSE +0 -0
  34. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/apis/__init__.py +0 -0
  35. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/exceptions.py +0 -0
  36. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi/models/__init__.py +0 -0
  37. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi.egg-info/dependency_links.txt +0 -0
  38. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/mcsmapi.egg-info/top_level.txt +0 -0
  39. {mcsmapi-0.1.6 → mcsmapi-0.1.8b1}/setup.cfg +0 -0
@@ -1,15 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcsmapi
3
- Version: 0.1.6
3
+ Version: 0.1.8b1
4
4
  Summary: Shortcut the pypi package of MCSM./快捷操作MCSM的pypi包
5
5
  Author-email: molanp <molanpp@outlook.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Source, https://github.com/molanp/mcsmapi
8
8
  Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Requires-Python: >=3.10
9
11
  Description-Content-Type: text/markdown
10
12
  License-File: LICENSE
11
13
  Requires-Dist: requests
12
- Requires-Dist: pydantic
14
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
13
15
  Dynamic: license-file
14
16
 
15
17
  # MCSM API
@@ -82,9 +84,10 @@ mcsm.login_with_apikey("apikey")
82
84
 
83
85
  # Get dashboard data
84
86
  overview = mcsm.overview()
87
+ overview_data = overview.overview()
85
88
 
86
89
  # Get MCSM version
87
- mcsm_version = mcsm.overview().version
90
+ mcsm_version = overview_data.version
88
91
  ```
89
92
 
90
93
  ## Contributing
@@ -68,9 +68,10 @@ mcsm.login_with_apikey("apikey")
68
68
 
69
69
  # Get dashboard data
70
70
  overview = mcsm.overview()
71
+ overview_data = overview.overview()
71
72
 
72
73
  # Get MCSM version
73
- mcsm_version = mcsm.overview().version
74
+ mcsm_version = overview_data.version
74
75
  ```
75
76
 
76
77
  ## Contributing
@@ -1,5 +1,4 @@
1
1
  import urllib.parse
2
- from mcsmapi.models.overview import OverviewModel
3
2
  from mcsmapi.pool import ApiPool
4
3
  from mcsmapi.apis.file import File
5
4
  from mcsmapi.apis.user import User
@@ -11,12 +10,12 @@ from mcsmapi.request import Request
11
10
 
12
11
 
13
12
  class MCSMAPI:
13
+
14
14
  def __init__(self, url: str, timeout: int = 5) -> None:
15
15
  split_url = urllib.parse.urlsplit(url)
16
16
  Request.set_mcsm_url(
17
17
  urllib.parse.urljoin(f"{split_url.scheme}://{split_url.netloc}", "")
18
18
  )
19
- self.authentication = None
20
19
  Request.set_timeout(timeout)
21
20
 
22
21
  def login(self, username: str, password: str) -> "MCSMAPI":
@@ -35,8 +34,8 @@ class MCSMAPI:
35
34
  self.authentication = "apikey"
36
35
  return self
37
36
 
38
- def overview(self) -> OverviewModel:
39
- return Overview().init()
37
+ def overview(self) -> Overview:
38
+ return Overview()
40
39
 
41
40
  def instance(self) -> Instance:
42
41
  return Instance()
@@ -0,0 +1,92 @@
1
+ from typing import Any
2
+ from mcsmapi.pool import ApiPool
3
+ from mcsmapi.request import send
4
+ from mcsmapi.models.daemon import DaemonConfig, DaemonModel
5
+
6
+
7
+ class Daemon:
8
+ @staticmethod
9
+ def show() -> list[DaemonConfig]:
10
+ """
11
+ 获取全部节点配置信息
12
+
13
+ :returns: 节点的配置信息列表
14
+ """
15
+ daemons = send(
16
+ "GET",
17
+ f"{ApiPool.SERVICE}/remote_services_list",
18
+ )
19
+ return [DaemonConfig(**daemon) for daemon in daemons]
20
+
21
+ @staticmethod
22
+ def system() -> list[DaemonModel]:
23
+ """
24
+ 获取全部节点的系统信息
25
+
26
+ :returns: 节点系统信息列表
27
+ """
28
+ daemons = send(
29
+ "GET",
30
+ f"{ApiPool.SERVICE}/remote_services_system",
31
+ )
32
+ return [DaemonModel(**daemon) for daemon in daemons]
33
+
34
+ @staticmethod
35
+ def add(config: dict[str, Any]) -> str:
36
+ """
37
+ 新增一个节点
38
+
39
+ :params config: 节点的配置信息,以字典形式提供,缺失内容由DaemonConfig模型补全
40
+
41
+ :returns: 新增节点的UUID
42
+ """
43
+ return send(
44
+ "POST",
45
+ f"{ApiPool.SERVICE}/remote_service",
46
+ data=DaemonConfig(**config).model_dump(),
47
+ )
48
+
49
+ @staticmethod
50
+ def delete(daemonId: str) -> bool:
51
+ """
52
+ 删除一个节点
53
+
54
+ :params daemonId: 节点的UUID
55
+
56
+ :returns: 删除成功后返回True
57
+ """
58
+ return send(
59
+ "DELETE", f"{ApiPool.SERVICE}/remote_service", params={"uuid": daemonId}
60
+ )
61
+
62
+ @staticmethod
63
+ def link(daemonId: str) -> bool:
64
+ """
65
+ 连接一个节点
66
+
67
+ :params daemonId: 节点的UUID
68
+
69
+ :returns: 连接成功后返回True
70
+ """
71
+ return send(
72
+ "GET", f"{ApiPool.SERVICE}/link_remote_service", params={"uuid": daemonId}
73
+ )
74
+
75
+ @staticmethod
76
+ def update(daemonId: str, config: dict[str, Any]) -> bool:
77
+ """
78
+ 更新一个节点的配置
79
+
80
+ **不建议直接使用此函数,建议调用overview()后在remote属性内使用节点对象的updateConfig方法按需更新**
81
+
82
+ :params daemonId: 节点的UUID
83
+ :params config: 节点的配置信息,以字典形式提供,缺失内容由DaemonConfig模型补全
84
+
85
+ :returns: 更新成功后返回True
86
+ """
87
+ return send(
88
+ "PUT",
89
+ f"{ApiPool.SERVICE}/remote_service",
90
+ params={"uuid": daemonId},
91
+ data=DaemonConfig(**config).model_dump(),
92
+ )
@@ -0,0 +1,308 @@
1
+ from typing import Literal
2
+ from mcsmapi.pool import ApiPool
3
+ from mcsmapi.request import Request, send, upload
4
+ from mcsmapi.models.file import FileDownloadConfig, FileList
5
+ import urllib.parse
6
+ import os
7
+
8
+
9
+ class File:
10
+ @staticmethod
11
+ def show(
12
+ daemonId: str,
13
+ uuid: str,
14
+ target: str = "",
15
+ page: int = 0,
16
+ page_size: int = 100,
17
+ file_name: str = "",
18
+ ) -> FileList:
19
+ """
20
+ 获取文件列表
21
+
22
+ :params daemonId: 节点的UUID
23
+ :params uuid: 实例的UUID
24
+ :params target: 用于文件过滤的目标路径
25
+ :params page: 指定分页的页码
26
+ :params page_size: 指定每页的文件数量
27
+ :params file_name: 用于在文件列表中过滤出名称包含指定字符串的文件或文件夹
28
+
29
+ :returns: 包含文件列表信息和分页详情的FileList模型
30
+ """
31
+ result = send(
32
+ "GET",
33
+ f"{ApiPool.FILE}/list",
34
+ params={
35
+ "daemonId": daemonId,
36
+ "uuid": uuid,
37
+ "target": target,
38
+ "page": page,
39
+ "page_size": page_size,
40
+ "file_name": file_name,
41
+ },
42
+ )
43
+ return FileList(**result, daemonId=daemonId, uuid=uuid)
44
+
45
+ @staticmethod
46
+ def content(daemonId: str, uuid: str, target: str) -> str:
47
+ """
48
+ 获取文件内容
49
+
50
+ :params daemonId: 节点的UUID
51
+ :params uuid: 实例的UUID
52
+ :params target: 文件的目标路径
53
+
54
+ :returns: 文件的内容信息
55
+ """
56
+ return send(
57
+ "PUT",
58
+ f"{ApiPool.FILE}",
59
+ params={"daemonId": daemonId, "uuid": uuid},
60
+ data={"target": target},
61
+ )
62
+
63
+ @staticmethod
64
+ def update(daemonId: str, uuid: str, target: str, text: str) -> bool:
65
+ """
66
+ 更新文件内容
67
+
68
+ :params daemonId: 节点的UUID
69
+ :params uuid: 实例的UUID
70
+ :params target: 目标文件的路径
71
+ :params text: 新的文件内容
72
+
73
+ :returns: 更新成功后返回True
74
+ """
75
+ return send(
76
+ "PUT",
77
+ f"{ApiPool.FILE}",
78
+ params={"daemonId": daemonId, "uuid": uuid},
79
+ data={"target": target, "text": text},
80
+ )
81
+
82
+ @staticmethod
83
+ def download(daemonId: str, uuid: str, file_name: str) -> str:
84
+ """
85
+ 下载文件
86
+
87
+ :params daemonId: 节点的UUID
88
+ :params uuid: 实例的UUID
89
+ :params file_name: 要下载的文件的实例内完整路径, eg: /backup/world.zip
90
+
91
+ :returns: 文件下载URL
92
+ """
93
+
94
+ result = send(
95
+ "POST",
96
+ f"{ApiPool.FILE}/download",
97
+ params={"daemonId": daemonId, "uuid": uuid, "file_name": file_name},
98
+ )
99
+ result = FileDownloadConfig(**result)
100
+ protocol = Request.mcsm_url.split("://")[0]
101
+ base_url = urllib.parse.urljoin(f"{protocol}://{result.addr}", "download")
102
+ return urllib.parse.urljoin(base_url, f"{result.password}/{file_name}")
103
+
104
+ @staticmethod
105
+ async def upload(daemonId: str, uuid: str, file: bytes, upload_dir: str) -> bool:
106
+ """
107
+ 上传文件
108
+
109
+ :params daemonId: 节点的UUID
110
+ :params uuid: 实例的UUID
111
+ :params file: 要上传的文件内容
112
+ :params upload_dir: 文件上传到的目标路径
113
+
114
+ :returns: 上传成功后返回True
115
+ """
116
+ result = send(
117
+ "POST",
118
+ f"{ApiPool.FILE}/upload",
119
+ params={"daemonId": daemonId, "uuid": uuid, "upload_dir": upload_dir},
120
+ )
121
+ result = FileDownloadConfig(**result)
122
+ protocol = Request.mcsm_url.split("://")[0]
123
+ base_url = urllib.parse.urljoin(f"{protocol}://{result.addr}", "upload")
124
+ final_url = urllib.parse.urljoin(base_url, result.password)
125
+ await upload(final_url, file)
126
+ return True
127
+
128
+ @staticmethod
129
+ def copy(daemonId: str, uuid: str, copy_map: dict[str, str]) -> bool:
130
+ """
131
+ 复制多个文件夹或文件到指定位置
132
+
133
+ :params daemonId: 节点的UUID
134
+ :params uuid: 实例的UUID
135
+ :params copy_map: 复制映射,格式为 {源路径: 目标路径}
136
+
137
+ :returns: 复制成功后返回True
138
+ """
139
+ targets = [[source, target] for source, target in copy_map.items()]
140
+ return send(
141
+ "POST",
142
+ f"{ApiPool.FILE}/copy",
143
+ params={"daemonId": daemonId, "uuid": uuid},
144
+ data={"targets": targets},
145
+ )
146
+
147
+ @staticmethod
148
+ def copyOne(daemonId: str, uuid: str, source: str, target: str) -> bool:
149
+ """
150
+ 复制单个文件或文件夹到指定位置
151
+
152
+ :params daemonId: 节点的UUID
153
+ :params uuid: 实例的UUID
154
+ :params source: 源文件或文件夹的路径
155
+ :params target: 目标文件或文件夹的路径
156
+
157
+ :return: 移动成功后返回True
158
+ """
159
+ return File.copy(daemonId, uuid, {source: target})
160
+
161
+ @staticmethod
162
+ def move(daemonId: str, uuid: str, copy_map: dict[str, str]) -> bool:
163
+ """
164
+ 移动多个文件或文件夹到指定位置
165
+
166
+ :params daemonId: 节点的UUID
167
+ :params uuid: 实例的UUID
168
+ :params copy_map: 移动映射,格式为 {源路径: 目标路径}
169
+
170
+ :returns: 移动成功后返回True
171
+ """
172
+ targets = [[source, target] for source, target in copy_map.items()]
173
+ return send(
174
+ "PUT",
175
+ f"{ApiPool.FILE}/move",
176
+ params={"daemonId": daemonId, "uuid": uuid},
177
+ data={"targets": targets},
178
+ )
179
+
180
+ @staticmethod
181
+ def moveOne(daemonId: str, uuid: str, source: str, target: str) -> bool:
182
+ """
183
+ 从源路径移动单个文件或文件夹到目标路径
184
+
185
+ :params daemonId: 节点的UUID
186
+ :params uuid: 实例的UUID
187
+ :params source: 源文件或文件夹的路径
188
+ :params target: 目标文件或文件夹的路径
189
+
190
+ :returns: 移动成功后返回True
191
+ """
192
+ return File.move(daemonId, uuid, {source: target})
193
+
194
+ @staticmethod
195
+ def rename(daemonId: str, uuid: str, source: str, new_name: str) -> bool:
196
+ """
197
+ 重命名单个文件或文件夹
198
+
199
+ :params daemonId: 节点的UUID
200
+ :params uuid: 实例的UUID
201
+ :params source: 源文件或文件夹的路径
202
+ :params new_name: 源文件或文件夹的新名字
203
+
204
+ :returns: 重命名成功后返回True
205
+ """
206
+ directory = os.path.dirname(source)
207
+ target = os.path.join(directory, new_name)
208
+ return File.moveOne(daemonId, uuid, source, target)
209
+
210
+ @staticmethod
211
+ def zip(daemonId: str, uuid: str, source: str, targets: list[str]) -> bool:
212
+ """
213
+ 压缩多个文件或文件夹到指定位置
214
+
215
+ :params daemonId: 节点的UUID
216
+ :params uuid: 实例的UUID
217
+ :params source: 要压缩到的目标文件的路径
218
+ :params targets: 需要压缩的文件路径
219
+
220
+ **返回:**
221
+ - bool: 压缩成功后返回True
222
+ """
223
+ return send(
224
+ "POST",
225
+ f"{ApiPool.FILE}/compress",
226
+ params={"daemonId": daemonId, "uuid": uuid},
227
+ data={"type": 1, "code": "utf-8", "source": source, "targets": targets},
228
+ )
229
+
230
+ @staticmethod
231
+ def unzip(
232
+ daemonId: str,
233
+ uuid: str,
234
+ source: str,
235
+ targets: str,
236
+ code: Literal["utf-8", "gbk", "big5"] = "utf-8",
237
+ ) -> bool:
238
+ """
239
+ 解压缩指定的zip文件到目标位置
240
+
241
+ :params daemonId: 节点的UUID
242
+ :params uuid: 实例的UUID
243
+ :params source: 需要解压的zip文件路径
244
+ :params targets: 解压到的目标路径
245
+ :params code: 压缩文件的编码方式
246
+
247
+ :returns: 解压成功后返回True
248
+ """
249
+ return send(
250
+ "POST",
251
+ f"{ApiPool.FILE}/compress",
252
+ params={"daemonId": daemonId, "uuid": uuid},
253
+ data={"type": 2, "code": code, "source": source, "targets": targets},
254
+ )
255
+
256
+ @staticmethod
257
+ def delete(daemonId: str, uuid: str, targets: list[str]) -> bool:
258
+ """
259
+ 删除多个文件或文件夹
260
+
261
+ :params daemonId: 节点的UUID
262
+ :params uuid: 实例的UUID
263
+ :params targets: 要删除的文件或文件夹的路径
264
+
265
+ :returns: 删除成功后返回True
266
+ """
267
+ return send(
268
+ "DELETE",
269
+ ApiPool.FILE,
270
+ params={"daemonId": daemonId, "uuid": uuid},
271
+ data={"targets": targets},
272
+ )
273
+
274
+ @staticmethod
275
+ def createFile(daemonId: str, uuid: str, target: str) -> bool:
276
+ """
277
+ 创建文件
278
+
279
+ :params daemonId: 节点的UUID
280
+ :params uuid: 实例的UUID
281
+ :params target: 目标文件的路径,包含文件名
282
+
283
+ :returns: 创建成功后返回True
284
+ """
285
+ return send(
286
+ "POST",
287
+ f"{ApiPool.FILE}/touch",
288
+ params={"daemonId": daemonId, "uuid": uuid},
289
+ data={"target": target},
290
+ )
291
+
292
+ @staticmethod
293
+ def createFolder(daemonId: str, uuid: str, target: str) -> bool:
294
+ """
295
+ 创建文件夹
296
+
297
+ :params daemonId: 节点的UUID
298
+ :params uuid: 实例的UUID
299
+ :params target: 目标文件夹的路径
300
+
301
+ :returns: 创建成功后返回True
302
+ """
303
+ return send(
304
+ "POST",
305
+ f"{ApiPool.FILE}/mkdir",
306
+ params={"daemonId": daemonId, "uuid": uuid},
307
+ data={"target": target},
308
+ )
@@ -4,15 +4,14 @@ from mcsmapi.models.image import DockerImageItem, DockerContainerItem, DockerNet
4
4
 
5
5
 
6
6
  class Image:
7
- def images(self, daemonId: str) -> list[DockerImageItem]:
7
+ @staticmethod
8
+ def images(daemonId: str) -> list[DockerImageItem]:
8
9
  """
9
10
  获取镜像列表
10
11
 
11
- **参数:**
12
- - daemonId (str): 守护进程的唯一标识符。
12
+ :params daemonId: 节点的UUID
13
13
 
14
- **返回:**
15
- - list[ImageModel]: 包含镜像列表详情的 ImageModel 模型的列表。
14
+ :returns: 包含镜像列表详情的 ImageModel 模型的列表
16
15
  """
17
16
  result = send(
18
17
  "GET",
@@ -24,15 +23,14 @@ class Image:
24
23
 
25
24
  return [DockerImageItem(**item) for item in result]
26
25
 
27
- def containers(self, daemonId: str) -> list[DockerContainerItem]:
26
+ @staticmethod
27
+ def containers(daemonId: str) -> list[DockerContainerItem]:
28
28
  """
29
29
  获取容器列表
30
30
 
31
- **参数:**
32
- - daemonId (str): 守护进程的唯一标识符。
31
+ :params daemonId: 节点的UUID
33
32
 
34
- **返回:**
35
- - list[DockerContainerItem]: 包含容器列表详情的 DockerContainerItem 模型的列表。
33
+ :params: 包含容器列表详情的 DockerContainerItem 模型的列表
36
34
  """
37
35
  result = send(
38
36
  "GET",
@@ -44,15 +42,14 @@ class Image:
44
42
 
45
43
  return [DockerContainerItem(**item) for item in result]
46
44
 
47
- def network(self, daemonId: str) -> list[DockerNetworkItem]:
45
+ @staticmethod
46
+ def network(daemonId: str) -> list[DockerNetworkItem]:
48
47
  """
49
48
  获取网络接口列表
50
49
 
51
- **参数:**
52
- - daemonId (str): 守护进程的唯一标识符。
50
+ :params daemonId: 节点的UUID
53
51
 
54
- **返回:**
55
- - list[DockerNetworkItem]: 包含网络接口列表详情的 DockerNetworkItem 模型的列表。
52
+ :returns: 包含网络接口列表详情的 DockerNetworkItem 模型的列表
56
53
  """
57
54
  result = send(
58
55
  "GET",
@@ -63,18 +60,17 @@ class Image:
63
60
  )
64
61
  return [DockerNetworkItem(**item) for item in result]
65
62
 
66
- def add(self, daemonId: str, dockerFile: str, name: str, tag: str) -> bool:
63
+ @staticmethod
64
+ def add(daemonId: str, dockerFile: str, name: str, tag: str) -> bool:
67
65
  """
68
66
  新增一个镜像
69
67
 
70
- **参数:**
71
- - daemonId (str): 守护进程的唯一标识符。
72
- - dockerFile (str): DockerFile Config
73
- - name (str): 镜像名称。
74
- - tag (str): 镜像版本。
68
+ :params daemonId: 节点的UUID
69
+ :params dockerFile: DockerFile Config 内容
70
+ :params name: 镜像名称
71
+ :params tag: 镜像版本
75
72
 
76
- **返回:**
77
- - bool: 新增镜像成功后返回True。
73
+ :returns: 新增镜像成功后返回True
78
74
  """
79
75
  return send(
80
76
  "POST",
@@ -83,17 +79,20 @@ class Image:
83
79
  data={"dockerFile": dockerFile, "name": name, "tag": tag},
84
80
  )
85
81
 
86
- def progress(self, daemonId: str) -> dict[str, int]:
82
+ @staticmethod
83
+ def progress(daemonId: str) -> dict[str, int]:
87
84
  """
88
85
  获取镜像构建进度
89
86
 
90
- ## **由于文档此部分内容不详,未使用模型**
87
+ :params daemonId: 节点的UUID
91
88
 
92
- **参数:**
93
- - daemonId (str): 守护进程的唯一标识符。
89
+ :returns: {容器名称: 当前状态}
94
90
 
95
- **返回:**
96
- - dict[str, int]: 包含构建进度信息的字典。
91
+ 状态码对照:
92
+ ```
93
+ -1: 镜像构建失败
94
+ 1: 镜像构建中
95
+ 2: 镜像构建完成
97
96
  """
98
97
  return send(
99
98
  "GET",