mcsmapi 0.1.6__py3-none-any.whl → 0.1.7__py3-none-any.whl
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/__init__.py +3 -4
- mcsmapi/apis/daemon.py +15 -13
- mcsmapi/apis/file.py +36 -24
- mcsmapi/apis/image.py +10 -5
- mcsmapi/apis/instance.py +27 -17
- mcsmapi/apis/overview.py +12 -8
- mcsmapi/apis/user.py +9 -5
- mcsmapi/models/common.py +30 -0
- mcsmapi/models/daemon.py +42 -70
- mcsmapi/models/file.py +41 -35
- mcsmapi/models/image.py +82 -80
- mcsmapi/models/instance.py +98 -82
- mcsmapi/models/overview.py +107 -49
- mcsmapi/models/user.py +41 -34
- mcsmapi/pool.py +1 -0
- mcsmapi/request.py +20 -14
- {mcsmapi-0.1.6.dist-info → mcsmapi-0.1.7.dist-info}/METADATA +4 -2
- mcsmapi-0.1.7.dist-info/RECORD +24 -0
- mcsmapi-0.1.6.dist-info/RECORD +0 -23
- {mcsmapi-0.1.6.dist-info → mcsmapi-0.1.7.dist-info}/WHEEL +0 -0
- {mcsmapi-0.1.6.dist-info → mcsmapi-0.1.7.dist-info}/licenses/LICENSE +0 -0
- {mcsmapi-0.1.6.dist-info → mcsmapi-0.1.7.dist-info}/top_level.txt +0 -0
mcsmapi/__init__.py
CHANGED
@@ -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) ->
|
39
|
-
return Overview()
|
37
|
+
def overview(self) -> Overview:
|
38
|
+
return Overview()
|
40
39
|
|
41
40
|
def instance(self) -> Instance:
|
42
41
|
return Instance()
|
mcsmapi/apis/daemon.py
CHANGED
@@ -2,11 +2,11 @@ from typing import Any
|
|
2
2
|
from mcsmapi.pool import ApiPool
|
3
3
|
from mcsmapi.request import send
|
4
4
|
from mcsmapi.models.daemon import DaemonConfig, DaemonModel
|
5
|
-
from mcsmapi.models.daemon.instance import InstanceDetail
|
6
5
|
|
7
6
|
|
8
7
|
class Daemon:
|
9
|
-
|
8
|
+
@staticmethod
|
9
|
+
def show() -> list[DaemonConfig]:
|
10
10
|
"""
|
11
11
|
获取全部节点配置信息
|
12
12
|
|
@@ -18,11 +18,12 @@ class Daemon:
|
|
18
18
|
f"{ApiPool.SERVICE}/remote_services_list",
|
19
19
|
)
|
20
20
|
return [DaemonConfig(**daemon) for daemon in daemons]
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
@staticmethod
|
23
|
+
def system() -> list[DaemonModel]:
|
23
24
|
"""
|
24
25
|
获取全部节点的系统信息
|
25
|
-
|
26
|
+
|
26
27
|
返回:
|
27
28
|
- List[DaemonModel]: 节点系统信息列表
|
28
29
|
"""
|
@@ -32,7 +33,8 @@ class Daemon:
|
|
32
33
|
)
|
33
34
|
return [DaemonModel(**daemon) for daemon in daemons]
|
34
35
|
|
35
|
-
|
36
|
+
@staticmethod
|
37
|
+
def add(config: dict[str, Any]) -> str:
|
36
38
|
"""
|
37
39
|
新增一个节点。
|
38
40
|
|
@@ -47,8 +49,8 @@ class Daemon:
|
|
47
49
|
f"{ApiPool.SERVICE}/remote_service",
|
48
50
|
data=DaemonConfig(**config).dict(),
|
49
51
|
)
|
50
|
-
|
51
|
-
def delete(
|
52
|
+
@staticmethod
|
53
|
+
def delete(daemonId: str) -> bool:
|
52
54
|
"""
|
53
55
|
删除一个节点。
|
54
56
|
|
@@ -61,8 +63,8 @@ class Daemon:
|
|
61
63
|
return send(
|
62
64
|
"DELETE", f"{ApiPool.SERVICE}/remote_service", params={"uuid": daemonId}
|
63
65
|
)
|
64
|
-
|
65
|
-
def link(
|
66
|
+
@staticmethod
|
67
|
+
def link(daemonId: str) -> bool:
|
66
68
|
"""
|
67
69
|
连接一个节点。
|
68
70
|
|
@@ -75,11 +77,11 @@ class Daemon:
|
|
75
77
|
return send(
|
76
78
|
"GET", f"{ApiPool.SERVICE}/link_remote_service", params={"uuid": daemonId}
|
77
79
|
)
|
78
|
-
|
79
|
-
def update(
|
80
|
+
@staticmethod
|
81
|
+
def update(daemonId: str, config: dict[str, Any]) -> bool:
|
80
82
|
"""
|
81
83
|
更新一个节点的配置。
|
82
|
-
|
84
|
+
|
83
85
|
**不建议直接使用此函数,建议调用overview()后在remote属性内使用updateConfig方法按需更新**
|
84
86
|
|
85
87
|
参数:
|
mcsmapi/apis/file.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
from mcsmapi.pool import ApiPool
|
2
2
|
from mcsmapi.request import Request, send, upload
|
3
|
-
from mcsmapi.models.file import
|
3
|
+
from mcsmapi.models.file import FileDownloadConfig, FileList
|
4
4
|
import urllib.parse
|
5
5
|
import os
|
6
6
|
|
7
7
|
|
8
8
|
class File:
|
9
|
+
@staticmethod
|
9
10
|
def show(
|
10
|
-
self,
|
11
11
|
daemonId: str,
|
12
12
|
uuid: str,
|
13
13
|
target: str = "",
|
14
14
|
page: int = 0,
|
15
15
|
page_size: int = 100,
|
16
|
-
file_name: str = ""
|
16
|
+
file_name: str = "",
|
17
17
|
) -> FileList:
|
18
18
|
"""
|
19
19
|
获取文件列表
|
@@ -43,7 +43,8 @@ class File:
|
|
43
43
|
)
|
44
44
|
return FileList(**result, daemonId=daemonId, uuid=uuid)
|
45
45
|
|
46
|
-
|
46
|
+
@staticmethod
|
47
|
+
def content(daemonId: str, uuid: str, target: str) -> str | bytes:
|
47
48
|
"""
|
48
49
|
获取文件内容
|
49
50
|
|
@@ -62,7 +63,8 @@ class File:
|
|
62
63
|
data={"target": target},
|
63
64
|
)
|
64
65
|
|
65
|
-
|
66
|
+
@staticmethod
|
67
|
+
def update(daemonId: str, uuid: str, target: str, text: str) -> bool:
|
66
68
|
"""
|
67
69
|
更新文件内容
|
68
70
|
|
@@ -82,7 +84,8 @@ class File:
|
|
82
84
|
data={"target": target, "text": text},
|
83
85
|
)
|
84
86
|
|
85
|
-
|
87
|
+
@staticmethod
|
88
|
+
def download(daemonId: str, uuid: str, file_name: str) -> str:
|
86
89
|
"""
|
87
90
|
下载文件
|
88
91
|
|
@@ -100,14 +103,13 @@ class File:
|
|
100
103
|
f"{ApiPool.FILE}/download",
|
101
104
|
params={"daemonId": daemonId, "uuid": uuid, "file_name": file_name},
|
102
105
|
)
|
103
|
-
result =
|
106
|
+
result = FileDownloadConfig(**result)
|
104
107
|
protocol = Request.mcsm_url.split("://")[0]
|
105
108
|
base_url = urllib.parse.urljoin(f"{protocol}://{result.addr}", "download")
|
106
109
|
return urllib.parse.urljoin(base_url, f"{result.password}/{file_name}")
|
107
110
|
|
108
|
-
|
109
|
-
|
110
|
-
) -> bool:
|
111
|
+
@staticmethod
|
112
|
+
async def upload(daemonId: str, uuid: str, file: bytes, upload_dir: str) -> bool:
|
111
113
|
"""
|
112
114
|
上传文件
|
113
115
|
|
@@ -125,14 +127,15 @@ class File:
|
|
125
127
|
f"{ApiPool.FILE}/upload",
|
126
128
|
params={"daemonId": daemonId, "uuid": uuid, "upload_dir": upload_dir},
|
127
129
|
)
|
128
|
-
result =
|
130
|
+
result = FileDownloadConfig(**result)
|
129
131
|
protocol = Request.mcsm_url.split("://")[0]
|
130
132
|
base_url = urllib.parse.urljoin(f"{protocol}://{result.addr}", "upload")
|
131
133
|
final_url = urllib.parse.urljoin(base_url, result.password)
|
132
134
|
await upload(final_url, file)
|
133
135
|
return True
|
134
136
|
|
135
|
-
|
137
|
+
@staticmethod
|
138
|
+
def copy(daemonId: str, uuid: str, copy_map: dict[str, str]) -> bool:
|
136
139
|
"""
|
137
140
|
复制多个文件夹或文件到指定位置。
|
138
141
|
|
@@ -152,7 +155,8 @@ class File:
|
|
152
155
|
data={"targets": targets},
|
153
156
|
)
|
154
157
|
|
155
|
-
|
158
|
+
@staticmethod
|
159
|
+
def copyOne(daemonId: str, uuid: str, source: str, target: str) -> bool:
|
156
160
|
"""
|
157
161
|
复制单个文件或文件夹到指定位置。
|
158
162
|
|
@@ -165,9 +169,10 @@ class File:
|
|
165
169
|
**返回:**
|
166
170
|
- bool: 移动成功后返回True。
|
167
171
|
"""
|
168
|
-
return
|
172
|
+
return File.copy(daemonId, uuid, {source: target})
|
169
173
|
|
170
|
-
|
174
|
+
@staticmethod
|
175
|
+
def move(daemonId: str, uuid: str, copy_map: dict[str, str]) -> bool:
|
171
176
|
"""
|
172
177
|
移动多个文件或文件夹到指定位置。
|
173
178
|
|
@@ -187,7 +192,8 @@ class File:
|
|
187
192
|
data={"targets": targets},
|
188
193
|
)
|
189
194
|
|
190
|
-
|
195
|
+
@staticmethod
|
196
|
+
def moveOne(daemonId: str, uuid: str, source: str, target: str) -> bool:
|
191
197
|
"""
|
192
198
|
从源路径移动单个文件或文件夹到目标路径。
|
193
199
|
|
@@ -200,9 +206,10 @@ class File:
|
|
200
206
|
返回:
|
201
207
|
- bool: 移动成功后返回True。
|
202
208
|
"""
|
203
|
-
return
|
209
|
+
return File.move(daemonId, uuid, {source: target})
|
204
210
|
|
205
|
-
|
211
|
+
@staticmethod
|
212
|
+
def rename(daemonId: str, uuid: str, source: str, new_name: str) -> bool:
|
206
213
|
"""
|
207
214
|
重命名单个文件或文件夹。
|
208
215
|
|
@@ -217,9 +224,10 @@ class File:
|
|
217
224
|
"""
|
218
225
|
directory = os.path.dirname(source)
|
219
226
|
target = os.path.join(directory, new_name)
|
220
|
-
return
|
227
|
+
return File.moveOne(daemonId, uuid, source, target)
|
221
228
|
|
222
|
-
|
229
|
+
@staticmethod
|
230
|
+
def zip(daemonId: str, uuid: str, source: str, targets: list[str]) -> bool:
|
223
231
|
"""
|
224
232
|
压缩多个文件或文件夹到指定位置。
|
225
233
|
|
@@ -239,8 +247,9 @@ class File:
|
|
239
247
|
data={"type": 1, "code": "utf-8", "source": source, "targets": targets},
|
240
248
|
)
|
241
249
|
|
250
|
+
@staticmethod
|
242
251
|
def unzip(
|
243
|
-
|
252
|
+
daemonId: str, uuid: str, source: str, target: str, code: str = "utf-8"
|
244
253
|
) -> bool:
|
245
254
|
"""
|
246
255
|
解压缩指定的zip文件到目标位置。
|
@@ -263,7 +272,8 @@ class File:
|
|
263
272
|
data={"type": 2, "code": code, "source": source, "targets": target},
|
264
273
|
)
|
265
274
|
|
266
|
-
|
275
|
+
@staticmethod
|
276
|
+
def delete(daemonId: str, uuid: str, targets: list[str]) -> bool:
|
267
277
|
"""
|
268
278
|
删除多个文件或文件夹。
|
269
279
|
|
@@ -282,7 +292,8 @@ class File:
|
|
282
292
|
data={"targets": targets},
|
283
293
|
)
|
284
294
|
|
285
|
-
|
295
|
+
@staticmethod
|
296
|
+
def createFile(daemonId: str, uuid: str, target: str) -> bool:
|
286
297
|
"""
|
287
298
|
创建文件。
|
288
299
|
|
@@ -301,7 +312,8 @@ class File:
|
|
301
312
|
data={"target": target},
|
302
313
|
)
|
303
314
|
|
304
|
-
|
315
|
+
@staticmethod
|
316
|
+
def createFolder(daemonId: str, uuid: str, target: str) -> bool:
|
305
317
|
"""
|
306
318
|
创建文件夹
|
307
319
|
|
mcsmapi/apis/image.py
CHANGED
@@ -4,7 +4,8 @@ from mcsmapi.models.image import DockerImageItem, DockerContainerItem, DockerNet
|
|
4
4
|
|
5
5
|
|
6
6
|
class Image:
|
7
|
-
|
7
|
+
@staticmethod
|
8
|
+
def images(daemonId: str) -> list[DockerImageItem]:
|
8
9
|
"""
|
9
10
|
获取镜像列表
|
10
11
|
|
@@ -24,7 +25,8 @@ class Image:
|
|
24
25
|
|
25
26
|
return [DockerImageItem(**item) for item in result]
|
26
27
|
|
27
|
-
|
28
|
+
@staticmethod
|
29
|
+
def containers(daemonId: str) -> list[DockerContainerItem]:
|
28
30
|
"""
|
29
31
|
获取容器列表
|
30
32
|
|
@@ -44,7 +46,8 @@ class Image:
|
|
44
46
|
|
45
47
|
return [DockerContainerItem(**item) for item in result]
|
46
48
|
|
47
|
-
|
49
|
+
@staticmethod
|
50
|
+
def network(daemonId: str) -> list[DockerNetworkItem]:
|
48
51
|
"""
|
49
52
|
获取网络接口列表
|
50
53
|
|
@@ -63,7 +66,8 @@ class Image:
|
|
63
66
|
)
|
64
67
|
return [DockerNetworkItem(**item) for item in result]
|
65
68
|
|
66
|
-
|
69
|
+
@staticmethod
|
70
|
+
def add(daemonId: str, dockerFile: str, name: str, tag: str) -> bool:
|
67
71
|
"""
|
68
72
|
新增一个镜像
|
69
73
|
|
@@ -83,7 +87,8 @@ class Image:
|
|
83
87
|
data={"dockerFile": dockerFile, "name": name, "tag": tag},
|
84
88
|
)
|
85
89
|
|
86
|
-
|
90
|
+
@staticmethod
|
91
|
+
def progress(daemonId: str) -> dict[str, int]:
|
87
92
|
"""
|
88
93
|
获取镜像构建进度
|
89
94
|
|
mcsmapi/apis/instance.py
CHANGED
@@ -10,8 +10,8 @@ from mcsmapi.models.instance import (
|
|
10
10
|
|
11
11
|
|
12
12
|
class Instance:
|
13
|
+
@staticmethod
|
13
14
|
def search(
|
14
|
-
self,
|
15
15
|
daemonId: str,
|
16
16
|
page: int = 1,
|
17
17
|
page_size: int = 20,
|
@@ -49,7 +49,8 @@ class Instance:
|
|
49
49
|
)
|
50
50
|
return InstanceSearchList(**result, daemonId=daemonId)
|
51
51
|
|
52
|
-
|
52
|
+
@staticmethod
|
53
|
+
def detail(daemonId: str, uuid: str) -> InstanceDetail:
|
53
54
|
"""
|
54
55
|
获取指定实例的详细信息
|
55
56
|
|
@@ -67,7 +68,8 @@ class Instance:
|
|
67
68
|
)
|
68
69
|
return InstanceDetail(**result)
|
69
70
|
|
70
|
-
|
71
|
+
@staticmethod
|
72
|
+
def create(daemonId: str, config: dict[str, Any]) -> InstanceCreateResult:
|
71
73
|
"""
|
72
74
|
创建一个实例。
|
73
75
|
|
@@ -86,10 +88,11 @@ class Instance:
|
|
86
88
|
)
|
87
89
|
return InstanceCreateResult(**result)
|
88
90
|
|
89
|
-
|
91
|
+
@staticmethod
|
92
|
+
def updateConfig(daemonId: str, uuid: str, config: dict) -> str | bool:
|
90
93
|
"""
|
91
94
|
更新实例配置。
|
92
|
-
|
95
|
+
|
93
96
|
**不建议直接使用此函数,建议调用search后在data属性内使用updateConfig方法按需更新**
|
94
97
|
|
95
98
|
**参数:**
|
@@ -108,9 +111,8 @@ class Instance:
|
|
108
111
|
)
|
109
112
|
return result.get("uuid", True)
|
110
113
|
|
111
|
-
|
112
|
-
|
113
|
-
) -> list[str]:
|
114
|
+
@staticmethod
|
115
|
+
def delete(daemonId: str, uuids: list[str], deleteFile: bool = False) -> list[str]:
|
114
116
|
"""
|
115
117
|
删除实例。
|
116
118
|
|
@@ -129,7 +131,8 @@ class Instance:
|
|
129
131
|
data={"uuids": uuids, "deleteFile": deleteFile},
|
130
132
|
)
|
131
133
|
|
132
|
-
|
134
|
+
@staticmethod
|
135
|
+
def start(daemonId: str, uuid: str) -> str | bool:
|
133
136
|
"""
|
134
137
|
启动实例。
|
135
138
|
|
@@ -147,7 +150,8 @@ class Instance:
|
|
147
150
|
)
|
148
151
|
return result.get("instanceUuid", True)
|
149
152
|
|
150
|
-
|
153
|
+
@staticmethod
|
154
|
+
def stop(daemonId: str, uuid: str) -> str | bool:
|
151
155
|
"""
|
152
156
|
关闭实例。
|
153
157
|
|
@@ -165,7 +169,8 @@ class Instance:
|
|
165
169
|
)
|
166
170
|
return result.get("instanceUuid", True)
|
167
171
|
|
168
|
-
|
172
|
+
@staticmethod
|
173
|
+
def restart(daemonId: str, uuid: str) -> str | bool:
|
169
174
|
"""
|
170
175
|
重启实例。
|
171
176
|
|
@@ -183,7 +188,8 @@ class Instance:
|
|
183
188
|
)
|
184
189
|
return result.get("instanceUuid", True)
|
185
190
|
|
186
|
-
|
191
|
+
@staticmethod
|
192
|
+
def kill(daemonId: str, uuid: str) -> str | bool:
|
187
193
|
"""
|
188
194
|
强制关闭实例。
|
189
195
|
|
@@ -201,7 +207,8 @@ class Instance:
|
|
201
207
|
)
|
202
208
|
return result.get("instanceUuid", True)
|
203
209
|
|
204
|
-
|
210
|
+
@staticmethod
|
211
|
+
def batchOperation(instances: list[dict[str, str]], operation: str) -> bool:
|
205
212
|
"""
|
206
213
|
对多个实例进行批量操作。
|
207
214
|
|
@@ -217,7 +224,8 @@ class Instance:
|
|
217
224
|
else:
|
218
225
|
raise ValueError("operation must be one of start, stop, restart, kill")
|
219
226
|
|
220
|
-
|
227
|
+
@staticmethod
|
228
|
+
def update(daemonId: str, uuid: str) -> bool:
|
221
229
|
"""
|
222
230
|
升级实例。
|
223
231
|
|
@@ -234,7 +242,8 @@ class Instance:
|
|
234
242
|
params={"daemonId": daemonId, "uuid": uuid, "task_name": "update"},
|
235
243
|
)
|
236
244
|
|
237
|
-
|
245
|
+
@staticmethod
|
246
|
+
def command(daemonId: str, uuid: str, command: str) -> str:
|
238
247
|
"""
|
239
248
|
向实例发送命令。
|
240
249
|
|
@@ -253,7 +262,8 @@ class Instance:
|
|
253
262
|
)
|
254
263
|
return result.get("instanceUuid", True)
|
255
264
|
|
256
|
-
|
265
|
+
@staticmethod
|
266
|
+
def get_output(daemonId: str, uuid: str, size: int | str = "") -> str:
|
257
267
|
"""
|
258
268
|
获取实例输出。
|
259
269
|
|
@@ -271,8 +281,8 @@ class Instance:
|
|
271
281
|
params={"daemonId": daemonId, "uuid": uuid, "size": size},
|
272
282
|
)
|
273
283
|
|
284
|
+
@staticmethod
|
274
285
|
def reinstall(
|
275
|
-
self,
|
276
286
|
daemonId: str,
|
277
287
|
uuid: str,
|
278
288
|
targetUrl: str,
|
mcsmapi/apis/overview.py
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
from mcsmapi.pool import ApiPool
|
2
2
|
from mcsmapi.request import send
|
3
|
-
from mcsmapi.models.overview import OverviewModel
|
3
|
+
from mcsmapi.models.overview import OverviewModel, LogDetail
|
4
4
|
|
5
5
|
|
6
6
|
class Overview:
|
7
|
-
|
7
|
+
@staticmethod
|
8
|
+
def overview():
|
8
9
|
"""
|
9
|
-
|
10
|
-
|
11
|
-
本方法通过发送GET请求获取API概览信息,确保返回的数据类型为字典,
|
12
|
-
然后使用这些数据来构建一个OverviewModel实例。
|
13
|
-
|
14
|
-
:return: 返回一个OverviewModel实例,该实例使用获取的API概览信息进行初始化。
|
10
|
+
获取面板基本信息
|
15
11
|
"""
|
16
12
|
result = send("GET", ApiPool.OVERVIEW)
|
17
13
|
return OverviewModel(**result)
|
14
|
+
|
15
|
+
@staticmethod
|
16
|
+
def logs():
|
17
|
+
"""
|
18
|
+
获取面板操作日志
|
19
|
+
"""
|
20
|
+
result = send("GET", ApiPool.LOG)
|
21
|
+
return [LogDetail(**item) for item in result]
|
mcsmapi/apis/user.py
CHANGED
@@ -5,8 +5,9 @@ from mcsmapi.models.user import SearchUserModel, UserConfig
|
|
5
5
|
|
6
6
|
|
7
7
|
class User:
|
8
|
+
@staticmethod
|
8
9
|
def search(
|
9
|
-
|
10
|
+
username: str = "", page: int = 1, page_size: int = 20, role: str = ""
|
10
11
|
) -> SearchUserModel:
|
11
12
|
"""根据用户名和角色搜索用户信息
|
12
13
|
|
@@ -32,7 +33,8 @@ class User:
|
|
32
33
|
)
|
33
34
|
return SearchUserModel(**result)
|
34
35
|
|
35
|
-
|
36
|
+
@staticmethod
|
37
|
+
def create(username: str, password: str, permission: int = 1) -> str | bool:
|
36
38
|
"""
|
37
39
|
创建新用户的方法
|
38
40
|
|
@@ -50,7 +52,8 @@ class User:
|
|
50
52
|
data={"username": username, "password": password, "permission": permission},
|
51
53
|
).get("uuid", True)
|
52
54
|
|
53
|
-
|
55
|
+
@staticmethod
|
56
|
+
def update(uuid: str, config: dict[str, Any]) -> bool:
|
54
57
|
"""
|
55
58
|
更新用户信息的方法
|
56
59
|
|
@@ -66,10 +69,11 @@ class User:
|
|
66
69
|
return send(
|
67
70
|
"PUT",
|
68
71
|
ApiPool.AUTH,
|
69
|
-
data={"uuid": uuid, "config": UserConfig(**config).
|
72
|
+
data={"uuid": uuid, "config": UserConfig(**config).model_dump()},
|
70
73
|
)
|
71
74
|
|
72
|
-
|
75
|
+
@staticmethod
|
76
|
+
def delete(uuids: list[str]) -> bool:
|
73
77
|
"""
|
74
78
|
删除用户的方法
|
75
79
|
|
mcsmapi/models/common.py
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
|
3
|
+
|
4
|
+
class CpuMemChart(BaseModel):
|
5
|
+
"""节点资源使用率信息"""
|
6
|
+
|
7
|
+
cpu: float
|
8
|
+
"""cpu使用率"""
|
9
|
+
mem: float
|
10
|
+
"""内存使用率"""
|
11
|
+
|
12
|
+
|
13
|
+
class ProcessInfo(BaseModel):
|
14
|
+
"""节点进程详细信息"""
|
15
|
+
|
16
|
+
cpu: int
|
17
|
+
"""远程节点使用的cpu资源(单位: byte)"""
|
18
|
+
memory: int
|
19
|
+
"""远程节点使用的内存资源(单位: byte)"""
|
20
|
+
cwd: str
|
21
|
+
"""远程节点的工作路径"""
|
22
|
+
|
23
|
+
|
24
|
+
class InstanceInfo(BaseModel):
|
25
|
+
"""实例统计信息"""
|
26
|
+
|
27
|
+
running: int
|
28
|
+
"""运行中实例数量"""
|
29
|
+
total: int
|
30
|
+
"""全部实例数量"""
|