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,361 @@
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"/agent/{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[Agent]:
37
+ if response.status_code == 200:
38
+ response_200 = Agent.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[Agent]:
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: AgentRequest,
63
+ ) -> Response[Agent]:
64
+ """Provides CRUD operations for Agent instances.
65
+
66
+ This ViewSet manages Agent records, ensuring that users can only interact
67
+ with agents based on their permissions and organizational context.
68
+ It filters agent listings for users and handles the logic for creating
69
+ agents, including associating them with the correct organization and owner.
70
+
71
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
72
+ Auth0 authentication is supported as fallback for web dashboard use.
73
+
74
+ Permissions are based on IsAuthenticated, with queryset filtering providing
75
+ row-level access control.
76
+
77
+ Class Attributes:
78
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
79
+ This is further filtered by `get_queryset()`.
80
+ serializer_class (AgentSerializer): The serializer used for validating and
81
+ deserializing input, and for serializing output.
82
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
83
+ permission_classes (list): List of permission classes to use.
84
+ parser_classes (list): List of parser classes for handling request data.
85
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
86
+
87
+ Args:
88
+ id (UUID):
89
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
90
+ creating
91
+ or updating Agent instances.
92
+
93
+ This serializer provides a comprehensive representation of an Agent,
94
+ including its type, endpoint, and nested details for related 'organization'
95
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
96
+ for write operations.
97
+
98
+ Attributes:
99
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
100
+ serializer for the agent's organization. Displays minimal details.
101
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
102
+ for the agent's owner's user profile. Displays minimal details.
103
+ Can be null if the agent has no owner or the owner has no profile.
104
+ agent_type (CharField): The type of the agent as a string
105
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
106
+
107
+ Meta:
108
+ model (Agent): The model class that this serializer works with.
109
+ fields (tuple): The fields to include in the serialized output.
110
+ Includes standard Agent fields like 'endpoint', 'type',
111
+ and the read-only nested details.
112
+ read_only_fields (tuple): Fields that are read-only and cannot be
113
+ set during create/update operations through this serializer.
114
+ This includes 'id', 'created_at', 'updated_at', and the
115
+ nested detail fields.
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[Agent]
123
+ """
124
+
125
+ kwargs = _get_kwargs(
126
+ id=id,
127
+ body=body,
128
+ )
129
+
130
+ response = client.get_httpx_client().request(
131
+ **kwargs,
132
+ )
133
+
134
+ return _build_response(client=client, response=response)
135
+
136
+
137
+ def sync(
138
+ id: UUID,
139
+ *,
140
+ client: AuthenticatedClient,
141
+ body: AgentRequest,
142
+ ) -> Optional[Agent]:
143
+ """Provides CRUD operations for Agent instances.
144
+
145
+ This ViewSet manages Agent records, ensuring that users can only interact
146
+ with agents based on their permissions and organizational context.
147
+ It filters agent listings for users and handles the logic for creating
148
+ agents, including associating them with the correct organization and owner.
149
+
150
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
151
+ Auth0 authentication is supported as fallback for web dashboard use.
152
+
153
+ Permissions are based on IsAuthenticated, with queryset filtering providing
154
+ row-level access control.
155
+
156
+ Class Attributes:
157
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
158
+ This is further filtered by `get_queryset()`.
159
+ serializer_class (AgentSerializer): The serializer used for validating and
160
+ deserializing input, and for serializing output.
161
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
162
+ permission_classes (list): List of permission classes to use.
163
+ parser_classes (list): List of parser classes for handling request data.
164
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
165
+
166
+ Args:
167
+ id (UUID):
168
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
169
+ creating
170
+ or updating Agent instances.
171
+
172
+ This serializer provides a comprehensive representation of an Agent,
173
+ including its type, endpoint, and nested details for related 'organization'
174
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
175
+ for write operations.
176
+
177
+ Attributes:
178
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
179
+ serializer for the agent's organization. Displays minimal details.
180
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
181
+ for the agent's owner's user profile. Displays minimal details.
182
+ Can be null if the agent has no owner or the owner has no profile.
183
+ agent_type (CharField): The type of the agent as a string
184
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
185
+
186
+ Meta:
187
+ model (Agent): The model class that this serializer works with.
188
+ fields (tuple): The fields to include in the serialized output.
189
+ Includes standard Agent fields like 'endpoint', 'type',
190
+ and the read-only nested details.
191
+ read_only_fields (tuple): Fields that are read-only and cannot be
192
+ set during create/update operations through this serializer.
193
+ This includes 'id', 'created_at', 'updated_at', and the
194
+ nested detail fields.
195
+
196
+ Raises:
197
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
198
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
199
+
200
+ Returns:
201
+ Agent
202
+ """
203
+
204
+ return sync_detailed(
205
+ id=id,
206
+ client=client,
207
+ body=body,
208
+ ).parsed
209
+
210
+
211
+ async def asyncio_detailed(
212
+ id: UUID,
213
+ *,
214
+ client: AuthenticatedClient,
215
+ body: AgentRequest,
216
+ ) -> Response[Agent]:
217
+ """Provides CRUD operations for Agent instances.
218
+
219
+ This ViewSet manages Agent records, ensuring that users can only interact
220
+ with agents based on their permissions and organizational context.
221
+ It filters agent listings for users and handles the logic for creating
222
+ agents, including associating them with the correct organization and owner.
223
+
224
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
225
+ Auth0 authentication is supported as fallback for web dashboard use.
226
+
227
+ Permissions are based on IsAuthenticated, with queryset filtering providing
228
+ row-level access control.
229
+
230
+ Class Attributes:
231
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
232
+ This is further filtered by `get_queryset()`.
233
+ serializer_class (AgentSerializer): The serializer used for validating and
234
+ deserializing input, and for serializing output.
235
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
236
+ permission_classes (list): List of permission classes to use.
237
+ parser_classes (list): List of parser classes for handling request data.
238
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
239
+
240
+ Args:
241
+ id (UUID):
242
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
243
+ creating
244
+ or updating Agent instances.
245
+
246
+ This serializer provides a comprehensive representation of an Agent,
247
+ including its type, endpoint, and nested details for related 'organization'
248
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
249
+ for write operations.
250
+
251
+ Attributes:
252
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
253
+ serializer for the agent's organization. Displays minimal details.
254
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
255
+ for the agent's owner's user profile. Displays minimal details.
256
+ Can be null if the agent has no owner or the owner has no profile.
257
+ agent_type (CharField): The type of the agent as a string
258
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
259
+
260
+ Meta:
261
+ model (Agent): The model class that this serializer works with.
262
+ fields (tuple): The fields to include in the serialized output.
263
+ Includes standard Agent fields like 'endpoint', 'type',
264
+ and the read-only nested details.
265
+ read_only_fields (tuple): Fields that are read-only and cannot be
266
+ set during create/update operations through this serializer.
267
+ This includes 'id', 'created_at', 'updated_at', and the
268
+ nested detail fields.
269
+
270
+ Raises:
271
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
272
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
273
+
274
+ Returns:
275
+ Response[Agent]
276
+ """
277
+
278
+ kwargs = _get_kwargs(
279
+ id=id,
280
+ body=body,
281
+ )
282
+
283
+ response = await client.get_async_httpx_client().request(**kwargs)
284
+
285
+ return _build_response(client=client, response=response)
286
+
287
+
288
+ async def asyncio(
289
+ id: UUID,
290
+ *,
291
+ client: AuthenticatedClient,
292
+ body: AgentRequest,
293
+ ) -> Optional[Agent]:
294
+ """Provides CRUD operations for Agent instances.
295
+
296
+ This ViewSet manages Agent records, ensuring that users can only interact
297
+ with agents based on their permissions and organizational context.
298
+ It filters agent listings for users and handles the logic for creating
299
+ agents, including associating them with the correct organization and owner.
300
+
301
+ SDK-primary endpoint - API Key authentication is recommended for programmatic access.
302
+ Auth0 authentication is supported as fallback for web dashboard use.
303
+
304
+ Permissions are based on IsAuthenticated, with queryset filtering providing
305
+ row-level access control.
306
+
307
+ Class Attributes:
308
+ queryset (QuerySet): The default queryset for listing agents, initially all agents.
309
+ This is further filtered by `get_queryset()`.
310
+ serializer_class (AgentSerializer): The serializer used for validating and
311
+ deserializing input, and for serializing output.
312
+ authentication_classes (list): API Key (primary) + Auth0 (fallback) authentication.
313
+ permission_classes (list): List of permission classes to use.
314
+ parser_classes (list): List of parser classes for handling request data.
315
+ lookup_field (str): The model field used for looking up individual instances (UUID 'id').
316
+
317
+ Args:
318
+ id (UUID):
319
+ body (AgentRequest): Serializes Agent model instances to JSON and validates data for
320
+ creating
321
+ or updating Agent instances.
322
+
323
+ This serializer provides a comprehensive representation of an Agent,
324
+ including its type, endpoint, and nested details for related 'organization'
325
+ and 'owner' for read operations, while allowing 'organization' and 'owner' IDs
326
+ for write operations.
327
+
328
+ Attributes:
329
+ organization_detail (OrganizationMinimalSerializer): Read-only nested
330
+ serializer for the agent's organization. Displays minimal details.
331
+ owner_detail (UserProfileMinimalSerializer): Read-only nested serializer
332
+ for the agent's owner's user profile. Displays minimal details.
333
+ Can be null if the agent has no owner or the owner has no profile.
334
+ agent_type (CharField): The type of the agent as a string
335
+ (e.g., LITELLM, OPENAI_SDK, GOOGLE_ADK).
336
+
337
+ Meta:
338
+ model (Agent): The model class that this serializer works with.
339
+ fields (tuple): The fields to include in the serialized output.
340
+ Includes standard Agent fields like 'endpoint', 'type',
341
+ and the read-only nested details.
342
+ read_only_fields (tuple): Fields that are read-only and cannot be
343
+ set during create/update operations through this serializer.
344
+ This includes 'id', 'created_at', 'updated_at', and the
345
+ nested detail fields.
346
+
347
+ Raises:
348
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
349
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
350
+
351
+ Returns:
352
+ Agent
353
+ """
354
+
355
+ return (
356
+ await asyncio_detailed(
357
+ id=id,
358
+ client=client,
359
+ body=body,
360
+ )
361
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,170 @@
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_api_token_log_list import PaginatedAPITokenLogList
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": "/apilogs",
25
+ "params": params,
26
+ }
27
+
28
+ return _kwargs
29
+
30
+
31
+ def _parse_response(
32
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
33
+ ) -> Optional[PaginatedAPITokenLogList]:
34
+ if response.status_code == 200:
35
+ response_200 = PaginatedAPITokenLogList.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[PaginatedAPITokenLogList]:
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[PaginatedAPITokenLogList]:
60
+ """Provides read-only access to APITokenLog entries for the user's organization.
61
+
62
+ Web-only endpoint - requires Auth0 authentication.
63
+ Usage logs are intended for web dashboard monitoring.
64
+
65
+ Args:
66
+ page (Union[Unset, int]):
67
+
68
+ Raises:
69
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
70
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
71
+
72
+ Returns:
73
+ Response[PaginatedAPITokenLogList]
74
+ """
75
+
76
+ kwargs = _get_kwargs(
77
+ page=page,
78
+ )
79
+
80
+ response = client.get_httpx_client().request(
81
+ **kwargs,
82
+ )
83
+
84
+ return _build_response(client=client, response=response)
85
+
86
+
87
+ def sync(
88
+ *,
89
+ client: AuthenticatedClient,
90
+ page: Union[Unset, int] = UNSET,
91
+ ) -> Optional[PaginatedAPITokenLogList]:
92
+ """Provides read-only access to APITokenLog entries for the user's organization.
93
+
94
+ Web-only endpoint - requires Auth0 authentication.
95
+ Usage logs are intended for web dashboard monitoring.
96
+
97
+ Args:
98
+ page (Union[Unset, int]):
99
+
100
+ Raises:
101
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
102
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
103
+
104
+ Returns:
105
+ PaginatedAPITokenLogList
106
+ """
107
+
108
+ return sync_detailed(
109
+ client=client,
110
+ page=page,
111
+ ).parsed
112
+
113
+
114
+ async def asyncio_detailed(
115
+ *,
116
+ client: AuthenticatedClient,
117
+ page: Union[Unset, int] = UNSET,
118
+ ) -> Response[PaginatedAPITokenLogList]:
119
+ """Provides read-only access to APITokenLog entries for the user's organization.
120
+
121
+ Web-only endpoint - requires Auth0 authentication.
122
+ Usage logs are intended for web dashboard monitoring.
123
+
124
+ Args:
125
+ page (Union[Unset, int]):
126
+
127
+ Raises:
128
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
129
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
130
+
131
+ Returns:
132
+ Response[PaginatedAPITokenLogList]
133
+ """
134
+
135
+ kwargs = _get_kwargs(
136
+ page=page,
137
+ )
138
+
139
+ response = await client.get_async_httpx_client().request(**kwargs)
140
+
141
+ return _build_response(client=client, response=response)
142
+
143
+
144
+ async def asyncio(
145
+ *,
146
+ client: AuthenticatedClient,
147
+ page: Union[Unset, int] = UNSET,
148
+ ) -> Optional[PaginatedAPITokenLogList]:
149
+ """Provides read-only access to APITokenLog entries for the user's organization.
150
+
151
+ Web-only endpoint - requires Auth0 authentication.
152
+ Usage logs are intended for web dashboard monitoring.
153
+
154
+ Args:
155
+ page (Union[Unset, int]):
156
+
157
+ Raises:
158
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
159
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
160
+
161
+ Returns:
162
+ PaginatedAPITokenLogList
163
+ """
164
+
165
+ return (
166
+ await asyncio_detailed(
167
+ client=client,
168
+ page=page,
169
+ )
170
+ ).parsed
@@ -0,0 +1,162 @@
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.api_token_log import APITokenLog
9
+ from ...types import Response
10
+
11
+
12
+ def _get_kwargs(
13
+ id: int,
14
+ ) -> dict[str, Any]:
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": f"/apilogs/{id}",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
25
+ ) -> Optional[APITokenLog]:
26
+ if response.status_code == 200:
27
+ response_200 = APITokenLog.from_dict(response.json())
28
+
29
+ return response_200
30
+ if client.raise_on_unexpected_status:
31
+ raise errors.UnexpectedStatus(response.status_code, response.content)
32
+ else:
33
+ return None
34
+
35
+
36
+ def _build_response(
37
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
38
+ ) -> Response[APITokenLog]:
39
+ return Response(
40
+ status_code=HTTPStatus(response.status_code),
41
+ content=response.content,
42
+ headers=response.headers,
43
+ parsed=_parse_response(client=client, response=response),
44
+ )
45
+
46
+
47
+ def sync_detailed(
48
+ id: int,
49
+ *,
50
+ client: AuthenticatedClient,
51
+ ) -> Response[APITokenLog]:
52
+ """Provides read-only access to APITokenLog entries for the user's organization.
53
+
54
+ Web-only endpoint - requires Auth0 authentication.
55
+ Usage logs are intended for web dashboard monitoring.
56
+
57
+ Args:
58
+ id (int):
59
+
60
+ Raises:
61
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
62
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
63
+
64
+ Returns:
65
+ Response[APITokenLog]
66
+ """
67
+
68
+ kwargs = _get_kwargs(
69
+ id=id,
70
+ )
71
+
72
+ response = client.get_httpx_client().request(
73
+ **kwargs,
74
+ )
75
+
76
+ return _build_response(client=client, response=response)
77
+
78
+
79
+ def sync(
80
+ id: int,
81
+ *,
82
+ client: AuthenticatedClient,
83
+ ) -> Optional[APITokenLog]:
84
+ """Provides read-only access to APITokenLog entries for the user's organization.
85
+
86
+ Web-only endpoint - requires Auth0 authentication.
87
+ Usage logs are intended for web dashboard monitoring.
88
+
89
+ Args:
90
+ id (int):
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ APITokenLog
98
+ """
99
+
100
+ return sync_detailed(
101
+ id=id,
102
+ client=client,
103
+ ).parsed
104
+
105
+
106
+ async def asyncio_detailed(
107
+ id: int,
108
+ *,
109
+ client: AuthenticatedClient,
110
+ ) -> Response[APITokenLog]:
111
+ """Provides read-only access to APITokenLog entries for the user's organization.
112
+
113
+ Web-only endpoint - requires Auth0 authentication.
114
+ Usage logs are intended for web dashboard monitoring.
115
+
116
+ Args:
117
+ id (int):
118
+
119
+ Raises:
120
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
121
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
122
+
123
+ Returns:
124
+ Response[APITokenLog]
125
+ """
126
+
127
+ kwargs = _get_kwargs(
128
+ id=id,
129
+ )
130
+
131
+ response = await client.get_async_httpx_client().request(**kwargs)
132
+
133
+ return _build_response(client=client, response=response)
134
+
135
+
136
+ async def asyncio(
137
+ id: int,
138
+ *,
139
+ client: AuthenticatedClient,
140
+ ) -> Optional[APITokenLog]:
141
+ """Provides read-only access to APITokenLog entries for the user's organization.
142
+
143
+ Web-only endpoint - requires Auth0 authentication.
144
+ Usage logs are intended for web dashboard monitoring.
145
+
146
+ Args:
147
+ id (int):
148
+
149
+ Raises:
150
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
151
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
152
+
153
+ Returns:
154
+ APITokenLog
155
+ """
156
+
157
+ return (
158
+ await asyncio_detailed(
159
+ id=id,
160
+ client=client,
161
+ )
162
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""