mcsmapi 0.1.2__py3-none-any.whl → 0.1.4__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/models/user.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import Any, List
2
2
  from pydantic import BaseModel
3
- from ..models.instance import InstanceDetail, UserInstancesList
3
+ from mcsmapi.models.instance import InstanceDetail, UserInstancesList
4
4
 
5
5
 
6
6
  class UserModel(BaseModel):
@@ -23,9 +23,9 @@ class UserModel(BaseModel):
23
23
  删除该用户。
24
24
 
25
25
  **返回:**
26
- - bool: 删除成功后返回True。
26
+ <br> - bool: 删除成功后返回True。
27
27
  """
28
- from ..apis.user import User
28
+ from mcsmapi.apis.user import User
29
29
 
30
30
  return User().delete([self.uuid])
31
31
 
@@ -34,12 +34,12 @@ class UserModel(BaseModel):
34
34
  更新该用户的信息。
35
35
 
36
36
  参数:
37
- - config (dict[str, Any]): 用户的新信息,以字典形式提供,缺失内容使用原用户信息填充。
37
+ <br> - config (dict[str, Any]): 用户的新信息,以字典形式提供,缺失内容使用原用户信息填充。
38
38
 
39
39
  返回:
40
- - bool: 更新成功后返回True。
40
+ <br> - bool: 更新成功后返回True。
41
41
  """
42
- from ..apis.user import User
42
+ from mcsmapi.apis.user import User
43
43
 
44
44
  updated_config = self.dict()
45
45
  updated_config.update(config)
mcsmapi/request.py CHANGED
@@ -11,32 +11,34 @@ class Request:
11
11
  apikey = None
12
12
  token = None
13
13
 
14
- @staticmethod
15
- def set_mcsm_url(url):
14
+ @classmethod
15
+ def set_mcsm_url(cls, url):
16
16
  """设置类级别的 mcsm_url"""
17
- Request.mcsm_url = url
17
+ cls.mcsm_url = url
18
18
 
19
- @staticmethod
20
- def set_timeout(timeout):
19
+ @classmethod
20
+ def set_timeout(cls, timeout):
21
21
  """设置类级别的 timeout"""
22
- Request.timeout = timeout
22
+ cls.timeout = timeout
23
23
 
24
- @staticmethod
25
- def set_apikey(apikey):
24
+ @classmethod
25
+ def set_apikey(cls, apikey):
26
26
  """设置类级别的 apikey"""
27
- Request.apikey = apikey
27
+ cls.apikey = apikey
28
28
 
29
- @staticmethod
30
- def set_token(token):
29
+ @classmethod
30
+ def set_token(cls, token):
31
31
  """设置类级别的 token"""
32
- Request.token = token
32
+ cls.token = token
33
33
 
34
- def __init__(self, mcsm_url=None, timeout=None):
34
+ @classmethod
35
+ def __init__(cls, mcsm_url=None, timeout=None):
35
36
  """初始化时使用类变量,或者使用传入的参数覆盖默认值"""
36
- self.mcsm_url = mcsm_url or Request.mcsm_url
37
- self.timeout = timeout or Request.timeout
37
+ cls.mcsm_url = mcsm_url or cls.mcsm_url
38
+ cls.timeout = timeout or cls.timeout
38
39
 
39
- def send(self, method: str, endpoint: Any, params=None, data=None) -> Any:
40
+ @classmethod
41
+ def send(cls, method: str, endpoint: Any, params=None, data=None) -> Any:
40
42
  """发送 HTTP 请求"""
41
43
  if params is None:
42
44
  params = {}
@@ -45,20 +47,20 @@ class Request:
45
47
  if not isinstance(endpoint, str):
46
48
  endpoint = str(endpoint)
47
49
 
48
- url = urllib.parse.urljoin(self.mcsm_url, endpoint)
49
- if Request.apikey is not None:
50
- params["apikey"] = Request.apikey
51
- data["apikey"] = Request.apikey
52
- if Request.token is not None:
53
- params["token"] = Request.token
54
- data["token"] = Request.token
50
+ url = urllib.parse.urljoin(cls.mcsm_url, endpoint)
51
+ if cls.apikey is not None:
52
+ params["apikey"] = cls.apikey
53
+ data["apikey"] = cls.apikey
54
+ if cls.token is not None:
55
+ params["token"] = cls.token
56
+ data["token"] = cls.token
55
57
 
56
- response = Request.session.request(
58
+ response = cls.session.request(
57
59
  method.upper(),
58
60
  url,
59
61
  params=params,
60
62
  data=data,
61
- timeout=self.timeout,
63
+ timeout=cls.timeout,
62
64
  )
63
65
  try:
64
66
  response.raise_for_status()
@@ -68,15 +70,16 @@ class Request:
68
70
  response.status_code, response.json().get("data", response.text)
69
71
  ) from e
