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,275 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.attack import Attack
9
+ from ...models.attack_request import AttackRequest
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ body: AttackRequest,
16
+ ) -> dict[str, Any]:
17
+ headers: dict[str, Any] = {}
18
+
19
+ _kwargs: dict[str, Any] = {
20
+ "method": "post",
21
+ "url": "/attack",
22
+ }
23
+
24
+ _kwargs["json"] = body.to_dict()
25
+
26
+ headers["Content-Type"] = "application/json"
27
+
28
+ _kwargs["headers"] = headers
29
+ return _kwargs
30
+
31
+
32
+ def _parse_response(
33
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
34
+ ) -> Optional[Attack]:
35
+ if response.status_code == 201:
36
+ response_201 = Attack.from_dict(response.json())
37
+
38
+ return response_201
39
+ if client.raise_on_unexpected_status:
40
+ raise errors.UnexpectedStatus(response.status_code, response.content)
41
+ else:
42
+ return None
43
+
44
+
45
+ def _build_response(
46
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
47
+ ) -> Response[Attack]:
48
+ return Response(
49
+ status_code=HTTPStatus(response.status_code),
50
+ content=response.content,
51
+ headers=response.headers,
52
+ parsed=_parse_response(client=client, response=response),
53
+ )
54
+
55
+
56
+ def sync_detailed(
57
+ *,
58
+ client: AuthenticatedClient,
59
+ body: AttackRequest,
60
+ ) -> Response[Attack]:
61
+ """Manages Attack configurations through standard CRUD operations.
62
+
63
+ This ViewSet allows clients to:
64
+ - Create new Attack configurations.
65
+ - List existing Attack configurations (with filtering based on user/org).
66
+ - Retrieve details of a specific Attack configuration.
67
+ - Update an existing Attack configuration.
68
+ - Delete an Attack configuration.
69
+
70
+ The actual execution of an attack based on these configurations, and the
71
+ management of run statuses or results, are handled by other parts of the API
72
+ (e.g., potentially a RunViewSet or similar).
73
+
74
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
75
+ Auth0 authentication is supported as fallback for web dashboard use.
76
+
77
+ Attributes:
78
+ queryset: The base queryset, retrieving all Attack objects with related
79
+ entities (agent, owner, organization) pre-fetched.
80
+ serializer_class: The serializer (`AttackSerializer`) used for data
81
+ conversion for Attack configurations.
82
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
83
+ permission_classes: List of permission enforcement classes.
84
+ parser_classes: List of parsers for request data (JSONParser).
85
+ lookup_field: The model field used for looking up individual instances ('id').
86
+
87
+ Args:
88
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
89
+ configuration.
90
+
91
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
92
+ for API requests and responses. It includes read-only fields for related
93
+ object names (like agent_name, owner_username) for convenience in API outputs.
94
+
95
+ Raises:
96
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
97
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
98
+
99
+ Returns:
100
+ Response[Attack]
101
+ """
102
+
103
+ kwargs = _get_kwargs(
104
+ body=body,
105
+ )
106
+
107
+ response = client.get_httpx_client().request(
108
+ **kwargs,
109
+ )
110
+
111
+ return _build_response(client=client, response=response)
112
+
113
+
114
+ def sync(
115
+ *,
116
+ client: AuthenticatedClient,
117
+ body: AttackRequest,
118
+ ) -> Optional[Attack]:
119
+ """Manages Attack configurations through standard CRUD operations.
120
+
121
+ This ViewSet allows clients to:
122
+ - Create new Attack configurations.
123
+ - List existing Attack configurations (with filtering based on user/org).
124
+ - Retrieve details of a specific Attack configuration.
125
+ - Update an existing Attack configuration.
126
+ - Delete an Attack configuration.
127
+
128
+ The actual execution of an attack based on these configurations, and the
129
+ management of run statuses or results, are handled by other parts of the API
130
+ (e.g., potentially a RunViewSet or similar).
131
+
132
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
133
+ Auth0 authentication is supported as fallback for web dashboard use.
134
+
135
+ Attributes:
136
+ queryset: The base queryset, retrieving all Attack objects with related
137
+ entities (agent, owner, organization) pre-fetched.
138
+ serializer_class: The serializer (`AttackSerializer`) used for data
139
+ conversion for Attack configurations.
140
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
141
+ permission_classes: List of permission enforcement classes.
142
+ parser_classes: List of parsers for request data (JSONParser).
143
+ lookup_field: The model field used for looking up individual instances ('id').
144
+
145
+ Args:
146
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
147
+ configuration.
148
+
149
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
150
+ for API requests and responses. It includes read-only fields for related
151
+ object names (like agent_name, owner_username) for convenience in API outputs.
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Attack
159
+ """
160
+
161
+ return sync_detailed(
162
+ client=client,
163
+ body=body,
164
+ ).parsed
165
+
166
+
167
+ async def asyncio_detailed(
168
+ *,
169
+ client: AuthenticatedClient,
170
+ body: AttackRequest,
171
+ ) -> Response[Attack]:
172
+ """Manages Attack configurations through standard CRUD operations.
173
+
174
+ This ViewSet allows clients to:
175
+ - Create new Attack configurations.
176
+ - List existing Attack configurations (with filtering based on user/org).
177
+ - Retrieve details of a specific Attack configuration.
178
+ - Update an existing Attack configuration.
179
+ - Delete an Attack configuration.
180
+
181
+ The actual execution of an attack based on these configurations, and the
182
+ management of run statuses or results, are handled by other parts of the API
183
+ (e.g., potentially a RunViewSet or similar).
184
+
185
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
186
+ Auth0 authentication is supported as fallback for web dashboard use.
187
+
188
+ Attributes:
189
+ queryset: The base queryset, retrieving all Attack objects with related
190
+ entities (agent, owner, organization) pre-fetched.
191
+ serializer_class: The serializer (`AttackSerializer`) used for data
192
+ conversion for Attack configurations.
193
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
194
+ permission_classes: List of permission enforcement classes.
195
+ parser_classes: List of parsers for request data (JSONParser).
196
+ lookup_field: The model field used for looking up individual instances ('id').
197
+
198
+ Args:
199
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
200
+ configuration.
201
+
202
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
203
+ for API requests and responses. It includes read-only fields for related
204
+ object names (like agent_name, owner_username) for convenience in API outputs.
205
+
206
+ Raises:
207
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
208
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
209
+
210
+ Returns:
211
+ Response[Attack]
212
+ """
213
+
214
+ kwargs = _get_kwargs(
215
+ body=body,
216
+ )
217
+
218
+ response = await client.get_async_httpx_client().request(**kwargs)
219
+
220
+ return _build_response(client=client, response=response)
221
+
222
+
223
+ async def asyncio(
224
+ *,
225
+ client: AuthenticatedClient,
226
+ body: AttackRequest,
227
+ ) -> Optional[Attack]:
228
+ """Manages Attack configurations through standard CRUD operations.
229
+
230
+ This ViewSet allows clients to:
231
+ - Create new Attack configurations.
232
+ - List existing Attack configurations (with filtering based on user/org).
233
+ - Retrieve details of a specific Attack configuration.
234
+ - Update an existing Attack configuration.
235
+ - Delete an Attack configuration.
236
+
237
+ The actual execution of an attack based on these configurations, and the
238
+ management of run statuses or results, are handled by other parts of the API
239
+ (e.g., potentially a RunViewSet or similar).
240
+
241
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
242
+ Auth0 authentication is supported as fallback for web dashboard use.
243
+
244
+ Attributes:
245
+ queryset: The base queryset, retrieving all Attack objects with related
246
+ entities (agent, owner, organization) pre-fetched.
247
+ serializer_class: The serializer (`AttackSerializer`) used for data
248
+ conversion for Attack configurations.
249
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
250
+ permission_classes: List of permission enforcement classes.
251
+ parser_classes: List of parsers for request data (JSONParser).
252
+ lookup_field: The model field used for looking up individual instances ('id').
253
+
254
+ Args:
255
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
256
+ configuration.
257
+
258
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
259
+ for API requests and responses. It includes read-only fields for related
260
+ object names (like agent_name, owner_username) for convenience in API outputs.
261
+
262
+ Raises:
263
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
264
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
265
+
266
+ Returns:
267
+ Attack
268
+ """
269
+
270
+ return (
271
+ await asyncio_detailed(
272
+ client=client,
273
+ body=body,
274
+ )
275
+ ).parsed
@@ -0,0 +1,146 @@
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 ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ id: UUID,
14
+ ) -> dict[str, Any]:
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "delete",
17
+ "url": f"/attack/{id}",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
25
+ ) -> Optional[Any]:
26
+ if response.status_code == 204:
27
+ return None
28
+ if client.raise_on_unexpected_status:
29
+ raise errors.UnexpectedStatus(response.status_code, response.content)
30
+ else:
31
+ return None
32
+
33
+
34
+ def _build_response(
35
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
36
+ ) -> Response[Any]:
37
+ return Response(
38
+ status_code=HTTPStatus(response.status_code),
39
+ content=response.content,
40
+ headers=response.headers,
41
+ parsed=_parse_response(client=client, response=response),
42
+ )
43
+
44
+
45
+ def sync_detailed(
46
+ id: UUID,
47
+ *,
48
+ client: AuthenticatedClient,
49
+ ) -> Response[Any]:
50
+ """Manages Attack configurations through standard CRUD operations.
51
+
52
+ This ViewSet allows clients to:
53
+ - Create new Attack configurations.
54
+ - List existing Attack configurations (with filtering based on user/org).
55
+ - Retrieve details of a specific Attack configuration.
56
+ - Update an existing Attack configuration.
57
+ - Delete an Attack configuration.
58
+
59
+ The actual execution of an attack based on these configurations, and the
60
+ management of run statuses or results, are handled by other parts of the API
61
+ (e.g., potentially a RunViewSet or similar).
62
+
63
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
64
+ Auth0 authentication is supported as fallback for web dashboard use.
65
+
66
+ Attributes:
67
+ queryset: The base queryset, retrieving all Attack objects with related
68
+ entities (agent, owner, organization) pre-fetched.
69
+ serializer_class: The serializer (`AttackSerializer`) used for data
70
+ conversion for Attack configurations.
71
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
72
+ permission_classes: List of permission enforcement classes.
73
+ parser_classes: List of parsers for request data (JSONParser).
74
+ lookup_field: The model field used for looking up individual instances ('id').
75
+
76
+ Args:
77
+ id (UUID):
78
+
79
+ Raises:
80
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
81
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
82
+
83
+ Returns:
84
+ Response[Any]
85
+ """
86
+
87
+ kwargs = _get_kwargs(
88
+ id=id,
89
+ )
90
+
91
+ response = client.get_httpx_client().request(
92
+ **kwargs,
93
+ )
94
+
95
+ return _build_response(client=client, response=response)
96
+
97
+
98
+ async def asyncio_detailed(
99
+ id: UUID,
100
+ *,
101
+ client: AuthenticatedClient,
102
+ ) -> Response[Any]:
103
+ """Manages Attack configurations through standard CRUD operations.
104
+
105
+ This ViewSet allows clients to:
106
+ - Create new Attack configurations.
107
+ - List existing Attack configurations (with filtering based on user/org).
108
+ - Retrieve details of a specific Attack configuration.
109
+ - Update an existing Attack configuration.
110
+ - Delete an Attack configuration.
111
+
112
+ The actual execution of an attack based on these configurations, and the
113
+ management of run statuses or results, are handled by other parts of the API
114
+ (e.g., potentially a RunViewSet or similar).
115
+
116
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
117
+ Auth0 authentication is supported as fallback for web dashboard use.
118
+
119
+ Attributes:
120
+ queryset: The base queryset, retrieving all Attack objects with related
121
+ entities (agent, owner, organization) pre-fetched.
122
+ serializer_class: The serializer (`AttackSerializer`) used for data
123
+ conversion for Attack configurations.
124
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
125
+ permission_classes: List of permission enforcement classes.
126
+ parser_classes: List of parsers for request data (JSONParser).
127
+ lookup_field: The model field used for looking up individual instances ('id').
128
+
129
+ Args:
130
+ id (UUID):
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[Any]
138
+ """
139
+
140
+ kwargs = _get_kwargs(
141
+ id=id,
142
+ )
143
+
144
+ response = await client.get_async_httpx_client().request(**kwargs)
145
+
146
+ return _build_response(client=client, response=response)
@@ -0,0 +1,254 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, Optional, Union
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.paginated_attack_list import PaginatedAttackList
9
+ from ...types import UNSET, Response, Unset
10
+
11
+
12
+ def _get_kwargs(
13
+ *,
14
+ page: Union[Unset, int] = UNSET,
15
+ ) -> dict[str, Any]:
16
+ params: dict[str, Any] = {}
17
+
18
+ params["page"] = page
19
+
20
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
21
+
22
+ _kwargs: dict[str, Any] = {
23
+ "method": "get",
24
+ "url": "/attack",
25
+ "params": params,
26
+ }
27
+
28
+ return _kwargs
29
+
30
+
31
+ def _parse_response(
32
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
33
+ ) -> Optional[PaginatedAttackList]:
34
+ if response.status_code == 200:
35
+ response_200 = PaginatedAttackList.from_dict(response.json())
36
+
37
+ return response_200
38
+ if client.raise_on_unexpected_status:
39
+ raise errors.UnexpectedStatus(response.status_code, response.content)
40
+ else:
41
+ return None
42
+
43
+
44
+ def _build_response(
45
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
46
+ ) -> Response[PaginatedAttackList]:
47
+ return Response(
48
+ status_code=HTTPStatus(response.status_code),
49
+ content=response.content,
50
+ headers=response.headers,
51
+ parsed=_parse_response(client=client, response=response),
52
+ )
53
+
54
+
55
+ def sync_detailed(
56
+ *,
57
+ client: AuthenticatedClient,
58
+ page: Union[Unset, int] = UNSET,
59
+ ) -> Response[PaginatedAttackList]:
60
+ """Manages Attack configurations through standard CRUD operations.
61
+
62
+ This ViewSet allows clients to:
63
+ - Create new Attack configurations.
64
+ - List existing Attack configurations (with filtering based on user/org).
65
+ - Retrieve details of a specific Attack configuration.
66
+ - Update an existing Attack configuration.
67
+ - Delete an Attack configuration.
68
+
69
+ The actual execution of an attack based on these configurations, and the
70
+ management of run statuses or results, are handled by other parts of the API
71
+ (e.g., potentially a RunViewSet or similar).
72
+
73
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
74
+ Auth0 authentication is supported as fallback for web dashboard use.
75
+
76
+ Attributes:
77
+ queryset: The base queryset, retrieving all Attack objects with related
78
+ entities (agent, owner, organization) pre-fetched.
79
+ serializer_class: The serializer (`AttackSerializer`) used for data
80
+ conversion for Attack configurations.
81
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
82
+ permission_classes: List of permission enforcement classes.
83
+ parser_classes: List of parsers for request data (JSONParser).
84
+ lookup_field: The model field used for looking up individual instances ('id').
85
+
86
+ Args:
87
+ page (Union[Unset, int]):
88
+
89
+ Raises:
90
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
92
+
93
+ Returns:
94
+ Response[PaginatedAttackList]
95
+ """
96
+
97
+ kwargs = _get_kwargs(
98
+ page=page,
99
+ )
100
+
101
+ response = client.get_httpx_client().request(
102
+ **kwargs,
103
+ )
104
+
105
+ return _build_response(client=client, response=response)
106
+
107
+
108
+ def sync(
109
+ *,
110
+ client: AuthenticatedClient,
111
+ page: Union[Unset, int] = UNSET,
112
+ ) -> Optional[PaginatedAttackList]:
113
+ """Manages Attack configurations through standard CRUD operations.
114
+
115
+ This ViewSet allows clients to:
116
+ - Create new Attack configurations.
117
+ - List existing Attack configurations (with filtering based on user/org).
118
+ - Retrieve details of a specific Attack configuration.
119
+ - Update an existing Attack configuration.
120
+ - Delete an Attack configuration.
121
+
122
+ The actual execution of an attack based on these configurations, and the
123
+ management of run statuses or results, are handled by other parts of the API
124
+ (e.g., potentially a RunViewSet or similar).
125
+
126
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
127
+ Auth0 authentication is supported as fallback for web dashboard use.
128
+
129
+ Attributes:
130
+ queryset: The base queryset, retrieving all Attack objects with related
131
+ entities (agent, owner, organization) pre-fetched.
132
+ serializer_class: The serializer (`AttackSerializer`) used for data
133
+ conversion for Attack configurations.
134
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
135
+ permission_classes: List of permission enforcement classes.
136
+ parser_classes: List of parsers for request data (JSONParser).
137
+ lookup_field: The model field used for looking up individual instances ('id').
138
+
139
+ Args:
140
+ page (Union[Unset, int]):
141
+
142
+ Raises:
143
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
144
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
145
+
146
+ Returns:
147
+ PaginatedAttackList
148
+ """
149
+
150
+ return sync_detailed(
151
+ client=client,
152
+ page=page,
153
+ ).parsed
154
+
155
+
156
+ async def asyncio_detailed(
157
+ *,
158
+ client: AuthenticatedClient,
159
+ page: Union[Unset, int] = UNSET,
160
+ ) -> Response[PaginatedAttackList]:
161
+ """Manages Attack configurations through standard CRUD operations.
162
+
163
+ This ViewSet allows clients to:
164
+ - Create new Attack configurations.
165
+ - List existing Attack configurations (with filtering based on user/org).
166
+ - Retrieve details of a specific Attack configuration.
167
+ - Update an existing Attack configuration.
168
+ - Delete an Attack configuration.
169
+
170
+ The actual execution of an attack based on these configurations, and the
171
+ management of run statuses or results, are handled by other parts of the API
172
+ (e.g., potentially a RunViewSet or similar).
173
+
174
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
175
+ Auth0 authentication is supported as fallback for web dashboard use.
176
+
177
+ Attributes:
178
+ queryset: The base queryset, retrieving all Attack objects with related
179
+ entities (agent, owner, organization) pre-fetched.
180
+ serializer_class: The serializer (`AttackSerializer`) used for data
181
+ conversion for Attack configurations.
182
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
183
+ permission_classes: List of permission enforcement classes.
184
+ parser_classes: List of parsers for request data (JSONParser).
185
+ lookup_field: The model field used for looking up individual instances ('id').
186
+
187
+ Args:
188
+ page (Union[Unset, int]):
189
+
190
+ Raises:
191
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
192
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
193
+
194
+ Returns:
195
+ Response[PaginatedAttackList]
196
+ """
197
+
198
+ kwargs = _get_kwargs(
199
+ page=page,
200
+ )
201
+
202
+ response = await client.get_async_httpx_client().request(**kwargs)
203
+
204
+ return _build_response(client=client, response=response)
205
+
206
+
207
+ async def asyncio(
208
+ *,
209
+ client: AuthenticatedClient,
210
+ page: Union[Unset, int] = UNSET,
211
+ ) -> Optional[PaginatedAttackList]:
212
+ """Manages Attack configurations through standard CRUD operations.
213
+
214
+ This ViewSet allows clients to:
215
+ - Create new Attack configurations.
216
+ - List existing Attack configurations (with filtering based on user/org).
217
+ - Retrieve details of a specific Attack configuration.
218
+ - Update an existing Attack configuration.
219
+ - Delete an Attack configuration.
220
+
221
+ The actual execution of an attack based on these configurations, and the
222
+ management of run statuses or results, are handled by other parts of the API
223
+ (e.g., potentially a RunViewSet or similar).
224
+
225
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
226
+ Auth0 authentication is supported as fallback for web dashboard use.
227
+
228
+ Attributes:
229
+ queryset: The base queryset, retrieving all Attack objects with related
230
+ entities (agent, owner, organization) pre-fetched.
231
+ serializer_class: The serializer (`AttackSerializer`) used for data
232
+ conversion for Attack configurations.
233
+ authentication_classes: API Key (primary) + Auth0 (fallback) authentication.
234
+ permission_classes: List of permission enforcement classes.
235
+ parser_classes: List of parsers for request data (JSONParser).
236
+ lookup_field: The model field used for looking up individual instances ('id').
237
+
238
+ Args:
239
+ page (Union[Unset, int]):
240
+
241
+ Raises:
242
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
243
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
244
+
245
+ Returns:
246
+ PaginatedAttackList
247
+ """
248
+
249
+ return (
250
+ await asyncio_detailed(
251
+ client=client,
252
+ page=page,
253
+ )
254
+ ).parsed