marzban 0.2.8__tar.gz → 0.2.9__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.
marzban-0.2.9/PKG-INFO ADDED
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.1
2
+ Name: marzban
3
+ Version: 0.2.9
4
+ Summary: Асинхронная библиотека Python для взаимодействия с MarzbanAPI
5
+ Home-page: https://github.com/sm1ky/marzban_api
6
+ Author: Artem
7
+ Author-email: contant@sm1ky.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.23.0
15
+ Requires-Dist: pydantic>=1.10.0
16
+
17
+
18
+ # MarzbanAPI Client
19
+
20
+ **MarzbanAPI Client** is an asynchronous Python library designed for interacting with [Marzban](https://github.com/Gozargah/Marzban). It provides comprehensive methods for managing administrators, users, nodes, and system statistics.
21
+
22
+ ## Installation
23
+
24
+ To install the latest version of the library, use:
25
+
26
+ ```bash
27
+ pip install marzban
28
+ ```
29
+
30
+ ## Project Links
31
+ - **PyPI**: [marzban](https://pypi.org/project/marzban/)
32
+ - **GitHub Repository**: [marzban_api](https://github.com/sm1ky/marzban_api)
33
+
34
+ ## Detailed Documentation
35
+
36
+ For detailed documentation and usage examples, select your preferred language below:
37
+
38
+ - [English](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_en.md)
39
+ - [Русский (Russian)](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_ru.md)
40
+
41
+ ## Contributing
42
+
43
+ We welcome contributions! If you encounter any issues or have suggestions for improvements, please feel free to [open an issue](https://github.com/sm1ky/marzban_api/issues) or submit a Pull Request (PR).
44
+
45
+ ## Support
46
+
47
+ If you have any questions or need assistance, you can contact the author via:
48
+ - **Email**: [contant@sm1ky.com](mailto:contant@sm1ky.com)
49
+ - **Telegram**: [@sm1ky](https://t.me/sm1ky)
50
+
51
+ ## License
52
+
53
+ This project is licensed under the MIT License. For more details, refer to the [LICENSE file](https://github.com/sm1ky/marzban_api/blob/production/LICENSE).
@@ -0,0 +1,37 @@
1
+
2
+ # MarzbanAPI Client
3
+
4
+ **MarzbanAPI Client** is an asynchronous Python library designed for interacting with [Marzban](https://github.com/Gozargah/Marzban). It provides comprehensive methods for managing administrators, users, nodes, and system statistics.
5
+
6
+ ## Installation
7
+
8
+ To install the latest version of the library, use:
9
+
10
+ ```bash
11
+ pip install marzban
12
+ ```
13
+
14
+ ## Project Links
15
+ - **PyPI**: [marzban](https://pypi.org/project/marzban/)
16
+ - **GitHub Repository**: [marzban_api](https://github.com/sm1ky/marzban_api)
17
+
18
+ ## Detailed Documentation
19
+
20
+ For detailed documentation and usage examples, select your preferred language below:
21
+
22
+ - [English](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_en.md)
23
+ - [Русский (Russian)](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_ru.md)
24
+
25
+ ## Contributing
26
+
27
+ We welcome contributions! If you encounter any issues or have suggestions for improvements, please feel free to [open an issue](https://github.com/sm1ky/marzban_api/issues) or submit a Pull Request (PR).
28
+
29
+ ## Support
30
+
31
+ If you have any questions or need assistance, you can contact the author via:
32
+ - **Email**: [contant@sm1ky.com](mailto:contant@sm1ky.com)
33
+ - **Telegram**: [@sm1ky](https://t.me/sm1ky)
34
+
35
+ ## License
36
+
37
+ This project is licensed under the MIT License. For more details, refer to the [LICENSE file](https://github.com/sm1ky/marzban_api/blob/production/LICENSE).
@@ -25,7 +25,9 @@ from .models import (
25
25
  ProxyInbound,
26
26
  Token,
27
27
  HTTPValidationError,
28
- ValidationError
28
+ ValidationError,
29
+ SubscriptionUserResponse,
30
+ SystemStats
29
31
  )
30
32
 
31
33
  __all__ = (
@@ -57,6 +59,8 @@ __all__ = (
57
59
  "Token",
58
60
  "HTTPValidationError",
59
61
  "ValidationError",
62
+ "SubscriptionUserResponse",
63
+ "SystemStats"
60
64
  )
61
65
 
62
- __version__ = "0.2.8"
66
+ __version__ = "0.2.9"
@@ -223,5 +223,45 @@ class MarzbanAPI:
223
223
  response = await self._request("GET", url, token, params=params)
224
224
  return NodesUsageResponse(**response.json())
225
225
 
226
+ async def get_user_subscription_info(self, url: str = None, token: str = None) -> SubscriptionUserResponse:
227
+ if url:
228
+ # Use the provided URL if it is given
229
+ final_url = url + "/info"
230
+ elif token:
231
+ # Form the URL using the token if it is provided
232
+ final_url = f"/sub/{token}/info"
233
+ else:
234
+ raise ValueError("Either url or token must be provided")
235
+
236
+ response = await self._request("GET", final_url)
237
+ return SubscriptionUserResponse(**response.json())
238
+
239
+ async def get_user_usage(self, url: str = None, token: str = None, start: Optional[str] = None, end: Optional[str] = None) -> Any:
240
+ if url:
241
+ # Use the provided URL if it is given
242
+ final_url = url + "/usage"
243
+ elif token:
244
+ # Form the URL using the token if it is provided
245
+ final_url = f"/sub/{token}/usage"
246
+ else:
247
+ raise ValueError("Either url or token must be provided")
248
+
249
+ params = {"start": start, "end": end}
250
+ response = await self._request("GET", final_url, params=params)
251
+ return response.json()
252
+
253
+ async def get_user_subscription_with_client_type(self, client_type: str, url: str = None, token: str = None) -> Any:
254
+ if url:
255
+ # Use the provided URL if it is given
256
+ final_url = url + f"/{client_type}"
257
+ elif token:
258
+ # Form the URL using the token if it is provided
259
+ final_url = f"/sub/{token}/{client_type}"
260
+ else:
261
+ raise ValueError("Either url or token must be provided")
262
+
263
+ response = await self._request("GET", final_url)
264
+ return response.json()
265
+
226
266
  async def close(self):
227
267
  await self.client.aclose()
@@ -1,5 +1,5 @@
1
- from pydantic import BaseModel
2
- from typing import Optional, List, Dict, Any, ClassVar
1
+ from pydantic import BaseModel, field_validator, ValidationInfo, AfterValidator, ValidationError
2
+ from typing import Optional, List, Dict, Any, ClassVar, Annotated
3
3
 
4
4
  class Token(BaseModel):
5
5
  access_token: str
@@ -23,19 +23,6 @@ class AdminModify(BaseModel):
23
23
  class HTTPValidationError(BaseModel):
24
24
  detail: Optional[List[Dict[str, Any]]] = None
25
25
 
26
- class SystemStats(BaseModel):
27
- version: str
28
- mem_total: int
29
- mem_used: int
30
- cpu_cores: int
31
- cpu_usage: float
32
- total_user: int
33
- users_active: int
34
- incoming_bandwidth: int
35
- outgoing_bandwidth: int
36
- incoming_bandwidth_speed: int
37
- outgoing_bandwidth_speed: int
38
-
39
26
  class ProxySettings(BaseModel):
40
27
  id: Optional[str] = None
41
28
  flow: Optional[str] = None
@@ -75,7 +62,13 @@ class UserResponse(BaseModel):
75
62
  created_at: Optional[str] = None
76
63
  links: Optional[List[str]] = []
77
64
  subscription_url: Optional[str] = None
65
+ subscription_token: Optional[str] = None
78
66
  excluded_inbounds: Optional[Dict[str, List[str]]] = None
67
+
68
+ def __init__(self, **data):
69
+ super().__init__(**data)
70
+ if not self.subscription_token and self.subscription_url:
71
+ self.subscription_token = self.subscription_url.split('/')[-1]
79
72
 
80
73
  class NodeCreate(BaseModel):
81
74
  name: str
@@ -197,3 +190,39 @@ class ValidationError(BaseModel):
197
190
  loc: List[Any]
198
191
  msg: str
199
192
  type: str
193
+
194
+ class SubscriptionUserResponse(BaseModel):
195
+ proxies: Dict[str, Any]
196
+ expire: Optional[int] = None
197
+ data_limit: Optional[int] = None
198
+ data_limit_reset_strategy: str = "no_reset"
199
+ inbounds: Dict[str, List[str]] = {}
200
+ note: Optional[str] = None
201
+ sub_updated_at: Optional[str] = None
202
+ sub_last_user_agent: Optional[str] = None
203
+ online_at: Optional[str] = None
204
+ on_hold_expire_duration: Optional[int] = None
205
+ on_hold_timeout: Optional[str] = None
206
+ auto_delete_in_days: Optional[int] = None
207
+ username: str
208
+ status: str
209
+ used_traffic: int
210
+ lifetime_used_traffic: int = 0
211
+ created_at: str
212
+ links: List[str] = []
213
+ subscription_url: str = ""
214
+ excluded_inbounds: Dict[str, List[str]] = {}
215
+ admin: Optional[Admin] = None
216
+
217
+ class SystemStats(BaseModel):
218
+ version: Optional[str] = None
219
+ mem_total: Optional[int] = None
220
+ mem_used: Optional[int] = None
221
+ cpu_cores: Optional[int] = None
222
+ cpu_usage: Optional[float] = None
223
+ total_user: Optional[int] = None
224
+ users_active: Optional[int] = None
225
+ incoming_bandwidth: Optional[int] = None
226
+ outgoing_bandwidth: Optional[int] = None
227
+ incoming_bandwidth_speed: Optional[int] = None
228
+ outgoing_bandwidth_speed: Optional[int] = None
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.1
2
+ Name: marzban
3
+ Version: 0.2.9
4
+ Summary: Асинхронная библиотека Python для взаимодействия с MarzbanAPI
5
+ Home-page: https://github.com/sm1ky/marzban_api
6
+ Author: Artem
7
+ Author-email: contant@sm1ky.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: httpx>=0.23.0
15
+ Requires-Dist: pydantic>=1.10.0
16
+
17
+
18
+ # MarzbanAPI Client
19
+
20
+ **MarzbanAPI Client** is an asynchronous Python library designed for interacting with [Marzban](https://github.com/Gozargah/Marzban). It provides comprehensive methods for managing administrators, users, nodes, and system statistics.
21
+
22
+ ## Installation
23
+
24
+ To install the latest version of the library, use:
25
+
26
+ ```bash
27
+ pip install marzban
28
+ ```
29
+
30
+ ## Project Links
31
+ - **PyPI**: [marzban](https://pypi.org/project/marzban/)
32
+ - **GitHub Repository**: [marzban_api](https://github.com/sm1ky/marzban_api)
33
+
34
+ ## Detailed Documentation
35
+
36
+ For detailed documentation and usage examples, select your preferred language below:
37
+
38
+ - [English](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_en.md)
39
+ - [Русский (Russian)](https://github.com/sm1ky/marzban_api/blob/production/.readme/README_ru.md)
40
+
41
+ ## Contributing
42
+
43
+ We welcome contributions! If you encounter any issues or have suggestions for improvements, please feel free to [open an issue](https://github.com/sm1ky/marzban_api/issues) or submit a Pull Request (PR).
44
+
45
+ ## Support
46
+
47
+ If you have any questions or need assistance, you can contact the author via:
48
+ - **Email**: [contant@sm1ky.com](mailto:contant@sm1ky.com)
49
+ - **Telegram**: [@sm1ky](https://t.me/sm1ky)
50
+
51
+ ## License
52
+
53
+ This project is licensed under the MIT License. For more details, refer to the [LICENSE file](https://github.com/sm1ky/marzban_api/blob/production/LICENSE).
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="marzban",
8
- version="0.2.8",
8
+ version="0.2.9",
9
9
  packages=find_packages(),
10
10
  install_requires=[
11
11
  "httpx>=0.23.0",
marzban-0.2.8/PKG-INFO DELETED
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: marzban
3
- Version: 0.2.8
4
- Summary: Асинхронная библиотека Python для взаимодействия с MarzbanAPI
5
- Home-page: https://github.com/sm1ky/marzban_api
6
- Author: Artem
7
- Author-email: contant@sm1ky.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: httpx>=0.23.0
15
- Requires-Dist: pydantic>=1.10.0
16
-
17
- # MarzbanAPI Client
18
-
19
- Это асинхронная библиотека Python для взаимодействия с MarzbanAPI, предоставляющая методы для управления администраторами, пользователями, узлами и системной статистикой.
20
-
21
- ## Установка
22
-
23
- ```bash
24
- pip install marzban
25
- ```
26
-
27
- Project in Pypi - https://pypi.org/project/marzban/
28
-
29
- If you notice an error, please create a PR and attach logs
30
- You can contact me by mail contant@sm1ky.com or in Telegram @sm1ky
marzban-0.2.8/README.md DELETED
@@ -1,14 +0,0 @@
1
- # MarzbanAPI Client
2
-
3
- Это асинхронная библиотека Python для взаимодействия с MarzbanAPI, предоставляющая методы для управления администраторами, пользователями, узлами и системной статистикой.
4
-
5
- ## Установка
6
-
7
- ```bash
8
- pip install marzban
9
- ```
10
-
11
- Project in Pypi - https://pypi.org/project/marzban/
12
-
13
- If you notice an error, please create a PR and attach logs
14
- You can contact me by mail contant@sm1ky.com or in Telegram @sm1ky
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: marzban
3
- Version: 0.2.8
4
- Summary: Асинхронная библиотека Python для взаимодействия с MarzbanAPI
5
- Home-page: https://github.com/sm1ky/marzban_api
6
- Author: Artem
7
- Author-email: contant@sm1ky.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: httpx>=0.23.0
15
- Requires-Dist: pydantic>=1.10.0
16
-
17
- # MarzbanAPI Client
18
-
19
- Это асинхронная библиотека Python для взаимодействия с MarzbanAPI, предоставляющая методы для управления администраторами, пользователями, узлами и системной статистикой.
20
-
21
- ## Установка
22
-
23
- ```bash
24
- pip install marzban
25
- ```
26
-
27
- Project in Pypi - https://pypi.org/project/marzban/
28
-
29
- If you notice an error, please create a PR and attach logs
30
- You can contact me by mail contant@sm1ky.com or in Telegram @sm1ky
File without changes
File without changes