hackagent 0.3.1__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.
Files changed (183) hide show
  1. hackagent/__init__.py +12 -0
  2. hackagent/agent.py +214 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +347 -0
  6. hackagent/api/agent/agent_destroy.py +140 -0
  7. hackagent/api/agent/agent_list.py +242 -0
  8. hackagent/api/agent/agent_partial_update.py +361 -0
  9. hackagent/api/agent/agent_retrieve.py +235 -0
  10. hackagent/api/agent/agent_update.py +361 -0
  11. hackagent/api/apilogs/__init__.py +1 -0
  12. hackagent/api/apilogs/apilogs_list.py +170 -0
  13. hackagent/api/apilogs/apilogs_retrieve.py +162 -0
  14. hackagent/api/attack/__init__.py +1 -0
  15. hackagent/api/attack/attack_create.py +275 -0
  16. hackagent/api/attack/attack_destroy.py +146 -0
  17. hackagent/api/attack/attack_list.py +254 -0
  18. hackagent/api/attack/attack_partial_update.py +289 -0
  19. hackagent/api/attack/attack_retrieve.py +247 -0
  20. hackagent/api/attack/attack_update.py +289 -0
  21. hackagent/api/checkout/__init__.py +1 -0
  22. hackagent/api/checkout/checkout_create.py +225 -0
  23. hackagent/api/generate/__init__.py +1 -0
  24. hackagent/api/generate/generate_create.py +253 -0
  25. hackagent/api/judge/__init__.py +1 -0
  26. hackagent/api/judge/judge_create.py +253 -0
  27. hackagent/api/key/__init__.py +1 -0
  28. hackagent/api/key/key_create.py +179 -0
  29. hackagent/api/key/key_destroy.py +103 -0
  30. hackagent/api/key/key_list.py +170 -0
  31. hackagent/api/key/key_retrieve.py +162 -0
  32. hackagent/api/organization/__init__.py +1 -0
  33. hackagent/api/organization/organization_create.py +208 -0
  34. hackagent/api/organization/organization_destroy.py +104 -0
  35. hackagent/api/organization/organization_list.py +170 -0
  36. hackagent/api/organization/organization_me_retrieve.py +126 -0
  37. hackagent/api/organization/organization_partial_update.py +222 -0
  38. hackagent/api/organization/organization_retrieve.py +163 -0
  39. hackagent/api/organization/organization_update.py +222 -0
  40. hackagent/api/prompt/__init__.py +1 -0
  41. hackagent/api/prompt/prompt_create.py +171 -0
  42. hackagent/api/prompt/prompt_destroy.py +104 -0
  43. hackagent/api/prompt/prompt_list.py +185 -0
  44. hackagent/api/prompt/prompt_partial_update.py +185 -0
  45. hackagent/api/prompt/prompt_retrieve.py +163 -0
  46. hackagent/api/prompt/prompt_update.py +185 -0
  47. hackagent/api/result/__init__.py +1 -0
  48. hackagent/api/result/result_create.py +175 -0
  49. hackagent/api/result/result_destroy.py +106 -0
  50. hackagent/api/result/result_list.py +249 -0
  51. hackagent/api/result/result_partial_update.py +193 -0
  52. hackagent/api/result/result_retrieve.py +167 -0
  53. hackagent/api/result/result_trace_create.py +177 -0
  54. hackagent/api/result/result_update.py +189 -0
  55. hackagent/api/run/__init__.py +1 -0
  56. hackagent/api/run/run_create.py +187 -0
  57. hackagent/api/run/run_destroy.py +112 -0
  58. hackagent/api/run/run_list.py +291 -0
  59. hackagent/api/run/run_partial_update.py +201 -0
  60. hackagent/api/run/run_result_create.py +177 -0
  61. hackagent/api/run/run_retrieve.py +179 -0
  62. hackagent/api/run/run_run_tests_create.py +187 -0
  63. hackagent/api/run/run_update.py +201 -0
  64. hackagent/api/user/__init__.py +1 -0
  65. hackagent/api/user/user_create.py +212 -0
  66. hackagent/api/user/user_destroy.py +106 -0
  67. hackagent/api/user/user_list.py +174 -0
  68. hackagent/api/user/user_me_retrieve.py +126 -0
  69. hackagent/api/user/user_me_update.py +196 -0
  70. hackagent/api/user/user_partial_update.py +226 -0
  71. hackagent/api/user/user_retrieve.py +167 -0
  72. hackagent/api/user/user_update.py +226 -0
  73. hackagent/attacks/AdvPrefix/__init__.py +41 -0
  74. hackagent/attacks/AdvPrefix/completions.py +416 -0
  75. hackagent/attacks/AdvPrefix/config.py +259 -0
  76. hackagent/attacks/AdvPrefix/evaluation.py +745 -0
  77. hackagent/attacks/AdvPrefix/evaluators.py +564 -0
  78. hackagent/attacks/AdvPrefix/generate.py +711 -0
  79. hackagent/attacks/AdvPrefix/utils.py +307 -0
  80. hackagent/attacks/__init__.py +35 -0
  81. hackagent/attacks/advprefix.py +507 -0
  82. hackagent/attacks/base.py +106 -0
  83. hackagent/attacks/strategies.py +906 -0
  84. hackagent/cli/__init__.py +19 -0
  85. hackagent/cli/commands/__init__.py +20 -0
  86. hackagent/cli/commands/agent.py +100 -0
  87. hackagent/cli/commands/attack.py +417 -0
  88. hackagent/cli/commands/config.py +301 -0
  89. hackagent/cli/commands/results.py +327 -0
  90. hackagent/cli/config.py +249 -0
  91. hackagent/cli/main.py +515 -0
  92. hackagent/cli/tui/__init__.py +31 -0
  93. hackagent/cli/tui/actions_logger.py +200 -0
  94. hackagent/cli/tui/app.py +288 -0
  95. hackagent/cli/tui/base.py +137 -0
  96. hackagent/cli/tui/logger.py +318 -0
  97. hackagent/cli/tui/views/__init__.py +33 -0
  98. hackagent/cli/tui/views/agents.py +488 -0
  99. hackagent/cli/tui/views/attacks.py +624 -0
  100. hackagent/cli/tui/views/config.py +244 -0
  101. hackagent/cli/tui/views/dashboard.py +307 -0
  102. hackagent/cli/tui/views/results.py +1210 -0
  103. hackagent/cli/tui/widgets/__init__.py +24 -0
  104. hackagent/cli/tui/widgets/actions.py +346 -0
  105. hackagent/cli/tui/widgets/logs.py +435 -0
  106. hackagent/cli/utils.py +276 -0
  107. hackagent/client.py +286 -0
  108. hackagent/errors.py +37 -0
  109. hackagent/logger.py +83 -0
  110. hackagent/models/__init__.py +109 -0
  111. hackagent/models/agent.py +223 -0
  112. hackagent/models/agent_request.py +129 -0
  113. hackagent/models/api_token_log.py +184 -0
  114. hackagent/models/attack.py +154 -0
  115. hackagent/models/attack_request.py +82 -0
  116. hackagent/models/checkout_session_request_request.py +76 -0
  117. hackagent/models/checkout_session_response.py +59 -0
  118. hackagent/models/choice.py +81 -0
  119. hackagent/models/choice_message.py +67 -0
  120. hackagent/models/evaluation_status_enum.py +14 -0
  121. hackagent/models/generate_error_response.py +59 -0
  122. hackagent/models/generate_request_request.py +212 -0
  123. hackagent/models/generate_success_response.py +115 -0
  124. hackagent/models/generic_error_response.py +70 -0
  125. hackagent/models/message_request.py +67 -0
  126. hackagent/models/organization.py +102 -0
  127. hackagent/models/organization_minimal.py +68 -0
  128. hackagent/models/organization_request.py +71 -0
  129. hackagent/models/paginated_agent_list.py +123 -0
  130. hackagent/models/paginated_api_token_log_list.py +123 -0
  131. hackagent/models/paginated_attack_list.py +123 -0
  132. hackagent/models/paginated_organization_list.py +123 -0
  133. hackagent/models/paginated_prompt_list.py +123 -0
  134. hackagent/models/paginated_result_list.py +123 -0
  135. hackagent/models/paginated_run_list.py +123 -0
  136. hackagent/models/paginated_user_api_key_list.py +123 -0
  137. hackagent/models/paginated_user_profile_list.py +123 -0
  138. hackagent/models/patched_agent_request.py +128 -0
  139. hackagent/models/patched_attack_request.py +92 -0
  140. hackagent/models/patched_organization_request.py +71 -0
  141. hackagent/models/patched_prompt_request.py +125 -0
  142. hackagent/models/patched_result_request.py +237 -0
  143. hackagent/models/patched_run_request.py +138 -0
  144. hackagent/models/patched_user_profile_request.py +99 -0
  145. hackagent/models/prompt.py +220 -0
  146. hackagent/models/prompt_request.py +126 -0
  147. hackagent/models/result.py +294 -0
  148. hackagent/models/result_list_evaluation_status.py +14 -0
  149. hackagent/models/result_request.py +232 -0
  150. hackagent/models/run.py +233 -0
  151. hackagent/models/run_list_status.py +12 -0
  152. hackagent/models/run_request.py +133 -0
  153. hackagent/models/status_enum.py +12 -0
  154. hackagent/models/step_type_enum.py +14 -0
  155. hackagent/models/trace.py +121 -0
  156. hackagent/models/trace_request.py +94 -0
  157. hackagent/models/usage.py +75 -0
  158. hackagent/models/user_api_key.py +201 -0
  159. hackagent/models/user_api_key_request.py +73 -0
  160. hackagent/models/user_profile.py +135 -0
  161. hackagent/models/user_profile_minimal.py +76 -0
  162. hackagent/models/user_profile_request.py +99 -0
  163. hackagent/router/__init__.py +25 -0
  164. hackagent/router/adapters/__init__.py +20 -0
  165. hackagent/router/adapters/base.py +63 -0
  166. hackagent/router/adapters/google_adk.py +671 -0
  167. hackagent/router/adapters/litellm_adapter.py +524 -0
  168. hackagent/router/adapters/openai_adapter.py +426 -0
  169. hackagent/router/router.py +969 -0
  170. hackagent/router/types.py +54 -0
  171. hackagent/tracking/__init__.py +42 -0
  172. hackagent/tracking/context.py +163 -0
  173. hackagent/tracking/decorators.py +299 -0
  174. hackagent/tracking/tracker.py +441 -0
  175. hackagent/types.py +54 -0
  176. hackagent/utils.py +194 -0
  177. hackagent/vulnerabilities/__init__.py +13 -0
  178. hackagent/vulnerabilities/prompts.py +81 -0
  179. hackagent-0.3.1.dist-info/METADATA +122 -0
  180. hackagent-0.3.1.dist-info/RECORD +183 -0
  181. hackagent-0.3.1.dist-info/WHEEL +4 -0
  182. hackagent-0.3.1.dist-info/entry_points.txt +2 -0
  183. hackagent-0.3.1.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,291 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+ from uuid import UUID
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.paginated_run_list import PaginatedRunList
10
+ from ...models.run_list_status import RunListStatus
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ agent: Union[Unset, UUID] = UNSET,
17
+ attack: Union[Unset, UUID] = UNSET,
18
+ is_client_executed: Union[Unset, bool] = UNSET,
19
+ organization: Union[Unset, UUID] = UNSET,
20
+ page: Union[Unset, int] = UNSET,
21
+ page_size: Union[Unset, int] = UNSET,
22
+ status: Union[Unset, RunListStatus] = UNSET,
23
+ ) -> dict[str, Any]:
24
+ params: dict[str, Any] = {}
25
+
26
+ json_agent: Union[Unset, str] = UNSET
27
+ if not isinstance(agent, Unset):
28
+ json_agent = str(agent)
29
+ params["agent"] = json_agent
30
+
31
+ json_attack: Union[Unset, str] = UNSET
32
+ if not isinstance(attack, Unset):
33
+ json_attack = str(attack)
34
+ params["attack"] = json_attack
35
+
36
+ params["is_client_executed"] = is_client_executed
37
+
38
+ json_organization: Union[Unset, str] = UNSET
39
+ if not isinstance(organization, Unset):
40
+ json_organization = str(organization)
41
+ params["organization"] = json_organization
42
+
43
+ params["page"] = page
44
+
45
+ params["page_size"] = page_size
46
+
47
+ json_status: Union[Unset, str] = UNSET
48
+ if not isinstance(status, Unset):
49
+ json_status = status.value
50
+
51
+ params["status"] = json_status
52
+
53
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
54
+
55
+ _kwargs: dict[str, Any] = {
56
+ "method": "get",
57
+ "url": "/run",
58
+ "params": params,
59
+ }
60
+
61
+ return _kwargs
62
+
63
+
64
+ def _parse_response(
65
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
66
+ ) -> Optional[PaginatedRunList]:
67
+ if response.status_code == 200:
68
+ response_200 = PaginatedRunList.from_dict(response.json())
69
+
70
+ return response_200
71
+ if client.raise_on_unexpected_status:
72
+ raise errors.UnexpectedStatus(response.status_code, response.content)
73
+ else:
74
+ return None
75
+
76
+
77
+ def _build_response(
78
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
79
+ ) -> Response[PaginatedRunList]:
80
+ return Response(
81
+ status_code=HTTPStatus(response.status_code),
82
+ content=response.content,
83
+ headers=response.headers,
84
+ parsed=_parse_response(client=client, response=response),
85
+ )
86
+
87
+
88
+ def sync_detailed(
89
+ *,
90
+ client: AuthenticatedClient,
91
+ agent: Union[Unset, UUID] = UNSET,
92
+ attack: Union[Unset, UUID] = UNSET,
93
+ is_client_executed: Union[Unset, bool] = UNSET,
94
+ organization: Union[Unset, UUID] = UNSET,
95
+ page: Union[Unset, int] = UNSET,
96
+ page_size: Union[Unset, int] = UNSET,
97
+ status: Union[Unset, RunListStatus] = UNSET,
98
+ ) -> Response[PaginatedRunList]:
99
+ """ViewSet for managing Run instances.
100
+ Primarily for listing/retrieving runs.
101
+ Creation of server-side runs is handled by custom actions.
102
+ Runs initiated from Attack definitions are created via AttackViewSet.
103
+
104
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
105
+ Auth0 authentication is supported as fallback for web dashboard use.
106
+ This is a core SDK operation for executing and monitoring security tests.
107
+
108
+ Args:
109
+ agent (Union[Unset, UUID]):
110
+ attack (Union[Unset, UUID]):
111
+ is_client_executed (Union[Unset, bool]):
112
+ organization (Union[Unset, UUID]):
113
+ page (Union[Unset, int]):
114
+ page_size (Union[Unset, int]):
115
+ status (Union[Unset, RunListStatus]):
116
+
117
+ Raises:
118
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
119
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
120
+
121
+ Returns:
122
+ Response[PaginatedRunList]
123
+ """
124
+
125
+ kwargs = _get_kwargs(
126
+ agent=agent,
127
+ attack=attack,
128
+ is_client_executed=is_client_executed,
129
+ organization=organization,
130
+ page=page,
131
+ page_size=page_size,
132
+ status=status,
133
+ )
134
+
135
+ response = client.get_httpx_client().request(
136
+ **kwargs,
137
+ )
138
+
139
+ return _build_response(client=client, response=response)
140
+
141
+
142
+ def sync(
143
+ *,
144
+ client: AuthenticatedClient,
145
+ agent: Union[Unset, UUID] = UNSET,
146
+ attack: Union[Unset, UUID] = UNSET,
147
+ is_client_executed: Union[Unset, bool] = UNSET,
148
+ organization: Union[Unset, UUID] = UNSET,
149
+ page: Union[Unset, int] = UNSET,
150
+ page_size: Union[Unset, int] = UNSET,
151
+ status: Union[Unset, RunListStatus] = UNSET,
152
+ ) -> Optional[PaginatedRunList]:
153
+ """ViewSet for managing Run instances.
154
+ Primarily for listing/retrieving runs.
155
+ Creation of server-side runs is handled by custom actions.
156
+ Runs initiated from Attack definitions are created via AttackViewSet.
157
+
158
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
159
+ Auth0 authentication is supported as fallback for web dashboard use.
160
+ This is a core SDK operation for executing and monitoring security tests.
161
+
162
+ Args:
163
+ agent (Union[Unset, UUID]):
164
+ attack (Union[Unset, UUID]):
165
+ is_client_executed (Union[Unset, bool]):
166
+ organization (Union[Unset, UUID]):
167
+ page (Union[Unset, int]):
168
+ page_size (Union[Unset, int]):
169
+ status (Union[Unset, RunListStatus]):
170
+
171
+ Raises:
172
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
173
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
174
+
175
+ Returns:
176
+ PaginatedRunList
177
+ """
178
+
179
+ return sync_detailed(
180
+ client=client,
181
+ agent=agent,
182
+ attack=attack,
183
+ is_client_executed=is_client_executed,
184
+ organization=organization,
185
+ page=page,
186
+ page_size=page_size,
187
+ status=status,
188
+ ).parsed
189
+
190
+
191
+ async def asyncio_detailed(
192
+ *,
193
+ client: AuthenticatedClient,
194
+ agent: Union[Unset, UUID] = UNSET,
195
+ attack: Union[Unset, UUID] = UNSET,
196
+ is_client_executed: Union[Unset, bool] = UNSET,
197
+ organization: Union[Unset, UUID] = UNSET,
198
+ page: Union[Unset, int] = UNSET,
199
+ page_size: Union[Unset, int] = UNSET,
200
+ status: Union[Unset, RunListStatus] = UNSET,
201
+ ) -> Response[PaginatedRunList]:
202
+ """ViewSet for managing Run instances.
203
+ Primarily for listing/retrieving runs.
204
+ Creation of server-side runs is handled by custom actions.
205
+ Runs initiated from Attack definitions are created via AttackViewSet.
206
+
207
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
208
+ Auth0 authentication is supported as fallback for web dashboard use.
209
+ This is a core SDK operation for executing and monitoring security tests.
210
+
211
+ Args:
212
+ agent (Union[Unset, UUID]):
213
+ attack (Union[Unset, UUID]):
214
+ is_client_executed (Union[Unset, bool]):
215
+ organization (Union[Unset, UUID]):
216
+ page (Union[Unset, int]):
217
+ page_size (Union[Unset, int]):
218
+ status (Union[Unset, RunListStatus]):
219
+
220
+ Raises:
221
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
222
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
223
+
224
+ Returns:
225
+ Response[PaginatedRunList]
226
+ """
227
+
228
+ kwargs = _get_kwargs(
229
+ agent=agent,
230
+ attack=attack,
231
+ is_client_executed=is_client_executed,
232
+ organization=organization,
233
+ page=page,
234
+ page_size=page_size,
235
+ status=status,
236
+ )
237
+
238
+ response = await client.get_async_httpx_client().request(**kwargs)
239
+
240
+ return _build_response(client=client, response=response)
241
+
242
+
243
+ async def asyncio(
244
+ *,
245
+ client: AuthenticatedClient,
246
+ agent: Union[Unset, UUID] = UNSET,
247
+ attack: Union[Unset, UUID] = UNSET,
248
+ is_client_executed: Union[Unset, bool] = UNSET,
249
+ organization: Union[Unset, UUID] = UNSET,
250
+ page: Union[Unset, int] = UNSET,
251
+ page_size: Union[Unset, int] = UNSET,
252
+ status: Union[Unset, RunListStatus] = UNSET,
253
+ ) -> Optional[PaginatedRunList]:
254
+ """ViewSet for managing Run instances.
255
+ Primarily for listing/retrieving runs.
256
+ Creation of server-side runs is handled by custom actions.
257
+ Runs initiated from Attack definitions are created via AttackViewSet.
258
+
259
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
260
+ Auth0 authentication is supported as fallback for web dashboard use.
261
+ This is a core SDK operation for executing and monitoring security tests.
262
+
263
+ Args:
264
+ agent (Union[Unset, UUID]):
265
+ attack (Union[Unset, UUID]):
266
+ is_client_executed (Union[Unset, bool]):
267
+ organization (Union[Unset, UUID]):
268
+ page (Union[Unset, int]):
269
+ page_size (Union[Unset, int]):
270
+ status (Union[Unset, RunListStatus]):
271
+
272
+ Raises:
273
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
274
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
275
+
276
+ Returns:
277
+ PaginatedRunList
278
+ """
279
+
280
+ return (
281
+ await asyncio_detailed(
282
+ client=client,
283
+ agent=agent,
284
+ attack=attack,
285
+ is_client_executed=is_client_executed,
286
+ organization=organization,
287
+ page=page,
288
+ page_size=page_size,
289
+ status=status,
290
+ )
291
+ ).parsed
@@ -0,0 +1,201 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+ from uuid import UUID
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.patched_run_request import PatchedRunRequest
10
+ from ...models.run import Run
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ id: UUID,
16
+ *,
17
+ body: PatchedRunRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "patch",
23
+ "url": f"/run/{id}",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Optional[Run]:
37
+ if response.status_code == 200:
38
+ response_200 = Run.from_dict(response.json())
39
+
40
+ return response_200
41
+ if client.raise_on_unexpected_status:
42
+ raise errors.UnexpectedStatus(response.status_code, response.content)
43
+ else:
44
+ return None
45
+
46
+
47
+ def _build_response(
48
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
49
+ ) -> Response[Run]:
50
+ return Response(
51
+ status_code=HTTPStatus(response.status_code),
52
+ content=response.content,
53
+ headers=response.headers,
54
+ parsed=_parse_response(client=client, response=response),
55
+ )
56
+
57
+
58
+ def sync_detailed(
59
+ id: UUID,
60
+ *,
61
+ client: AuthenticatedClient,
62
+ body: PatchedRunRequest,
63
+ ) -> Response[Run]:
64
+ """ViewSet for managing Run instances.
65
+ Primarily for listing/retrieving runs.
66
+ Creation of server-side runs is handled by custom actions.
67
+ Runs initiated from Attack definitions are created via AttackViewSet.
68
+
69
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
70
+ Auth0 authentication is supported as fallback for web dashboard use.
71
+ This is a core SDK operation for executing and monitoring security tests.
72
+
73
+ Args:
74
+ id (UUID):
75
+ body (PatchedRunRequest): Serializer for the Run model, used for both input and output.
76
+
77
+ Raises:
78
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
79
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
80
+
81
+ Returns:
82
+ Response[Run]
83
+ """
84
+
85
+ kwargs = _get_kwargs(
86
+ id=id,
87
+ body=body,
88
+ )
89
+
90
+ response = client.get_httpx_client().request(
91
+ **kwargs,
92
+ )
93
+
94
+ return _build_response(client=client, response=response)
95
+
96
+
97
+ def sync(
98
+ id: UUID,
99
+ *,
100
+ client: AuthenticatedClient,
101
+ body: PatchedRunRequest,
102
+ ) -> Optional[Run]:
103
+ """ViewSet for managing Run instances.
104
+ Primarily for listing/retrieving runs.
105
+ Creation of server-side runs is handled by custom actions.
106
+ Runs initiated from Attack definitions are created via AttackViewSet.
107
+
108
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
109
+ Auth0 authentication is supported as fallback for web dashboard use.
110
+ This is a core SDK operation for executing and monitoring security tests.
111
+
112
+ Args:
113
+ id (UUID):
114
+ body (PatchedRunRequest): Serializer for the Run model, used for both input and output.
115
+
116
+ Raises:
117
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
118
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
119
+
120
+ Returns:
121
+ Run
122
+ """
123
+
124
+ return sync_detailed(
125
+ id=id,
126
+ client=client,
127
+ body=body,
128
+ ).parsed
129
+
130
+
131
+ async def asyncio_detailed(
132
+ id: UUID,
133
+ *,
134
+ client: AuthenticatedClient,
135
+ body: PatchedRunRequest,
136
+ ) -> Response[Run]:
137
+ """ViewSet for managing Run instances.
138
+ Primarily for listing/retrieving runs.
139
+ Creation of server-side runs is handled by custom actions.
140
+ Runs initiated from Attack definitions are created via AttackViewSet.
141
+
142
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
143
+ Auth0 authentication is supported as fallback for web dashboard use.
144
+ This is a core SDK operation for executing and monitoring security tests.
145
+
146
+ Args:
147
+ id (UUID):
148
+ body (PatchedRunRequest): Serializer for the Run model, used for both input and output.
149
+
150
+ Raises:
151
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
152
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
153
+
154
+ Returns:
155
+ Response[Run]
156
+ """
157
+
158
+ kwargs = _get_kwargs(
159
+ id=id,
160
+ body=body,
161
+ )
162
+
163
+ response = await client.get_async_httpx_client().request(**kwargs)
164
+
165
+ return _build_response(client=client, response=response)
166
+
167
+
168
+ async def asyncio(
169
+ id: UUID,
170
+ *,
171
+ client: AuthenticatedClient,
172
+ body: PatchedRunRequest,
173
+ ) -> Optional[Run]:
174
+ """ViewSet for managing Run instances.
175
+ Primarily for listing/retrieving runs.
176
+ Creation of server-side runs is handled by custom actions.
177
+ Runs initiated from Attack definitions are created via AttackViewSet.
178
+
179
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
180
+ Auth0 authentication is supported as fallback for web dashboard use.
181
+ This is a core SDK operation for executing and monitoring security tests.
182
+
183
+ Args:
184
+ id (UUID):
185
+ body (PatchedRunRequest): Serializer for the Run model, used for both input and output.
186
+
187
+ Raises:
188
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
189
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
190
+
191
+ Returns:
192
+ Run
193
+ """
194
+
195
+ return (
196
+ await asyncio_detailed(
197
+ id=id,
198
+ client=client,
199
+ body=body,
200
+ )
201
+ ).parsed
@@ -0,0 +1,177 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+ from uuid import UUID
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.result import Result
10
+ from ...models.result_request import ResultRequest
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ id: UUID,
16
+ *,
17
+ body: ResultRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "post",
23
+ "url": f"/run/{id}/result",
24
+ }
25
+
26
+ _kwargs["json"] = body.to_dict()
27
+
28
+ headers["Content-Type"] = "application/json"
29
+
30
+ _kwargs["headers"] = headers
31
+ return _kwargs
32
+
33
+
34
+ def _parse_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Optional[Result]:
37
+ if response.status_code == 200:
38
+ response_200 = Result.from_dict(response.json())
39
+
40
+ return response_200
41
+ if client.raise_on_unexpected_status:
42
+ raise errors.UnexpectedStatus(response.status_code, response.content)
43
+ else:
44
+ return None
45
+
46
+
47
+ def _build_response(
48
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
49
+ ) -> Response[Result]:
50
+ return Response(
51
+ status_code=HTTPStatus(response.status_code),
52
+ content=response.content,
53
+ headers=response.headers,
54
+ parsed=_parse_response(client=client, response=response),
55
+ )
56
+
57
+
58
+ def sync_detailed(
59
+ id: UUID,
60
+ *,
61
+ client: AuthenticatedClient,
62
+ body: ResultRequest,
63
+ ) -> Response[Result]:
64
+ """Creates a new Result associated with this Run.
65
+ The run instance is fetched using the 'id' (the lookup_field) from the URL.
66
+
67
+ Args:
68
+ id (UUID):
69
+ body (ResultRequest): Serializer for the Result model, often nested in RunSerializer.
70
+
71
+ Raises:
72
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
73
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
74
+
75
+ Returns:
76
+ Response[Result]
77
+ """
78
+
79
+ kwargs = _get_kwargs(
80
+ id=id,
81
+ body=body,
82
+ )
83
+
84
+ response = client.get_httpx_client().request(
85
+ **kwargs,
86
+ )
87
+
88
+ return _build_response(client=client, response=response)
89
+
90
+
91
+ def sync(
92
+ id: UUID,
93
+ *,
94
+ client: AuthenticatedClient,
95
+ body: ResultRequest,
96
+ ) -> Optional[Result]:
97
+ """Creates a new Result associated with this Run.
98
+ The run instance is fetched using the 'id' (the lookup_field) from the URL.
99
+
100
+ Args:
101
+ id (UUID):
102
+ body (ResultRequest): Serializer for the Result model, often nested in RunSerializer.
103
+
104
+ Raises:
105
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
107
+
108
+ Returns:
109
+ Result
110
+ """
111
+
112
+ return sync_detailed(
113
+ id=id,
114
+ client=client,
115
+ body=body,
116
+ ).parsed
117
+
118
+
119
+ async def asyncio_detailed(
120
+ id: UUID,
121
+ *,
122
+ client: AuthenticatedClient,
123
+ body: ResultRequest,
124
+ ) -> Response[Result]:
125
+ """Creates a new Result associated with this Run.
126
+ The run instance is fetched using the 'id' (the lookup_field) from the URL.
127
+
128
+ Args:
129
+ id (UUID):
130
+ body (ResultRequest): Serializer for the Result model, often nested in RunSerializer.
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Response[Result]
138
+ """
139
+
140
+ kwargs = _get_kwargs(
141
+ id=id,
142
+ body=body,
143
+ )
144
+
145
+ response = await client.get_async_httpx_client().request(**kwargs)
146
+
147
+ return _build_response(client=client, response=response)
148
+
149
+
150
+ async def asyncio(
151
+ id: UUID,
152
+ *,
153
+ client: AuthenticatedClient,
154
+ body: ResultRequest,
155
+ ) -> Optional[Result]:
156
+ """Creates a new Result associated with this Run.
157
+ The run instance is fetched using the 'id' (the lookup_field) from the URL.
158
+
159
+ Args:
160
+ id (UUID):
161
+ body (ResultRequest): Serializer for the Result model, often nested in RunSerializer.
162
+
163
+ Raises:
164
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
165
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
166
+
167
+ Returns:
168
+ Result
169
+ """
170
+
171
+ return (
172
+ await asyncio_detailed(
173
+ id=id,
174
+ client=client,
175
+ body=body,
176
+ )
177
+ ).parsed