hackagent 0.1.0__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 (117) hide show
  1. hackagent/__init__.py +23 -0
  2. hackagent/agent.py +193 -0
  3. hackagent/api/__init__.py +1 -0
  4. hackagent/api/agent/__init__.py +1 -0
  5. hackagent/api/agent/agent_create.py +340 -0
  6. hackagent/api/agent/agent_destroy.py +136 -0
  7. hackagent/api/agent/agent_list.py +234 -0
  8. hackagent/api/agent/agent_partial_update.py +354 -0
  9. hackagent/api/agent/agent_retrieve.py +227 -0
  10. hackagent/api/agent/agent_update.py +354 -0
  11. hackagent/api/attack/__init__.py +1 -0
  12. hackagent/api/attack/attack_create.py +264 -0
  13. hackagent/api/attack/attack_destroy.py +140 -0
  14. hackagent/api/attack/attack_list.py +242 -0
  15. hackagent/api/attack/attack_partial_update.py +278 -0
  16. hackagent/api/attack/attack_retrieve.py +235 -0
  17. hackagent/api/attack/attack_update.py +278 -0
  18. hackagent/api/key/__init__.py +1 -0
  19. hackagent/api/key/key_create.py +168 -0
  20. hackagent/api/key/key_destroy.py +97 -0
  21. hackagent/api/key/key_list.py +158 -0
  22. hackagent/api/key/key_retrieve.py +150 -0
  23. hackagent/api/prompt/__init__.py +1 -0
  24. hackagent/api/prompt/prompt_create.py +160 -0
  25. hackagent/api/prompt/prompt_destroy.py +98 -0
  26. hackagent/api/prompt/prompt_list.py +173 -0
  27. hackagent/api/prompt/prompt_partial_update.py +174 -0
  28. hackagent/api/prompt/prompt_retrieve.py +151 -0
  29. hackagent/api/prompt/prompt_update.py +174 -0
  30. hackagent/api/result/__init__.py +1 -0
  31. hackagent/api/result/result_create.py +160 -0
  32. hackagent/api/result/result_destroy.py +98 -0
  33. hackagent/api/result/result_list.py +233 -0
  34. hackagent/api/result/result_partial_update.py +178 -0
  35. hackagent/api/result/result_retrieve.py +151 -0
  36. hackagent/api/result/result_trace_create.py +178 -0
  37. hackagent/api/result/result_update.py +174 -0
  38. hackagent/api/run/__init__.py +1 -0
  39. hackagent/api/run/run_create.py +172 -0
  40. hackagent/api/run/run_destroy.py +104 -0
  41. hackagent/api/run/run_list.py +260 -0
  42. hackagent/api/run/run_partial_update.py +186 -0
  43. hackagent/api/run/run_result_create.py +178 -0
  44. hackagent/api/run/run_retrieve.py +163 -0
  45. hackagent/api/run/run_run_tests_create.py +172 -0
  46. hackagent/api/run/run_update.py +186 -0
  47. hackagent/attacks/AdvPrefix/README.md +7 -0
  48. hackagent/attacks/AdvPrefix/__init__.py +0 -0
  49. hackagent/attacks/AdvPrefix/completer.py +438 -0
  50. hackagent/attacks/AdvPrefix/config.py +59 -0
  51. hackagent/attacks/AdvPrefix/preprocessing.py +521 -0
  52. hackagent/attacks/AdvPrefix/scorer.py +259 -0
  53. hackagent/attacks/AdvPrefix/scorer_parser.py +498 -0
  54. hackagent/attacks/AdvPrefix/selector.py +246 -0
  55. hackagent/attacks/AdvPrefix/step1_generate.py +324 -0
  56. hackagent/attacks/AdvPrefix/step4_compute_ce.py +293 -0
  57. hackagent/attacks/AdvPrefix/step6_get_completions.py +387 -0
  58. hackagent/attacks/AdvPrefix/step7_evaluate_responses.py +289 -0
  59. hackagent/attacks/AdvPrefix/step8_aggregate_evaluations.py +177 -0
  60. hackagent/attacks/AdvPrefix/step9_select_prefixes.py +59 -0
  61. hackagent/attacks/AdvPrefix/utils.py +192 -0
  62. hackagent/attacks/__init__.py +6 -0
  63. hackagent/attacks/advprefix.py +1136 -0
  64. hackagent/attacks/base.py +50 -0
  65. hackagent/attacks/strategies.py +539 -0
  66. hackagent/branding.py +143 -0
  67. hackagent/client.py +328 -0
  68. hackagent/errors.py +31 -0
  69. hackagent/logger.py +67 -0
  70. hackagent/models/__init__.py +71 -0
  71. hackagent/models/agent.py +240 -0
  72. hackagent/models/agent_request.py +169 -0
  73. hackagent/models/agent_type_enum.py +12 -0
  74. hackagent/models/attack.py +154 -0
  75. hackagent/models/attack_request.py +82 -0
  76. hackagent/models/evaluation_status_enum.py +14 -0
  77. hackagent/models/organization_minimal.py +68 -0
  78. hackagent/models/paginated_agent_list.py +123 -0
  79. hackagent/models/paginated_attack_list.py +123 -0
  80. hackagent/models/paginated_prompt_list.py +123 -0
  81. hackagent/models/paginated_result_list.py +123 -0
  82. hackagent/models/paginated_run_list.py +123 -0
  83. hackagent/models/paginated_user_api_key_list.py +123 -0
  84. hackagent/models/patched_agent_request.py +176 -0
  85. hackagent/models/patched_attack_request.py +92 -0
  86. hackagent/models/patched_prompt_request.py +162 -0
  87. hackagent/models/patched_result_request.py +237 -0
  88. hackagent/models/patched_run_request.py +138 -0
  89. hackagent/models/prompt.py +226 -0
  90. hackagent/models/prompt_request.py +155 -0
  91. hackagent/models/result.py +294 -0
  92. hackagent/models/result_list_evaluation_status.py +14 -0
  93. hackagent/models/result_request.py +232 -0
  94. hackagent/models/run.py +233 -0
  95. hackagent/models/run_list_status.py +12 -0
  96. hackagent/models/run_request.py +133 -0
  97. hackagent/models/status_enum.py +12 -0
  98. hackagent/models/step_type_enum.py +14 -0
  99. hackagent/models/trace.py +121 -0
  100. hackagent/models/trace_request.py +94 -0
  101. hackagent/models/user_api_key.py +201 -0
  102. hackagent/models/user_api_key_request.py +73 -0
  103. hackagent/models/user_profile_minimal.py +76 -0
  104. hackagent/py.typed +1 -0
  105. hackagent/router/__init__.py +11 -0
  106. hackagent/router/adapters/__init__.py +5 -0
  107. hackagent/router/adapters/google_adk.py +658 -0
  108. hackagent/router/adapters/litellm_adapter.py +290 -0
  109. hackagent/router/base.py +48 -0
  110. hackagent/router/router.py +753 -0
  111. hackagent/types.py +46 -0
  112. hackagent/utils.py +61 -0
  113. hackagent/vulnerabilities/__init__.py +0 -0
  114. hackagent-0.1.0.dist-info/LICENSE +202 -0
  115. hackagent-0.1.0.dist-info/METADATA +173 -0
  116. hackagent-0.1.0.dist-info/RECORD +117 -0
  117. hackagent-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,354 @@
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.agent import Agent
10
+ from ...models.agent_request import AgentRequest
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ id: UUID,
16
+ *,
17
+ body: AgentRequest,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ _kwargs: dict[str, Any] = {
22
+ "method": "put",
23
+ "url": f"/api/agent/{id}",
24
+ }
25
+
26
+ _body = body.to_dict()
27
+
28
+ _kwargs["json"] = _body
29
+ headers["Content-Type"] = "application/json"
30
+
31
+ _kwargs["headers"] = headers
32
+ return _kwargs
33
+
34
+
35
+ def _parse_response(
36
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
37
+ ) -> Optional[Agent]:
38
+ if response.status_code == 200:
39
+ response_200 = Agent.from_dict(response.json())
40
+
41
+ return response_200
42
+ if client.raise_on_unexpected_status:
43
+ raise errors.UnexpectedStatus(response.status_code, response.content)
44
+ else:
45
+ return None
46
+
47
+
48
+ def _build_response(
49
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
50
+ ) -> Response[Agent]:
51
+ return Response(
52
+ status_code=HTTPStatus(response.status_code),
53
+ content=response.content,
54
+ headers=response.headers,
55
+ parsed=_parse_response(client=client, response=response),
56
+ )
57
+
58
+
59
+ def sync_detailed(
60
+ id: UUID,
61
+ *,
62
+ client: AuthenticatedClient,
63
+ body: AgentRequest,
64
+ ) -> Response[Agent]:
65
+ """Provides CRUD operations for Agent instances.
66
+
67
+ This ViewSet manages Agent records, ensuring that users can only interact
68
+ with agents based on their permissions and organizational context.
69
+ It filters agent listings for users and handles the logic for creating
70
+ agents, including associating them with the correct organization and owner.
71
+
72
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
73
+ Permissions are based on IsAuthenticated, with queryset filtering providing
74
+ row-level access control.
75
+
76
+ Class Attributes:
77
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
78
+ This is further filtered by `get_queryset()`.
79
+ serializer_class (AgentSerializer): The serializer used for validating and
80
+ deserializing input, and for serializing output.
81
+ authentication_classes (list): List of authentication classes to use.
82
+ permission_classes (list): List of permission classes to use.
83
+ parser_classes (list): List of parser classes for handling request data.
84
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
85
+
86
+ Args:
87
+ id (UUID):
88
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
89
+ creating
90
+ or updating Agent instances.
91
+
92
+ This serializer provides a comprehensive representation of an Agent,
93
+ including its type, endpoint, and nested details for related 'organization'
94
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
95
+ for write operations.
96
+
97
+ Attributes:
98
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
99
+ serializer for the agent's organization. Displays minimal details.
100
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
101
+ for the agent's owner's user profile. Displays minimal details.
102
+ Can be null if the agent has no owner or the owner has no profile.
103
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
104
+ Uses the choices defined in the Agent model's AgentType enum.
105
+
106
+ Meta:
107
+ model (Agent): The model class that this serializer works with.
108
+ fields (tuple): The fields to include in the serialized output.
109
+ Includes standard Agent fields like 'endpoint', 'type',
110
+ and the read-only nested details.
111
+ read_only_fields (tuple): Fields that are read-only and cannot be
112
+ set during create/update operations through this serializer.
113
+ This includes 'id', 'created_at', 'updated_at', and the
114
+ nested detail fields.
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
+ Response[Agent]
122
+ """
123
+
124
+ kwargs = _get_kwargs(
125
+ id=id,
126
+ body=body,
127
+ )
128
+
129
+ response = client.get_httpx_client().request(
130
+ **kwargs,
131
+ )
132
+
133
+ return _build_response(client=client, response=response)
134
+
135
+
136
+ def sync(
137
+ id: UUID,
138
+ *,
139
+ client: AuthenticatedClient,
140
+ body: AgentRequest,
141
+ ) -> Optional[Agent]:
142
+ """Provides CRUD operations for Agent instances.
143
+
144
+ This ViewSet manages Agent records, ensuring that users can only interact
145
+ with agents based on their permissions and organizational context.
146
+ It filters agent listings for users and handles the logic for creating
147
+ agents, including associating them with the correct organization and owner.
148
+
149
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
150
+ Permissions are based on IsAuthenticated, with queryset filtering providing
151
+ row-level access control.
152
+
153
+ Class Attributes:
154
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
155
+ This is further filtered by `get_queryset()`.
156
+ serializer_class (AgentSerializer): The serializer used for validating and
157
+ deserializing input, and for serializing output.
158
+ authentication_classes (list): List of authentication classes to use.
159
+ permission_classes (list): List of permission classes to use.
160
+ parser_classes (list): List of parser classes for handling request data.
161
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
162
+
163
+ Args:
164
+ id (UUID):
165
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
166
+ creating
167
+ or updating Agent instances.
168
+
169
+ This serializer provides a comprehensive representation of an Agent,
170
+ including its type, endpoint, and nested details for related 'organization'
171
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
172
+ for write operations.
173
+
174
+ Attributes:
175
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
176
+ serializer for the agent's organization. Displays minimal details.
177
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
178
+ for the agent's owner's user profile. Displays minimal details.
179
+ Can be null if the agent has no owner or the owner has no profile.
180
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
181
+ Uses the choices defined in the Agent model's AgentType enum.
182
+
183
+ Meta:
184
+ model (Agent): The model class that this serializer works with.
185
+ fields (tuple): The fields to include in the serialized output.
186
+ Includes standard Agent fields like 'endpoint', 'type',
187
+ and the read-only nested details.
188
+ read_only_fields (tuple): Fields that are read-only and cannot be
189
+ set during create/update operations through this serializer.
190
+ This includes 'id', 'created_at', 'updated_at', and the
191
+ nested detail fields.
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ Agent
199
+ """
200
+
201
+ return sync_detailed(
202
+ id=id,
203
+ client=client,
204
+ body=body,
205
+ ).parsed
206
+
207
+
208
+ async def asyncio_detailed(
209
+ id: UUID,
210
+ *,
211
+ client: AuthenticatedClient,
212
+ body: AgentRequest,
213
+ ) -> Response[Agent]:
214
+ """Provides CRUD operations for Agent instances.
215
+
216
+ This ViewSet manages Agent records, ensuring that users can only interact
217
+ with agents based on their permissions and organizational context.
218
+ It filters agent listings for users and handles the logic for creating
219
+ agents, including associating them with the correct organization and owner.
220
+
221
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
222
+ Permissions are based on IsAuthenticated, with queryset filtering providing
223
+ row-level access control.
224
+
225
+ Class Attributes:
226
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
227
+ This is further filtered by `get_queryset()`.
228
+ serializer_class (AgentSerializer): The serializer used for validating and
229
+ deserializing input, and for serializing output.
230
+ authentication_classes (list): List of authentication classes to use.
231
+ permission_classes (list): List of permission classes to use.
232
+ parser_classes (list): List of parser classes for handling request data.
233
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
234
+
235
+ Args:
236
+ id (UUID):
237
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
238
+ creating
239
+ or updating Agent instances.
240
+
241
+ This serializer provides a comprehensive representation of an Agent,
242
+ including its type, endpoint, and nested details for related 'organization'
243
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
244
+ for write operations.
245
+
246
+ Attributes:
247
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
248
+ serializer for the agent's organization. Displays minimal details.
249
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
250
+ for the agent's owner's user profile. Displays minimal details.
251
+ Can be null if the agent has no owner or the owner has no profile.
252
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
253
+ Uses the choices defined in the Agent model's AgentType enum.
254
+
255
+ Meta:
256
+ model (Agent): The model class that this serializer works with.
257
+ fields (tuple): The fields to include in the serialized output.
258
+ Includes standard Agent fields like 'endpoint', 'type',
259
+ and the read-only nested details.
260
+ read_only_fields (tuple): Fields that are read-only and cannot be
261
+ set during create/update operations through this serializer.
262
+ This includes 'id', 'created_at', 'updated_at', and the
263
+ nested detail fields.
264
+
265
+ Raises:
266
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
267
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
268
+
269
+ Returns:
270
+ Response[Agent]
271
+ """
272
+
273
+ kwargs = _get_kwargs(
274
+ id=id,
275
+ body=body,
276
+ )
277
+
278
+ response = await client.get_async_httpx_client().request(**kwargs)
279
+
280
+ return _build_response(client=client, response=response)
281
+
282
+
283
+ async def asyncio(
284
+ id: UUID,
285
+ *,
286
+ client: AuthenticatedClient,
287
+ body: AgentRequest,
288
+ ) -> Optional[Agent]:
289
+ """Provides CRUD operations for Agent instances.
290
+
291
+ This ViewSet manages Agent records, ensuring that users can only interact
292
+ with agents based on their permissions and organizational context.
293
+ It filters agent listings for users and handles the logic for creating
294
+ agents, including associating them with the correct organization and owner.
295
+
296
+ Authentication uses UserAPIKeyAuthentication and PrivyAuthentication.
297
+ Permissions are based on IsAuthenticated, with queryset filtering providing
298
+ row-level access control.
299
+
300
+ Class Attributes:
301
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
302
+ This is further filtered by `get_queryset()`.
303
+ serializer_class (AgentSerializer): The serializer used for validating and
304
+ deserializing input, and for serializing output.
305
+ authentication_classes (list): List of authentication classes to use.
306
+ permission_classes (list): List of permission classes to use.
307
+ parser_classes (list): List of parser classes for handling request data.
308
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
309
+
310
+ Args:
311
+ id (UUID):
312
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
313
+ creating
314
+ or updating Agent instances.
315
+
316
+ This serializer provides a comprehensive representation of an Agent,
317
+ including its type, endpoint, and nested details for related 'organization'
318
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
319
+ for write operations.
320
+
321
+ Attributes:
322
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
323
+ serializer for the agent's organization. Displays minimal details.
324
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
325
+ for the agent's owner's user profile. Displays minimal details.
326
+ Can be null if the agent has no owner or the owner has no profile.
327
+ type (CharField): The type of the agent (e.g., GENERIC_ADK, OPENAI_SDK).
328
+ Uses the choices defined in the Agent model's AgentType enum.
329
+
330
+ Meta:
331
+ model (Agent): The model class that this serializer works with.
332
+ fields (tuple): The fields to include in the serialized output.
333
+ Includes standard Agent fields like 'endpoint', 'type',
334
+ and the read-only nested details.
335
+ read_only_fields (tuple): Fields that are read-only and cannot be
336
+ set during create/update operations through this serializer.
337
+ This includes 'id', 'created_at', 'updated_at', and the
338
+ nested detail fields.
339
+
340
+ Raises:
341
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
342
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
343
+
344
+ Returns:
345
+ Agent
346
+ """
347
+
348
+ return (
349
+ await asyncio_detailed(
350
+ id=id,
351
+ client=client,
352
+ body=body,
353
+ )
354
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,264 @@
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": "/api/attack",
22
+ }
23
+
24
+ _body = body.to_dict()
25
+
26
+ _kwargs["json"] = _body
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
35
+ ) -> Optional[Attack]:
36
+ if response.status_code == 201:
37
+ response_201 = Attack.from_dict(response.json())
38
+
39
+ return response_201
40
+ if client.raise_on_unexpected_status:
41
+ raise errors.UnexpectedStatus(response.status_code, response.content)
42
+ else:
43
+ return None
44
+
45
+
46
+ def _build_response(
47
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
48
+ ) -> Response[Attack]:
49
+ return Response(
50
+ status_code=HTTPStatus(response.status_code),
51
+ content=response.content,
52
+ headers=response.headers,
53
+ parsed=_parse_response(client=client, response=response),
54
+ )
55
+
56
+
57
+ def sync_detailed(
58
+ *,
59
+ client: AuthenticatedClient,
60
+ body: AttackRequest,
61
+ ) -> Response[Attack]:
62
+ """Manages Attack configurations through standard CRUD operations.
63
+
64
+ This ViewSet allows clients to:
65
+ - Create new Attack configurations.
66
+ - List existing Attack configurations (with filtering based on user/org).
67
+ - Retrieve details of a specific Attack configuration.
68
+ - Update an existing Attack configuration.
69
+ - Delete an Attack configuration.
70
+
71
+ The actual execution of an attack based on these configurations, and the
72
+ management of run statuses or results, are handled by other parts of the API
73
+ (e.g., potentially a RunViewSet or similar).
74
+
75
+ Attributes:
76
+ queryset: The base queryset, retrieving all Attack objects with related
77
+ entities (agent, owner, organization) pre-fetched.
78
+ serializer_class: The serializer (`AttackSerializer`) used for data
79
+ conversion for Attack configurations.
80
+ authentication_classes: List of authentication backends used.
81
+ permission_classes: List of permission enforcement classes.
82
+ parser_classes: List of parsers for request data (JSONParser).
83
+ lookup_field: The model field used for looking up individual instances ('id').
84
+
85
+ Args:
86
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
87
+ configuration.
88
+
89
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
90
+ for API requests and responses. It includes read-only fields for related
91
+ object names (like agent_name, owner_username) for convenience in API outputs.
92
+
93
+ Raises:
94
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
95
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
96
+
97
+ Returns:
98
+ Response[Attack]
99
+ """
100
+
101
+ kwargs = _get_kwargs(
102
+ body=body,
103
+ )
104
+
105
+ response = client.get_httpx_client().request(
106
+ **kwargs,
107
+ )
108
+
109
+ return _build_response(client=client, response=response)
110
+
111
+
112
+ def sync(
113
+ *,
114
+ client: AuthenticatedClient,
115
+ body: AttackRequest,
116
+ ) -> Optional[Attack]:
117
+ """Manages Attack configurations through standard CRUD operations.
118
+
119
+ This ViewSet allows clients to:
120
+ - Create new Attack configurations.
121
+ - List existing Attack configurations (with filtering based on user/org).
122
+ - Retrieve details of a specific Attack configuration.
123
+ - Update an existing Attack configuration.
124
+ - Delete an Attack configuration.
125
+
126
+ The actual execution of an attack based on these configurations, and the
127
+ management of run statuses or results, are handled by other parts of the API
128
+ (e.g., potentially a RunViewSet or similar).
129
+
130
+ Attributes:
131
+ queryset: The base queryset, retrieving all Attack objects with related
132
+ entities (agent, owner, organization) pre-fetched.
133
+ serializer_class: The serializer (`AttackSerializer`) used for data
134
+ conversion for Attack configurations.
135
+ authentication_classes: List of authentication backends used.
136
+ permission_classes: List of permission enforcement classes.
137
+ parser_classes: List of parsers for request data (JSONParser).
138
+ lookup_field: The model field used for looking up individual instances ('id').
139
+
140
+ Args:
141
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
142
+ configuration.
143
+
144
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
145
+ for API requests and responses. It includes read-only fields for related
146
+ object names (like agent_name, owner_username) for convenience in API outputs.
147
+
148
+ Raises:
149
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
150
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
151
+
152
+ Returns:
153
+ Attack
154
+ """
155
+
156
+ return sync_detailed(
157
+ client=client,
158
+ body=body,
159
+ ).parsed
160
+
161
+
162
+ async def asyncio_detailed(
163
+ *,
164
+ client: AuthenticatedClient,
165
+ body: AttackRequest,
166
+ ) -> Response[Attack]:
167
+ """Manages Attack configurations through standard CRUD operations.
168
+
169
+ This ViewSet allows clients to:
170
+ - Create new Attack configurations.
171
+ - List existing Attack configurations (with filtering based on user/org).
172
+ - Retrieve details of a specific Attack configuration.
173
+ - Update an existing Attack configuration.
174
+ - Delete an Attack configuration.
175
+
176
+ The actual execution of an attack based on these configurations, and the
177
+ management of run statuses or results, are handled by other parts of the API
178
+ (e.g., potentially a RunViewSet or similar).
179
+
180
+ Attributes:
181
+ queryset: The base queryset, retrieving all Attack objects with related
182
+ entities (agent, owner, organization) pre-fetched.
183
+ serializer_class: The serializer (`AttackSerializer`) used for data
184
+ conversion for Attack configurations.
185
+ authentication_classes: List of authentication backends used.
186
+ permission_classes: List of permission enforcement classes.
187
+ parser_classes: List of parsers for request data (JSONParser).
188
+ lookup_field: The model field used for looking up individual instances ('id').
189
+
190
+ Args:
191
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
192
+ configuration.
193
+
194
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
195
+ for API requests and responses. It includes read-only fields for related
196
+ object names (like agent_name, owner_username) for convenience in API outputs.
197
+
198
+ Raises:
199
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
200
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
201
+
202
+ Returns:
203
+ Response[Attack]
204
+ """
205
+
206
+ kwargs = _get_kwargs(
207
+ body=body,
208
+ )
209
+
210
+ response = await client.get_async_httpx_client().request(**kwargs)
211
+
212
+ return _build_response(client=client, response=response)
213
+
214
+
215
+ async def asyncio(
216
+ *,
217
+ client: AuthenticatedClient,
218
+ body: AttackRequest,
219
+ ) -> Optional[Attack]:
220
+ """Manages Attack configurations through standard CRUD operations.
221
+
222
+ This ViewSet allows clients to:
223
+ - Create new Attack configurations.
224
+ - List existing Attack configurations (with filtering based on user/org).
225
+ - Retrieve details of a specific Attack configuration.
226
+ - Update an existing Attack configuration.
227
+ - Delete an Attack configuration.
228
+
229
+ The actual execution of an attack based on these configurations, and the
230
+ management of run statuses or results, are handled by other parts of the API
231
+ (e.g., potentially a RunViewSet or similar).
232
+
233
+ Attributes:
234
+ queryset: The base queryset, retrieving all Attack objects with related
235
+ entities (agent, owner, organization) pre-fetched.
236
+ serializer_class: The serializer (`AttackSerializer`) used for data
237
+ conversion for Attack configurations.
238
+ authentication_classes: List of authentication backends used.
239
+ permission_classes: List of permission enforcement classes.
240
+ parser_classes: List of parsers for request data (JSONParser).
241
+ lookup_field: The model field used for looking up individual instances ('id').
242
+
243
+ Args:
244
+ body (AttackRequest): Serializer for the Attack model, which represents an Attack
245
+ configuration.
246
+
247
+ Handles the conversion of Attack configuration instances to JSON (and vice-versa)
248
+ for API requests and responses. It includes read-only fields for related
249
+ object names (like agent_name, owner_username) for convenience in API outputs.
250
+
251
+ Raises:
252
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
253
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
254
+
255
+ Returns:
256
+ Attack
257
+ """
258
+
259
+ return (
260
+ await asyncio_detailed(
261
+ client=client,
262
+ body=body,
263
+ )
264
+ ).parsed