robot-wrapper-sdk 0.2.4__tar.gz → 0.2.5__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.
Files changed (22) hide show
  1. robot_wrapper_sdk-0.2.5/PKG-INFO +171 -0
  2. robot_wrapper_sdk-0.2.5/README.md +161 -0
  3. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/pyproject.toml +1 -1
  4. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/__init__.py +25 -1
  5. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/application/usecases.py +26 -2
  6. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/domain/entities.py +26 -0
  7. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/domain/repositories.py +32 -0
  8. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/infrastructure/robot_api_repository.py +66 -2
  9. robot_wrapper_sdk-0.2.5/robot_wrapper_sdk.egg-info/PKG-INFO +171 -0
  10. robot_wrapper_sdk-0.2.4/PKG-INFO +0 -104
  11. robot_wrapper_sdk-0.2.4/README.md +0 -94
  12. robot_wrapper_sdk-0.2.4/robot_wrapper_sdk.egg-info/PKG-INFO +0 -104
  13. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/examples/main.py +0 -0
  14. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/application/__init__.py +0 -0
  15. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/domain/__init__.py +0 -0
  16. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/infrastructure/__init__.py +0 -0
  17. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_sdk/infrastructure/api_client.py +0 -0
  18. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_wrapper_sdk.egg-info/SOURCES.txt +0 -0
  19. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_wrapper_sdk.egg-info/dependency_links.txt +0 -0
  20. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_wrapper_sdk.egg-info/requires.txt +0 -0
  21. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/robot_wrapper_sdk.egg-info/top_level.txt +0 -0
  22. {robot_wrapper_sdk-0.2.4 → robot_wrapper_sdk-0.2.5}/setup.cfg +0 -0
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: robot-wrapper-sdk
3
+ Version: 0.2.5
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).
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "robot-wrapper-sdk"
11
- version = "0.2.4"
11
+ version = "0.2.5"
12
12
  description = "Robot Platform API SDK"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.10"
@@ -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
- __all__ = ["RobotPlatformModule", "AsyncRobotPlatformModule"]
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
@@ -26,12 +26,44 @@ class RobotAPIRepository(RobotRepository):
26
26
  if platform: params["platform"] = platform
27
27
  if status: params["status"] = status
28
28
  if project_id: params["project_id"] = project_id
29
-
29
+
30
30
  resp = self.client.request("GET", "/robots", params=params)
31
31
  data = resp.get("data", [])
32
32
  total = resp.get("total", 0)
33
33
  return [Robot(**r) for r in data], total
34
34
 
35
+ def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
36
+ resp = self.client.request(
37
+ "POST",
38
+ "/robots/login/acquire",
39
+ json={"limit": limit, "lock_minutes": lock_minutes},
40
+ )
41
+ data = resp.get("data", [])
42
+ return [Robot(**r) for r in data]
43
+
44
+ def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
45
+ resp = self.client.request(
46
+ "POST",
47
+ "/robots/security-hardened/acquire",
48
+ json={"limit": limit, "lock_minutes": lock_minutes, "min_age_days": min_age_days},
49
+ )
50
+ data = resp.get("data", [])
51
+ return [Robot(**r) for r in data]
52
+
53
+ def update_auth_status(self, robot_id: str, auth_status: str) -> None:
54
+ self.client.request(
55
+ "PATCH",
56
+ f"/robots/{robot_id}/auth-status",
57
+ json={"auth_status": auth_status},
58
+ )
59
+
60
+ def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
61
+ self.client.request(
62
+ "PATCH",
63
+ f"/robots/{robot_id}/security-hardened",
64
+ json={"security_hardened": security_hardened},
65
+ )
66
+
35
67
  class AsyncRobotAPIRepository(AsyncRobotRepository):
36
68
  def __init__(self, client: AsyncHTTPClient):
37
69
  self.client = client
@@ -55,8 +87,40 @@ class AsyncRobotAPIRepository(AsyncRobotRepository):
55
87
  if platform: params["platform"] = platform
56
88
  if status: params["status"] = status
57
89
  if project_id: params["project_id"] = project_id
58
-
90
+
59
91
  resp = await self.client.request("GET", "/robots", params=params)