70
72
 
71
- async def upload(self, url: str, file: bytes) -> bool:
73
+ @classmethod
74
+ async def upload(cls, url: str, file: bytes) -> bool:
72
75
  """上传文件"""
73
76
 
74
- response = Request.session.request(
77
+ response = cls.session.request(
75
78
  "POST",
76
79
  url,
77
80
  headers={"Content-Type": "multipart/form-data"},
78
81
  files={"file": file},
79
- timeout=self.timeout,
82
+ timeout=cls.timeout,
80
83
  )
81
84
  try:
82
85
  response.raise_for_status()
@@ -1,15 +1,16 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: mcsmapi
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Shortcut the pypi package of MCSM./快捷操作MCSM的pypi包
5
5
  Author-email: molanp <molanpp@outlook.com>
6
+ License-Expression: MIT
6
7
  Project-URL: Source, https://github.com/molanp/mcsmapi
7
8
  Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  Requires-Dist: requests
12
12
  Requires-Dist: pydantic
13
+ Dynamic: license-file
13
14
 
14
15
  # MCSM API
15
16
 
@@ -22,6 +23,10 @@ English|[Chinese Simplified](README_zh-cn.md)
22
23
  > [!important]
23
24
  > We need your help, the documentation for this project has not been written yet, if you are willing, please submit pr to help us write the documentation.
24
25
 
26
+ ## Documentation
27
+
28
+ The documentation is not yet complete, if you need it, please visit [https://deepwiki.com/molanp/mcsmapi](https://deepwiki.com/molanp/mcsmapi)
29
+
25
30
  ## Introduction
26
31
 
27
32
  `mcsmapi` is a PyPI package based on [MCSManager](https://github.com/MCSManager/MCSManager), designed to simplify interactions with the MCSM API.
@@ -38,8 +43,8 @@ pip install mcsmapi
38
43
 
39
44
  ## Supported Features
40
45
 
41
- - [x] Dashboard data ([Overview](doc/en/Overview.md))
42
- - [x] User management ([User](doc/en/User.md))
46
+ - [x] Dashboard data (`Overview`)
47
+ - [x] User management (`User`)
43
48
  - [x] Instance management (`Instance`)
44
49
  - [x] Daemon management (`Daemon`)
45
50
  - [x] File management (`File`)
@@ -57,7 +62,7 @@ pip install mcsmapi
57
62
  from mcsmapi import MCSMAPI
58
63
 
59
64
  # Initialize
60
- mcsm = MCSMAPI("https://example.com")
65
+ mcsm = MCSMAPI("https://example.com") # https or http required
61
66
 
62
67
  # Log in with username and password (API permissions depend on the account permissions)
63
68
  mcsm.login("username", "password")
@@ -0,0 +1,23 @@
1
+ mcsmapi/__init__.py,sha256=Xm0gsQMecMZwD1of9UGOkTan25l_jqrWkG-7mg0YgF4,1514
2
+ mcsmapi/exceptions.py,sha256=mHsAHyoX9SiFDGBMEhesA_ao9hhZZ38EGTp97K7VDp8,184
3
+ mcsmapi/pool.py,sha256=CoOYbyECp4FoXkzwFN7WgtS3vgZtvWO8e93i18vhOEI,308
4
+ mcsmapi/request.py,sha256=5mCzKgrh4OPFKvBo22kIDpX_D1zqCza1nglYUeGWveg,2618
5
+ mcsmapi/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ mcsmapi/apis/daemon.py,sha256=DT8u3nhelbd8EU24gRsuAW43QAXmGKTmuYs7fT3Fx2c,2014
7
+ mcsmapi/apis/file.py,sha256=9oAKJsFo3iBYVI5hCd0BUv5Px0GXgHeQqIy2K3q3CNc,10890
8
+ mcsmapi/apis/image.py,sha256=y9BoATZnDj2NbVWYpEAIDcO-pBXAtpQlcLgJUHoXkDk,2960
9
+ mcsmapi/apis/instance.py,sha256=gToVq_2nJrlEB9LKKYdpaUsH-rcxLo_0B3W-2kpXsaM,11198
10
+ mcsmapi/apis/overview.py,sha256=4bS3RGSykdQ1JyBTM-I9na6v0SCijEG1CN-WxqabfUo,625
11
+ mcsmapi/apis/user.py,sha256=HgUJUKIxH6rUwjuevJwj_4JziF2oOqrLBwr2xXnalrM,3024
12
+ mcsmapi/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ mcsmapi/models/daemon.py,sha256=z2DmnXpjI8bq50BAbq3xrkVudOsRpVjXA2LyvUbocgY,3593
14
+ mcsmapi/models/file.py,sha256=ly1LidhvdFr7XIeNnQWjM9cGxcWjGws8UCf4_ykMmQk,2822
15
+ mcsmapi/models/image.py,sha256=jbi4cZCYtfaG-ca7aeI5DOmXXxWTZYCYDqdkzjtuHhc,2804
16
+ mcsmapi/models/instance.py,sha256=zXqNWM2QuSmWsIRUz78aNewvj4JG7GQvH3QFgF8xDYc,5728
17
+ mcsmapi/models/overview.py,sha256=TUvAqr_6h7O2ZC-CWngh8xz4zz6a4av66wgNRUN3NLg,1321
18
+ mcsmapi/models/user.py,sha256=JNlVvpMcK-Rv67JLS8f7lUVp4TXH2gJbUE5LicZUooM,1970
19
+ mcsmapi-0.1.4.dist-info/licenses/LICENSE,sha256=bMKDPsvaybvY-4TTlSZtCXPPtxb7KPpDVqXgDA8Ogo0,1068
20
+ mcsmapi-0.1.4.dist-info/METADATA,sha256=0RVUYmmLKt0djp7X08zVpN4KISbl4huZD2xgbSDL8rA,2602
21
+ mcsmapi-0.1.4.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
22
+ mcsmapi-0.1.4.dist-info/top_level.txt,sha256=8MUYHd1Or4cbSCd93IaqLA72w0weEuKieopVwIfVlWo,8
23
+ mcsmapi-0.1.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 molanp
3
+ Copyright (c) 2024-2025 molanp
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,21 +0,0 @@
1
- mcsmapi/__init__.py,sha256=vRKH5GjiGU9rPkUoQB7XMgJThhl1pA2x-7mYAL6Lkdo,1449
2
- mcsmapi/exceptions.py,sha256=mHsAHyoX9SiFDGBMEhesA_ao9hhZZ38EGTp97K7VDp8,184
3
- mcsmapi/pool.py,sha256=CoOYbyECp4FoXkzwFN7WgtS3vgZtvWO8e93i18vhOEI,308
4
- mcsmapi/request.py,sha256=w_IWOOkxtp_WaaJ1b46ZwaSsWcNnY-CmGF3hhW92fvg,2615
5
- mcsmapi/apis/daemon.py,sha256=a0351ca2I68S2lFRg5wtV52FuLsaT-_dnqhuBXpE-tQ,1960
6
- mcsmapi/apis/file.py,sha256=UKD295UK9755Y_fEANZCxPyS9uwpkJ6KcqnNlM2YHMY,10592
7
- mcsmapi/apis/image.py,sha256=kGuO2U3D3OM8p1jo31U3ACKv-DD-60pkhn1LNiEhhM4,2890
8
- mcsmapi/apis/instance.py,sha256=GTSMSfwaYElrSO3DO4IBbU8OJvd1A34DzgsL_xgU6I0,10968
9
- mcsmapi/apis/overview.py,sha256=tBiZZEXVQukzMqw3EvAVbjkG6h2KO115ylpNRONSJ9s,607
10
- mcsmapi/apis/user.py,sha256=Xza7jAmy8ORkeO2NS-nzKPkG5Immp4FUtskEN0Hd9Z4,2950
11
- mcsmapi/models/daemon.py,sha256=8c0BfNN4OmGlxkDIf-t5tLqfg4ZvODQ9-amqFOJrwSg,3518
12
- mcsmapi/models/file.py,sha256=qI_3e5C7cHUc0botBP7YWU90J-Uu2-JILzBTQ-PicRA,2760
13
- mcsmapi/models/image.py,sha256=akx0b7aUnpl-9F2AHUbkinUP15hLHAnSdLlZZxM3bcI,2773
14
- mcsmapi/models/instance.py,sha256=eDQng8BAVep_ufDYbLHc-sM5JIPn0-AeNqgkOh8wFEM,5595
15
- mcsmapi/models/overview.py,sha256=hgKn5VyheJVo81N1tqEfmBYJi71QVrg2Qd-ffmIT_Mo,1305
16
- mcsmapi/models/user.py,sha256=CDJjiG9cY8gW4rYD8SDnxvMGnn1cdeUU801NucPfnrA,1940
17
- mcsmapi-0.1.2.dist-info/LICENSE,sha256=kn0yZGn5uLIJtr2aAXy8pz_wJqal15ZGnynTU1fCnLQ,1063
18
- mcsmapi-0.1.2.dist-info/METADATA,sha256=RPzcnpPvkHs2DTR98fnmjpmSg8YHywzio9NpUeT_25o,2456
19
- mcsmapi-0.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
- mcsmapi-0.1.2.dist-info/top_level.txt,sha256=8MUYHd1Or4cbSCd93IaqLA72w0weEuKieopVwIfVlWo,8
21
- mcsmapi-0.1.2.dist-info/RECORD,,