knowledge2 0.4.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 (139) hide show
  1. knowledge2-0.4.0.dist-info/METADATA +556 -0
  2. knowledge2-0.4.0.dist-info/RECORD +139 -0
  3. knowledge2-0.4.0.dist-info/WHEEL +5 -0
  4. knowledge2-0.4.0.dist-info/top_level.txt +1 -0
  5. sdk/__init__.py +70 -0
  6. sdk/_async_base.py +525 -0
  7. sdk/_async_paging.py +57 -0
  8. sdk/_base.py +541 -0
  9. sdk/_logging.py +41 -0
  10. sdk/_paging.py +73 -0
  11. sdk/_preview.py +70 -0
  12. sdk/_raw_response.py +25 -0
  13. sdk/_request_options.py +51 -0
  14. sdk/_transport.py +144 -0
  15. sdk/_validation.py +25 -0
  16. sdk/_validation_response.py +36 -0
  17. sdk/_version.py +3 -0
  18. sdk/async_client.py +320 -0
  19. sdk/async_resources/__init__.py +45 -0
  20. sdk/async_resources/_mixin_base.py +42 -0
  21. sdk/async_resources/a2a.py +230 -0
  22. sdk/async_resources/agents.py +489 -0
  23. sdk/async_resources/audit.py +145 -0
  24. sdk/async_resources/auth.py +133 -0
  25. sdk/async_resources/console.py +409 -0
  26. sdk/async_resources/corpora.py +276 -0
  27. sdk/async_resources/deployments.py +106 -0
  28. sdk/async_resources/documents.py +592 -0
  29. sdk/async_resources/feeds.py +248 -0
  30. sdk/async_resources/indexes.py +208 -0
  31. sdk/async_resources/jobs.py +165 -0
  32. sdk/async_resources/metadata.py +48 -0
  33. sdk/async_resources/models.py +102 -0
  34. sdk/async_resources/onboarding.py +538 -0
  35. sdk/async_resources/orgs.py +37 -0
  36. sdk/async_resources/pipelines.py +523 -0
  37. sdk/async_resources/projects.py +90 -0
  38. sdk/async_resources/search.py +262 -0
  39. sdk/async_resources/training.py +357 -0
  40. sdk/async_resources/usage.py +91 -0
  41. sdk/client.py +417 -0
  42. sdk/config.py +182 -0
  43. sdk/errors.py +178 -0
  44. sdk/examples/auth_factory.py +34 -0
  45. sdk/examples/batch_operations.py +57 -0
  46. sdk/examples/document_upload.py +56 -0
  47. sdk/examples/e2e_lifecycle.py +213 -0
  48. sdk/examples/error_handling.py +61 -0
  49. sdk/examples/pagination.py +64 -0
  50. sdk/examples/quickstart.py +36 -0
  51. sdk/examples/request_options.py +44 -0
  52. sdk/examples/search.py +64 -0
  53. sdk/integrations/__init__.py +57 -0
  54. sdk/integrations/_client.py +101 -0
  55. sdk/integrations/langchain/__init__.py +6 -0
  56. sdk/integrations/langchain/retriever.py +166 -0
  57. sdk/integrations/langchain/tools.py +108 -0
  58. sdk/integrations/llamaindex/__init__.py +11 -0
  59. sdk/integrations/llamaindex/filters.py +78 -0
  60. sdk/integrations/llamaindex/retriever.py +162 -0
  61. sdk/integrations/llamaindex/tools.py +109 -0
  62. sdk/integrations/llamaindex/vector_store.py +320 -0
  63. sdk/models/__init__.py +18 -0
  64. sdk/models/_base.py +24 -0
  65. sdk/models/_registry.py +457 -0
  66. sdk/models/a2a.py +92 -0
  67. sdk/models/agents.py +109 -0
  68. sdk/models/audit.py +28 -0
  69. sdk/models/auth.py +49 -0
  70. sdk/models/chunks.py +20 -0
  71. sdk/models/common.py +14 -0
  72. sdk/models/console.py +103 -0
  73. sdk/models/corpora.py +48 -0
  74. sdk/models/deployments.py +13 -0
  75. sdk/models/documents.py +126 -0
  76. sdk/models/embeddings.py +24 -0
  77. sdk/models/evaluation.py +17 -0
  78. sdk/models/feedback.py +9 -0
  79. sdk/models/feeds.py +57 -0
  80. sdk/models/indexes.py +36 -0
  81. sdk/models/jobs.py +52 -0
  82. sdk/models/models.py +26 -0
  83. sdk/models/onboarding.py +323 -0
  84. sdk/models/orgs.py +11 -0
  85. sdk/models/pipelines.py +147 -0
  86. sdk/models/projects.py +19 -0
  87. sdk/models/search.py +149 -0
  88. sdk/models/training.py +57 -0
  89. sdk/models/usage.py +39 -0
  90. sdk/namespaces.py +386 -0
  91. sdk/py.typed +0 -0
  92. sdk/resources/__init__.py +45 -0
  93. sdk/resources/_mixin_base.py +40 -0
  94. sdk/resources/a2a.py +230 -0
  95. sdk/resources/agents.py +487 -0
  96. sdk/resources/audit.py +144 -0
  97. sdk/resources/auth.py +138 -0
  98. sdk/resources/console.py +411 -0
  99. sdk/resources/corpora.py +269 -0
  100. sdk/resources/deployments.py +105 -0
  101. sdk/resources/documents.py +597 -0
  102. sdk/resources/feeds.py +246 -0
  103. sdk/resources/indexes.py +210 -0
  104. sdk/resources/jobs.py +164 -0
  105. sdk/resources/metadata.py +53 -0
  106. sdk/resources/models.py +99 -0
  107. sdk/resources/onboarding.py +542 -0
  108. sdk/resources/orgs.py +35 -0
  109. sdk/resources/pipeline_builder.py +257 -0
  110. sdk/resources/pipelines.py +520 -0
  111. sdk/resources/projects.py +87 -0
  112. sdk/resources/search.py +277 -0
  113. sdk/resources/training.py +358 -0
  114. sdk/resources/usage.py +92 -0
  115. sdk/types/__init__.py +366 -0
  116. sdk/types/a2a.py +88 -0
  117. sdk/types/agents.py +133 -0
  118. sdk/types/audit.py +26 -0
  119. sdk/types/auth.py +45 -0
  120. sdk/types/chunks.py +18 -0
  121. sdk/types/common.py +10 -0
  122. sdk/types/console.py +99 -0
  123. sdk/types/corpora.py +42 -0
  124. sdk/types/deployments.py +11 -0
  125. sdk/types/documents.py +104 -0
  126. sdk/types/embeddings.py +22 -0
  127. sdk/types/evaluation.py +15 -0
  128. sdk/types/feedback.py +7 -0
  129. sdk/types/feeds.py +61 -0
  130. sdk/types/indexes.py +30 -0
  131. sdk/types/jobs.py +50 -0
  132. sdk/types/models.py +22 -0
  133. sdk/types/onboarding.py +395 -0
  134. sdk/types/orgs.py +9 -0
  135. sdk/types/pipelines.py +177 -0
  136. sdk/types/projects.py +14 -0
  137. sdk/types/search.py +116 -0
  138. sdk/types/training.py +55 -0
  139. sdk/types/usage.py +37 -0
