pixelarraythirdparty 1.0.7__tar.gz → 1.0.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.
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/PKG-INFO +1 -1
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/__init__.py +4 -1
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/client.py +36 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/cron/cron.py +37 -37
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/filestorage/__init__.py +6 -0
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/filestorage/filestorage.py +530 -0
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/order/order.py +341 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/product/product.py +46 -47
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/unified_login/__init__.py +16 -0
- pixelarraythirdparty-1.0.9/pixelarraythirdparty/unified_login/unified_login.py +18 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/user/user.py +44 -44
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty.egg-info/PKG-INFO +1 -1
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty.egg-info/SOURCES.txt +4 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pyproject.toml +1 -1
- pixelarraythirdparty-1.0.7/pixelarraythirdparty/client.py +0 -47
- pixelarraythirdparty-1.0.7/pixelarraythirdparty/order/order.py +0 -702
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/LICENSE +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/MANIFEST.in +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/cron/__init__.py +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/order/__init__.py +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/product/__init__.py +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty/user/__init__.py +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty.egg-info/dependency_links.txt +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty.egg-info/requires.txt +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/pixelarraythirdparty.egg-info/top_level.txt +0 -0
- {pixelarraythirdparty-1.0.7 → pixelarraythirdparty-1.0.9}/setup.cfg +0 -0
|
@@ -8,9 +8,10 @@ PixelArray 第三方微服务客户端
|
|
|
8
8
|
- product: 产品管理模块
|
|
9
9
|
- cron: 定时任务管理模块
|
|
10
10
|
- user: 用户管理模块
|
|
11
|
+
- unified_login: 统一登录模块
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
|
-
__version__ = "1.0.
|
|
14
|
+
__version__ = "1.0.9"
|
|
14
15
|
__author__ = "Lu qi"
|
|
15
16
|
__email__ = "qi.lu@pixelarrayai.com"
|
|
16
17
|
|
|
@@ -20,4 +21,6 @@ __all__ = [
|
|
|
20
21
|
"cron",
|
|
21
22
|
"user",
|
|
22
23
|
"order",
|
|
24
|
+
"filestorage",
|
|
25
|
+
"unified_login",
|
|
23
26
|
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import aiohttp
|
|
2
|
+
from typing import Dict, Any, Tuple
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AsyncClient:
|
|
6
|
+
def __init__(self, api_key: str):
|
|
7
|
+
self.base_url = "https://thirdparty.pixelarrayai.com"
|
|
8
|
+
self.api_key = api_key
|
|
9
|
+
self.headers = {
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
"X-API-Key": self.api_key,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async def _request(
|
|
15
|
+
self, method: str, url: str, **kwargs
|
|
16
|
+
) -> Tuple[Dict[str, Any], bool]:
|
|
17
|
+
# 如果kwargs中有headers,则合并headers
|
|
18
|
+
headers = self.headers.copy()
|
|
19
|
+
if "headers" in kwargs:
|
|
20
|
+
headers.update(kwargs["headers"])
|
|
21
|
+
kwargs = {k: v for k, v in kwargs.items() if k != "headers"}
|
|
22
|
+
|
|
23
|
+
async with aiohttp.ClientSession() as session:
|
|
24
|
+
req_method = getattr(session, method.lower())
|
|
25
|
+
async with req_method(
|
|
26
|
+
f"{self.base_url}{url}", headers=headers, **kwargs
|
|
27
|
+
) as resp:
|
|
28
|
+
if resp.status == 200:
|
|
29
|
+
try:
|
|
30
|
+
result = await resp.json()
|
|
31
|
+
if result.get("success") is True:
|
|
32
|
+
return result.get("data", {}), True
|
|
33
|
+
except:
|
|
34
|
+
# 如果不是JSON响应,返回空
|
|
35
|
+
pass
|
|
36
|
+
return {}, False
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from pixelarraythirdparty.client import
|
|
1
|
+
from pixelarraythirdparty.client import AsyncClient
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
def get_cron_status(self):
|
|
4
|
+
class CronManagerAsync(AsyncClient):
|
|
5
|
+
async def get_cron_status(self):
|
|
6
6
|
"""
|
|
7
|
-
获取Cron
|
|
8
|
-
|
|
7
|
+
获取Cron服务状态(异步版本)
|
|
8
|
+
|
|
9
9
|
功能说明:
|
|
10
10
|
获取Cron服务的运行状态,包括已注册的任务、工作节点状态等。
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
输入参数:
|
|
13
13
|
无
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
返回字段:
|
|
16
16
|
data (dict): Cron服务状态信息
|
|
17
17
|
- registered_tasks (dict): 已注册的任务列表,按工作节点分组
|
|
@@ -19,50 +19,50 @@ class CronManager(Client):
|
|
|
19
19
|
- scheduled_task_count (int): 定时任务数量
|
|
20
20
|
- timestamp (str): 状态获取时间
|
|
21
21
|
success (bool): 操作是否成功
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
异常情况:
|
|
24
24
|
- 获取Cron状态失败:返回错误信息"获取Cron状态失败"
|
|
25
25
|
"""
|
|
26
|
-
data, success = self._request("GET", "/api/cron/status")
|
|
26
|
+
data, success = await self._request("GET", "/api/cron/status")
|
|
27
27
|
if not success:
|
|
28
28
|
return {}, False
|
|
29
29
|
return data, True
|
|
30
30
|
|
|
31
|
-
def get_cron_tasks(self):
|
|
31
|
+
async def get_cron_tasks(self):
|
|
32
32
|
"""
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
获取已注册任务列表(异步版本)
|
|
34
|
+
|
|
35
35
|
功能说明:
|
|
36
36
|
获取所有已注册的Cron任务列表。
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
输入参数:
|
|
39
39
|
无
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
返回字段:
|
|
42
42
|
data (dict): 任务列表信息
|
|
43
43
|
- tasks (list): 已注册的任务名称列表
|
|
44
44
|
- count (int): 任务数量
|
|
45
45
|
- timestamp (str): 获取时间
|
|
46
46
|
success (bool): 操作是否成功
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
异常情况:
|
|
49
49
|
- 获取任务列表失败:返回错误信息"获取任务列表失败"
|
|
50
50
|
"""
|
|
51
|
-
data, success = self._request("GET", "/api/cron/tasks")
|
|
51
|
+
data, success = await self._request("GET", "/api/cron/tasks")
|
|
52
52
|
if not success:
|
|
53
53
|
return {}, False
|
|
54
54
|
return data, True
|
|
55
55
|
|
|
56
|
-
def get_cron_tasks_scheduled(self):
|
|
56
|
+
async def get_cron_tasks_scheduled(self):
|
|
57
57
|
"""
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
获取定时任务列表(异步版本)
|
|
59
|
+
|
|
60
60
|
功能说明:
|
|
61
61
|
获取所有配置的定时任务列表,包括任务详情、执行时间、状态等。
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
输入参数:
|
|
64
64
|
无
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
返回字段:
|
|
67
67
|
data (dict): 定时任务列表信息
|
|
68
68
|
- tasks (list): 定时任务列表
|
|
@@ -81,25 +81,25 @@ class CronManager(Client):
|
|
|
81
81
|
- count (int): 任务数量
|
|
82
82
|
- timestamp (str): 获取时间
|
|
83
83
|
success (bool): 操作是否成功
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
异常情况:
|
|
86
86
|
- 获取定时任务列表失败:返回错误信息"获取定时任务列表失败"
|
|
87
87
|
"""
|
|
88
|
-
data, success = self._request("GET", "/api/cron/tasks/scheduled")
|
|
88
|
+
data, success = await self._request("GET", "/api/cron/tasks/scheduled")
|
|
89
89
|
if not success:
|
|
90
90
|
return {}, False
|
|
91
91
|
return data, True
|
|
92
92
|
|
|
93
|
-
def get_cron_tasks_detail(self, task_name: str):
|
|
93
|
+
async def get_cron_tasks_detail(self, task_name: str):
|
|
94
94
|
"""
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
获取任务详情(异步版本)
|
|
96
|
+
|
|
97
97
|
功能说明:
|
|
98
98
|
根据任务名称获取指定任务的详细信息。
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
输入参数:
|
|
101
101
|
task_name (str): 任务名称,必填,需要URL编码
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
返回字段:
|
|
104
104
|
data (dict): 任务详细信息
|
|
105
105
|
- task_name (str): 任务名称
|
|
@@ -112,28 +112,28 @@ class CronManager(Client):
|
|
|
112
112
|
- registration_info (dict): 注册信息
|
|
113
113
|
- timestamp (str): 获取时间
|
|
114
114
|
success (bool): 操作是否成功
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
异常情况:
|
|
117
117
|
- 任务不存在:返回错误信息"任务不存在"
|
|
118
118
|
- 获取任务详情失败:返回错误信息"获取任务详情失败"
|
|
119
119
|
"""
|
|
120
|
-
data, success = self._request("GET", f"/api/cron/tasks/{task_name}")
|
|
120
|
+
data, success = await self._request("GET", f"/api/cron/tasks/{task_name}")
|
|
121
121
|
if not success:
|
|
122
122
|
return {}, False
|
|
123
123
|
return data, True
|
|
124
124
|
|
|
125
|
-
def trigger_cron_task(self, task_name: str, args: list, kwargs: dict):
|
|
125
|
+
async def trigger_cron_task(self, task_name: str, args: list, kwargs: dict):
|
|
126
126
|
"""
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
触发任务执行(异步版本)
|
|
128
|
+
|
|
129
129
|
功能说明:
|
|
130
130
|
手动触发指定任务的执行,支持传递参数。
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
输入参数:
|
|
133
133
|
task_name (str): 任务名称,必填,需要URL编码
|
|
134
134
|
args (list): 任务参数列表,可选
|
|
135
135
|
kwargs (dict): 任务关键字参数,可选
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
返回字段:
|
|
138
138
|
data (dict): 任务触发信息
|
|
139
139
|
- task_id (str): 任务ID
|
|
@@ -141,12 +141,12 @@ class CronManager(Client):
|
|
|
141
141
|
- status (str): 任务状态,初始为"PENDING"
|
|
142
142
|
- message (str): 触发消息
|
|
143
143
|
success (bool): 操作是否成功
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
异常情况:
|
|
146
146
|
- 任务不存在:返回错误信息"任务不存在"
|
|
147
147
|
- 任务触发失败:返回错误信息"任务触发失败"
|
|
148
148
|
"""
|
|
149
|
-
data, success = self._request(
|
|
149
|
+
data, success = await self._request(
|
|
150
150
|
"POST",
|
|
151
151
|
f"/api/cron/tasks/{task_name}/trigger",
|
|
152
152
|
json={"args": args, "kwargs": kwargs},
|