60
92
  data = resp.get("data", [])
61
93
  total = resp.get("total", 0)
62
94
  return [Robot(**r) for r in data], total
95
+
96
+ async def acquire_need_login(self, limit: int = 20, lock_minutes: int = 30) -> List[Robot]:
97
+ resp = await self.client.request(
98
+ "POST",
99
+ "/robots/login/acquire",
100
+ json={"limit": limit, "lock_minutes": lock_minutes},
101
+ )
102
+ data = resp.get("data", [])
103
+ return [Robot(**r) for r in data]
104
+
105
+ async def acquire_unhardened(self, limit: int = 20, lock_minutes: int = 30, min_age_days: int = 0) -> List[Robot]:
106
+ resp = await self.client.request(
107
+ "POST",
108
+ "/robots/security-hardened/acquire",
109
+ json={"limit": limit, "lock_minutes": lock_minutes, "min_age_days": min_age_days},
110
+ )
111
+ data = resp.get("data", [])
112
+ return [Robot(**r) for r in data]
113
+
114
+ async def update_auth_status(self, robot_id: str, auth_status: str) -> None:
115
+ await self.client.request(
116
+ "PATCH",
117
+ f"/robots/{robot_id}/auth-status",
118
+ json={"auth_status": auth_status},
119
+ )
120
+
121
+ async def update_security_hardened(self, robot_id: str, security_hardened: bool) -> None:
122
+ await self.client.request(
123
+ "PATCH",
124
+ f"/robots/{robot_id}/security-hardened",
125
+ json={"security_hardened": security_hardened},
126
+ )
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.4
2
+ Name: robot-wrapper-sdk
3
+ Version: 0.2.5
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).
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: robot-wrapper-sdk
3
- Version: 0.2.4
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
- **Robot Platform** provides a clean‑architecture, DDD‑compliant Python SDK for interacting with the robot management backend. The SDK ships with both synchronous and asynchronous clients, automatic authentication, and token‑refresh middleware.
14
-
15
- ---
16
-
17
- ## 📦 Installation
18
- ```sh
19
- pip install robot-wrapper-sdk
20
- ```
21
-
22
- ---
23
-
24
- ## 🚀 Quick start
25
- ```python
26
- from robot_sdk import RobotPlatformModule
27
-
28
- # Auto‑configuration via environment variables (recommended)
29
- # ROBOT_PLATFORM_BASE_URL
30
- # ROBOT_PLATFORM_APP_ID
31
- # ROBOT_PLATFORM_APP_SECRET
32
- # ROBOT_PLATFORM_PROXY_URL (optional: socks5h://..., http://...)
33
-
34
- sdk = RobotPlatformModule() # reads env vars automatically
35
-
36
- # Or manual configuration with proxy support
37
- sdk = RobotPlatformModule(
38
- base_url="https://api.example.com",
39
- app_id="...",
40
- app_secret="...",
41
- proxy_url="socks5h://192.168.3.100:1080"
42
- )
43
-
44
- # Synchronous call example
45
- robot = sdk.robot_usecase.get_robot_profile("2029943774539935744")
46
- print(robot.platform)
47
-
48
- # Asynchronous call example
49
- import asyncio
50
-
51
- async def async_demo():
52
- async_sdk = await RobotPlatformModule.async_init()
53
- robot = await async_sdk.robot_usecase.get_robot_profile_async("2029943774539935744")
54
- print(robot.platform)
55
-
56
- asyncio.run(async_demo())
57
- ```
58
-
59
- ---
60
-
61
- ## 📚 Documentation
62
- The full API reference and usage guide live in the repository:
63
- - **Guide**: [`docs/guide.md`](docs/guide.md) – step‑by‑step walkthrough of all use‑cases.
64
- - **API reference** is generated from type‑hints and can be inspected via `help(RobotPlatformModule)`.
65
-
66
- ---
67
-
68
- ## 💡 Examples
69
- The `examples/` directory contains ready‑to‑run scripts that demonstrate common scenarios:
70
- - [`examples/auth_flow.py`](examples/auth_flow.py) – login, token refresh, and error handling.
71
- - [`examples/robot_profile.py`](examples/robot_profile.py) – fetch robot details synchronously.
72
- - [`examples/async_robot_profile.py`](examples/async_robot_profile.py) – the same operation with `asyncio`.
73
-
74
- Run any example directly:
75
- ```sh
76
- python examples/robot_profile.py
77
- ```
78
-
79
- ---
80
-
81
- ## 🛠️ Build & publish (maintainer guide)
82
- ```sh
83
- # Create a clean virtual environment
84
- make venv
85
-
86
- # Install build tools
87
- make install
88
-
89
- # Build source and wheel distributions
90
- make build
91
-
92
- # Publish to PyPI (requires twine and valid credentials)
93
- make publish
94
- ```
95
- The `Makefile` lives in the SDK root and abstracts the above commands.
96
-
97
- ---
98
-
99
- ## 📄 License
100
- MIT License – see the bundled `LICENSE` file.
101
-
102
- ---
103
-
104
- *This README is rendered on PyPI, so all relative links (`docs/`, `examples/`) resolve to the files shipped in the source distribution, allowing developers to browse the documentation and example code directly from the package page.*
@@ -1,94 +0,0 @@
1
- # Robot Platform SDK (Python)
2
-
3
- **Robot Platform** provides a clean‑architecture, DDD‑compliant Python SDK for interacting with the robot management backend. The SDK ships with both synchronous and asynchronous clients, automatic authentication, and token‑refresh middleware.
4
-
5
- ---
6
-
7
- ## 📦 Installation
8
- ```sh
9
- pip install robot-wrapper-sdk
10
- ```
11
-
12
- ---
13
-
14
- ## 🚀 Quick start
15
- ```python
16
- from robot_sdk import RobotPlatformModule
17
-
18
- # Auto‑configuration via environment variables (recommended)
19
- # ROBOT_PLATFORM_BASE_URL
20
- # ROBOT_PLATFORM_APP_ID
21
- # ROBOT_PLATFORM_APP_SECRET
22
- # ROBOT_PLATFORM_PROXY_URL (optional: socks5h://..., http://...)
23
-
24
- sdk = RobotPlatformModule() # reads env vars automatically
25
-
26
- # Or manual configuration with proxy support
27
- sdk = RobotPlatformModule(
28
- base_url="https://api.example.com",
29
- app_id="...",
30
- app_secret="...",
31
- proxy_url="socks5h://192.168.3.100:1080"
32
- )
33
-
34
- # Synchronous call example
35
- robot = sdk.robot_usecase.get_robot_profile("2029943774539935744")
36
- print(robot.platform)
37
-
38
- # Asynchronous call example
39
- import asyncio
40
-
41
- async def async_demo():
42
- async_sdk = await RobotPlatformModule.async_init()
43
- robot = await async_sdk.robot_usecase.get_robot_profile_async("2029943774539935744")
44
- print(robot.platform)
45
-
46
- asyncio.run(async_demo())
47
- ```
48
-
49
- ---
50
-
51
- ## 📚 Documentation
52
- The full API reference and usage guide live in the repository:
53
- - **Guide**: [`docs/guide.md`](docs/guide.md) – step‑by‑step walkthrough of all use‑cases.
54
- - **API reference** is generated from type‑hints and can be inspected via `help(RobotPlatformModule)`.
55
-
56
- ---
57
-
58
- ## 💡 Examples
59
- The `examples/` directory contains ready‑to‑run scripts that demonstrate common scenarios:
60
- - [`examples/auth_flow.py`](examples/auth_flow.py) – login, token refresh, and error handling.
61
- - [`examples/robot_profile.py`](examples/robot_profile.py) – fetch robot details synchronously.
62
- - [`examples/async_robot_profile.py`](examples/async_robot_profile.py) – the same operation with `asyncio`.
63
-
64
- Run any example directly:
65
- ```sh
66
- python examples/robot_profile.py
67
- ```
68
-
69
- ---
70
-
71
- ## 🛠️ Build & publish (maintainer guide)
72
- ```sh
73
- # Create a clean virtual environment
74
- make venv
75
-
76
- # Install build tools
77
- make install
78
-
79
- # Build source and wheel distributions
80
- make build
81
-
82
- # Publish to PyPI (requires twine and valid credentials)
83
- make publish
84
- ```
85
- The `Makefile` lives in the SDK root and abstracts the above commands.
86
-
87
- ---
88
-
89
- ## 📄 License
90
- MIT License – see the bundled `LICENSE` file.
91
-
92
- ---
93
-
94
- *This README is rendered on PyPI, so all relative links (`docs/`, `examples/`) resolve to the files shipped in the source distribution, allowing developers to browse the documentation and example code directly from the package page.*
@@ -1,104 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: robot-wrapper-sdk
3
- Version: 0.2.4
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
- **Robot Platform** provides a clean‑architecture, DDD‑compliant Python SDK for interacting with the robot management backend. The SDK ships with both synchronous and asynchronous clients, automatic authentication, and token‑refresh middleware.
14
-
15
- ---
16
-
17
- ## 📦 Installation
18
- ```sh
19
- pip install robot-wrapper-sdk
20
- ```
21
-
22
- ---
23
-
24
- ## 🚀 Quick start
25
- ```python
26
- from robot_sdk import RobotPlatformModule
27
-
28
- # Auto‑configuration via environment variables (recommended)
29
- # ROBOT_PLATFORM_BASE_URL
30
- # ROBOT_PLATFORM_APP_ID
31
- # ROBOT_PLATFORM_APP_SECRET
32
- # ROBOT_PLATFORM_PROXY_URL (optional: socks5h://..., http://...)
33
-
34
- sdk = RobotPlatformModule() # reads env vars automatically
35
-
36
- # Or manual configuration with proxy support
37
- sdk = RobotPlatformModule(
38
- base_url="https://api.example.com",
39
- app_id="...",
40
- app_secret="...",
41
- proxy_url="socks5h://192.168.3.100:1080"
42
- )
43
-
44
- # Synchronous call example
45
- robot = sdk.robot_usecase.get_robot_profile("2029943774539935744")
46
- print(robot.platform)
47
-
48
- # Asynchronous call example
49
- import asyncio
50
-
51
- async def async_demo():
52
- async_sdk = await RobotPlatformModule.async_init()
53
- robot = await async_sdk.robot_usecase.get_robot_profile_async("2029943774539935744")
54
- print(robot.platform)
55
-
56
- asyncio.run(async_demo())
57
- ```
58
-
59
- ---
60
-
61
- ## 📚 Documentation
62
- The full API reference and usage guide live in the repository:
63
- - **Guide**: [`docs/guide.md`](docs/guide.md) – step‑by‑step walkthrough of all use‑cases.
64
- - **API reference** is generated from type‑hints and can be inspected via `help(RobotPlatformModule)`.
65
-
66
- ---
67
-
68
- ## 💡 Examples
69
- The `examples/` directory contains ready‑to‑run scripts that demonstrate common scenarios:
70
- - [`examples/auth_flow.py`](examples/auth_flow.py) – login, token refresh, and error handling.
71
- - [`examples/robot_profile.py`](examples/robot_profile.py) – fetch robot details synchronously.
72
- - [`examples/async_robot_profile.py`](examples/async_robot_profile.py) – the same operation with `asyncio`.
73
-
74
- Run any example directly:
75
- ```sh
76
- python examples/robot_profile.py
77
- ```
78
-
79
- ---
80
-
81
- ## 🛠️ Build & publish (maintainer guide)
82
- ```sh
83
- # Create a clean virtual environment
84
- make venv
85
-
86
- # Install build tools
87
- make install
88
-
89
- # Build source and wheel distributions
90
- make build
91
-
92
- # Publish to PyPI (requires twine and valid credentials)
93
- make publish
94
- ```
95
- The `Makefile` lives in the SDK root and abstracts the above commands.
96
-
97
- ---
98
-
99
- ## 📄 License
100
- MIT License – see the bundled `LICENSE` file.
101
-
102
- ---
103
-
104
- *This README is rendered on PyPI, so all relative links (`docs/`, `examples/`) resolve to the files shipped in the source distribution, allowing developers to browse the documentation and example code directly from the package page.*