robot-wrapper-sdk 0.2.4__tar.gz → 0.2.6__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.
- robot_wrapper_sdk-0.2.6/PKG-INFO +171 -0
- robot_wrapper_sdk-0.2.6/README.md +161 -0
- robot_wrapper_sdk-0.2.6/examples/main.py +80 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/pyproject.toml +1 -1
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/__init__.py +25 -1
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/application/usecases.py +26 -2
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/domain/entities.py +26 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/domain/repositories.py +32 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/infrastructure/api_client.py +55 -20
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/infrastructure/robot_api_repository.py +66 -2
- robot_wrapper_sdk-0.2.6/robot_wrapper_sdk.egg-info/PKG-INFO +171 -0
- robot_wrapper_sdk-0.2.4/PKG-INFO +0 -104
- robot_wrapper_sdk-0.2.4/README.md +0 -94
- robot_wrapper_sdk-0.2.4/examples/main.py +0 -42
- robot_wrapper_sdk-0.2.4/robot_wrapper_sdk.egg-info/PKG-INFO +0 -104
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/application/__init__.py +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/domain/__init__.py +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_sdk/infrastructure/__init__.py +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_wrapper_sdk.egg-info/SOURCES.txt +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_wrapper_sdk.egg-info/dependency_links.txt +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_wrapper_sdk.egg-info/requires.txt +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/robot_wrapper_sdk.egg-info/top_level.txt +0 -0
- {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.6}/setup.cfg +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robot-wrapper-sdk
|
|
3
|
+
Version: 0.2.6
|
|
4
|
+
Summary: Robot Platform API SDK
|
|
5
|
+
Author-email: GH Robot Platform Team <team@ghrobot.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: httpx[socks]>=0.24.1
|
|
10
|
+
|
|
11
|
+
# Robot Platform SDK (Python)
|
|
12
|
+
|
|
13
|
+
Python SDK for Robot Platform with:
|
|
14
|
+
- develop-app authentication (`app_id`/`app_secret`),
|
|
15
|
+
- sync + async clients,
|
|
16
|
+
- auto token refresh,
|
|
17
|
+
- robot operations and login/hardening task flow.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install robot-wrapper-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
Set environment variables (recommended):
|
|
28
|
+
|
|
29
|
+
- `ROBOT_PLATFORM_BASE_URL`
|
|
30
|
+
- `ROBOT_PLATFORM_APP_ID`
|
|
31
|
+
- `ROBOT_PLATFORM_APP_SECRET`
|
|
32
|
+
- `ROBOT_PLATFORM_PROXY_URL` (optional)
|
|
33
|
+
|
|
34
|
+
Or pass values directly when creating the module.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quick Start (Sync)
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from robot_sdk import RobotPlatformModule
|
|
42
|
+
|
|
43
|
+
sdk = RobotPlatformModule(
|
|
44
|
+
base_url="http://localhost:8085",
|
|
45
|
+
app_id="your_app_id",
|
|
46
|
+
app_secret="your_app_secret",
|
|
47
|
+
# proxy_url="socks5h://192.168.3.100:1080", # optional
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# Read robot
|
|
51
|
+
robot = sdk.get_robot("2047631542552334336")
|
|
52
|
+
print(robot.platform if robot else "not found")
|
|
53
|
+
|
|
54
|
+
# Update lifecycle status
|
|
55
|
+
sdk.update_status("2047631542552334336", "live")
|
|
56
|
+
|
|
57
|
+
# Acquire login tasks
|
|
58
|
+
login_tasks = sdk.acquire_need_login(limit=20, lock_minutes=30)
|
|
59
|
+
|
|
60
|
+
# Update auth status after worker result
|
|
61
|
+
sdk.update_auth_status("2047631542552334336", "authorized")
|
|
62
|
+
# allowed values: authorized | unauthorized | logged_out
|
|
63
|
+
|
|
64
|
+
# Acquire hardening tasks
|
|
65
|
+
hardening_tasks = sdk.acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)
|
|
66
|
+
|
|
67
|
+
# Update hardening status after worker result
|
|
68
|
+
sdk.update_security_hardened("2047631542552334336", True)
|
|
69
|
+
|
|
70
|
+
sdk.close()
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Quick Start (Async)
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import asyncio
|
|
77
|
+
from robot_sdk import AsyncRobotPlatformModule
|
|
78
|
+
|
|
79
|
+
async def main():
|
|
80
|
+
sdk = AsyncRobotPlatformModule(
|
|
81
|
+
base_url="http://localhost:8085",
|
|
82
|
+
app_id="your_app_id",
|
|
83
|
+
app_secret="your_app_secret",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
robot = await sdk.get_robot("2047631542552334336")
|
|
87
|
+
print(robot.platform if robot else "not found")
|
|
88
|
+
|
|
89
|
+
await sdk.update_auth_status("2047631542552334336", "authorized")
|
|
90
|
+
await sdk.update_security_hardened("2047631542552334336", True)
|
|
91
|
+
|
|
92
|
+
await sdk.close()
|
|
93
|
+
|
|
94
|
+
asyncio.run(main())
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Response Shape (Placeholder)
|
|
100
|
+
|
|
101
|
+
Acquire endpoints return:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"status": "success",
|
|
106
|
+
"code": 200,
|
|
107
|
+
"message": "OK",
|
|
108
|
+
"data": [
|
|
109
|
+
{
|
|
110
|
+
"id": "2047631542552334336",
|
|
111
|
+
"username": "example_user_1",
|
|
112
|
+
"platform": "facebook",
|
|
113
|
+
"status": "live",
|
|
114
|
+
"auth_status": "unauthorized",
|
|
115
|
+
"metadata": {
|
|
116
|
+
"security_hardened": false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Update endpoints return:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"status": "success",
|
|
128
|
+
"code": 200,
|
|
129
|
+
"message": "OK",
|
|
130
|
+
"data": null
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Main API
|
|
137
|
+
|
|
138
|
+
### `RobotPlatformModule` (sync)
|
|
139
|
+
- `list_robots(platform=None, status=None, project_id=None, page=1, limit=20)`
|
|
140
|
+
- `get_robot(robot_id)`
|
|
141
|
+
- `delete_robot(robot_id)`
|
|
142
|
+
- `get_secrets(robot_id)`
|
|
143
|
+
- `update_status(robot_id, status)`
|
|
144
|
+
- `acquire_need_login(limit=20, lock_minutes=30)`
|
|
145
|
+
- `acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)`
|
|
146
|
+
- `update_auth_status(robot_id, auth_status)`
|
|
147
|
+
- `update_security_hardened(robot_id, security_hardened)`
|
|
148
|
+
- `close()`
|
|
149
|
+
|
|
150
|
+
### `AsyncRobotPlatformModule` (async)
|
|
151
|
+
Async equivalents of all methods above, plus `await close()`.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Documentation
|
|
156
|
+
|
|
157
|
+
- Usage guide: [`docs/guide.md`](docs/guide.md)
|
|
158
|
+
- Package code: `robot_sdk/`
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Build & Publish (Maintainers)
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
make venv
|
|
166
|
+
make install
|
|
167
|
+
make build
|
|
168
|
+
make publish
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Requires valid PyPI credentials (Twine).
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Robot Platform SDK (Python)
|
|
2
|
+
|
|
3
|
+
Python SDK for Robot Platform with:
|
|
4
|
+
- develop-app authentication (`app_id`/`app_secret`),
|
|
5
|
+
- sync + async clients,
|
|
6
|
+
- auto token refresh,
|
|
7
|
+
- robot operations and login/hardening task flow.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install robot-wrapper-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Configuration
|
|
16
|
+
|
|
17
|
+
Set environment variables (recommended):
|
|
18
|
+
|
|
19
|
+
- `ROBOT_PLATFORM_BASE_URL`
|
|
20
|
+
- `ROBOT_PLATFORM_APP_ID`
|
|
21
|
+
- `ROBOT_PLATFORM_APP_SECRET`
|
|
22
|
+
- `ROBOT_PLATFORM_PROXY_URL` (optional)
|
|
23
|
+
|
|
24
|
+
Or pass values directly when creating the module.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Quick Start (Sync)
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from robot_sdk import RobotPlatformModule
|
|
32
|
+
|
|
33
|
+
sdk = RobotPlatformModule(
|
|
34
|
+
base_url="http://localhost:8085",
|
|
35
|
+
app_id="your_app_id",
|
|
36
|
+
app_secret="your_app_secret",
|
|
37
|
+
# proxy_url="socks5h://192.168.3.100:1080", # optional
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Read robot
|
|
41
|
+
robot = sdk.get_robot("2047631542552334336")
|
|
42
|
+
print(robot.platform if robot else "not found")
|
|
43
|
+
|
|
44
|
+
# Update lifecycle status
|
|
45
|
+
sdk.update_status("2047631542552334336", "live")
|
|
46
|
+
|
|
47
|
+
# Acquire login tasks
|
|
48
|
+
login_tasks = sdk.acquire_need_login(limit=20, lock_minutes=30)
|
|
49
|
+
|
|
50
|
+
# Update auth status after worker result
|
|
51
|
+
sdk.update_auth_status("2047631542552334336", "authorized")
|
|
52
|
+
# allowed values: authorized | unauthorized | logged_out
|
|
53
|
+
|
|
54
|
+
# Acquire hardening tasks
|
|
55
|
+
hardening_tasks = sdk.acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)
|
|
56
|
+
|
|
57
|
+
# Update hardening status after worker result
|
|
58
|
+
sdk.update_security_hardened("2047631542552334336", True)
|
|
59
|
+
|
|
60
|
+
sdk.close()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start (Async)
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
from robot_sdk import AsyncRobotPlatformModule
|
|
68
|
+
|
|
69
|
+
async def main():
|
|
70
|
+
sdk = AsyncRobotPlatformModule(
|
|
71
|
+
base_url="http://localhost:8085",
|
|
72
|
+
app_id="your_app_id",
|
|
73
|
+
app_secret="your_app_secret",
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
robot = await sdk.get_robot("2047631542552334336")
|
|
77
|
+
print(robot.platform if robot else "not found")
|
|
78
|
+
|
|
79
|
+
await sdk.update_auth_status("2047631542552334336", "authorized")
|
|
80
|
+
await sdk.update_security_hardened("2047631542552334336", True)
|
|
81
|
+
|
|
82
|
+
await sdk.close()
|
|
83
|
+
|
|
84
|
+
asyncio.run(main())
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Response Shape (Placeholder)
|
|
90
|
+
|
|
91
|
+
Acquire endpoints return:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"status": "success",
|
|
96
|
+
"code": 200,
|
|
97
|
+
"message": "OK",
|
|
98
|
+
"data": [
|
|
99
|
+
{
|
|
100
|
+
"id": "2047631542552334336",
|
|
101
|
+
"username": "example_user_1",
|
|
102
|
+
"platform": "facebook",
|
|
103
|
+
"status": "live",
|
|
104
|
+
"auth_status": "unauthorized",
|
|
105
|
+
"metadata": {
|
|
106
|
+
"security_hardened": false
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Update endpoints return:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"status": "success",
|
|
118
|
+
"code": 200,
|
|
119
|
+
"message": "OK",
|
|
120
|
+
"data": null
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Main API
|
|
127
|
+
|
|
128
|
+
### `RobotPlatformModule` (sync)
|
|
129
|
+
- `list_robots(platform=None, status=None, project_id=None, page=1, limit=20)`
|
|
130
|
+
- `get_robot(robot_id)`
|
|
131
|
+
- `delete_robot(robot_id)`
|
|
132
|
+
- `get_secrets(robot_id)`
|
|
133
|
+
- `update_status(robot_id, status)`
|
|
134
|
+
- `acquire_need_login(limit=20, lock_minutes=30)`
|
|
135
|
+
- `acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)`
|
|
136
|
+
- `update_auth_status(robot_id, auth_status)`
|
|
137
|
+
- `update_security_hardened(robot_id, security_hardened)`
|
|
138
|
+
- `close()`
|
|
139
|
+
|
|
140
|
+
### `AsyncRobotPlatformModule` (async)
|
|
141
|
+
Async equivalents of all methods above, plus `await close()`.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Documentation
|
|
146
|
+
|
|
147
|
+
- Usage guide: [`docs/guide.md`](docs/guide.md)
|
|
148
|
+
- Package code: `robot_sdk/`
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Build & Publish (Maintainers)
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
make venv
|
|
156
|
+
make install
|
|
157
|
+
make build
|
|
158
|
+
make publish
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Requires valid PyPI credentials (Twine).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
6
|
+
from robot_sdk import RobotPlatformModule, AsyncRobotPlatformModule
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def setup_environ():
|
|
10
|
+
# Update theo develop-app auth flow
|
|
11
|
+
os.environ["ROBOT_PLATFORM_BASE_URL"] = "http://localhost:8085"
|
|
12
|
+
os.environ["ROBOT_PLATFORM_APP_ID"] = "your_app_id"
|
|
13
|
+
os.environ["ROBOT_PLATFORM_APP_SECRET"] = "your_app_secret"
|
|
14
|
+
# os.environ["ROBOT_PLATFORM_PROXY_URL"] = "socks5h://192.168.3.100:1080"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_sync():
|
|
18
|
+
print("--- SYNC EXECUTION ---")
|
|
19
|
+
module = RobotPlatformModule()
|
|
20
|
+
try:
|
|
21
|
+
robot_id = "2047631542552334336"
|
|
22
|
+
|
|
23
|
+
robot = module.get_robot(robot_id)
|
|
24
|
+
if robot:
|
|
25
|
+
print("Robot:", robot.username, robot.platform)
|
|
26
|
+
else:
|
|
27
|
+
print("Robot not found")
|
|
28
|
+
|
|
29
|
+
login_tasks = module.acquire_need_login(limit=20, lock_minutes=30)
|
|
30
|
+
print("Acquire login tasks:", len(login_tasks))
|
|
31
|
+
|
|
32
|
+
module.update_auth_status(robot_id, "authorized")
|
|
33
|
+
print("Updated auth_status -> authorized")
|
|
34
|
+
|
|
35
|
+
hardening_tasks = module.acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)
|
|
36
|
+
print("Acquire hardening tasks:", len(hardening_tasks))
|
|
37
|
+
|
|
38
|
+
module.update_security_hardened(robot_id, True)
|
|
39
|
+
print("Updated security_hardened -> true")
|
|
40
|
+
|
|
41
|
+
except Exception as e:
|
|
42
|
+
print("Sync demo error:", e)
|
|
43
|
+
finally:
|
|
44
|
+
module.close()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async def test_async():
|
|
48
|
+
print("--- ASYNC EXECUTION ---")
|
|
49
|
+
module = AsyncRobotPlatformModule()
|
|
50
|
+
try:
|
|
51
|
+
robot_id = "2047631542552334336"
|
|
52
|
+
|
|
53
|
+
robot = await module.get_robot(robot_id)
|
|
54
|
+
if robot:
|
|
55
|
+
print("Robot:", robot.username, robot.platform)
|
|
56
|
+
else:
|
|
57
|
+
print("Robot not found")
|
|
58
|
+
|
|
59
|
+
login_tasks = await module.acquire_need_login(limit=20, lock_minutes=30)
|
|
60
|
+
print("Acquire login tasks:", len(login_tasks))
|
|
61
|
+
|
|
62
|
+
await module.update_auth_status(robot_id, "authorized")
|
|
63
|
+
print("Updated auth_status -> authorized")
|
|
64
|
+
|
|
65
|
+
hardening_tasks = await module.acquire_unhardened(limit=20, lock_minutes=30, min_age_days=0)
|
|
66
|
+
print("Acquire hardening tasks:", len(hardening_tasks))
|
|
67
|
+
|
|
68
|
+
await module.update_security_hardened(robot_id, True)
|
|
69
|
+
print("Updated security_hardened -> true")
|
|
70
|
+
|
|
71
|
+
except Exception as e:
|
|
72
|
+
print("Async demo error:", e)
|
|
73
|
+
finally:
|
|
74
|
+
await module.close()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
setup_environ()
|
|
79
|
+
test_sync()
|
|
80
|
+
asyncio.run(test_async())
|
|
@@ -31,6 +31,18 @@ class RobotPlatformModule:
|
|
|
31
31
|
def update_status(self, robot_id: str, status: str) -> None:
|
|
32
32
|
self.robot_usecase.update_status(robot_id, status)
|
|
33
33
|
|
|
34
|
+
def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30):
|
|
35
|
+
return self.robot_usecase.acquire_need_login(limit, lock_minutes)
|
|
36
|
+
|
|
37
|
+
def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0):
|
|
38
|
+
return self.robot_usecase.acquire_unhardened(limit, lock_minutes, min_age_days)
|
|
39
|
+
|
|
40
|
+
def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
41
|
+
self.robot_usecase.update_auth_status(robot_id, auth_status)
|
|
42
|
+
|
|
43
|
+
def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
44
|
+
self.robot_usecase.update_security_hardened(robot_id, security_hardened)
|
|
45
|
+
|
|
34
46
|
|
|
35
47
|
class AsyncRobotPlatformModule:
|
|
36
48
|
"""Asynchronous Facade for the Robot Platform SDK."""
|
|
@@ -57,4 +69,16 @@ class AsyncRobotPlatformModule:
|
|
|
57
69
|
async def update_status(self, robot_id: str, status: str) -> None:
|
|
58
70
|
await self.robot_usecase.update_status(robot_id, status)
|
|
59
71
|
|
|
60
|
-
|
|
72
|
+
async def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30):
|
|
73
|
+
return await self.robot_usecase.acquire_need_login(limit, lock_minutes)
|
|
74
|
+
|
|
75
|
+
async def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0):
|
|
76
|
+
return await self.robot_usecase.acquire_unhardened(limit, lock_minutes, min_age_days)
|
|
77
|
+
|
|
78
|
+
async def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
79
|
+
await self.robot_usecase.update_auth_status(robot_id, auth_status)
|
|
80
|
+
|
|
81
|
+
async def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
82
|
+
await self.robot_usecase.update_security_hardened(robot_id, security_hardened)
|
|
83
|
+
|
|
84
|
+
__all__ = ["RobotPlatformModule", "AsyncRobotPlatformModule", "Robot", "RobotSecrets"]
|
|
@@ -21,12 +21,24 @@ class RobotUsecase:
|
|
|
21
21
|
def list_robots(self, platform: Optional[str] = None, status: Optional[str] = None, project_id: Optional[int] = None, page: int = 1, limit: int = 20) -> Dict[str, Any]:
|
|
22
22
|
items, total = self.repo.list_robots(platform, status, project_id, page, limit)
|
|
23
23
|
return {
|
|
24
|
-
"data": [r.__dict__ for r in items],
|
|
24
|
+
"data": [r.__dict__ for r in items],
|
|
25
25
|
"total": total,
|
|
26
26
|
"page": page,
|
|
27
27
|
"limit": limit
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
|
|
31
|
+
return self.repo.acquire_need_login(limit, lock_minutes)
|
|
32
|
+
|
|
33
|
+
def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
|
|
34
|
+
return self.repo.acquire_unhardened(limit, lock_minutes, min_age_days)
|
|
35
|
+
|
|
36
|
+
def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
37
|
+
self.repo.update_auth_status(robot_id, auth_status)
|
|
38
|
+
|
|
39
|
+
def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
40
|
+
self.repo.update_security_hardened(robot_id, security_hardened)
|
|
41
|
+
|
|
30
42
|
|
|
31
43
|
class AsyncRobotUsecase:
|
|
32
44
|
def __init__(self, repo: AsyncRobotRepository):
|
|
@@ -47,8 +59,20 @@ class AsyncRobotUsecase:
|
|
|
47
59
|
async def list_robots(self, platform: Optional[str] = None, status: Optional[str] = None, project_id: Optional[int] = None, page: int = 1, limit: int = 20) -> Dict[str, Any]:
|
|
48
60
|
items, total = await self.repo.list_robots(platform, status, project_id, page, limit)
|
|
49
61
|
return {
|
|
50
|
-
"data": [r.__dict__ for r in items],
|
|
62
|
+
"data": [r.__dict__ for r in items],
|
|
51
63
|
"total": total,
|
|
52
64
|
"page": page,
|
|
53
65
|
"limit": limit
|
|
54
66
|
}
|
|
67
|
+
|
|
68
|
+
async def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
|
|
69
|
+
return await self.repo.acquire_need_login(limit, lock_minutes)
|
|
70
|
+
|
|
71
|
+
async def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
|
|
72
|
+
return await self.repo.acquire_unhardened(limit, lock_minutes, min_age_days)
|
|
73
|
+
|
|
74
|
+
async def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
75
|
+
await self.repo.update_auth_status(robot_id, auth_status)
|
|
76
|
+
|
|
77
|
+
async def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
78
|
+
await self.repo.update_security_hardened(robot_id, security_hardened)
|
|
@@ -23,3 +23,29 @@ class RobotActivity:
|
|
|
23
23
|
activity_type: str
|
|
24
24
|
status: str
|
|
25
25
|
message: str
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class AcquireNeedLoginRequest:
|
|
29
|
+
limit: int = 20
|
|
30
|
+
lock_minutes: int = 30
|
|
31
|
+
|
|
32
|
+
@dataclass
|
|
33
|
+
class AcquireUnhardenedRequest:
|
|
34
|
+
limit: int = 20
|
|
35
|
+
lock_minutes: int = 30
|
|
36
|
+
min_age_days: int = 0
|
|
37
|
+
|
|
38
|
+
@dataclass
|
|
39
|
+
class UpdateAuthStatusRequest:
|
|
40
|
+
auth_status: str
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class UpdateSecurityHardenedRequest:
|
|
44
|
+
security_hardened: bool
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class StandardResponse:
|
|
48
|
+
status: str
|
|
49
|
+
code: int
|
|
50
|
+
message: str
|
|
51
|
+
data: Any = None
|
|
@@ -23,6 +23,22 @@ class RobotRepository(ABC):
|
|
|
23
23
|
def list_robots(self, platform: Optional[str] = None, status: Optional[str] = None, project_id: Optional[int] = None, page: int = 1, limit: int = 20) -> Tuple[List[Robot], int]:
|
|
24
24
|
pass
|
|
25
25
|
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
40
|
+
pass
|
|
41
|
+
|
|
26
42
|
class AsyncRobotRepository(ABC):
|
|
27
43
|
@abstractmethod
|
|
28
44
|
async def find_by_id(self, robot_id: str) -> Optional[Robot]:
|
|
@@ -43,3 +59,19 @@ class AsyncRobotRepository(ABC):
|
|
|
43
59
|
@abstractmethod
|
|
44
60
|
async def list_robots(self, platform: Optional[str] = None, status: Optional[str] = None, project_id: Optional[int] = None, page: int = 1, limit: int = 20) -> Tuple[List[Robot], int]:
|
|
45
61
|
pass
|
|
62
|
+
|
|
63
|
+
@abstractmethod
|
|
64
|
+
async def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
async def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
async def update_auth_status(self, robot_id: str, auth_status: str) -> None:
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
async def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
|
|
77
|
+
pass
|