@@ -0,0 +1,133 @@
1
+ """Async authentication resource mixin for the Knowledge2 SDK."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import warnings
6
+ from typing import Any
7
+
8
+ from sdk._request_options import RequestOptions
9
+ from sdk._validation import require_str
10
+ from sdk.async_resources._mixin_base import AsyncRequesterMixin
11
+ from sdk.types import (
12
+ ApiKeyCreateResponse,
13
+ ApiKeyListResponse,
14
+ ApiKeyRevokeResponse,
15
+ ApiKeyRotateResponse,
16
+ WhoAmIResponse,
17
+ )
18
+
19
+
20
+ class AsyncAuthMixin(AsyncRequesterMixin):
21
+ async def create_api_key(
22
+ self,
23
+ org_id: str,
24
+ name: str,
25
+ scopes: dict[str, Any] | None = None,
26
+ request_options: RequestOptions | None = None,
27
+ ) -> ApiKeyCreateResponse:
28
+ """Create a new API key for the given organisation.
29
+
30
+ Args:
31
+ org_id: Organisation that will own the key.
32
+ name: Human-readable name for the key.
33
+ scopes: Optional scope restrictions for the key.
34
+
35
+ Returns:
36
+ The newly created API key, including the raw secret (shown only once).
37
+
38
+ Raises:
39
+ Knowledge2Error: If the API request fails.
40
+ """
41
+ org_id = require_str(org_id, "org_id")
42
+ payload: dict[str, Any] = {"org_id": org_id, "name": name}
43
+ if scopes is not None:
44
+ payload["scopes"] = scopes
45
+ data = await self._request(
46
+ "POST", "/v1/auth/api-keys", json=payload, request_options=request_options
47
+ )
48
+ return self._maybe_validate(data, "ApiKeyCreateResponse")
49
+
50
+ async def list_api_keys(
51
+ self, *, request_options: RequestOptions | None = None
52
+ ) -> ApiKeyListResponse:
53
+ """List all API keys visible to the current credentials.
54
+
55
+ Returns:
56
+ A list of API key metadata objects.
57
+
58
+ Raises:
59
+ Knowledge2Error: If the API request fails.
60
+ """
61
+ data = await self._request("GET", "/v1/auth/api-keys", request_options=request_options)
62
+ return self._maybe_validate(data, "ApiKeyListResponse")
63
+
64
+ async def revoke_api_key(
65
+ self,
66
+ key_id: str,
67
+ request_options: RequestOptions | None = None,
68
+ ) -> ApiKeyRevokeResponse:
69
+ """Revoke an API key so it can no longer be used for authentication.
70
+
71
+ Args:
72
+ key_id: Unique identifier of the API key to revoke.
73
+
74
+ Returns:
75
+ Confirmation of the revocation.
76
+
77
+ Raises:
78
+ NotFoundError: If the key does not exist.
79
+ Knowledge2Error: If the API request fails.
80
+ """
81
+ key_id = require_str(key_id, "key_id")
82
+ data = await self._request(
83
+ "POST", f"/v1/auth/api-keys/{key_id}:revoke", request_options=request_options
84
+ )
85
+ return self._maybe_validate(data, "ApiKeyRevokeResponse")
86
+
87
+ async def rotate_api_key(
88
+ self,
89
+ key_id: str,
90
+ request_options: RequestOptions | None = None,
91
+ ) -> ApiKeyRotateResponse:
92
+ """Rotate an API key, generating a new secret and invalidating the old one.
93
+
94
+ Args:
95
+ key_id: Unique identifier of the API key to rotate.
96
+
97
+ Returns:
98
+ The rotated key with the new raw secret (shown only once).
99
+
100
+ Raises:
101
+ NotFoundError: If the key does not exist.
102
+ Knowledge2Error: If the API request fails.
103
+ """
104
+ key_id = require_str(key_id, "key_id")
105
+ data = await self._request(
106
+ "POST", f"/v1/auth/api-keys/{key_id}:rotate", request_options=request_options
107
+ )
108
+ return self._maybe_validate(data, "ApiKeyRotateResponse")
109
+
110
+ async def get_whoami(self, *, request_options: RequestOptions | None = None) -> WhoAmIResponse:
111
+ """Return information about the current API key.
112
+
113
+ Returns:
114
+ A dict containing ``org_id``, ``key_id``, ``name``,
115
+ ``scopes``, and other metadata for the authenticated key.
116
+ """
117
+ data = await self._request("GET", "/v1/auth/whoami", request_options=request_options)
118
+ return self._maybe_validate(data, "WhoAmIResponse")
119
+
120
+ async def fetch_whoami(
121
+ self, *, request_options: RequestOptions | None = None
122
+ ) -> WhoAmIResponse:
123
+ """Return information about the current API key.
124
+
125
+ .. deprecated::
126
+ Use :meth:`get_whoami` instead.
127
+ """
128
+ warnings.warn(
129
+ "fetch_whoami() is deprecated, use get_whoami() instead",
130
+ DeprecationWarning,
131
+ stacklevel=2,
132
+ )
133
+ return await self.get_whoami()
@@ -0,0 +1,409 @@
1
+ """Async console resource mixin for the Knowledge2 SDK."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from sdk._request_options import RequestOptions
8
+ from sdk._validation import require_str
9
+ from sdk.async_resources._mixin_base import AsyncRequesterMixin
10
+ from sdk.types import (
11
+ ApiKeyCreateResponse,
12
+ ApiKeyListResponse,
13
+ ApiKeyRevokeResponse,
14
+ ConsoleBootstrapResponse,
15
+ ConsoleMeResponse,
16
+ ConsoleOrgResponse,
17
+ ConsoleProjectItem,
18
+ ConsoleProjectListResponse,
19
+ ConsoleSummaryResponse,
20
+ InviteAcceptResponse,
21
+ InviteCreateResponse,
22
+ InviteListResponse,
23
+ MemberRemoveResponse,
24
+ MemberUpdateResponse,
25
+ TeamListResponse,
26
+ )
27
+
28
+
29
+ class AsyncConsoleMixin(AsyncRequesterMixin):
30
+ async def console_me(
31
+ self,
32
+ *,
33
+ project_id: str | None = None,
34
+ request_options: RequestOptions | None = None,
35
+ ) -> ConsoleMeResponse:
36
+ """Retrieve the current console user profile.
37
+
38
+ Args:
39
+ project_id: Optional project context to include in the response.
40
+
41
+ Returns:
42
+ The authenticated user's console profile information.
43
+
44
+ Raises:
45
+ Knowledge2Error: If the API request fails.
46
+ """
47
+ params: dict[str, Any] = {}
48
+ if project_id is not None:
49
+ params["project_id"] = project_id
50
+ data = await self._request(
51
+ "GET", "/v1/console/me", params=params or None, request_options=request_options
52
+ )
53
+ return self._maybe_validate(data, "ConsoleMeResponse")
54
+
55
+ async def console_bootstrap(
56
+ self,
57
+ *,
58
+ org_name: str | None = None,
59
+ project_name: str | None = None,
60
+ email: str | None = None,
61
+ name: str | None = None,
62
+ request_options: RequestOptions | None = None,
63
+ ) -> ConsoleBootstrapResponse:
64
+ """Bootstrap a new console session, creating org/project if needed.
65
+
66
+ Args:
67
+ org_name: Name for the organisation to create or associate.
68
+ project_name: Name for the default project to create.
69
+ email: Contact email for the new organisation.
70
+ name: Display name for the user.
71
+
72
+ Returns:
73
+ Bootstrap result containing created or existing org/project details.
74
+
75
+ Raises:
76
+ Knowledge2Error: If the API request fails.
77
+ """
78
+ payload: dict[str, Any] = {}
79
+ if org_name is not None:
80
+ payload["org_name"] = org_name
81
+ if project_name is not None:
82
+ payload["project_name"] = project_name
83
+ if email is not None:
84
+ payload["email"] = email
85
+ if name is not None:
86
+ payload["name"] = name
87
+ data = await self._request(
88
+ "POST", "/v1/console/bootstrap", json=payload, request_options=request_options
89
+ )
90
+ return self._maybe_validate(data, "ConsoleBootstrapResponse")
91
+
92
+ async def console_summary(
93
+ self, *, request_options: RequestOptions | None = None
94
+ ) -> ConsoleSummaryResponse:
95
+ """Retrieve a high-level summary of the console (corpora, jobs, etc.).
96
+
97
+ Returns:
98
+ Aggregated summary statistics for the current organisation.
99
+
100
+ Raises:
101
+ Knowledge2Error: If the API request fails.
102
+ """
103
+ data = await self._request("GET", "/v1/console/summary", request_options=request_options)
104
+ return self._maybe_validate(data, "ConsoleSummaryResponse")
105
+
106
+ async def console_projects(
107
+ self, *, request_options: RequestOptions | None = None
108
+ ) -> ConsoleProjectListResponse:
109
+ """List all projects visible in the console.
110
+
111
+ Returns:
112
+ A list of console project summaries.
113
+
114
+ Raises:
115
+ Knowledge2Error: If the API request fails.
116
+ """
117
+ data = await self._request("GET", "/v1/console/projects", request_options=request_options)
118
+ return self._maybe_validate(data, "ConsoleProjectListResponse")
119
+
120
+ async def console_get_project(
121
+ self,
122
+ project_id: str,
123
+ request_options: RequestOptions | None = None,
124
+ ) -> ConsoleProjectItem:
125
+ """Retrieve details of a single console project.
126
+
127
+ Args:
128
+ project_id: Unique identifier of the project.
129
+
130
+ Returns:
131
+ Detailed project information.
132
+
133
+ Raises:
134
+ NotFoundError: If the project does not exist.
135
+ Knowledge2Error: If the API request fails.
136
+ """
137
+ project_id = require_str(project_id, "project_id")
138
+ data = await self._request(
139
+ "GET", f"/v1/console/projects/{project_id}", request_options=request_options
140
+ )
141
+ return self._maybe_validate(data, "ConsoleProjectItem")
142
+
143
+ async def console_update_project(
144
+ self,
145
+ project_id: str,
146
+ *,
147
+ name: str | None = None,
148
+ graph_rag_policy: dict[str, Any] | None = None,
149
+ request_options: RequestOptions | None = None,
150
+ ) -> ConsoleProjectItem:
151
+ """Update a console project's settings.
152
+
153
+ Args:
154
+ project_id: Unique identifier of the project to update.
155
+ name: New display name for the project.
156
+ graph_rag_policy: Updated GraphRAG policy configuration.
157
+
158
+ Returns:
159
+ The updated project information.
160
+
161
+ Raises:
162
+ NotFoundError: If the project does not exist.
163
+ Knowledge2Error: If the API request fails.
164
+ """
165
+ project_id = require_str(project_id, "project_id")
166
+ payload: dict[str, Any] = {}
167
+ if name is not None:
168
+ payload["name"] = name
169
+ if graph_rag_policy is not None:
170
+ payload["graph_rag_policy"] = graph_rag_policy
171
+ data = await self._request(
172
+ "PATCH",
173
+ f"/v1/console/projects/{project_id}",
174
+ json=payload,
175
+ request_options=request_options,
176
+ )
177
+ return self._maybe_validate(data, "ConsoleProjectItem")
178
+
179
+ async def console_get_org(
180
+ self, *, request_options: RequestOptions | None = None
181
+ ) -> ConsoleOrgResponse:
182
+ """Retrieve the current organisation's console profile.
183
+
184
+ Returns:
185
+ Organisation details including name and settings.
186
+
187
+ Raises:
188
+ Knowledge2Error: If the API request fails.
189
+ """
190
+ data = await self._request("GET", "/v1/console/org", request_options=request_options)
191
+ return self._maybe_validate(data, "ConsoleOrgResponse")
192
+
193
+ async def console_update_org(
194
+ self,
195
+ *,
196
+ name: str | None = None,
197
+ contact_email: str | None = None,
198
+ request_options: RequestOptions | None = None,
199
+ ) -> ConsoleOrgResponse:
200
+ """Update the current organisation's settings.
201
+
202
+ Args:
203
+ name: New display name for the organisation.
204
+ contact_email: New contact email address.
205
+
206
+ Returns:
207
+ The updated organisation details.
208
+
209
+ Raises:
210
+ Knowledge2Error: If the API request fails.
211
+ """
212
+ payload: dict[str, Any] = {}
213
+ if name is not None:
214
+ payload["name"] = name
215
+ if contact_email is not None:
216
+ payload["contact_email"] = contact_email
217
+ data = await self._request(
218
+ "PATCH", "/v1/console/org", json=payload, request_options=request_options
219
+ )
220
+ return self._maybe_validate(data, "ConsoleOrgResponse")
221
+
222
+ async def console_list_team(
223
+ self, *, request_options: RequestOptions | None = None
224
+ ) -> TeamListResponse:
225
+ """List all team members in the current organisation.
226
+
227
+ Returns:
228
+ A list of team member records with roles.
229
+
230
+ Raises:
231
+ Knowledge2Error: If the API request fails.
232
+ """
233
+ data = await self._request("GET", "/v1/console/team", request_options=request_options)
234
+ return self._maybe_validate(data, "TeamListResponse")
235
+
236
+ async def console_list_invites(
237
+ self, *, request_options: RequestOptions | None = None
238
+ ) -> InviteListResponse:
239
+ """List pending team invitations for the current organisation.
240
+
241
+ Returns:
242
+ A list of pending invitation records.
243
+
244
+ Raises:
245
+ Knowledge2Error: If the API request fails.
246
+ """
247
+ data = await self._request("GET", "/v1/console/invites", request_options=request_options)
248
+ return self._maybe_validate(data, "InviteListResponse")
249
+
250
+ async def console_create_invite(
251
+ self,
252
+ email: str,
253
+ role: str = "member",
254
+ request_options: RequestOptions | None = None,
255
+ ) -> InviteCreateResponse:
256
+ """Invite a new member to the current organisation.
257
+
258
+ Args:
259
+ email: Email address of the person to invite.
260
+ role: Role to assign (e.g. ``"member"``, ``"admin"``).
261
+
262
+ Returns:
263
+ The created invitation record.
264
+
265
+ Raises:
266
+ ConflictError: If an invitation for this email already exists.
267
+ Knowledge2Error: If the API request fails.
268
+ """
269
+ payload = {"email": email, "role": role}
270
+ data = await self._request(
271
+ "POST", "/v1/console/invites", json=payload, request_options=request_options
272
+ )
273
+ return self._maybe_validate(data, "InviteCreateResponse")
274
+
275
+ async def console_accept_invite(
276
+ self,
277
+ token: str,
278
+ request_options: RequestOptions | None = None,
279
+ ) -> InviteAcceptResponse:
280
+ """Accept a pending team invitation.
281
+
282
+ Args:
283
+ token: The invitation token received via email.
284
+
285
+ Returns:
286
+ Confirmation of the accepted invitation.
287
+
288
+ Raises:
289
+ NotFoundError: If the invitation token is invalid or expired.
290
+ Knowledge2Error: If the API request fails.
291
+ """
292
+ token = require_str(token, "token")
293
+ data = await self._request(
294
+ "POST", f"/v1/console/invites/{token}/accept", request_options=request_options
295
+ )
296
+ return self._maybe_validate(data, "InviteAcceptResponse")
297
+
298
+ async def console_update_member_role(
299
+ self,
300
+ membership_id: str,
301
+ role: str,
302
+ request_options: RequestOptions | None = None,
303
+ ) -> MemberUpdateResponse:
304
+ """Update a team member's role within the organisation.
305
+
306
+ Args:
307
+ membership_id: Unique identifier of the membership to update.
308
+ role: New role to assign (e.g. ``"member"``, ``"admin"``).
309
+
310
+ Returns:
311
+ The updated membership record.
312
+
313
+ Raises:
314
+ NotFoundError: If the membership does not exist.
315
+ Knowledge2Error: If the API request fails.
316
+ """
317
+ membership_id = require_str(membership_id, "membership_id")
318
+ payload = {"role": role}
319
+ data = await self._request(
320
+ "PATCH",
321
+ f"/v1/console/team/{membership_id}",
322
+ json=payload,
323
+ request_options=request_options,
324
+ )
325
+ return self._maybe_validate(data, "MemberUpdateResponse")
326
+
327
+ async def console_remove_member(
328
+ self,
329
+ membership_id: str,
330
+ request_options: RequestOptions | None = None,
331
+ ) -> MemberRemoveResponse:
332
+ """Remove a member from the organisation.
333
+
334
+ Args:
335
+ membership_id: Unique identifier of the membership to remove.
336
+
337
+ Returns:
338
+ Confirmation of the member removal.
339
+
340
+ Raises:
341
+ NotFoundError: If the membership does not exist.
342
+ Knowledge2Error: If the API request fails.
343
+ """
344
+ membership_id = require_str(membership_id, "membership_id")
345
+ data = await self._request(
346
+ "DELETE", f"/v1/console/team/{membership_id}", request_options=request_options
347
+ )
348
+ return self._maybe_validate(data, "MemberRemoveResponse")
349
+
350
+ async def console_list_api_keys(
351
+ self, *, request_options: RequestOptions | None = None
352
+ ) -> ApiKeyListResponse:
353
+ """List API keys managed through the console.
354
+
355
+ Returns:
356
+ A list of API key metadata objects.
357
+
358
+ Raises:
359
+ Knowledge2Error: If the API request fails.
360
+ """
361
+ data = await self._request("GET", "/v1/console/api-keys", request_options=request_options)
362
+ return self._maybe_validate(data, "ApiKeyListResponse")
363
+
364
+ async def console_create_api_key(
365
+ self,
366
+ name: str,
367
+ access: str = "retrieval",
368
+ request_options: RequestOptions | None = None,
369
+ ) -> ApiKeyCreateResponse:
370
+ """Create a new API key through the console.
371
+
372
+ Args:
373
+ name: Human-readable name for the key.
374
+ access: Access level for the key (e.g. ``"retrieval"``, ``"admin"``).
375
+
376
+ Returns:
377
+ The newly created API key, including the raw secret (shown only once).
378
+
379
+ Raises:
380
+ Knowledge2Error: If the API request fails.
381
+ """
382
+ payload = {"name": name, "access": access}
383
+ data = await self._request(
384
+ "POST", "/v1/console/api-keys", json=payload, request_options=request_options
385
+ )
386
+ return self._maybe_validate(data, "ApiKeyCreateResponse")
387
+
388
+ async def console_revoke_api_key(
389
+ self,
390
+ key_id: str,
391
+ request_options: RequestOptions | None = None,
392
+ ) -> ApiKeyRevokeResponse:
393
+ """Revoke an API key through the console.
394
+
395
+ Args:
396
+ key_id: Unique identifier of the API key to revoke.
397
+
398
+ Returns:
399
+ Confirmation of the revocation.
400
+
401
+ Raises:
402
+ NotFoundError: If the key does not exist.
403
+ Knowledge2Error: If the API request fails.
404
+ """
405
+ key_id = require_str(key_id, "key_id")
406
+ data = await self._request(
407
+ "POST", f"/v1/console/api-keys/{key_id}:revoke", request_options=request_options
408
+ )
409
+ return self._maybe_validate(data, "ApiKeyRevokeResponse")