universal-mcp 0.1.7rc1__py3-none-any.whl → 0.1.8__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 (61) hide show
  1. universal_mcp/__init__.py +0 -2
  2. universal_mcp/analytics.py +75 -0
  3. universal_mcp/applications/ahrefs/README.md +76 -0
  4. universal_mcp/applications/ahrefs/app.py +2291 -0
  5. universal_mcp/applications/application.py +95 -5
  6. universal_mcp/applications/calendly/README.md +78 -0
  7. universal_mcp/applications/calendly/__init__.py +0 -0
  8. universal_mcp/applications/calendly/app.py +1195 -0
  9. universal_mcp/applications/coda/README.md +133 -0
  10. universal_mcp/applications/coda/__init__.py +0 -0
  11. universal_mcp/applications/coda/app.py +3671 -0
  12. universal_mcp/applications/e2b/app.py +14 -28
  13. universal_mcp/applications/figma/README.md +74 -0
  14. universal_mcp/applications/figma/__init__.py +0 -0
  15. universal_mcp/applications/figma/app.py +1261 -0
  16. universal_mcp/applications/firecrawl/app.py +38 -35
  17. universal_mcp/applications/github/app.py +127 -85
  18. universal_mcp/applications/google_calendar/app.py +62 -138
  19. universal_mcp/applications/google_docs/app.py +47 -52
  20. universal_mcp/applications/google_drive/app.py +119 -113
  21. universal_mcp/applications/google_mail/app.py +124 -50
  22. universal_mcp/applications/google_sheet/app.py +89 -91
  23. universal_mcp/applications/markitdown/app.py +9 -8
  24. universal_mcp/applications/notion/app.py +254 -134
  25. universal_mcp/applications/perplexity/app.py +13 -41
  26. universal_mcp/applications/reddit/app.py +94 -85
  27. universal_mcp/applications/resend/app.py +12 -13
  28. universal_mcp/applications/{serp → serpapi}/app.py +14 -25
  29. universal_mcp/applications/tavily/app.py +11 -18
  30. universal_mcp/applications/wrike/README.md +71 -0
  31. universal_mcp/applications/wrike/__init__.py +0 -0
  32. universal_mcp/applications/wrike/app.py +1372 -0
  33. universal_mcp/applications/youtube/README.md +82 -0
  34. universal_mcp/applications/youtube/__init__.py +0 -0
  35. universal_mcp/applications/youtube/app.py +1428 -0
  36. universal_mcp/applications/zenquotes/app.py +12 -2
  37. universal_mcp/exceptions.py +9 -2
  38. universal_mcp/integrations/__init__.py +24 -1
  39. universal_mcp/integrations/agentr.py +27 -4
  40. universal_mcp/integrations/integration.py +146 -32
  41. universal_mcp/logger.py +3 -56
  42. universal_mcp/servers/__init__.py +6 -14
  43. universal_mcp/servers/server.py +201 -146
  44. universal_mcp/stores/__init__.py +7 -2
  45. universal_mcp/stores/store.py +103 -40
  46. universal_mcp/tools/__init__.py +3 -0
  47. universal_mcp/tools/adapters.py +43 -0
  48. universal_mcp/tools/func_metadata.py +213 -0
  49. universal_mcp/tools/tools.py +342 -0
  50. universal_mcp/utils/docgen.py +325 -119
  51. universal_mcp/utils/docstring_parser.py +179 -0
  52. universal_mcp/utils/dump_app_tools.py +33 -23
  53. universal_mcp/utils/installation.py +201 -10
  54. universal_mcp/utils/openapi.py +229 -46
  55. {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/METADATA +9 -5
  56. universal_mcp-0.1.8.dist-info/RECORD +81 -0
  57. universal_mcp-0.1.7rc1.dist-info/RECORD +0 -58
  58. /universal_mcp/{utils/bridge.py → applications/ahrefs/__init__.py} +0 -0
  59. /universal_mcp/applications/{serp → serpapi}/README.md +0 -0
  60. {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/WHEEL +0 -0
  61. {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,3671 @@
1
+ from typing import Any
2
+
3
+ from universal_mcp.applications import APIApplication
4
+ from universal_mcp.integrations import Integration
5
+
6
+
7
+ class CodaApp(APIApplication):
8
+ def __init__(self, integration: Integration = None, **kwargs) -> None:
9
+ super().__init__(name="coda", integration=integration, **kwargs)
10
+ self.base_url = "https://coda.io/apis/v1"
11
+
12
+ def list_categories(
13
+ self,
14
+ ) -> dict[str, Any]:
15
+ """
16
+ Retrieves a dictionary of available categories from the API endpoint.
17
+
18
+ Args:
19
+ None: This function takes no arguments
20
+
21
+ Returns:
22
+ dict: A dictionary representing the categories data from the server response.
23
+
24
+ Raises:
25
+ HTTPError: If the HTTP request to the categories endpoint fails or returns an error status code.
26
+
27
+ Tags:
28
+ list, categories, api, important
29
+ """
30
+ url = f"{self.base_url}/categories"
31
+ query_params = {}
32
+ response = self._get(url, params=query_params)
33
+ response.raise_for_status()
34
+ return response.json()
35
+
36
+ def list_docs(
37
+ self,
38
+ isOwner=None,
39
+ isPublished=None,
40
+ query=None,
41
+ sourceDoc=None,
42
+ isStarred=None,
43
+ inGallery=None,
44
+ workspaceId=None,
45
+ folderId=None,
46
+ limit=None,
47
+ pageToken=None,
48
+ ) -> dict[str, Any]:
49
+ """
50
+ Retrieves a list of documents based on specified filtering and pagination criteria.
51
+
52
+ Args:
53
+ isOwner: Optional[bool]. If True, filters to documents owned by the current user.
54
+ isPublished: Optional[bool]. If True, filters to only published documents.
55
+ query: Optional[str]. Text search query to filter documents by title or content.
56
+ sourceDoc: Optional[str]. ID of the source document to filter derivative documents.
57
+ isStarred: Optional[bool]. If True, filters to starred documents.
58
+ inGallery: Optional[bool]. If True, filters to documents shown in the gallery.
59
+ workspaceId: Optional[str]. Filters documents belonging to a specific workspace.
60
+ folderId: Optional[str]. Filters documents within a particular folder.
61
+ limit: Optional[int]. Maximum number of documents to return.
62
+ pageToken: Optional[str]. Token for pagination to retrieve the next page of results.
63
+
64
+ Returns:
65
+ dict[str, Any]: A dictionary containing the list of documents and pagination metadata.
66
+
67
+ Raises:
68
+ requests.HTTPError: If the API request fails or returns an unsuccessful status code.
69
+
70
+ Tags:
71
+ list, docs, filter, pagination, management, important
72
+ """
73
+ url = f"{self.base_url}/docs"
74
+ query_params = {
75
+ k: v
76
+ for k, v in [
77
+ ("isOwner", isOwner),
78
+ ("isPublished", isPublished),
79
+ ("query", query),
80
+ ("sourceDoc", sourceDoc),
81
+ ("isStarred", isStarred),
82
+ ("inGallery", inGallery),
83
+ ("workspaceId", workspaceId),
84
+ ("folderId", folderId),
85
+ ("limit", limit),
86
+ ("pageToken", pageToken),
87
+ ]
88
+ if v is not None
89
+ }
90
+ response = self._get(url, params=query_params)
91
+ response.raise_for_status()
92
+ return response.json()
93
+
94
+ def create_doc(
95
+ self, title=None, sourceDoc=None, timezone=None, folderId=None, initialPage=None
96
+ ) -> dict[str, Any]:
97
+ """
98
+ Creates a new document with the specified properties and returns its metadata as a dictionary.
99
+
100
+ Args:
101
+ title: Optional[str]. The title of the new document.
102
+ sourceDoc: Optional[str]. Identifier for a source document to duplicate or base the new document on.
103
+ timezone: Optional[str]. Timezone setting for the document, if applicable.
104
+ folderId: Optional[str]. Identifier of the folder where the document will be created.
105
+ initialPage: Optional[dict]. Content or configuration for the initial page of the document.
106
+
107
+ Returns:
108
+ dict[str, Any]: A dictionary containing the metadata and details of the newly created document.
109
+
110
+ Raises:
111
+ requests.HTTPError: If the HTTP request to create the document fails or the server responds with an error status.
112
+
113
+ Tags:
114
+ create, document, api, management, important
115
+ """
116
+ request_body = {
117
+ "title": title,
118
+ "sourceDoc": sourceDoc,
119
+ "timezone": timezone,
120
+ "folderId": folderId,
121
+ "initialPage": initialPage,
122
+ }
123
+ request_body = {k: v for k, v in request_body.items() if v is not None}
124
+ url = f"{self.base_url}/docs"
125
+ query_params = {}
126
+ response = self._post(url, data=request_body, params=query_params)
127
+ response.raise_for_status()
128
+ return response.json()
129
+
130
+ def get_doc(self, docId) -> dict[str, Any]:
131
+ """
132
+ Retrieves a document by its unique identifier from the remote service.
133
+
134
+ Args:
135
+ docId: The unique identifier of the document to retrieve. Must not be None.
136
+
137
+ Returns:
138
+ A dictionary containing the JSON representation of the requested document.
139
+
140
+ Raises:
141
+ ValueError: If 'docId' is None.
142
+ requests.exceptions.HTTPError: If the HTTP request to retrieve the document fails.
143
+
144
+ Tags:
145
+ get, fetch, document, remote-access, important
146
+ """
147
+ if docId is None:
148
+ raise ValueError("Missing required parameter 'docId'")
149
+ url = f"{self.base_url}/docs/{docId}"
150
+ query_params = {}
151
+ response = self._get(url, params=query_params)
152
+ response.raise_for_status()
153
+ return response.json()
154
+
155
+ def delete_doc(self, docId) -> dict[str, Any]:
156
+ """
157
+ Deletes a document by its ID from the remote service.
158
+
159
+ Args:
160
+ docId: The unique identifier of the document to delete.
161
+
162
+ Returns:
163
+ A dictionary containing the response data from the delete operation.
164
+
165
+ Raises:
166
+ ValueError: If 'docId' is None.
167
+ HTTPError: If the HTTP request to delete the document fails.
168
+
169
+ Tags:
170
+ delete, document, management, important, api, http
171
+ """
172
+ if docId is None:
173
+ raise ValueError("Missing required parameter 'docId'")
174
+ url = f"{self.base_url}/docs/{docId}"
175
+ query_params = {}
176
+ response = self._delete(url, params=query_params)
177
+ response.raise_for_status()
178
+ return response.json()
179
+
180
+ def update_doc(self, docId, title=None, iconName=None) -> dict[str, Any]:
181
+ """
182
+ Updates the metadata of a document, such as its title and icon, using the provided document ID.
183
+
184
+ Args:
185
+ docId: str. The unique identifier of the document to update. Must not be None.
186
+ title: str, optional. The new title for the document. If None, the title is not updated.
187
+ iconName: str, optional. The new icon name for the document. If None, the icon is not updated.
188
+
189
+ Returns:
190
+ dict[str, Any]: The JSON response from the API containing the updated document metadata.
191
+
192
+ Raises:
193
+ ValueError: Raised if 'docId' is None.
194
+ requests.HTTPError: Raised if the HTTP request to update the document fails.
195
+
196
+ Tags:
197
+ update, document, api, metadata, management, important
198
+ """
199
+ if docId is None:
200
+ raise ValueError("Missing required parameter 'docId'")
201
+ request_body = {
202
+ "title": title,
203
+ "iconName": iconName,
204
+ }
205
+ request_body = {k: v for k, v in request_body.items() if v is not None}
206
+ url = f"{self.base_url}/docs/{docId}"
207
+ query_params = {}
208
+ response = self._patch(url, data=request_body, params=query_params)
209
+ response.raise_for_status()
210
+ return response.json()
211
+
212
+ def get_sharing_metadata(self, docId) -> dict[str, Any]:
213
+ """
214
+ Retrieves sharing metadata for the specified document by its ID.
215
+
216
+ Args:
217
+ docId: str. The unique identifier of the document whose sharing metadata is to be retrieved.
218
+
219
+ Returns:
220
+ dict. A dictionary containing the sharing metadata of the specified document.
221
+
222
+ Raises:
223
+ ValueError: If the required parameter 'docId' is None.
224
+ requests.HTTPError: If the HTTP request returns an unsuccessful status code.
225
+
226
+ Tags:
227
+ get, sharing-metadata, document, api-call, important
228
+ """
229
+ if docId is None:
230
+ raise ValueError("Missing required parameter 'docId'")
231
+ url = f"{self.base_url}/docs/{docId}/acl/metadata"
232
+ query_params = {}
233
+ response = self._get(url, params=query_params)
234
+ response.raise_for_status()
235
+ return response.json()
236
+
237
+ def get_permissions(self, docId, limit=None, pageToken=None) -> dict[str, Any]:
238
+ """
239
+ Retrieves the list of permissions for a specified document.
240
+
241
+ Args:
242
+ docId: The unique identifier of the document whose permissions are to be fetched.
243
+ limit: Optional; maximum number of permission records to return.
244
+ pageToken: Optional; token indicating the page of results to retrieve for pagination.
245
+
246
+ Returns:
247
+ A dictionary containing the document's permissions and optional pagination data.
248
+
249
+ Raises:
250
+ ValueError: If 'docId' is not provided.
251
+ requests.HTTPError: If the HTTP request to fetch permissions fails (non-success status code).
252
+
253
+ Tags:
254
+ get, permissions, document-management, api-call, important
255
+ """
256
+ if docId is None:
257
+ raise ValueError("Missing required parameter 'docId'")
258
+ url = f"{self.base_url}/docs/{docId}/acl/permissions"
259
+ query_params = {
260
+ k: v
261
+ for k, v in [("limit", limit), ("pageToken", pageToken)]
262
+ if v is not None
263
+ }
264
+ response = self._get(url, params=query_params)
265
+ response.raise_for_status()
266
+ return response.json()
267
+
268
+ def add_permission(
269
+ self, docId, access, principal, suppressEmail=None
270
+ ) -> dict[str, Any]:
271
+ """
272
+ Adds a permission entry for a specified document, granting access to a principal with defined access level.
273
+
274
+ Args:
275
+ docId: str. The unique identifier of the document to which the permission will be added.
276
+ access: str. The type of access to grant (e.g., 'read', 'write', 'admin').
277
+ principal: str. The identifier (email, group, or user ID) of the principal receiving access.
278
+ suppressEmail: Optional[bool]. If True, suppresses notification emails about the permission grant. Defaults to None.
279
+
280
+ Returns:
281
+ dict[str, Any]: The JSON response from the API containing details of the newly added permission.
282
+
283
+ Raises:
284
+ ValueError: If any of the required parameters ('docId', 'access', or 'principal') are missing or None.
285
+ requests.HTTPError: If the HTTP request to the backend API fails or returns an error response.
286
+
287
+ Tags:
288
+ add, permission, management, important, api, post
289
+ """
290
+ if docId is None:
291
+ raise ValueError("Missing required parameter 'docId'")
292
+ if access is None:
293
+ raise ValueError("Missing required parameter 'access'")
294
+ if principal is None:
295
+ raise ValueError("Missing required parameter 'principal'")
296
+ request_body = {
297
+ "access": access,
298
+ "principal": principal,
299
+ "suppressEmail": suppressEmail,
300
+ }
301
+ request_body = {k: v for k, v in request_body.items() if v is not None}
302
+ url = f"{self.base_url}/docs/{docId}/acl/permissions"
303
+ query_params = {}
304
+ response = self._post(url, data=request_body, params=query_params)
305
+ response.raise_for_status()
306
+ return response.json()
307
+
308
+ def delete_permission(self, docId, permissionId) -> dict[str, Any]:
309
+ """
310
+ Deletes a specific permission from a document by its identifier.
311
+
312
+ Args:
313
+ docId: str. The unique identifier of the document from which the permission will be deleted.
314
+ permissionId: str. The unique identifier of the permission to delete from the document.
315
+
316
+ Returns:
317
+ dict[str, Any]: JSON response containing the result of the delete operation.
318
+
319
+ Raises:
320
+ ValueError: Raised if 'docId' or 'permissionId' is None.
321
+ requests.HTTPError: Raised if the HTTP request to delete the permission fails or returns an error response.
322
+
323
+ Tags:
324
+ delete, permission-management, document, important
325
+ """
326
+ if docId is None:
327
+ raise ValueError("Missing required parameter 'docId'")
328
+ if permissionId is None:
329
+ raise ValueError("Missing required parameter 'permissionId'")
330
+ url = f"{self.base_url}/docs/{docId}/acl/permissions/{permissionId}"
331
+ query_params = {}
332
+ response = self._delete(url, params=query_params)
333
+ response.raise_for_status()
334
+ return response.json()
335
+
336
+ def search_principals(self, docId, query=None) -> dict[str, Any]:
337
+ """
338
+ Searches for principals in the access control list of a specified document, optionally filtering results by a query string.
339
+
340
+ Args:
341
+ docId: str. The unique identifier of the document whose principals are to be searched.
342
+ query: Optional[str]. A search string to filter principals. If None, all principals are returned.
343
+
344
+ Returns:
345
+ dict[str, Any]: The JSON response containing the list of principals matching the search criteria.
346
+
347
+ Raises:
348
+ ValueError: Raised if the required 'docId' parameter is None.
349
+ requests.HTTPError: Raised if the HTTP request to the server fails or returns an unsuccessful status code.
350
+
351
+ Tags:
352
+ search, acl, principals, document, api, important
353
+ """
354
+ if docId is None:
355
+ raise ValueError("Missing required parameter 'docId'")
356
+ url = f"{self.base_url}/docs/{docId}/acl/principals/search"
357
+ query_params = {k: v for k, v in [("query", query)] if v is not None}
358
+ response = self._get(url, params=query_params)
359
+ response.raise_for_status()
360
+ return response.json()
361
+
362
+ def get_acl_settings(self, docId) -> dict[str, Any]:
363
+ """
364
+ Retrieves the access control settings for a specified document.
365
+
366
+ Args:
367
+ docId: The unique identifier of the document whose ACL settings are to be retrieved.
368
+
369
+ Returns:
370
+ A dictionary containing the access control settings of the specified document.
371
+
372
+ Raises:
373
+ ValueError: Raised when 'docId' is None.
374
+ HTTPError: Raised if the HTTP request to retrieve ACL settings fails.
375
+
376
+ Tags:
377
+ get, acl, settings, document, management, important
378
+ """
379
+ if docId is None:
380
+ raise ValueError("Missing required parameter 'docId'")
381
+ url = f"{self.base_url}/docs/{docId}/acl/settings"
382
+ query_params = {}
383
+ response = self._get(url, params=query_params)
384
+ response.raise_for_status()
385
+ return response.json()
386
+
387
+ def update_acl_settings(
388
+ self,
389
+ docId,
390
+ allowEditorsToChangePermissions=None,
391
+ allowCopying=None,
392
+ allowViewersToRequestEditing=None,
393
+ ) -> dict[str, Any]:
394
+ """
395
+ Updates access control settings for a specific document.
396
+
397
+ Args:
398
+ docId: str. The unique identifier of the document whose ACL settings are to be updated.
399
+ allowEditorsToChangePermissions: Optional[bool]. If set, specifies whether editors can change sharing permissions.
400
+ allowCopying: Optional[bool]. If set, determines if viewers and commenters can copy, print, or download the document.
401
+ allowViewersToRequestEditing: Optional[bool]. If set, indicates whether viewers can request edit access to the document.
402
+
403
+ Returns:
404
+ dict[str, Any]: A dictionary containing the updated ACL settings returned by the server.
405
+
406
+ Raises:
407
+ ValueError: If 'docId' is None.
408
+ requests.HTTPError: If the HTTP request fails (e.g., due to invalid permissions, network errors, or the document does not exist).
409
+
410
+ Tags:
411
+ update, acl, settings, document, management, important
412
+ """
413
+ if docId is None:
414
+ raise ValueError("Missing required parameter 'docId'")
415
+ request_body = {
416
+ "allowEditorsToChangePermissions": allowEditorsToChangePermissions,
417
+ "allowCopying": allowCopying,
418
+ "allowViewersToRequestEditing": allowViewersToRequestEditing,
419
+ }
420
+ request_body = {k: v for k, v in request_body.items() if v is not None}
421
+ url = f"{self.base_url}/docs/{docId}/acl/settings"
422
+ query_params = {}
423
+ response = self._patch(url, data=request_body, params=query_params)
424
+ response.raise_for_status()
425
+ return response.json()
426
+
427
+ def publish_doc(
428
+ self,
429
+ docId,
430
+ slug=None,
431
+ discoverable=None,
432
+ earnCredit=None,
433
+ categoryNames=None,
434
+ mode=None,
435
+ ) -> dict[str, Any]:
436
+ """
437
+ Publishes a document with the specified docId and optional publication settings.
438
+
439
+ Args:
440
+ docId: str. The unique identifier of the document to publish. Required.
441
+ slug: str or None. Optional custom slug for the published document.
442
+ discoverable: bool or None. Whether the document should be discoverable. Optional.
443
+ earnCredit: bool or None. Whether publishing the document grants credit. Optional.
444
+ categoryNames: list[str] or None. Categories to associate with the document. Optional.
445
+ mode: str or None. The publication mode or workflow to use (if applicable). Optional.
446
+
447
+ Returns:
448
+ dict[str, Any]: The response from the publish API containing information about the published document.
449
+
450
+ Raises:
451
+ ValueError: If 'docId' is not provided.
452
+ requests.HTTPError: If the HTTP request to publish the document fails.
453
+
454
+ Tags:
455
+ publish, document, api, management, important
456
+ """
457
+ if docId is None:
458
+ raise ValueError("Missing required parameter 'docId'")
459
+ request_body = {
460
+ "slug": slug,
461
+ "discoverable": discoverable,
462
+ "earnCredit": earnCredit,
463
+ "categoryNames": categoryNames,
464
+ "mode": mode,
465
+ }
466
+ request_body = {k: v for k, v in request_body.items() if v is not None}
467
+ url = f"{self.base_url}/docs/{docId}/publish"
468
+ query_params = {}
469
+ response = self._put(url, data=request_body, params=query_params)
470
+ response.raise_for_status()
471
+ return response.json()
472
+
473
+ def unpublish_doc(self, docId) -> dict[str, Any]:
474
+ """
475
+ Unpublishes a document by revoking its published status using the provided document ID.
476
+
477
+ Args:
478
+ docId: str. The unique identifier of the document to be unpublished.
479
+
480
+ Returns:
481
+ dict[str, Any]: A dictionary containing the API's response to the unpublish operation.
482
+
483
+ Raises:
484
+ ValueError: If 'docId' is None.
485
+ requests.HTTPError: If the HTTP DELETE request fails with an error status code.
486
+
487
+ Tags:
488
+ unpublish, document-management, delete, async-job, important
489
+ """
490
+ if docId is None:
491
+ raise ValueError("Missing required parameter 'docId'")
492
+ url = f"{self.base_url}/docs/{docId}/publish"
493
+ query_params = {}
494
+ response = self._delete(url, params=query_params)
495
+ response.raise_for_status()
496
+ return response.json()
497
+
498
+ def list_pages(self, docId, limit=None, pageToken=None) -> dict[str, Any]:
499
+ """
500
+ Retrieves a paginated list of pages for a specified document.
501
+
502
+ Args:
503
+ docId: str. The unique identifier of the document whose pages are to be listed.
504
+ limit: Optional[int]. The maximum number of pages to return in a single response.
505
+ pageToken: Optional[str]. The token indicating the starting point for pagination.
506
+
507
+ Returns:
508
+ dict[str, Any]: A dictionary containing the paginated list of pages and any pagination metadata.
509
+
510
+ Raises:
511
+ ValueError: If the 'docId' parameter is not provided.
512
+ requests.HTTPError: If the HTTP request to the API fails.
513
+
514
+ Tags:
515
+ list, pages, pagination, api, important
516
+ """
517
+ if docId is None:
518
+ raise ValueError("Missing required parameter 'docId'")
519
+ url = f"{self.base_url}/docs/{docId}/pages"
520
+ query_params = {
521
+ k: v
522
+ for k, v in [("limit", limit), ("pageToken", pageToken)]
523
+ if v is not None
524
+ }
525
+ response = self._get(url, params=query_params)
526
+ response.raise_for_status()
527
+ return response.json()
528
+
529
+ def create_page(
530
+ self,
531
+ docId,
532
+ name=None,
533
+ subtitle=None,
534
+ iconName=None,
535
+ imageUrl=None,
536
+ parentPageId=None,
537
+ pageContent=None,
538
+ ) -> dict[str, Any]:
539
+ """
540
+ Creates a new page within a specified document and returns the page details.
541
+
542
+ Args:
543
+ docId: str. The unique identifier of the document in which the page should be created. Required.
544
+ name: str, optional. The name of the new page.
545
+ subtitle: str, optional. The subtitle of the new page.
546
+ iconName: str, optional. The name of the icon to associate with the page.
547
+ imageUrl: str, optional. The URL of an image to use for the page.
548
+ parentPageId: str, optional. The unique identifier of the parent page, if creating a subpage.
549
+ pageContent: Any, optional. The content to populate the new page with.
550
+
551
+ Returns:
552
+ dict[str, Any]: A dictionary representing the details of the created page as returned by the API.
553
+
554
+ Raises:
555
+ ValueError: If 'docId' is None.
556
+ requests.HTTPError: If the API request fails or responds with an unsuccessful status code.
557
+
558
+ Tags:
559
+ create, page, management, important
560
+ """
561
+ if docId is None:
562
+ raise ValueError("Missing required parameter 'docId'")
563
+ request_body = {
564
+ "name": name,
565
+ "subtitle": subtitle,
566
+ "iconName": iconName,
567
+ "imageUrl": imageUrl,
568
+ "parentPageId": parentPageId,
569
+ "pageContent": pageContent,
570
+ }
571
+ request_body = {k: v for k, v in request_body.items() if v is not None}
572
+ url = f"{self.base_url}/docs/{docId}/pages"
573
+ query_params = {}
574
+ response = self._post(url, data=request_body, params=query_params)
575
+ response.raise_for_status()
576
+ return response.json()
577
+
578
+ def get_page(self, docId, pageIdOrName) -> dict[str, Any]:
579
+ """
580
+ Retrieves details of a specific page within a document by its ID or name.
581
+
582
+ Args:
583
+ docId: str. The unique identifier of the document containing the desired page.
584
+ pageIdOrName: str. The unique identifier or name of the page to retrieve.
585
+
586
+ Returns:
587
+ dict[str, Any]: A dictionary containing the data for the specified page.
588
+
589
+ Raises:
590
+ ValueError: Raised if either 'docId' or 'pageIdOrName' is None.
591
+ requests.exceptions.HTTPError: Raised if the HTTP request to fetch the page fails.
592
+
593
+ Tags:
594
+ get, page, document, api, important
595
+ """
596
+ if docId is None:
597
+ raise ValueError("Missing required parameter 'docId'")
598
+ if pageIdOrName is None:
599
+ raise ValueError("Missing required parameter 'pageIdOrName'")
600
+ url = f"{self.base_url}/docs/{docId}/pages/{pageIdOrName}"
601
+ query_params = {}
602
+ response = self._get(url, params=query_params)
603
+ response.raise_for_status()
604
+ return response.json()
605
+
606
+ def update_page(
607
+ self,
608
+ docId,
609
+ pageIdOrName,
610
+ name=None,
611
+ subtitle=None,
612
+ iconName=None,
613
+ imageUrl=None,
614
+ isHidden=None,
615
+ contentUpdate=None,
616
+ ) -> dict[str, Any]:
617
+ """
618
+ Updates properties of a specific page within a document, sending changes to the server and returning the updated page data.
619
+
620
+ Args:
621
+ docId: str. Unique identifier of the document containing the page to update.
622
+ pageIdOrName: str. Identifier or name of the page to update.
623
+ name: str, optional. New name for the page.
624
+ subtitle: str, optional. New subtitle for the page.
625
+ iconName: str, optional. Icon to associate with the page.
626
+ imageUrl: str, optional. Image URL to represent the page.
627
+ isHidden: bool, optional. Whether the page should be hidden.
628
+ contentUpdate: Any, optional. Content data or structure to update the page with.
629
+
630
+ Returns:
631
+ dict. JSON response containing the updated page data as returned by the API.
632
+
633
+ Raises:
634
+ ValueError: If 'docId' or 'pageIdOrName' is not provided.
635
+ requests.HTTPError: If the HTTP request to update the page fails (non-2xx response).
636
+
637
+ Tags:
638
+ update, page-management, api, important
639
+ """
640
+ if docId is None:
641
+ raise ValueError("Missing required parameter 'docId'")
642
+ if pageIdOrName is None:
643
+ raise ValueError("Missing required parameter 'pageIdOrName'")
644
+ request_body = {
645
+ "name": name,
646
+ "subtitle": subtitle,
647
+ "iconName": iconName,
648
+ "imageUrl": imageUrl,
649
+ "isHidden": isHidden,
650
+ "contentUpdate": contentUpdate,
651
+ }
652
+ request_body = {k: v for k, v in request_body.items() if v is not None}
653
+ url = f"{self.base_url}/docs/{docId}/pages/{pageIdOrName}"
654
+ query_params = {}
655
+ response = self._put(url, data=request_body, params=query_params)
656
+ response.raise_for_status()
657
+ return response.json()
658
+
659
+ def delete_page(self, docId, pageIdOrName) -> dict[str, Any]:
660
+ """
661
+ Deletes a specific page from a document identified by docId and pageIdOrName.
662
+
663
+ Args:
664
+ docId: str. The unique identifier of the document from which to delete the page.
665
+ pageIdOrName: str. The ID or name of the page to be deleted from the document.
666
+
667
+ Returns:
668
+ dict[str, Any]: The API response as a dictionary representing the result of the deletion.
669
+
670
+ Raises:
671
+ ValueError: Raised if docId or pageIdOrName is None.
672
+ HTTPError: Raised if the HTTP request fails or returns an unsuccessful status code.
673
+
674
+ Tags:
675
+ delete, page-management, api, operation, important
676
+ """
677
+ if docId is None:
678
+ raise ValueError("Missing required parameter 'docId'")
679
+ if pageIdOrName is None:
680
+ raise ValueError("Missing required parameter 'pageIdOrName'")
681
+ url = f"{self.base_url}/docs/{docId}/pages/{pageIdOrName}"
682
+ query_params = {}
683
+ response = self._delete(url, params=query_params)
684
+ response.raise_for_status()
685
+ return response.json()
686
+
687
+ def begin_page_content_export(
688
+ self, docId, pageIdOrName, outputFormat
689
+ ) -> dict[str, Any]:
690
+ """
691
+ Initiates an export of a specific page's content from a document in the specified format.
692
+
693
+ Args:
694
+ docId: The unique identifier of the document containing the page to export.
695
+ pageIdOrName: The ID or name of the page to be exported from the document.
696
+ outputFormat: The desired format for the exported page content (e.g., 'pdf', 'docx').
697
+
698
+ Returns:
699
+ A dictionary containing the response data from the export operation, typically including information about the export job or downloaded content.
700
+
701
+ Raises:
702
+ ValueError: Raised if 'docId', 'pageIdOrName', or 'outputFormat' is None.
703
+ requests.exceptions.HTTPError: Raised if the HTTP request to start the export fails (e.g., due to network issues or invalid parameters).
704
+
705
+ Tags:
706
+ export, async-job, start, page, document, management, important
707
+ """
708
+ if docId is None:
709
+ raise ValueError("Missing required parameter 'docId'")
710
+ if pageIdOrName is None:
711
+ raise ValueError("Missing required parameter 'pageIdOrName'")
712
+ if outputFormat is None:
713
+ raise ValueError("Missing required parameter 'outputFormat'")
714
+ request_body = {
715
+ "outputFormat": outputFormat,
716
+ }
717
+ request_body = {k: v for k, v in request_body.items() if v is not None}
718
+ url = f"{self.base_url}/docs/{docId}/pages/{pageIdOrName}/export"
719
+ query_params = {}
720
+ response = self._post(url, data=request_body, params=query_params)
721
+ response.raise_for_status()
722
+ return response.json()
723
+
724
+ def get_page_content_export_status(
725
+ self, docId, pageIdOrName, requestId
726
+ ) -> dict[str, Any]:
727
+ """
728
+ Retrieves the export status of a specific page's content in a document by request ID.
729
+
730
+ Args:
731
+ docId: str. The unique identifier of the document.
732
+ pageIdOrName: str. The ID or name of the page whose export status is being queried.
733
+ requestId: str. The unique identifier for the export request.
734
+
735
+ Returns:
736
+ dict. A dictionary containing the status and details of the page content export request.
737
+
738
+ Raises:
739
+ ValueError: Raised if any of 'docId', 'pageIdOrName', or 'requestId' is None.
740
+ requests.HTTPError: Raised if the HTTP request to fetch the export status fails with a non-success status code.
741
+
742
+ Tags:
743
+ get, status, export, page, document, ai, important
744
+ """
745
+ if docId is None:
746
+ raise ValueError("Missing required parameter 'docId'")
747
+ if pageIdOrName is None:
748
+ raise ValueError("Missing required parameter 'pageIdOrName'")
749
+ if requestId is None:
750
+ raise ValueError("Missing required parameter 'requestId'")
751
+ url = f"{self.base_url}/docs/{docId}/pages/{pageIdOrName}/export/{requestId}"
752
+ query_params = {}
753
+ response = self._get(url, params=query_params)
754
+ response.raise_for_status()
755
+ return response.json()
756
+
757
+ def list_tables(
758
+ self, docId, limit=None, pageToken=None, sortBy=None, tableTypes=None
759
+ ) -> dict[str, Any]:
760
+ """
761
+ Retrieves a list of tables from a specified document with optional filtering, pagination, and sorting.
762
+
763
+ Args:
764
+ docId: str. The unique identifier of the document to retrieve tables from.
765
+ limit: Optional[int]. The maximum number of tables to return.
766
+ pageToken: Optional[str]. Token for fetching a specific results page.
767
+ sortBy: Optional[str]. Field to sort tables by.
768
+ tableTypes: Optional[str]. Comma-separated list of table types to filter results.
769
+
770
+ Returns:
771
+ dict[str, Any]: A dictionary containing the tables and related metadata retrieved from the document.
772
+
773
+ Raises:
774
+ ValueError: Raised if 'docId' is None.
775
+ requests.HTTPError: Raised if the HTTP request to the API fails.
776
+
777
+ Tags:
778
+ list, tables, document-management, api, important
779
+ """
780
+ if docId is None:
781
+ raise ValueError("Missing required parameter 'docId'")
782
+ url = f"{self.base_url}/docs/{docId}/tables"
783
+ query_params = {
784
+ k: v
785
+ for k, v in [
786
+ ("limit", limit),
787
+ ("pageToken", pageToken),
788
+ ("sortBy", sortBy),
789
+ ("tableTypes", tableTypes),
790
+ ]
791
+ if v is not None
792
+ }
793
+ response = self._get(url, params=query_params)
794
+ response.raise_for_status()
795
+ return response.json()
796
+
797
+ def get_table(
798
+ self, docId, tableIdOrName, useUpdatedTableLayouts=None
799
+ ) -> dict[str, Any]:
800
+ """
801
+ Retrieve table details from a document by table ID or name.
802
+
803
+ Args:
804
+ docId: The unique identifier of the document containing the table.
805
+ tableIdOrName: The unique ID or name of the table to retrieve.
806
+ useUpdatedTableLayouts: Optional; whether to use updated table layout formatting. Defaults to None.
807
+
808
+ Returns:
809
+ A dictionary containing the JSON response with table details.
810
+
811
+ Raises:
812
+ ValueError: If 'docId' or 'tableIdOrName' is not provided.
813
+ requests.HTTPError: If the HTTP request for the table details fails.
814
+
815
+ Tags:
816
+ get, table, ai, management, important
817
+ """
818
+ if docId is None:
819
+ raise ValueError("Missing required parameter 'docId'")
820
+ if tableIdOrName is None:
821
+ raise ValueError("Missing required parameter 'tableIdOrName'")
822
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}"
823
+ query_params = {
824
+ k: v
825
+ for k, v in [("useUpdatedTableLayouts", useUpdatedTableLayouts)]
826
+ if v is not None
827
+ }
828
+ response = self._get(url, params=query_params)
829
+ response.raise_for_status()
830
+ return response.json()
831
+
832
+ def list_columns(
833
+ self, docId, tableIdOrName, limit=None, pageToken=None, visibleOnly=None
834
+ ) -> dict[str, Any]:
835
+ """
836
+ Retrieves a list of columns for a specified table in a document, with optional filtering and pagination.
837
+
838
+ Args:
839
+ docId: str. The unique identifier of the document containing the table.
840
+ tableIdOrName: str. The ID or name of the target table within the document.
841
+ limit: Optional[int]. The maximum number of columns to return in the response.
842
+ pageToken: Optional[str]. A token to retrieve the next page of results, for pagination.
843
+ visibleOnly: Optional[bool]. If True, only returns columns that are currently visible.
844
+
845
+ Returns:
846
+ dict[str, Any]: A dictionary containing metadata and data about the columns in the specified table.
847
+
848
+ Raises:
849
+ ValueError: Raised if 'docId' or 'tableIdOrName' is not provided.
850
+ requests.HTTPError: Raised if the HTTP request to retrieve columns fails with a non-success status code.
851
+
852
+ Tags:
853
+ list, columns, table, document, api, metadata, important
854
+ """
855
+ if docId is None:
856
+ raise ValueError("Missing required parameter 'docId'")
857
+ if tableIdOrName is None:
858
+ raise ValueError("Missing required parameter 'tableIdOrName'")
859
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/columns"
860
+ query_params = {
861
+ k: v
862
+ for k, v in [
863
+ ("limit", limit),
864
+ ("pageToken", pageToken),
865
+ ("visibleOnly", visibleOnly),
866
+ ]
867
+ if v is not None
868
+ }
869
+ response = self._get(url, params=query_params)
870
+ response.raise_for_status()
871
+ return response.json()
872
+
873
+ def list_rows(
874
+ self,
875
+ docId,
876
+ tableIdOrName,
877
+ query=None,
878
+ sortBy=None,
879
+ useColumnNames=None,
880
+ valueFormat=None,
881
+ visibleOnly=None,
882
+ limit=None,
883
+ pageToken=None,
884
+ syncToken=None,
885
+ ) -> dict[str, Any]:
886
+ """
887
+ Retrieves a list of rows from a specified table in a document, with optional filtering, sorting, and pagination.
888
+
889
+ Args:
890
+ docId: str. The unique identifier of the document containing the target table.
891
+ tableIdOrName: str. The ID or name of the table from which to fetch rows.
892
+ query: str or None. An optional query string to filter rows based on specific conditions.
893
+ sortBy: str or None. Optional parameter to specify column(s) by which to sort the results.
894
+ useColumnNames: bool or None. If True, uses column names in the returned data instead of IDs.
895
+ valueFormat: str or None. Specifies how cell values should be formatted (e.g., display, raw).
896
+ visibleOnly: bool or None. If True, returns only visible rows.
897
+ limit: int or None. The maximum number of rows to return in the response.
898
+ pageToken: str or None. A token indicating the page of results to retrieve for pagination.
899
+ syncToken: str or None. A token to synchronize and fetch only new or changed rows since the last call.
900
+
901
+ Returns:
902
+ dict[str, Any]: A dictionary containing the list of rows, and possibly metadata such as pagination tokens.
903
+
904
+ Raises:
905
+ ValueError: Raised if 'docId' or 'tableIdOrName' is not provided.
906
+ requests.HTTPError: Raised if the HTTP request to fetch rows fails with a response error status.
907
+
908
+ Tags:
909
+ list, rows, table, document, api-call, filtering, pagination, fetch, important
910
+ """
911
+ if docId is None:
912
+ raise ValueError("Missing required parameter 'docId'")
913
+ if tableIdOrName is None:
914
+ raise ValueError("Missing required parameter 'tableIdOrName'")
915
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows"
916
+ query_params = {
917
+ k: v
918
+ for k, v in [
919
+ ("query", query),
920
+ ("sortBy", sortBy),
921
+ ("useColumnNames", useColumnNames),
922
+ ("valueFormat", valueFormat),
923
+ ("visibleOnly", visibleOnly),
924
+ ("limit", limit),
925
+ ("pageToken", pageToken),
926
+ ("syncToken", syncToken),
927
+ ]
928
+ if v is not None
929
+ }
930
+ response = self._get(url, params=query_params)
931
+ response.raise_for_status()
932
+ return response.json()
933
+
934
+ def upsert_rows(
935
+ self, docId, tableIdOrName, rows, disableParsing=None, keyColumns=None
936
+ ) -> dict[str, Any]:
937
+ """
938
+ Upserts (inserts or updates) multiple rows in a specified table within a document.
939
+
940
+ Args:
941
+ docId: str. The unique identifier of the document containing the target table.
942
+ tableIdOrName: str. The identifier or name of the table where rows will be upserted.
943
+ rows: list[dict]. A list of row data to insert or update in the table.
944
+ disableParsing: Optional[bool]. If True, disables automatic parsing of cell values. Defaults to None.
945
+ keyColumns: Optional[list[str]]. Columns used as keys to determine if a row should be inserted or updated. Defaults to None.
946
+
947
+ Returns:
948
+ dict[str, Any]: The API response as a dictionary containing the result details of the upsert operation.
949
+
950
+ Raises:
951
+ ValueError: Raised if any of the required parameters 'docId', 'tableIdOrName', or 'rows' is None.
952
+ requests.HTTPError: Raised if the API request fails with a non-success status code.
953
+
954
+ Tags:
955
+ upsert, rows, batch, table-management, important
956
+ """
957
+ if docId is None:
958
+ raise ValueError("Missing required parameter 'docId'")
959
+ if tableIdOrName is None:
960
+ raise ValueError("Missing required parameter 'tableIdOrName'")
961
+ if rows is None:
962
+ raise ValueError("Missing required parameter 'rows'")
963
+ request_body = {
964
+ "rows": rows,
965
+ "keyColumns": keyColumns,
966
+ }
967
+ request_body = {k: v for k, v in request_body.items() if v is not None}
968
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows"
969
+ query_params = {
970
+ k: v for k, v in [("disableParsing", disableParsing)] if v is not None
971
+ }
972
+ response = self._post(url, data=request_body, params=query_params)
973
+ response.raise_for_status()
974
+ return response.json()
975
+
976
+ def delete_rows(self, docId, tableIdOrName, rowIds) -> dict[str, Any]:
977
+ """
978
+ Deletes specified rows from a table within a given document.
979
+
980
+ Args:
981
+ docId: str. The unique identifier of the document containing the table.
982
+ tableIdOrName: str. The unique identifier or name of the table from which rows will be deleted.
983
+ rowIds: list. A list of string or integer row IDs specifying which rows to delete.
984
+
985
+ Returns:
986
+ dict. The JSON response from the API after the deletion operation.
987
+
988
+ Raises:
989
+ ValueError: Raised if 'docId', 'tableIdOrName', or 'rowIds' is None.
990
+ requests.HTTPError: Raised if the HTTP response indicates an unsuccessful status.
991
+
992
+ Tags:
993
+ delete, rows, batch, management, important
994
+ """
995
+ if docId is None:
996
+ raise ValueError("Missing required parameter 'docId'")
997
+ if tableIdOrName is None:
998
+ raise ValueError("Missing required parameter 'tableIdOrName'")
999
+ if rowIds is None:
1000
+ raise ValueError("Missing required parameter 'rowIds'")
1001
+ request_body = {
1002
+ "rowIds": rowIds,
1003
+ }
1004
+ request_body = {k: v for k, v in request_body.items() if v is not None}
1005
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows"
1006
+ query_params = {}
1007
+ response = self._delete(url, params=query_params)
1008
+ response.raise_for_status()
1009
+ return response.json()
1010
+
1011
+ def get_row(
1012
+ self, docId, tableIdOrName, rowIdOrName, useColumnNames=None, valueFormat=None
1013
+ ) -> dict[str, Any]:
1014
+ """
1015
+ Retrieves a specific row from a table in a document using the provided identifiers.
1016
+
1017
+ Args:
1018
+ docId: str. The unique identifier of the document containing the table.
1019
+ tableIdOrName: str. The unique ID or name of the table from which to retrieve the row.
1020
+ rowIdOrName: str. The unique ID or name of the row to retrieve.
1021
+ useColumnNames: Optional[bool]. If True, use column names instead of IDs in the response. Defaults to None.
1022
+ valueFormat: Optional[str]. Format in which to return cell values (e.g., 'formattedValue'). Defaults to None.
1023
+
1024
+ Returns:
1025
+ dict[str, Any]: A dictionary representing the JSON response containing the requested row's data.
1026
+
1027
+ Raises:
1028
+ ValueError: If any of 'docId', 'tableIdOrName', or 'rowIdOrName' is None.
1029
+ requests.HTTPError: If the HTTP request to retrieve the row fails or the server returns an error response.
1030
+
1031
+ Tags:
1032
+ get, row, table, fetch, api, important
1033
+ """
1034
+ if docId is None:
1035
+ raise ValueError("Missing required parameter 'docId'")
1036
+ if tableIdOrName is None:
1037
+ raise ValueError("Missing required parameter 'tableIdOrName'")
1038
+ if rowIdOrName is None:
1039
+ raise ValueError("Missing required parameter 'rowIdOrName'")
1040
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows/{rowIdOrName}"
1041
+ query_params = {
1042
+ k: v
1043
+ for k, v in [
1044
+ ("useColumnNames", useColumnNames),
1045
+ ("valueFormat", valueFormat),
1046
+ ]
1047
+ if v is not None
1048
+ }
1049
+ response = self._get(url, params=query_params)
1050
+ response.raise_for_status()
1051
+ return response.json()
1052
+
1053
+ def update_row(
1054
+ self, docId, tableIdOrName, rowIdOrName, row, disableParsing=None
1055
+ ) -> dict[str, Any]:
1056
+ """
1057
+ Updates an existing row in a specified table within a document by sending the updated row data to the API.
1058
+
1059
+ Args:
1060
+ docId: The unique identifier of the document containing the target table (str).
1061
+ tableIdOrName: The unique identifier or name of the table containing the row to update (str).
1062
+ rowIdOrName: The unique identifier or name of the row to update within the table (str).
1063
+ row: A dictionary representing the new row data to be applied (dict).
1064
+ disableParsing: Optional flag to disable response parsing when set (Any, optional).
1065
+
1066
+ Returns:
1067
+ A dictionary containing the JSON response from the API after the row update.
1068
+
1069
+ Raises:
1070
+ ValueError: Raised if any required parameter ('docId', 'tableIdOrName', 'rowIdOrName', or 'row') is missing.
1071
+
1072
+ Tags:
1073
+ update, row, api, management, important
1074
+ """
1075
+ if docId is None:
1076
+ raise ValueError("Missing required parameter 'docId'")
1077
+ if tableIdOrName is None:
1078
+ raise ValueError("Missing required parameter 'tableIdOrName'")
1079
+ if rowIdOrName is None:
1080
+ raise ValueError("Missing required parameter 'rowIdOrName'")
1081
+ if row is None:
1082
+ raise ValueError("Missing required parameter 'row'")
1083
+ request_body = {
1084
+ "row": row,
1085
+ }
1086
+ request_body = {k: v for k, v in request_body.items() if v is not None}
1087
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows/{rowIdOrName}"
1088
+ query_params = {
1089
+ k: v for k, v in [("disableParsing", disableParsing)] if v is not None
1090
+ }
1091
+ response = self._put(url, data=request_body, params=query_params)
1092
+ response.raise_for_status()
1093
+ return response.json()
1094
+
1095
+ def delete_row(self, docId, tableIdOrName, rowIdOrName) -> dict[str, Any]:
1096
+ """
1097
+ Deletes a specific row from a table in the given document.
1098
+
1099
+ Args:
1100
+ docId: str. Unique identifier of the document containing the target table.
1101
+ tableIdOrName: str. Identifier or name of the table from which to delete the row.
1102
+ rowIdOrName: str. Identifier or name of the row to be deleted.
1103
+
1104
+ Returns:
1105
+ dict[str, Any]: JSON response from the API after deleting the row.
1106
+
1107
+ Raises:
1108
+ ValueError: Raised if any of 'docId', 'tableIdOrName', or 'rowIdOrName' is None.
1109
+ requests.HTTPError: Raised if the HTTP request to delete the row fails.
1110
+
1111
+ Tags:
1112
+ delete, row-management, api, important
1113
+ """
1114
+ if docId is None:
1115
+ raise ValueError("Missing required parameter 'docId'")
1116
+ if tableIdOrName is None:
1117
+ raise ValueError("Missing required parameter 'tableIdOrName'")
1118
+ if rowIdOrName is None:
1119
+ raise ValueError("Missing required parameter 'rowIdOrName'")
1120
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows/{rowIdOrName}"
1121
+ query_params = {}
1122
+ response = self._delete(url, params=query_params)
1123
+ response.raise_for_status()
1124
+ return response.json()
1125
+
1126
+ def push_button(
1127
+ self, docId, tableIdOrName, rowIdOrName, columnIdOrName
1128
+ ) -> dict[str, Any]:
1129
+ """
1130
+ Triggers a button action on a specified cell within a table row in a document and returns the result.
1131
+
1132
+ Args:
1133
+ docId: str. The unique identifier of the document containing the table.
1134
+ tableIdOrName: str. The ID or name of the target table within the document.
1135
+ rowIdOrName: str. The ID or name of the specific row in the table.
1136
+ columnIdOrName: str. The ID or name of the column representing the button to be pressed.
1137
+
1138
+ Returns:
1139
+ dict[str, Any]: The response from the API as a dictionary representing the result of the button action.
1140
+
1141
+ Raises:
1142
+ ValueError: If any of the required parameters ('docId', 'tableIdOrName', 'rowIdOrName', 'columnIdOrName') are None.
1143
+ requests.HTTPError: If the HTTP request to the API fails or returns an error status code.
1144
+
1145
+ Tags:
1146
+ trigger, button-action, table, api, management, important
1147
+ """
1148
+ if docId is None:
1149
+ raise ValueError("Missing required parameter 'docId'")
1150
+ if tableIdOrName is None:
1151
+ raise ValueError("Missing required parameter 'tableIdOrName'")
1152
+ if rowIdOrName is None:
1153
+ raise ValueError("Missing required parameter 'rowIdOrName'")
1154
+ if columnIdOrName is None:
1155
+ raise ValueError("Missing required parameter 'columnIdOrName'")
1156
+ url = f"{self.base_url}/docs/{docId}/tables/{tableIdOrName}/rows/{rowIdOrName}/buttons/{columnIdOrName}"
1157
+ query_params = {}
1158
+ response = self._post(url, data={}, params=query_params)
1159
+ response.raise_for_status()
1160
+ return response.json()
1161
+
1162
+ def list_formulas(
1163
+ self, docId, limit=None, pageToken=None, sortBy=None
1164
+ ) -> dict[str, Any]:
1165
+ """
1166
+ Retrieves a list of formulas for a specified document, supporting pagination and sorting options.
1167
+
1168
+ Args:
1169
+ docId: str. The unique identifier of the document whose formulas are to be listed. Required.
1170
+ limit: int, optional. Maximum number of formulas to return in the response.
1171
+ pageToken: str, optional. Token indicating the page of results to retrieve for pagination.
1172
+ sortBy: str, optional. Field by which to sort the formulas.
1173
+
1174
+ Returns:
1175
+ dict[str, Any]: A dictionary containing the list of formulas and related pagination data from the API response.
1176
+
1177
+ Raises:
1178
+ ValueError: If 'docId' is not provided.
1179
+ requests.HTTPError: If the API request fails due to an HTTP error.
1180
+
1181
+ Tags:
1182
+ list, formulas, document-management, api, important
1183
+ """
1184
+ if docId is None:
1185
+ raise ValueError("Missing required parameter 'docId'")
1186
+ url = f"{self.base_url}/docs/{docId}/formulas"
1187
+ query_params = {
1188
+ k: v
1189
+ for k, v in [("limit", limit), ("pageToken", pageToken), ("sortBy", sortBy)]
1190
+ if v is not None
1191
+ }
1192
+ response = self._get(url, params=query_params)
1193
+ response.raise_for_status()
1194
+ return response.json()
1195
+
1196
+ def get_formula(self, docId, formulaIdOrName) -> dict[str, Any]:
1197
+ """
1198
+ Retrieves details of a specific formula from a document by formula ID or name.
1199
+
1200
+ Args:
1201
+ docId: The unique identifier of the document containing the formula.
1202
+ formulaIdOrName: The unique identifier or name of the formula to retrieve.
1203
+
1204
+ Returns:
1205
+ A dictionary containing the formula details as returned by the API.
1206
+
1207
+ Raises:
1208
+ ValueError: If either 'docId' or 'formulaIdOrName' is not provided.
1209
+ requests.HTTPError: If the HTTP request to fetch the formula fails.
1210
+
1211
+ Tags:
1212
+ get, formula, ai, management, important
1213
+ """
1214
+ if docId is None:
1215
+ raise ValueError("Missing required parameter 'docId'")
1216
+ if formulaIdOrName is None:
1217
+ raise ValueError("Missing required parameter 'formulaIdOrName'")
1218
+ url = f"{self.base_url}/docs/{docId}/formulas/{formulaIdOrName}"
1219
+ query_params = {}
1220
+ response = self._get(url, params=query_params)
1221
+ response.raise_for_status()
1222
+ return response.json()
1223
+
1224
+ def list_controls(
1225
+ self, docId, limit=None, pageToken=None, sortBy=None
1226
+ ) -> dict[str, Any]:
1227
+ """
1228
+ Retrieves a paginated list of controls associated with a specific document.
1229
+
1230
+ Args:
1231
+ docId: str. The unique identifier of the document whose controls are to be listed.
1232
+ limit: Optional[int]. Maximum number of controls to return. If None, the server default is used.
1233
+ pageToken: Optional[str]. Token indicating the page of results to retrieve, for pagination.
1234
+ sortBy: Optional[str]. Field by which to sort the results. If None, uses the server default sorting.
1235
+
1236
+ Returns:
1237
+ dict[str, Any]: A dictionary containing the list of controls and associated metadata.
1238
+
1239
+ Raises:
1240
+ ValueError: If 'docId' is not provided.
1241
+ requests.HTTPError: If the HTTP request fails with an error response from the server.
1242
+
1243
+ Tags:
1244
+ list, controls, management, pagination, important
1245
+ """
1246
+ if docId is None:
1247
+ raise ValueError("Missing required parameter 'docId'")
1248
+ url = f"{self.base_url}/docs/{docId}/controls"
1249
+ query_params = {
1250
+ k: v
1251
+ for k, v in [("limit", limit), ("pageToken", pageToken), ("sortBy", sortBy)]
1252
+ if v is not None
1253
+ }
1254
+ response = self._get(url, params=query_params)
1255
+ response.raise_for_status()
1256
+ return response.json()
1257
+
1258
+ def get_control(self, docId, controlIdOrName) -> dict[str, Any]:
1259
+ """
1260
+ Retrieves details for a specific control in a document by its ID or name.
1261
+
1262
+ Args:
1263
+ docId: The unique identifier of the document containing the control.
1264
+ controlIdOrName: The unique identifier or name of the control to retrieve.
1265
+
1266
+ Returns:
1267
+ A dictionary containing the JSON representation of the control's details.
1268
+
1269
+ Raises:
1270
+ ValueError: Raised if 'docId' or 'controlIdOrName' is None.
1271
+ requests.HTTPError: Raised if the HTTP request to retrieve the control fails.
1272
+
1273
+ Tags:
1274
+ get, control, document, management, important
1275
+ """
1276
+ if docId is None:
1277
+ raise ValueError("Missing required parameter 'docId'")
1278
+ if controlIdOrName is None:
1279
+ raise ValueError("Missing required parameter 'controlIdOrName'")
1280
+ url = f"{self.base_url}/docs/{docId}/controls/{controlIdOrName}"
1281
+ query_params = {}
1282
+ response = self._get(url, params=query_params)
1283
+ response.raise_for_status()
1284
+ return response.json()
1285
+
1286
+ def list_custom_doc_domains(self, docId) -> dict[str, Any]:
1287
+ """
1288
+ Retrieve the list of custom domains associated with a specified document.
1289
+
1290
+ Args:
1291
+ docId: The unique identifier of the document for which to list custom domains.
1292
+
1293
+ Returns:
1294
+ A dictionary containing the custom domain information for the specified document.
1295
+
1296
+ Raises:
1297
+ ValueError: If 'docId' is None.
1298
+ requests.HTTPError: If the HTTP request to retrieve domain information fails.
1299
+
1300
+ Tags:
1301
+ list, domains, management, important
1302
+ """
1303
+ if docId is None:
1304
+ raise ValueError("Missing required parameter 'docId'")
1305
+ url = f"{self.base_url}/docs/${docId}/domains"
1306
+ query_params = {}
1307
+ response = self._get(url, params=query_params)
1308
+ response.raise_for_status()
1309
+ return response.json()
1310
+
1311
+ def add_custom_doc_domain(self, docId, customDocDomain) -> dict[str, Any]:
1312
+ """
1313
+ Adds a custom document domain to a specified document.
1314
+
1315
+ Args:
1316
+ docId: The unique identifier of the document to which the custom domain will be added.
1317
+ customDocDomain: A dictionary containing the custom domain details to associate with the document.
1318
+
1319
+ Returns:
1320
+ A dictionary representing the server's JSON response after adding the custom domain.
1321
+
1322
+ Raises:
1323
+ ValueError: Raised if 'docId' or 'customDocDomain' is None.
1324
+ requests.HTTPError: Raised if the HTTP request to add the custom document domain fails.
1325
+
1326
+ Tags:
1327
+ add, custom-domain, document-management, api, important
1328
+ """
1329
+ if docId is None:
1330
+ raise ValueError("Missing required parameter 'docId'")
1331
+ if customDocDomain is None:
1332
+ raise ValueError("Missing required parameter 'customDocDomain'")
1333
+ request_body = {
1334
+ "customDocDomain": customDocDomain,
1335
+ }
1336
+ request_body = {k: v for k, v in request_body.items() if v is not None}
1337
+ url = f"{self.base_url}/docs/${docId}/domains"
1338
+ query_params = {}
1339
+ response = self._post(url, data=request_body, params=query_params)
1340
+ response.raise_for_status()
1341
+ return response.json()
1342
+
1343
+ def delete_custom_doc_domain(self, docId, customDocDomain) -> dict[str, Any]:
1344
+ """
1345
+ Deletes a custom document domain for a specific document by sending a DELETE request to the API.
1346
+
1347
+ Args:
1348
+ docId: str. The unique identifier of the document whose custom domain is to be deleted.
1349
+ customDocDomain: str. The name of the custom domain associated with the document to be removed.
1350
+
1351
+ Returns:
1352
+ dict[str, Any]: The JSON response from the API after the custom domain is deleted.
1353
+
1354
+ Raises:
1355
+ ValueError: Raised if 'docId' or 'customDocDomain' is None.
1356
+ requests.HTTPError: Raised if the API response status code indicates an error.
1357
+
1358
+ Tags:
1359
+ delete, management, api, doc-domain, important
1360
+ """
1361
+ if docId is None:
1362
+ raise ValueError("Missing required parameter 'docId'")
1363
+ if customDocDomain is None:
1364
+ raise ValueError("Missing required parameter 'customDocDomain'")
1365
+ url = f"{self.base_url}/docs/{docId}/domains/{customDocDomain}"
1366
+ query_params = {}
1367
+ response = self._delete(url, params=query_params)
1368
+ response.raise_for_status()
1369
+ return response.json()
1370
+
1371
+ def get_custom_doc_domain_provider(self, customDocDomain) -> dict[str, Any]:
1372
+ """
1373
+ Retrieves provider information for a specified custom document domain.
1374
+
1375
+ Args:
1376
+ customDocDomain: The identifier of the custom document domain for which provider information is requested. Must not be None.
1377
+
1378
+ Returns:
1379
+ A dictionary containing the provider details for the specified custom document domain.
1380
+
1381
+ Raises:
1382
+ ValueError: Raised if 'customDocDomain' is None.
1383
+ requests.HTTPError: Raised if the HTTP request to fetch provider data fails with a non-success status code.
1384
+
1385
+ Tags:
1386
+ get, domain, provider, ai, management, important
1387
+ """
1388
+ if customDocDomain is None:
1389
+ raise ValueError("Missing required parameter 'customDocDomain'")
1390
+ url = f"{self.base_url}/domains/provider/{customDocDomain}"
1391
+ query_params = {}
1392
+ response = self._get(url, params=query_params)
1393
+ response.raise_for_status()
1394
+ return response.json()
1395
+
1396
+ def whoami(
1397
+ self,
1398
+ ) -> dict[str, Any]:
1399
+ """
1400
+ Retrieves information about the current authenticated user from the API.
1401
+
1402
+ Returns:
1403
+ dict[str, Any]: A dictionary containing details about the authenticated user as returned by the API.
1404
+
1405
+ Raises:
1406
+ HTTPError: If the HTTP request to the /whoami endpoint fails or returns an unsuccessful status code.
1407
+
1408
+ Tags:
1409
+ whoami, user-info, fetch, api, important
1410
+ """
1411
+ url = f"{self.base_url}/whoami"
1412
+ query_params = {}
1413
+ response = self._get(url, params=query_params)
1414
+ response.raise_for_status()
1415
+ return response.json()
1416
+
1417
+ def resolve_browser_link(self, url, degradeGracefully=None) -> dict[str, Any]:
1418
+ """
1419
+ Resolves a browser link for the provided URL, optionally degrading gracefully, and returns the server's JSON response.
1420
+
1421
+ Args:
1422
+ url: str. The target URL to be resolved. Must not be None.
1423
+ degradeGracefully: Optional[bool]. Whether to degrade gracefully on failure. If None, uses default behavior.
1424
+
1425
+ Returns:
1426
+ dict[str, Any]: The JSON response from the server containing the resolved browser link information.
1427
+
1428
+ Raises:
1429
+ ValueError: If the 'url' parameter is None.
1430
+ requests.HTTPError: If the HTTP request returned an unsuccessful status code.
1431
+
1432
+ Tags:
1433
+ resolve, browser-link, get, api, important
1434
+ """
1435
+ if url is None:
1436
+ raise ValueError("Missing required parameter 'url'")
1437
+ url = f"{self.base_url}/resolveBrowserLink"
1438
+ query_params = {
1439
+ k: v
1440
+ for k, v in [("url", url), ("degradeGracefully", degradeGracefully)]
1441
+ if v is not None
1442
+ }
1443
+ response = self._get(url, params=query_params)
1444
+ response.raise_for_status()
1445
+ return response.json()
1446
+
1447
+ def get_mutation_status(self, requestId) -> dict[str, Any]:
1448
+ """
1449
+ Retrieves the mutation status for a given request ID.
1450
+
1451
+ Args:
1452
+ requestId: str. The unique identifier of the mutation request for which to retrieve status.
1453
+
1454
+ Returns:
1455
+ dict[str, Any]: The status information of the mutation request retrieved from the API.
1456
+
1457
+ Raises:
1458
+ ValueError: Raised if requestId is None.
1459
+ requests.HTTPError: Raised if the HTTP request to the mutation status endpoint fails.
1460
+
1461
+ Tags:
1462
+ get, status, mutation, api, important
1463
+ """
1464
+ if requestId is None:
1465
+ raise ValueError("Missing required parameter 'requestId'")
1466
+ url = f"{self.base_url}/mutationStatus/{requestId}"
1467
+ query_params = {}
1468
+ response = self._get(url, params=query_params)
1469
+ response.raise_for_status()
1470
+ return response.json()
1471
+
1472
+ def trigger_webhook_automation(
1473
+ self, docId, ruleId, request_body=None
1474
+ ) -> dict[str, Any]:
1475
+ """
1476
+ Triggers a webhook automation for the specified document and rule.
1477
+
1478
+ Args:
1479
+ docId: str. The unique identifier of the document for which the webhook automation is to be triggered.
1480
+ ruleId: str. The unique identifier of the automation rule to trigger.
1481
+ request_body: Optional[dict]. The payload to be sent with the webhook automation request. Defaults to None.
1482
+
1483
+ Returns:
1484
+ dict. The JSON response from the triggered webhook automation.
1485
+
1486
+ Raises:
1487
+ ValueError: Raised if 'docId' or 'ruleId' is None.
1488
+ requests.exceptions.HTTPError: Raised if the HTTP request fails with a status error.
1489
+
1490
+ Tags:
1491
+ trigger, webhook, automation, api, important
1492
+ """
1493
+ if docId is None:
1494
+ raise ValueError("Missing required parameter 'docId'")
1495
+ if ruleId is None:
1496
+ raise ValueError("Missing required parameter 'ruleId'")
1497
+ url = f"{self.base_url}/docs/{docId}/hooks/automation/{ruleId}"
1498
+ query_params = {}
1499
+ response = self._post(url, data=request_body, params=query_params)
1500
+ response.raise_for_status()
1501
+ return response.json()
1502
+
1503
+ def list_page_analytics(
1504
+ self, docId, sinceDate=None, untilDate=None, pageToken=None, limit=None
1505
+ ) -> dict[str, Any]:
1506
+ """
1507
+ Retrieves analytics data for the pages of a specific document, supporting optional filtering and pagination.
1508
+
1509
+ Args:
1510
+ docId: str. The unique identifier of the document for which to retrieve page analytics. Required.
1511
+ sinceDate: Optional[str]. ISO-8601 formatted date string to filter analytics from this date onward.
1512
+ untilDate: Optional[str]. ISO-8601 formatted date string to filter analytics up to this date.
1513
+ pageToken: Optional[str]. Token for pagination to retrieve the next set of results.
1514
+ limit: Optional[int]. Maximum number of analytics records to return.
1515
+
1516
+ Returns:
1517
+ dict[str, Any]: A dictionary containing page analytics data for the specified document, possibly including pagination information.
1518
+
1519
+ Raises:
1520
+ ValueError: If 'docId' is not provided.
1521
+ HTTPError: If the HTTP request for page analytics fails.
1522
+
1523
+ Tags:
1524
+ list, analytics, pages, management, important
1525
+ """
1526
+ if docId is None:
1527
+ raise ValueError("Missing required parameter 'docId'")
1528
+ url = f"{self.base_url}/analytics/docs/{docId}/pages"
1529
+ query_params = {
1530
+ k: v
1531
+ for k, v in [
1532
+ ("sinceDate", sinceDate),
1533
+ ("untilDate", untilDate),
1534
+ ("pageToken", pageToken),
1535
+ ("limit", limit),
1536
+ ]
1537
+ if v is not None
1538
+ }
1539
+ response = self._get(url, params=query_params)
1540
+ response.raise_for_status()
1541
+ return response.json()
1542
+
1543
+ def list_doc_analytics_summary(
1544
+ self, isPublished=None, sinceDate=None, untilDate=None, workspaceId=None
1545
+ ) -> dict[str, Any]:
1546
+ """
1547
+ Retrieves a summary of document analytics with optional filtering by publication status, date range, and workspace.
1548
+
1549
+ Args:
1550
+ isPublished: Optional[bool]. If provided, filters results to include only published or unpublished documents.
1551
+ sinceDate: Optional[str]. ISO 8601 formatted date string representing the start of the summary period.
1552
+ untilDate: Optional[str]. ISO 8601 formatted date string representing the end of the summary period.
1553
+ workspaceId: Optional[str]. If provided, limits results to documents in the specified workspace.
1554
+
1555
+ Returns:
1556
+ dict[str, Any]: A dictionary containing the analytics summary for documents matching the specified filters.
1557
+
1558
+ Raises:
1559
+ requests.HTTPError: If the HTTP request fails or returns a non-success status code.
1560
+
1561
+ Tags:
1562
+ list, analytics, summary, docs, api, important
1563
+ """
1564
+ url = f"{self.base_url}/analytics/docs/summary"
1565
+ query_params = {
1566
+ k: v
1567
+ for k, v in [
1568
+ ("isPublished", isPublished),
1569
+ ("sinceDate", sinceDate),
1570
+ ("untilDate", untilDate),
1571
+ ("workspaceId", workspaceId),
1572
+ ]
1573
+ if v is not None
1574
+ }
1575
+ response = self._get(url, params=query_params)
1576
+ response.raise_for_status()
1577
+ return response.json()
1578
+
1579
+ def list_pack_analytics(
1580
+ self,
1581
+ packIds=None,
1582
+ workspaceId=None,
1583
+ query=None,
1584
+ sinceDate=None,
1585
+ untilDate=None,
1586
+ scale=None,
1587
+ pageToken=None,
1588
+ orderBy=None,
1589
+ direction=None,
1590
+ isPublished=None,
1591
+ limit=None,
1592
+ ) -> dict[str, Any]:
1593
+ """
1594
+ Retrieves analytics data for specified content packs with optional filtering and pagination.
1595
+
1596
+ Args:
1597
+ packIds: Optional[list[str]]. List of pack IDs to filter analytics data for specific packs.
1598
+ workspaceId: Optional[str]. Workspace identifier to filter analytics by workspace scope.
1599
+ query: Optional[str]. Search query to filter results by text matching.
1600
+ sinceDate: Optional[str]. Start date for filtering analytics data (inclusive, in ISO format).
1601
+ untilDate: Optional[str]. End date for filtering analytics data (inclusive, in ISO format).
1602
+ scale: Optional[str]. Aggregation scale (e.g., 'daily', 'monthly') for analytics data.
1603
+ pageToken: Optional[str]. Token to retrieve the next page of results for pagination.
1604
+ orderBy: Optional[str]. Field name to order the results by.
1605
+ direction: Optional[str]. Sorting direction, typically 'asc' or 'desc'.
1606
+ isPublished: Optional[bool]. Filter for published or unpublished packs.
1607
+ limit: Optional[int]. Maximum number of results to return per page.
1608
+
1609
+ Returns:
1610
+ dict[str, Any]: A dictionary containing the analytics data for the requested packs, with metadata and results as provided by the API.
1611
+
1612
+ Raises:
1613
+ requests.exceptions.HTTPError: If the HTTP request to the analytics API fails or returns a non-success status code.
1614
+
1615
+ Tags:
1616
+ list, analytics, pack, filter, pagination, management, important
1617
+ """
1618
+ url = f"{self.base_url}/analytics/packs"
1619
+ query_params = {
1620
+ k: v
1621
+ for k, v in [
1622
+ ("packIds", packIds),
1623
+ ("workspaceId", workspaceId),
1624
+ ("query", query),
1625
+ ("sinceDate", sinceDate),
1626
+ ("untilDate", untilDate),
1627
+ ("scale", scale),
1628
+ ("pageToken", pageToken),
1629
+ ("orderBy", orderBy),
1630
+ ("direction", direction),
1631
+ ("isPublished", isPublished),
1632
+ ("limit", limit),
1633
+ ]
1634
+ if v is not None
1635
+ }
1636
+ response = self._get(url, params=query_params)
1637
+ response.raise_for_status()
1638
+ return response.json()
1639
+
1640
+ def list_pack_analytics_summary(
1641
+ self,
1642
+ packIds=None,
1643
+ workspaceId=None,
1644
+ isPublished=None,
1645
+ sinceDate=None,
1646
+ untilDate=None,
1647
+ ) -> dict[str, Any]:
1648
+ """
1649
+ Retrieves a summary of analytics for one or more packs, optionally filtered by pack IDs, workspace, publication status, and date range.
1650
+
1651
+ Args:
1652
+ packIds: Optional list of pack IDs to filter the analytics summary. If None, includes all packs.
1653
+ workspaceId: Optional ID of the workspace to filter results. If None, results are not limited by workspace.
1654
+ isPublished: Optional boolean to filter packs by publication status. If None, both published and unpublished packs are included.
1655
+ sinceDate: Optional ISO8601 string representing the start date for analytics data. If None, no lower date bound is applied.
1656
+ untilDate: Optional ISO8601 string representing the end date for analytics data. If None, no upper date bound is applied.
1657
+
1658
+ Returns:
1659
+ dict: A dictionary containing the analytics summary for the specified packs and filters.
1660
+
1661
+ Raises:
1662
+ requests.HTTPError: If the HTTP request to the analytics endpoint returns an unsuccessful status code.
1663
+
1664
+ Tags:
1665
+ list, analytics, summary, pack, filter, important
1666
+ """
1667
+ url = f"{self.base_url}/analytics/packs/summary"
1668
+ query_params = {
1669
+ k: v
1670
+ for k, v in [
1671
+ ("packIds", packIds),
1672
+ ("workspaceId", workspaceId),
1673
+ ("isPublished", isPublished),
1674
+ ("sinceDate", sinceDate),
1675
+ ("untilDate", untilDate),
1676
+ ]
1677
+ if v is not None
1678
+ }
1679
+ response = self._get(url, params=query_params)
1680
+ response.raise_for_status()
1681
+ return response.json()
1682
+
1683
+ def list_pack_formula_analytics(
1684
+ self,
1685
+ packId,
1686
+ packFormulaNames=None,
1687
+ packFormulaTypes=None,
1688
+ sinceDate=None,
1689
+ untilDate=None,
1690
+ scale=None,
1691
+ pageToken=None,
1692
+ orderBy=None,
1693
+ direction=None,
1694
+ limit=None,
1695
+ ) -> dict[str, Any]:
1696
+ """
1697
+ Retrieves analytics data for formulas within a specified pack, supporting various filtering and pagination options.
1698
+
1699
+ Args:
1700
+ packId: str. The unique identifier of the pack whose formula analytics are to be listed. Required.
1701
+ packFormulaNames: Optional[list[str]]. Filter formulas by their names.
1702
+ packFormulaTypes: Optional[list[str]]. Filter formulas by their types.
1703
+ sinceDate: Optional[str]. Restrict analytics to those recorded on or after this date (ISO 8601 format).
1704
+ untilDate: Optional[str]. Restrict analytics to those recorded before this date (ISO 8601 format).
1705
+ scale: Optional[str]. Specify granularity of analytics (e.g., 'daily', 'monthly').
1706
+ pageToken: Optional[str]. Continuation token for paginated results.
1707
+ orderBy: Optional[str]. Field by which to order results.
1708
+ direction: Optional[str]. Sort direction for ordered results ('asc' or 'desc').
1709
+ limit: Optional[int]. Maximum number of results to return.
1710
+
1711
+ Returns:
1712
+ dict[str, Any]: A dictionary containing the analytics data for the pack formulas, including pagination fields and the analytics records.
1713
+
1714
+ Raises:
1715
+ ValueError: If 'packId' is not provided.
1716
+ requests.HTTPError: If the underlying HTTP request to the analytics endpoint fails.
1717
+
1718
+ Tags:
1719
+ list, analytics, batch, management, important
1720
+ """
1721
+ if packId is None:
1722
+ raise ValueError("Missing required parameter 'packId'")
1723
+ url = f"{self.base_url}/analytics/packs/{packId}/formulas"
1724
+ query_params = {
1725
+ k: v
1726
+ for k, v in [
1727
+ ("packFormulaNames", packFormulaNames),
1728
+ ("packFormulaTypes", packFormulaTypes),
1729
+ ("sinceDate", sinceDate),
1730
+ ("untilDate", untilDate),
1731
+ ("scale", scale),
1732
+ ("pageToken", pageToken),
1733
+ ("orderBy", orderBy),
1734
+ ("direction", direction),
1735
+ ("limit", limit),
1736
+ ]
1737
+ if v is not None
1738
+ }
1739
+ response = self._get(url, params=query_params)
1740
+ response.raise_for_status()
1741
+ return response.json()
1742
+
1743
+ def get_analytics_last_updated(
1744
+ self,
1745
+ ) -> dict[str, Any]:
1746
+ """
1747
+ Retrieves the timestamp indicating when analytics data was last updated from the analytics API endpoint.
1748
+
1749
+ Args:
1750
+ None: This function takes no arguments
1751
+
1752
+ Returns:
1753
+ dict: A dictionary containing information about the last analytics update, as parsed from the server's JSON response.
1754
+
1755
+ Raises:
1756
+ requests.HTTPError: If the HTTP request to the analytics endpoint fails or returns an error status code.
1757
+
1758
+ Tags:
1759
+ get, analytics, status, management, http, important
1760
+ """
1761
+ url = f"{self.base_url}/analytics/updated"
1762
+ query_params = {}
1763
+ response = self._get(url, params=query_params)
1764
+ response.raise_for_status()
1765
+ return response.json()
1766
+
1767
+ def list_workspace_members(
1768
+ self, workspaceId, includedRoles=None, pageToken=None
1769
+ ) -> dict[str, Any]:
1770
+ """
1771
+ Lists members of the specified workspace, optionally filtered by roles and paginated.
1772
+
1773
+ Args:
1774
+ workspaceId: The unique identifier of the workspace whose members are to be listed.
1775
+ includedRoles: Optional. A list or comma-separated string of roles to filter the listed members.
1776
+ pageToken: Optional. A token string for fetching the next page of results in paginated responses.
1777
+
1778
+ Returns:
1779
+ A dictionary containing details of the workspace members, which may include user information and pagination data.
1780
+
1781
+ Raises:
1782
+ ValueError: Raised if 'workspaceId' is None.
1783
+ requests.HTTPError: Raised if the HTTP request to fetch workspace members fails.
1784
+
1785
+ Tags:
1786
+ list, workspace, members, management, api, important
1787
+ """
1788
+ if workspaceId is None:
1789
+ raise ValueError("Missing required parameter 'workspaceId'")
1790
+ url = f"{self.base_url}/workspaces/{workspaceId}/users"
1791
+ query_params = {
1792
+ k: v
1793
+ for k, v in [("includedRoles", includedRoles), ("pageToken", pageToken)]
1794
+ if v is not None
1795
+ }
1796
+ response = self._get(url, params=query_params)
1797
+ response.raise_for_status()
1798
+ return response.json()
1799
+
1800
+ def change_user_role(self, workspaceId, email, newRole) -> dict[str, Any]:
1801
+ """
1802
+ Change the role of a user within a specific workspace.
1803
+
1804
+ Args:
1805
+ workspaceId: The unique identifier of the workspace where the user's role will be changed.
1806
+ email: The email address of the user whose role is to be modified.
1807
+ newRole: The new role to assign to the user within the workspace.
1808
+
1809
+ Returns:
1810
+ A dictionary containing the server's response with updated user information and role details.
1811
+
1812
+ Raises:
1813
+ ValueError: Raised if 'workspaceId', 'email', or 'newRole' are missing or None.
1814
+ requests.HTTPError: Raised if the HTTP request to change the user's role fails with an error response from the server.
1815
+
1816
+ Tags:
1817
+ change, user-management, role-assignment, api, important
1818
+ """
1819
+ if workspaceId is None:
1820
+ raise ValueError("Missing required parameter 'workspaceId'")
1821
+ if email is None:
1822
+ raise ValueError("Missing required parameter 'email'")
1823
+ if newRole is None:
1824
+ raise ValueError("Missing required parameter 'newRole'")
1825
+ request_body = {
1826
+ "email": email,
1827
+ "newRole": newRole,
1828
+ }
1829
+ request_body = {k: v for k, v in request_body.items() if v is not None}
1830
+ url = f"{self.base_url}/workspaces/{workspaceId}/users/role"
1831
+ query_params = {}
1832
+ response = self._post(url, data=request_body, params=query_params)
1833
+ response.raise_for_status()
1834
+ return response.json()
1835
+
1836
+ def list_workspace_role_activity(self, workspaceId) -> dict[str, Any]:
1837
+ """
1838
+ Retrieves activity details and permissions for all roles within a specified workspace.
1839
+
1840
+ Args:
1841
+ workspaceId: The unique identifier of the workspace for which to list role activity.
1842
+
1843
+ Returns:
1844
+ A dictionary containing activity and permission information for each role in the workspace.
1845
+
1846
+ Raises:
1847
+ ValueError: Raised if 'workspaceId' is None, indicating a required parameter is missing.
1848
+ requests.HTTPError: Raised if the HTTP request to the backend API fails or returns an error status.
1849
+
1850
+ Tags:
1851
+ list, roles, permissions, workspace, management, important
1852
+ """
1853
+ if workspaceId is None:
1854
+ raise ValueError("Missing required parameter 'workspaceId'")
1855
+ url = f"{self.base_url}/workspaces/{workspaceId}/roles"
1856
+ query_params = {}
1857
+ response = self._get(url, params=query_params)
1858
+ response.raise_for_status()
1859
+ return response.json()
1860
+
1861
+ def list_packs(
1862
+ self,
1863
+ accessType=None,
1864
+ accessTypes=None,
1865
+ sortBy=None,
1866
+ limit=None,
1867
+ direction=None,
1868
+ pageToken=None,
1869
+ onlyWorkspaceId=None,
1870
+ parentWorkspaceIds=None,
1871
+ excludePublicPacks=None,
1872
+ excludeIndividualAcls=None,
1873
+ excludeWorkspaceAcls=None,
1874
+ includeBrainOnlyPacks=None,
1875
+ ) -> dict[str, Any]:
1876
+ """
1877
+ Retrieves a list of packs with optional filtering, sorting, and pagination parameters.
1878
+
1879
+ Args:
1880
+ accessType: Optional[str]. Specifies a single access type to filter packs.
1881
+ accessTypes: Optional[list[str]]. List of access types to filter packs.
1882
+ sortBy: Optional[str]. Field by which to sort the results.
1883
+ limit: Optional[int]. Maximum number of packs to return.
1884
+ direction: Optional[str]. Direction to sort the results (e.g., 'asc' or 'desc').
1885
+ pageToken: Optional[str]. Token to retrieve a specific page of results.
1886
+ onlyWorkspaceId: Optional[str]. Restricts results to packs belonging only to the specified workspace.
1887
+ parentWorkspaceIds: Optional[list[str]]. Filters packs by parent workspace IDs.
1888
+ excludePublicPacks: Optional[bool]. If True, excludes public packs from the results.
1889
+ excludeIndividualAcls: Optional[bool]. If True, excludes packs with individual ACLs.
1890
+ excludeWorkspaceAcls: Optional[bool]. If True, excludes packs with workspace-level ACLs.
1891
+ includeBrainOnlyPacks: Optional[bool]. If True, includes only 'brain-only' packs in the result.
1892
+
1893
+ Returns:
1894
+ dict[str, Any]: A dictionary containing the list of packs and associated metadata.
1895
+
1896
+ Raises:
1897
+ requests.exceptions.HTTPError: If the HTTP request fails or the server responds with an error status code.
1898
+
1899
+ Tags:
1900
+ list, packs, filter, sort, pagination, management, important
1901
+ """
1902
+ url = f"{self.base_url}/packs"
1903
+ query_params = {
1904
+ k: v
1905
+ for k, v in [
1906
+ ("accessType", accessType),
1907
+ ("accessTypes", accessTypes),
1908
+ ("sortBy", sortBy),
1909
+ ("limit", limit),
1910
+ ("direction", direction),
1911
+ ("pageToken", pageToken),
1912
+ ("onlyWorkspaceId", onlyWorkspaceId),
1913
+ ("parentWorkspaceIds", parentWorkspaceIds),
1914
+ ("excludePublicPacks", excludePublicPacks),
1915
+ ("excludeIndividualAcls", excludeIndividualAcls),
1916
+ ("excludeWorkspaceAcls", excludeWorkspaceAcls),
1917
+ ("includeBrainOnlyPacks", includeBrainOnlyPacks),
1918
+ ]
1919
+ if v is not None
1920
+ }
1921
+ response = self._get(url, params=query_params)
1922
+ response.raise_for_status()
1923
+ return response.json()
1924
+
1925
+ def create_pack(
1926
+ self, workspaceId=None, name=None, description=None, sourcePackId=None
1927
+ ) -> dict[str, Any]:
1928
+ """
1929
+ Creates a new pack in the specified workspace, optionally cloning from an existing source pack.
1930
+
1931
+ Args:
1932
+ workspaceId: Optional; The unique identifier for the workspace in which to create the pack.
1933
+ name: Optional; The name of the new pack.
1934
+ description: Optional; A description for the new pack.
1935
+ sourcePackId: Optional; The identifier of an existing pack to use as a source for cloning.
1936
+
1937
+ Returns:
1938
+ A dictionary containing the details of the created pack as returned by the API.
1939
+
1940
+ Raises:
1941
+ HTTPError: Raised if the API request fails with an HTTP error response.
1942
+
1943
+ Tags:
1944
+ create, pack, management, api, important
1945
+ """
1946
+ request_body = {
1947
+ "workspaceId": workspaceId,
1948
+ "name": name,
1949
+ "description": description,
1950
+ "sourcePackId": sourcePackId,
1951
+ }
1952
+ request_body = {k: v for k, v in request_body.items() if v is not None}
1953
+ url = f"{self.base_url}/packs"
1954
+ query_params = {}
1955
+ response = self._post(url, data=request_body, params=query_params)
1956
+ response.raise_for_status()
1957
+ return response.json()
1958
+
1959
+ def get_pack(self, packId) -> dict[str, Any]:
1960
+ """
1961
+ Retrieves the details of a specific pack by its ID from the API.
1962
+
1963
+ Args:
1964
+ packId: The unique identifier of the pack to retrieve. Must not be None.
1965
+
1966
+ Returns:
1967
+ A dictionary containing the pack details returned by the API.
1968
+
1969
+ Raises:
1970
+ ValueError: If 'packId' is None.
1971
+ HTTPError: If the HTTP request to the API fails or returns an error status.
1972
+
1973
+ Tags:
1974
+ get, pack, api, management, important
1975
+ """
1976
+ if packId is None:
1977
+ raise ValueError("Missing required parameter 'packId'")
1978
+ url = f"{self.base_url}/packs/{packId}"
1979
+ query_params = {}
1980
+ response = self._get(url, params=query_params)
1981
+ response.raise_for_status()
1982
+ return response.json()
1983
+
1984
+ def update_pack(
1985
+ self,
1986
+ packId,
1987
+ overallRateLimit=None,
1988
+ perConnectionRateLimit=None,
1989
+ logoAssetId=None,
1990
+ coverAssetId=None,
1991
+ exampleImages=None,
1992
+ sourceCodeVisibility=None,
1993
+ name=None,
1994
+ description=None,
1995
+ shortDescription=None,
1996
+ supportEmail=None,
1997
+ termsOfServiceUrl=None,
1998
+ privacyPolicyUrl=None,
1999
+ ) -> dict[str, Any]:
2000
+ """
2001
+ Updates the properties of an existing pack using the specified parameters.
2002
+
2003
+ Args:
2004
+ packId: str. The unique identifier of the pack to update. Required.
2005
+ overallRateLimit: Optional[int]. The maximum allowed requests per time period across all connections.
2006
+ perConnectionRateLimit: Optional[int]. The maximum allowed requests per time period per connection.
2007
+ logoAssetId: Optional[str]. The asset ID for the pack's logo image.
2008
+ coverAssetId: Optional[str]. The asset ID for the pack's cover image.
2009
+ exampleImages: Optional[list]. A list of example image asset IDs for the pack.
2010
+ sourceCodeVisibility: Optional[str]. The visibility setting for the pack's source code.
2011
+ name: Optional[str]. The display name of the pack.
2012
+ description: Optional[str]. The full description of the pack.
2013
+ shortDescription: Optional[str]. The short description of the pack.
2014
+ supportEmail: Optional[str]. A support email address for the pack.
2015
+ termsOfServiceUrl: Optional[str]. URL to the pack's terms of service.
2016
+ privacyPolicyUrl: Optional[str]. URL to the pack's privacy policy.
2017
+
2018
+ Returns:
2019
+ dict. A dictionary containing the updated pack's data returned by the server.
2020
+
2021
+ Raises:
2022
+ ValueError: If 'packId' is not provided.
2023
+ requests.HTTPError: If the HTTP request to update the pack fails.
2024
+
2025
+ Tags:
2026
+ update, pack-management, api, important
2027
+ """
2028
+ if packId is None:
2029
+ raise ValueError("Missing required parameter 'packId'")
2030
+ request_body = {
2031
+ "overallRateLimit": overallRateLimit,
2032
+ "perConnectionRateLimit": perConnectionRateLimit,
2033
+ "logoAssetId": logoAssetId,
2034
+ "coverAssetId": coverAssetId,
2035
+ "exampleImages": exampleImages,
2036
+ "sourceCodeVisibility": sourceCodeVisibility,
2037
+ "name": name,
2038
+ "description": description,
2039
+ "shortDescription": shortDescription,
2040
+ "supportEmail": supportEmail,
2041
+ "termsOfServiceUrl": termsOfServiceUrl,
2042
+ "privacyPolicyUrl": privacyPolicyUrl,
2043
+ }
2044
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2045
+ url = f"{self.base_url}/packs/{packId}"
2046
+ query_params = {}
2047
+ response = self._patch(url, data=request_body, params=query_params)
2048
+ response.raise_for_status()
2049
+ return response.json()
2050
+
2051
+ def delete_pack(self, packId) -> dict[str, Any]:
2052
+ """
2053
+ Deletes a pack by its unique identifier and returns the response from the server.
2054
+
2055
+ Args:
2056
+ packId: str. The unique identifier of the pack to be deleted.
2057
+
2058
+ Returns:
2059
+ dict[str, Any]: The server response parsed as a dictionary containing the result of the delete operation.
2060
+
2061
+ Raises:
2062
+ ValueError: If 'packId' is None.
2063
+ HTTPError: If the HTTP request to delete the pack fails with an error status code.
2064
+
2065
+ Tags:
2066
+ delete, pack-management, async-job, important
2067
+ """
2068
+ if packId is None:
2069
+ raise ValueError("Missing required parameter 'packId'")
2070
+ url = f"{self.base_url}/packs/{packId}"
2071
+ query_params = {}
2072
+ response = self._delete(url, params=query_params)
2073
+ response.raise_for_status()
2074
+ return response.json()
2075
+
2076
+ def get_pack_configuration_schema(self, packId) -> dict[str, Any]:
2077
+ """
2078
+ Retrieves the configuration schema for a given pack by its identifier.
2079
+
2080
+ Args:
2081
+ packId: str. The unique identifier of the pack whose configuration schema is to be retrieved.
2082
+
2083
+ Returns:
2084
+ dict[str, Any]: The configuration schema of the specified pack as a dictionary.
2085
+
2086
+ Raises:
2087
+ ValueError: If 'packId' is None.
2088
+ requests.HTTPError: If the HTTP request to fetch the schema fails (e.g., network issues, non-2xx response).
2089
+
2090
+ Tags:
2091
+ get, configuration, schema, pack, api, important
2092
+ """
2093
+ if packId is None:
2094
+ raise ValueError("Missing required parameter 'packId'")
2095
+ url = f"{self.base_url}/packs/{packId}/configurations/schema"
2096
+ query_params = {}
2097
+ response = self._get(url, params=query_params)
2098
+ response.raise_for_status()
2099
+ return response.json()
2100
+
2101
+ def list_pack_versions(self, packId, limit=None, pageToken=None) -> dict[str, Any]:
2102
+ """
2103
+ Retrieves a paginated list of versions for the specified pack.
2104
+
2105
+ Args:
2106
+ packId: The unique identifier of the pack whose versions are to be listed.
2107
+ limit: Optional; maximum number of versions to return in the response.
2108
+ pageToken: Optional; token indicating the page of results to retrieve for pagination.
2109
+
2110
+ Returns:
2111
+ A dictionary containing the list of pack versions and pagination metadata as returned by the API.
2112
+
2113
+ Raises:
2114
+ ValueError: Raised if 'packId' is not provided.
2115
+ HTTPError: Raised if the HTTP request to the API fails.
2116
+
2117
+ Tags:
2118
+ list, versions, api, management, paginated, important
2119
+ """
2120
+ if packId is None:
2121
+ raise ValueError("Missing required parameter 'packId'")
2122
+ url = f"{self.base_url}/packs/{packId}/versions"
2123
+ query_params = {
2124
+ k: v
2125
+ for k, v in [("limit", limit), ("pageToken", pageToken)]
2126
+ if v is not None
2127
+ }
2128
+ response = self._get(url, params=query_params)
2129
+ response.raise_for_status()
2130
+ return response.json()
2131
+
2132
+ def get_next_pack_version(
2133
+ self, packId, proposedMetadata, sdkVersion=None
2134
+ ) -> dict[str, Any]:
2135
+ """
2136
+ Determines the next available version for a given pack based on proposed metadata and optional SDK version.
2137
+
2138
+ Args:
2139
+ packId: str. The unique identifier of the pack for which the next version is to be determined.
2140
+ proposedMetadata: dict. Metadata describing the proposed changes or updates for the pack.
2141
+ sdkVersion: str, optional. The SDK version to use when determining the next pack version. If not provided, defaults to None.
2142
+
2143
+ Returns:
2144
+ dict. A dictionary containing information about the next available pack version, as returned by the server.
2145
+
2146
+ Raises:
2147
+ ValueError: If 'packId' or 'proposedMetadata' is not provided.
2148
+ requests.HTTPError: If the HTTP request to the server fails or returns a non-success status.
2149
+
2150
+ Tags:
2151
+ get, version, pack-management, important, ai
2152
+ """
2153
+ if packId is None:
2154
+ raise ValueError("Missing required parameter 'packId'")
2155
+ if proposedMetadata is None:
2156
+ raise ValueError("Missing required parameter 'proposedMetadata'")
2157
+ request_body = {
2158
+ "proposedMetadata": proposedMetadata,
2159
+ "sdkVersion": sdkVersion,
2160
+ }
2161
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2162
+ url = f"{self.base_url}/packs/{packId}/nextVersion"
2163
+ query_params = {}
2164
+ response = self._post(url, data=request_body, params=query_params)
2165
+ response.raise_for_status()
2166
+ return response.json()
2167
+
2168
+ def get_pack_version_diffs(
2169
+ self, packId, basePackVersion, targetPackVersion
2170
+ ) -> dict[str, Any]:
2171
+ """
2172
+ Retrieves the differences between two specific versions of a given pack.
2173
+
2174
+ Args:
2175
+ packId: The unique identifier of the pack to compare.
2176
+ basePackVersion: The base version of the pack to compare from.
2177
+ targetPackVersion: The target version of the pack to compare to.
2178
+
2179
+ Returns:
2180
+ A dictionary containing the differences between the specified pack versions.
2181
+
2182
+ Raises:
2183
+ ValueError: Raised if 'packId', 'basePackVersion', or 'targetPackVersion' is None.
2184
+ HTTPError: Raised if the HTTP request to retrieve the version differences fails.
2185
+
2186
+ Tags:
2187
+ get, diff, pack-management, version-control, important
2188
+ """
2189
+ if packId is None:
2190
+ raise ValueError("Missing required parameter 'packId'")
2191
+ if basePackVersion is None:
2192
+ raise ValueError("Missing required parameter 'basePackVersion'")
2193
+ if targetPackVersion is None:
2194
+ raise ValueError("Missing required parameter 'targetPackVersion'")
2195
+ url = f"{self.base_url}/packs/{packId}/versions/{basePackVersion}/diff/{targetPackVersion}"
2196
+ query_params = {}
2197
+ response = self._get(url, params=query_params)
2198
+ response.raise_for_status()
2199
+ return response.json()
2200
+
2201
+ def register_pack_version(self, packId, packVersion, bundleHash) -> dict[str, Any]:
2202
+ """
2203
+ Registers a new version of a pack with the given identifiers and bundle hash.
2204
+
2205
+ Args:
2206
+ packId: str. Unique identifier of the pack to register the version for.
2207
+ packVersion: str. Semantic version string of the pack to register.
2208
+ bundleHash: str. Hash representing the specific bundle/content for this version.
2209
+
2210
+ Returns:
2211
+ dict. The server response as a dictionary containing registration details for the pack version.
2212
+
2213
+ Raises:
2214
+ ValueError: If any of 'packId', 'packVersion', or 'bundleHash' is None.
2215
+ HTTPError: If the HTTP request to register the pack version fails (e.g., non-2xx response).
2216
+
2217
+ Tags:
2218
+ register, pack-management, async-job, important
2219
+ """
2220
+ if packId is None:
2221
+ raise ValueError("Missing required parameter 'packId'")
2222
+ if packVersion is None:
2223
+ raise ValueError("Missing required parameter 'packVersion'")
2224
+ if bundleHash is None:
2225
+ raise ValueError("Missing required parameter 'bundleHash'")
2226
+ request_body = {
2227
+ "bundleHash": bundleHash,
2228
+ }
2229
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2230
+ url = f"{self.base_url}/packs/{packId}/versions/{packVersion}/register"
2231
+ query_params = {}
2232
+ response = self._post(url, data=request_body, params=query_params)
2233
+ response.raise_for_status()
2234
+ return response.json()
2235
+
2236
+ def pack_version_upload_complete(
2237
+ self, packId, packVersion, notes=None, source=None, allowOlderSdkVersion=None
2238
+ ) -> dict[str, Any]:
2239
+ """
2240
+ Marks a pack version upload as complete and notifies the server with optional metadata.
2241
+
2242
+ Args:
2243
+ packId: str. Unique identifier of the pack whose version upload is being completed. Required.
2244
+ packVersion: str. Version string of the pack being marked as uploaded. Required.
2245
+ notes: Optional[str]. Additional notes about the upload or the version. Defaults to None.
2246
+ source: Optional[str]. Source identifier or metadata for the upload. Defaults to None.
2247
+ allowOlderSdkVersion: Optional[bool]. Whether to allow this pack version to specify an older SDK version. Defaults to None.
2248
+
2249
+ Returns:
2250
+ dict[str, Any]: JSON response from the server after upload completion notification.
2251
+
2252
+ Raises:
2253
+ ValueError: If 'packId' or 'packVersion' is not provided.
2254
+ requests.HTTPError: If the HTTP request fails or an error response is returned by the server.
2255
+
2256
+ Tags:
2257
+ upload-complete, pack-management, post, api, important
2258
+ """
2259
+ if packId is None:
2260
+ raise ValueError("Missing required parameter 'packId'")
2261
+ if packVersion is None:
2262
+ raise ValueError("Missing required parameter 'packVersion'")
2263
+ request_body = {
2264
+ "notes": notes,
2265
+ "source": source,
2266
+ "allowOlderSdkVersion": allowOlderSdkVersion,
2267
+ }
2268
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2269
+ url = f"{self.base_url}/packs/{packId}/versions/{packVersion}/uploadComplete"
2270
+ query_params = {}
2271
+ response = self._post(url, data=request_body, params=query_params)
2272
+ response.raise_for_status()
2273
+ return response.json()
2274
+
2275
+ def create_pack_release(
2276
+ self, packId, packVersion, releaseNotes=None
2277
+ ) -> dict[str, Any]:
2278
+ """
2279
+ Creates a new release for the specified pack with the given version and optional release notes.
2280
+
2281
+ Args:
2282
+ packId: str. Unique identifier of the pack for which the release is created.
2283
+ packVersion: str. Version number of the pack being released.
2284
+ releaseNotes: Optional[str]. Additional notes describing the release. Defaults to None.
2285
+
2286
+ Returns:
2287
+ dict. The JSON response from the server containing details about the created pack release.
2288
+
2289
+ Raises:
2290
+ ValueError: Raised if 'packId' or 'packVersion' is not provided.
2291
+ requests.HTTPError: Raised if the HTTP request to create the release fails.
2292
+
2293
+ Tags:
2294
+ create, pack-release, management, important
2295
+ """
2296
+ if packId is None:
2297
+ raise ValueError("Missing required parameter 'packId'")
2298
+ if packVersion is None:
2299
+ raise ValueError("Missing required parameter 'packVersion'")
2300
+ request_body = {
2301
+ "packVersion": packVersion,
2302
+ "releaseNotes": releaseNotes,
2303
+ }
2304
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2305
+ url = f"{self.base_url}/packs/{packId}/releases"
2306
+ query_params = {}
2307
+ response = self._post(url, data=request_body, params=query_params)
2308
+ response.raise_for_status()
2309
+ return response.json()
2310
+
2311
+ def list_pack_releases(self, packId, limit=None, pageToken=None) -> dict[str, Any]:
2312
+ """
2313
+ Retrieves a list of releases for a specified pack, supporting pagination.
2314
+
2315
+ Args:
2316
+ packId: str. Unique identifier of the pack whose releases are to be listed.
2317
+ limit: Optional[int]. Maximum number of releases to return per page. If not specified, the default backend limit is used.
2318
+ pageToken: Optional[str]. Token for pagination to retrieve the next page of results.
2319
+
2320
+ Returns:
2321
+ dict[str, Any]: A dictionary containing release data and pagination metadata as returned by the backend API.
2322
+
2323
+ Raises:
2324
+ ValueError: Raised if 'packId' is None.
2325
+ requests.HTTPError: Raised if the HTTP request to the backend API fails.
2326
+
2327
+ Tags:
2328
+ list, pack-releases, api, management, important
2329
+ """
2330
+ if packId is None:
2331
+ raise ValueError("Missing required parameter 'packId'")
2332
+ url = f"{self.base_url}/packs/{packId}/releases"
2333
+ query_params = {
2334
+ k: v
2335
+ for k, v in [("limit", limit), ("pageToken", pageToken)]
2336
+ if v is not None
2337
+ }
2338
+ response = self._get(url, params=query_params)
2339
+ response.raise_for_status()
2340
+ return response.json()
2341
+
2342
+ def update_pack_release(
2343
+ self, packId, packReleaseId, releaseNotes=None
2344
+ ) -> dict[str, Any]:
2345
+ """
2346
+ Updates the release information for a specific pack, including optional release notes.
2347
+
2348
+ Args:
2349
+ packId: str. Unique identifier for the pack whose release is being updated.
2350
+ packReleaseId: str. Unique identifier for the release within the specified pack.
2351
+ releaseNotes: Optional[str]. Additional notes or description for the release. Defaults to None.
2352
+
2353
+ Returns:
2354
+ dict[str, Any]: Parsed JSON response from the server containing updated release details.
2355
+
2356
+ Raises:
2357
+ ValueError: If 'packId' or 'packReleaseId' is not provided.
2358
+ HTTPError: If the HTTP request fails or returns a non-success status code.
2359
+
2360
+ Tags:
2361
+ update, pack-management, release, api, important
2362
+ """
2363
+ if packId is None:
2364
+ raise ValueError("Missing required parameter 'packId'")
2365
+ if packReleaseId is None:
2366
+ raise ValueError("Missing required parameter 'packReleaseId'")
2367
+ request_body = {
2368
+ "releaseNotes": releaseNotes,
2369
+ }
2370
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2371
+ url = f"{self.base_url}/packs/{packId}/releases/{packReleaseId}"
2372
+ query_params = {}
2373
+ response = self._put(url, data=request_body, params=query_params)
2374
+ response.raise_for_status()
2375
+ return response.json()
2376
+
2377
+ def set_pack_oauth_config(
2378
+ self, packId, clientId=None, clientSecret=None, redirectUri=None
2379
+ ) -> dict[str, Any]:
2380
+ """
2381
+ Configures or updates the OAuth settings for a specific pack by sending the provided client credentials and redirect URI to the server.
2382
+
2383
+ Args:
2384
+ packId: str. The unique identifier of the pack whose OAuth configuration is to be set. Required.
2385
+ clientId: str, optional. The OAuth client ID to be associated with the pack.
2386
+ clientSecret: str, optional. The OAuth client secret to be associated with the pack.
2387
+ redirectUri: str, optional. The redirect URI to be used for OAuth callbacks.
2388
+
2389
+ Returns:
2390
+ dict[str, Any]: The server's JSON response containing the updated OAuth configuration for the pack.
2391
+
2392
+ Raises:
2393
+ ValueError: Raised if 'packId' is not provided or is None.
2394
+ requests.HTTPError: Raised if the HTTP request to update the OAuth configuration fails.
2395
+
2396
+ Tags:
2397
+ set, oauth-config, management, important
2398
+ """
2399
+ if packId is None:
2400
+ raise ValueError("Missing required parameter 'packId'")
2401
+ request_body = {
2402
+ "clientId": clientId,
2403
+ "clientSecret": clientSecret,
2404
+ "redirectUri": redirectUri,
2405
+ }
2406
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2407
+ url = f"{self.base_url}/packs/{packId}/oauthConfig"
2408
+ query_params = {}
2409
+ response = self._put(url, data=request_body, params=query_params)
2410
+ response.raise_for_status()
2411
+ return response.json()
2412
+
2413
+ def get_pack_oauth_config(self, packId) -> dict[str, Any]:
2414
+ """
2415
+ Retrieves the OAuth configuration for a specific pack identified by packId.
2416
+
2417
+ Args:
2418
+ packId: str. The unique identifier of the pack for which to fetch the OAuth configuration.
2419
+
2420
+ Returns:
2421
+ dict[str, Any]: A dictionary containing the OAuth configuration data for the specified pack.
2422
+
2423
+ Raises:
2424
+ ValueError: Raised when the 'packId' parameter is None.
2425
+ requests.HTTPError: Raised if the HTTP request to retrieve the OAuth configuration fails (non-success status code).
2426
+
2427
+ Tags:
2428
+ get, oauth-config, pack, management, important
2429
+ """
2430
+ if packId is None:
2431
+ raise ValueError("Missing required parameter 'packId'")
2432
+ url = f"{self.base_url}/packs/{packId}/oauthConfig"
2433
+ query_params = {}
2434
+ response = self._get(url, params=query_params)
2435
+ response.raise_for_status()
2436
+ return response.json()
2437
+
2438
+ def set_pack_system_connection(self, packId, credentials) -> dict[str, Any]:
2439
+ """
2440
+ Sets the system connection for a specified pack using provided credentials.
2441
+
2442
+ Args:
2443
+ packId: str. Unique identifier of the pack for which the system connection is being set.
2444
+ credentials: Any. Credentials required to establish the system connection.
2445
+
2446
+ Returns:
2447
+ dict. JSON response from the API after setting the system connection.
2448
+
2449
+ Raises:
2450
+ ValueError: Raised if 'packId' or 'credentials' is None.
2451
+ requests.HTTPError: Raised if the HTTP request to set the system connection fails.
2452
+
2453
+ Tags:
2454
+ set, system-connection, pack, management, api, important
2455
+ """
2456
+ if packId is None:
2457
+ raise ValueError("Missing required parameter 'packId'")
2458
+ if credentials is None:
2459
+ raise ValueError("Missing required parameter 'credentials'")
2460
+ request_body = {
2461
+ "credentials": credentials,
2462
+ }
2463
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2464
+ url = f"{self.base_url}/packs/{packId}/systemConnection"
2465
+ query_params = {}
2466
+ response = self._put(url, data=request_body, params=query_params)
2467
+ response.raise_for_status()
2468
+ return response.json()
2469
+
2470
+ def get_pack_system_connection(self, packId) -> dict[str, Any]:
2471
+ """
2472
+ Retrieves the system connection information for a specified pack by its ID.
2473
+
2474
+ Args:
2475
+ packId: str. The unique identifier of the pack whose system connection details are to be retrieved.
2476
+
2477
+ Returns:
2478
+ dict[str, Any]: A dictionary containing the system connection information for the specified pack.
2479
+
2480
+ Raises:
2481
+ ValueError: Raised if 'packId' is None.
2482
+ requests.HTTPError: Raised if the HTTP request to the backend fails or returns an error status.
2483
+
2484
+ Tags:
2485
+ get, system-connection, pack, management, important
2486
+ """
2487
+ if packId is None:
2488
+ raise ValueError("Missing required parameter 'packId'")
2489
+ url = f"{self.base_url}/packs/{packId}/systemConnection"
2490
+ query_params = {}
2491
+ response = self._get(url, params=query_params)
2492
+ response.raise_for_status()
2493
+ return response.json()
2494
+
2495
+ def get_pack_permissions(self, packId) -> dict[str, Any]:
2496
+ """
2497
+ Retrieves the permissions associated with the specified pack.
2498
+
2499
+ Args:
2500
+ packId: str. The unique identifier of the pack whose permissions are to be retrieved.
2501
+
2502
+ Returns:
2503
+ dict[str, Any]: A dictionary containing the permissions data for the specified pack.
2504
+
2505
+ Raises:
2506
+ ValueError: If 'packId' is None.
2507
+ requests.HTTPError: If the HTTP request to retrieve permissions fails.
2508
+
2509
+ Tags:
2510
+ get, permissions, pack, important, ai, management
2511
+ """
2512
+ if packId is None:
2513
+ raise ValueError("Missing required parameter 'packId'")
2514
+ url = f"{self.base_url}/packs/{packId}/permissions"
2515
+ query_params = {}
2516
+ response = self._get(url, params=query_params)
2517
+ response.raise_for_status()
2518
+ return response.json()
2519
+
2520
+ def add_pack_permission(self, packId, principal, access) -> dict[str, Any]:
2521
+ """
2522
+ Adds a permission for a specified principal to a pack.
2523
+
2524
+ Args:
2525
+ packId: The unique identifier of the pack to which the permission will be added.
2526
+ principal: The user or group to whom the permission is being granted.
2527
+ access: The type of access being granted (e.g., 'read', 'write').
2528
+
2529
+ Returns:
2530
+ A dictionary containing the API response data from adding the pack permission.
2531
+
2532
+ Raises:
2533
+ ValueError: Raised if any of the parameters 'packId', 'principal', or 'access' is None.
2534
+ requests.HTTPError: Raised if the API request fails with an HTTP error status.
2535
+
2536
+ Tags:
2537
+ add, permission, pack-management, api, important
2538
+ """
2539
+ if packId is None:
2540
+ raise ValueError("Missing required parameter 'packId'")
2541
+ if principal is None:
2542
+ raise ValueError("Missing required parameter 'principal'")
2543
+ if access is None:
2544
+ raise ValueError("Missing required parameter 'access'")
2545
+ request_body = {
2546
+ "principal": principal,
2547
+ "access": access,
2548
+ }
2549
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2550
+ url = f"{self.base_url}/packs/{packId}/permissions"
2551
+ query_params = {}
2552
+ response = self._post(url, data=request_body, params=query_params)
2553
+ response.raise_for_status()
2554
+ return response.json()
2555
+
2556
+ def delete_pack_permission(self, packId, permissionId) -> dict[str, Any]:
2557
+ """
2558
+ Deletes a specific permission from a pack using the provided pack and permission IDs.
2559
+
2560
+ Args:
2561
+ packId: str. The unique identifier of the pack from which the permission will be deleted.
2562
+ permissionId: str. The unique identifier of the permission to be deleted.
2563
+
2564
+ Returns:
2565
+ dict[str, Any]: The server response as a dictionary containing confirmation or details of the deleted permission.
2566
+
2567
+ Raises:
2568
+ ValueError: Raised if either 'packId' or 'permissionId' is None.
2569
+ requests.HTTPError: Raised if the HTTP request to delete the permission fails.
2570
+
2571
+ Tags:
2572
+ delete, permission-management, important
2573
+ """
2574
+ if packId is None:
2575
+ raise ValueError("Missing required parameter 'packId'")
2576
+ if permissionId is None:
2577
+ raise ValueError("Missing required parameter 'permissionId'")
2578
+ url = f"{self.base_url}/packs/{packId}/permissions/{permissionId}"
2579
+ query_params = {}
2580
+ response = self._delete(url, params=query_params)
2581
+ response.raise_for_status()
2582
+ return response.json()
2583
+
2584
+ def list_pack_makers(self, packId) -> dict[str, Any]:
2585
+ """
2586
+ Retrieves a list of makers associated with the specified pack.
2587
+
2588
+ Args:
2589
+ packId: The unique identifier of the pack whose makers are to be listed.
2590
+
2591
+ Returns:
2592
+ A dictionary containing the makers for the specified pack as returned by the API.
2593
+
2594
+ Raises:
2595
+ ValueError: If 'packId' is None.
2596
+ HTTPError: If the HTTP request to retrieve makers fails.
2597
+
2598
+ Tags:
2599
+ list, pack, makers, api, important
2600
+ """
2601
+ if packId is None:
2602
+ raise ValueError("Missing required parameter 'packId'")
2603
+ url = f"{self.base_url}/packs/{packId}/makers"
2604
+ query_params = {}
2605
+ response = self._get(url, params=query_params)
2606
+ response.raise_for_status()
2607
+ return response.json()
2608
+
2609
+ def add_pack_maker(self, packId, loginId) -> dict[str, Any]:
2610
+ """
2611
+ Adds a maker to a specified pack using the provided login ID.
2612
+
2613
+ Args:
2614
+ packId: The unique identifier of the pack to which the maker will be added.
2615
+ loginId: The login ID of the maker to be added to the pack.
2616
+
2617
+ Returns:
2618
+ A dictionary containing the server's JSON response with details about the added maker.
2619
+
2620
+ Raises:
2621
+ ValueError: Raised if 'packId' or 'loginId' is None.
2622
+ HTTPError: Raised if the POST request to the server returns an unsuccessful status code.
2623
+
2624
+ Tags:
2625
+ add, maker, packs, management, important
2626
+ """
2627
+ if packId is None:
2628
+ raise ValueError("Missing required parameter 'packId'")
2629
+ if loginId is None:
2630
+ raise ValueError("Missing required parameter 'loginId'")
2631
+ request_body = {
2632
+ "loginId": loginId,
2633
+ }
2634
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2635
+ url = f"{self.base_url}/packs/{packId}/maker"
2636
+ query_params = {}
2637
+ response = self._post(url, data=request_body, params=query_params)
2638
+ response.raise_for_status()
2639
+ return response.json()
2640
+
2641
+ def delete_pack_maker(self, packId, loginId) -> dict[str, Any]:
2642
+ """
2643
+ Deletes a maker from a specified pack using the provided pack and login IDs.
2644
+
2645
+ Args:
2646
+ packId: The unique identifier of the pack from which the maker will be deleted.
2647
+ loginId: The login identifier of the maker to be deleted from the pack.
2648
+
2649
+ Returns:
2650
+ A dictionary containing the server's JSON response indicating the result of the delete operation.
2651
+
2652
+ Raises:
2653
+ ValueError: Raised if 'packId' or 'loginId' is None.
2654
+ requests.HTTPError: Raised if the HTTP request fails or returns an unsuccessful status code.
2655
+
2656
+ Tags:
2657
+ delete, pack-management, maker-management, important
2658
+ """
2659
+ if packId is None:
2660
+ raise ValueError("Missing required parameter 'packId'")
2661
+ if loginId is None:
2662
+ raise ValueError("Missing required parameter 'loginId'")
2663
+ url = f"{self.base_url}/packs/{packId}/maker/{loginId}"
2664
+ query_params = {}
2665
+ response = self._delete(url, params=query_params)
2666
+ response.raise_for_status()
2667
+ return response.json()
2668
+
2669
+ def list_pack_categories(self, packId) -> dict[str, Any]:
2670
+ """
2671
+ Retrieves the list of categories associated with a specific pack.
2672
+
2673
+ Args:
2674
+ packId: The unique identifier of the pack for which categories are to be listed.
2675
+
2676
+ Returns:
2677
+ A dictionary containing the categories data for the specified pack.
2678
+
2679
+ Raises:
2680
+ ValueError: If 'packId' is None.
2681
+ requests.HTTPError: If the HTTP request to retrieve categories fails.
2682
+
2683
+ Tags:
2684
+ list, categories, pack, api, management, important
2685
+ """
2686
+ if packId is None:
2687
+ raise ValueError("Missing required parameter 'packId'")
2688
+ url = f"{self.base_url}/packs/{packId}/categories"
2689
+ query_params = {}
2690
+ response = self._get(url, params=query_params)
2691
+ response.raise_for_status()
2692
+ return response.json()
2693
+
2694
+ def add_pack_category(self, packId, categoryName) -> dict[str, Any]:
2695
+ """
2696
+ Adds a new category to the specified pack by sending a POST request to the API.
2697
+
2698
+ Args:
2699
+ packId: str. Unique identifier of the pack to which the category will be added.
2700
+ categoryName: str. Name of the new category to add to the pack.
2701
+
2702
+ Returns:
2703
+ dict[str, Any]: The JSON response from the API containing details of the added category.
2704
+
2705
+ Raises:
2706
+ ValueError: Raised if 'packId' or 'categoryName' is None.
2707
+ requests.HTTPError: Raised if the HTTP request to the API fails or returns an error status.
2708
+
2709
+ Tags:
2710
+ add, category, pack-management, api, important
2711
+ """
2712
+ if packId is None:
2713
+ raise ValueError("Missing required parameter 'packId'")
2714
+ if categoryName is None:
2715
+ raise ValueError("Missing required parameter 'categoryName'")
2716
+ request_body = {
2717
+ "categoryName": categoryName,
2718
+ }
2719
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2720
+ url = f"{self.base_url}/packs/{packId}/category"
2721
+ query_params = {}
2722
+ response = self._post(url, data=request_body, params=query_params)
2723
+ response.raise_for_status()
2724
+ return response.json()
2725
+
2726
+ def delete_pack_category(self, packId, categoryName) -> dict[str, Any]:
2727
+ """
2728
+ Deletes a specific category from a pack by pack ID and category name.
2729
+
2730
+ Args:
2731
+ packId: The unique identifier of the pack from which the category will be deleted. Must not be None.
2732
+ categoryName: The name of the category to delete from the specified pack. Must not be None.
2733
+
2734
+ Returns:
2735
+ A dictionary containing the JSON response from the server after the category is deleted.
2736
+
2737
+ Raises:
2738
+ ValueError: Raised if 'packId' or 'categoryName' is None.
2739
+ requests.HTTPError: Raised if the HTTP request to delete the category fails.
2740
+
2741
+ Tags:
2742
+ delete, management, category, important
2743
+ """
2744
+ if packId is None:
2745
+ raise ValueError("Missing required parameter 'packId'")
2746
+ if categoryName is None:
2747
+ raise ValueError("Missing required parameter 'categoryName'")
2748
+ url = f"{self.base_url}/packs/{packId}/category/{categoryName}"
2749
+ query_params = {}
2750
+ response = self._delete(url, params=query_params)
2751
+ response.raise_for_status()
2752
+ return response.json()
2753
+
2754
+ def upload_pack_asset(
2755
+ self, packId, packAssetType, imageHash, mimeType, filename
2756
+ ) -> dict[str, Any]:
2757
+ """
2758
+ Uploads an asset file to the specified pack and returns the server response.
2759
+
2760
+ Args:
2761
+ packId: str. The unique identifier of the pack to which the asset is being uploaded.
2762
+ packAssetType: str. The type of asset (e.g., 'image', 'icon') being uploaded to the pack.
2763
+ imageHash: str. The unique hash value of the image asset for verification or deduplication.
2764
+ mimeType: str. The MIME type of the file being uploaded (e.g., 'image/png').
2765
+ filename: str. The name of the file to be uploaded.
2766
+
2767
+ Returns:
2768
+ dict[str, Any]: Parsed JSON response containing details about the uploaded asset or server-side status.
2769
+
2770
+ Raises:
2771
+ ValueError: Raised if any required parameter ('packId', 'packAssetType', 'imageHash', 'mimeType', 'filename') is missing or None.
2772
+ HTTPError: Raised if the server returns a non-successful status code in response to the upload request.
2773
+
2774
+ Tags:
2775
+ upload, asset-management, pack, async-job, important
2776
+ """
2777
+ if packId is None:
2778
+ raise ValueError("Missing required parameter 'packId'")
2779
+ if packAssetType is None:
2780
+ raise ValueError("Missing required parameter 'packAssetType'")
2781
+ if imageHash is None:
2782
+ raise ValueError("Missing required parameter 'imageHash'")
2783
+ if mimeType is None:
2784
+ raise ValueError("Missing required parameter 'mimeType'")
2785
+ if filename is None:
2786
+ raise ValueError("Missing required parameter 'filename'")
2787
+ request_body = {
2788
+ "packAssetType": packAssetType,
2789
+ "imageHash": imageHash,
2790
+ "mimeType": mimeType,
2791
+ "filename": filename,
2792
+ }
2793
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2794
+ url = f"{self.base_url}/packs/{packId}/uploadAsset"
2795
+ query_params = {}
2796
+ response = self._post(url, data=request_body, params=query_params)
2797
+ response.raise_for_status()
2798
+ return response.json()
2799
+
2800
+ def upload_pack_source_code(
2801
+ self, packId, payloadHash, filename, packVersion=None
2802
+ ) -> dict[str, Any]:
2803
+ """
2804
+ Uploads the source code for a specified pack by sending the provided file information and payload hash to the server.
2805
+
2806
+ Args:
2807
+ packId: str. The unique identifier of the pack to which the source code should be uploaded.
2808
+ payloadHash: str. The hash of the source code payload to ensure data integrity.
2809
+ filename: str. The name of the file being uploaded as source code.
2810
+ packVersion: str, optional. The version of the pack associated with the source code upload. Defaults to None.
2811
+
2812
+ Returns:
2813
+ dict[str, Any]: The server response as a dictionary, typically containing upload status and metadata.
2814
+
2815
+ Raises:
2816
+ ValueError: If any of 'packId', 'payloadHash', or 'filename' are None.
2817
+ requests.HTTPError: If the HTTP request to upload source code fails (e.g., network issues or server errors).
2818
+
2819
+ Tags:
2820
+ upload, pack-management, api, important
2821
+ """
2822
+ if packId is None:
2823
+ raise ValueError("Missing required parameter 'packId'")
2824
+ if payloadHash is None:
2825
+ raise ValueError("Missing required parameter 'payloadHash'")
2826
+ if filename is None:
2827
+ raise ValueError("Missing required parameter 'filename'")
2828
+ request_body = {
2829
+ "payloadHash": payloadHash,
2830
+ "filename": filename,
2831
+ "packVersion": packVersion,
2832
+ }
2833
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2834
+ url = f"{self.base_url}/packs/{packId}/uploadSourceCode"
2835
+ query_params = {}
2836
+ response = self._post(url, data=request_body, params=query_params)
2837
+ response.raise_for_status()
2838
+ return response.json()
2839
+
2840
+ def pack_asset_upload_complete(
2841
+ self, packId, packAssetId, packAssetType
2842
+ ) -> dict[str, Any]:
2843
+ """
2844
+ Marks an asset upload as complete for a given pack and asset type by sending a POST request to the server.
2845
+
2846
+ Args:
2847
+ packId: The unique identifier of the pack containing the asset.
2848
+ packAssetId: The unique identifier of the asset within the pack.
2849
+ packAssetType: The type of the asset being uploaded (e.g., image, audio, etc.).
2850
+
2851
+ Returns:
2852
+ A dictionary containing the server's JSON response indicating the result of the upload completion process.
2853
+
2854
+ Raises:
2855
+ ValueError: Raised if any of 'packId', 'packAssetId', or 'packAssetType' is None.
2856
+ requests.HTTPError: Raised if the HTTP request to mark the upload complete fails.
2857
+
2858
+ Tags:
2859
+ mark-complete, upload, asset-management, post-request, important
2860
+ """
2861
+ if packId is None:
2862
+ raise ValueError("Missing required parameter 'packId'")
2863
+ if packAssetId is None:
2864
+ raise ValueError("Missing required parameter 'packAssetId'")
2865
+ if packAssetType is None:
2866
+ raise ValueError("Missing required parameter 'packAssetType'")
2867
+ url = f"{self.base_url}/packs/{packId}/assets/{packAssetId}/assetType/{packAssetType}/uploadComplete"
2868
+ query_params = {}
2869
+ response = self._post(url, data={}, params=query_params)
2870
+ response.raise_for_status()
2871
+ return response.json()
2872
+
2873
+ def pack_source_code_upload_complete(
2874
+ self, packId, packVersion, filename, codeHash
2875
+ ) -> dict[str, Any]:
2876
+ """
2877
+ Marks the completion of a source code upload for a pack version by notifying the backend service.
2878
+
2879
+ Args:
2880
+ packId: The unique identifier of the pack.
2881
+ packVersion: The version string of the pack.
2882
+ filename: The name of the source code file that was uploaded.
2883
+ codeHash: The hash of the uploaded source code for verification.
2884
+
2885
+ Returns:
2886
+ A dictionary containing the response data from the backend after successfully marking the upload as complete.
2887
+
2888
+ Raises:
2889
+ ValueError: If any of the required parameters ('packId', 'packVersion', 'filename', 'codeHash') are None.
2890
+ requests.HTTPError: If the HTTP request to the backend fails or returns an error status code.
2891
+
2892
+ Tags:
2893
+ upload-complete, pack-management, ai, important
2894
+ """
2895
+ if packId is None:
2896
+ raise ValueError("Missing required parameter 'packId'")
2897
+ if packVersion is None:
2898
+ raise ValueError("Missing required parameter 'packVersion'")
2899
+ if filename is None:
2900
+ raise ValueError("Missing required parameter 'filename'")
2901
+ if codeHash is None:
2902
+ raise ValueError("Missing required parameter 'codeHash'")
2903
+ request_body = {
2904
+ "filename": filename,
2905
+ "codeHash": codeHash,
2906
+ }
2907
+ request_body = {k: v for k, v in request_body.items() if v is not None}
2908
+ url = f"{self.base_url}/packs/{packId}/versions/{packVersion}/sourceCode/uploadComplete"
2909
+ query_params = {}
2910
+ response = self._post(url, data=request_body, params=query_params)
2911
+ response.raise_for_status()
2912
+ return response.json()
2913
+
2914
+ def get_pack_source_code(self, packId, packVersion) -> dict[str, Any]:
2915
+ """
2916
+ Retrieves the source code for a specified pack version from the server.
2917
+
2918
+ Args:
2919
+ packId: str. The unique identifier of the pack whose source code is to be retrieved.
2920
+ packVersion: str. The specific version of the pack for which the source code is requested.
2921
+
2922
+ Returns:
2923
+ dict. A dictionary containing the source code and related metadata for the specified pack version.
2924
+
2925
+ Raises:
2926
+ ValueError: Raised if 'packId' or 'packVersion' is None.
2927
+ requests.HTTPError: Raised if the HTTP request to the server fails.
2928
+
2929
+ Tags:
2930
+ get, source-code, packs, version-management, important
2931
+ """
2932
+ if packId is None:
2933
+ raise ValueError("Missing required parameter 'packId'")
2934
+ if packVersion is None:
2935
+ raise ValueError("Missing required parameter 'packVersion'")
2936
+ url = f"{self.base_url}/packs/{packId}/versions/{packVersion}/sourceCode"
2937
+ query_params = {}
2938
+ response = self._get(url, params=query_params)
2939
+ response.raise_for_status()
2940
+ return response.json()
2941
+
2942
+ def list_pack_listings(
2943
+ self,
2944
+ packAccessTypes=None,
2945
+ packIds=None,
2946
+ onlyWorkspaceId=None,
2947
+ parentWorkspaceIds=None,
2948
+ excludePublicPacks=None,
2949
+ excludeWorkspaceAcls=None,
2950
+ excludeIndividualAcls=None,
2951
+ includeBrainOnlyPacks=None,
2952
+ sortBy=None,
2953
+ orderBy=None,
2954
+ direction=None,
2955
+ limit=None,
2956
+ pageToken=None,
2957
+ installContext=None,
2958
+ ) -> dict[str, Any]:
2959
+ """
2960
+ Retrieves a list of available pack listings based on specified filtering, sorting, and access control criteria.
2961
+
2962
+ Args:
2963
+ packAccessTypes: Optional; list of access type strings to filter packs by user permissions.
2964
+ packIds: Optional; list of pack IDs to retrieve specific packs.
2965
+ onlyWorkspaceId: Optional; string indicating a specific workspace to restrict results to.
2966
+ parentWorkspaceIds: Optional; list of parent workspace IDs to include packs from these workspaces.
2967
+ excludePublicPacks: Optional; boolean to exclude public packs from the results.
2968
+ excludeWorkspaceAcls: Optional; boolean to exclude packs with workspace-level ACLs.
2969
+ excludeIndividualAcls: Optional; boolean to exclude packs with individual-level ACLs.
2970
+ includeBrainOnlyPacks: Optional; boolean to include packs designated as 'brain-only'.
2971
+ sortBy: Optional; string specifying the field to sort results by.
2972
+ orderBy: Optional; string specifying the order of sorting (e.g., 'asc', 'desc').
2973
+ direction: Optional; string specifying sorting direction, typically 'asc' or 'desc'.
2974
+ limit: Optional; integer to limit the number of results returned.
2975
+ pageToken: Optional; string token for paginated results to fetch subsequent pages.
2976
+ installContext: Optional; string specifying the context for installation filtering.
2977
+
2978
+ Returns:
2979
+ dict[str, Any]: A dictionary containing the filtered list of pack listings and associated metadata, as returned by the API.
2980
+
2981
+ Raises:
2982
+ HTTPError: If the HTTP request to the packs listing endpoint returns an unsuccessful status code.
2983
+
2984
+ Tags:
2985
+ list, packs, filter, search, api, management, important
2986
+ """
2987
+ url = f"{self.base_url}/packs/listings"
2988
+ query_params = {
2989
+ k: v
2990
+ for k, v in [
2991
+ ("packAccessTypes", packAccessTypes),
2992
+ ("packIds", packIds),
2993
+ ("onlyWorkspaceId", onlyWorkspaceId),
2994
+ ("parentWorkspaceIds", parentWorkspaceIds),
2995
+ ("excludePublicPacks", excludePublicPacks),
2996
+ ("excludeWorkspaceAcls", excludeWorkspaceAcls),
2997
+ ("excludeIndividualAcls", excludeIndividualAcls),
2998
+ ("includeBrainOnlyPacks", includeBrainOnlyPacks),
2999
+ ("sortBy", sortBy),
3000
+ ("orderBy", orderBy),
3001
+ ("direction", direction),
3002
+ ("limit", limit),
3003
+ ("pageToken", pageToken),
3004
+ ("installContext", installContext),
3005
+ ]
3006
+ if v is not None
3007
+ }
3008
+ response = self._get(url, params=query_params)
3009
+ response.raise_for_status()
3010
+ return response.json()
3011
+
3012
+ def get_pack_listing(
3013
+ self,
3014
+ packId,
3015
+ workspaceId=None,
3016
+ docId=None,
3017
+ installContext=None,
3018
+ releaseChannel=None,
3019
+ ) -> dict[str, Any]:
3020
+ """
3021
+ Retrieves the listing details for a specified pack, optionally filtered by workspace, document, install context, or release channel.
3022
+
3023
+ Args:
3024
+ packId: str. The unique identifier of the pack to retrieve the listing for. Required.
3025
+ workspaceId: str or None. Optional workspace identifier to scope the pack listing.
3026
+ docId: str or None. Optional document identifier to further filter the pack listing.
3027
+ installContext: str or None. Optional installation context to refine the results.
3028
+ releaseChannel: str or None. Optional release channel (e.g., 'beta', 'stable') to select the listing version.
3029
+
3030
+ Returns:
3031
+ dict[str, Any]: A dictionary containing the pack listing details as returned by the API.
3032
+
3033
+ Raises:
3034
+ ValueError: If 'packId' is not provided.
3035
+ HTTPError: If the HTTP request to retrieve the pack listing fails.
3036
+
3037
+ Tags:
3038
+ get, listing, packs, api, important
3039
+ """
3040
+ if packId is None:
3041
+ raise ValueError("Missing required parameter 'packId'")
3042
+ url = f"{self.base_url}/packs/{packId}/listing"
3043
+ query_params = {
3044
+ k: v
3045
+ for k, v in [
3046
+ ("workspaceId", workspaceId),
3047
+ ("docId", docId),
3048
+ ("installContext", installContext),
3049
+ ("releaseChannel", releaseChannel),
3050
+ ]
3051
+ if v is not None
3052
+ }
3053
+ response = self._get(url, params=query_params)
3054
+ response.raise_for_status()
3055
+ return response.json()
3056
+
3057
+ def list_pack_logs(
3058
+ self,
3059
+ packId,
3060
+ docId,
3061
+ limit=None,
3062
+ pageToken=None,
3063
+ logTypes=None,
3064
+ beforeTimestamp=None,
3065
+ afterTimestamp=None,
3066
+ order=None,
3067
+ q=None,
3068
+ requestIds=None,
3069
+ ) -> dict[str, Any]:
3070
+ """
3071
+ Retrieves a paginated list of logs for a specified document in a pack, with advanced filtering and sorting options.
3072
+
3073
+ Args:
3074
+ packId: str. Unique identifier of the pack containing the document. Required.
3075
+ docId: str. Unique identifier of the document whose logs are to be retrieved. Required.
3076
+ limit: int, optional. Maximum number of log entries to return per page.
3077
+ pageToken: str, optional. Token for fetching a specific results page in paginated responses.
3078
+ logTypes: list or str, optional. Filter logs by type(s) (e.g., 'error', 'info').
3079
+ beforeTimestamp: str or int, optional. Retrieve logs generated before this timestamp.
3080
+ afterTimestamp: str or int, optional. Retrieve logs generated after this timestamp.
3081
+ order: str, optional. Sort order for the logs (e.g., 'asc', 'desc').
3082
+ q: str, optional. Search query to filter log entries.
3083
+ requestIds: list or str, optional. Filter logs by one or more request IDs.
3084
+
3085
+ Returns:
3086
+ dict[str, Any]: A dictionary containing the paginated list of logs and associated response metadata.
3087
+
3088
+ Raises:
3089
+ ValueError: If either 'packId' or 'docId' is not provided.
3090
+ requests.HTTPError: If the HTTP request to retrieve logs fails (e.g., due to network error or server rejection).
3091
+
3092
+ Tags:
3093
+ list, logs, pack-management, filter, pagination, important
3094
+ """
3095
+ if packId is None:
3096
+ raise ValueError("Missing required parameter 'packId'")
3097
+ if docId is None:
3098
+ raise ValueError("Missing required parameter 'docId'")
3099
+ url = f"{self.base_url}/packs/{packId}/docs/{docId}/logs"
3100
+ query_params = {
3101
+ k: v
3102
+ for k, v in [
3103
+ ("limit", limit),
3104
+ ("pageToken", pageToken),
3105
+ ("logTypes", logTypes),
3106
+ ("beforeTimestamp", beforeTimestamp),
3107
+ ("afterTimestamp", afterTimestamp),
3108
+ ("order", order),
3109
+ ("q", q),
3110
+ ("requestIds", requestIds),
3111
+ ]
3112
+ if v is not None
3113
+ }
3114
+ response = self._get(url, params=query_params)
3115
+ response.raise_for_status()
3116
+ return response.json()
3117
+
3118
+ def list_ingestion_logs(
3119
+ self,
3120
+ packId,
3121
+ organizationId,
3122
+ rootIngestionId,
3123
+ limit=None,
3124
+ pageToken=None,
3125
+ logTypes=None,
3126
+ ingestionExecutionId=None,
3127
+ beforeTimestamp=None,
3128
+ afterTimestamp=None,
3129
+ order=None,
3130
+ q=None,
3131
+ requestIds=None,
3132
+ ) -> dict[str, Any]:
3133
+ """
3134
+ Retrieves a list of ingestion logs for a specified pack, organization, and root ingestion, with support for filtering and pagination.
3135
+
3136
+ Args:
3137
+ packId: The unique identifier of the pack for which to retrieve logs.
3138
+ organizationId: The unique identifier of the organization associated with the logs.
3139
+ rootIngestionId: The root ingestion ID to filter logs by.
3140
+ limit: Optional; maximum number of log entries to return.
3141
+ pageToken: Optional; token for retrieving the next page of results.
3142
+ logTypes: Optional; list or comma-separated string specifying log types to filter by.
3143
+ ingestionExecutionId: Optional; filter logs by a specific ingestion execution ID.
3144
+ beforeTimestamp: Optional; return logs created before this timestamp (ISO 8601 or epoch format).
3145
+ afterTimestamp: Optional; return logs created after this timestamp (ISO 8601 or epoch format).
3146
+ order: Optional; sorting order of the results ('asc' or 'desc').
3147
+ q: Optional; query string to filter logs by content.
3148
+ requestIds: Optional; list or comma-separated string of request IDs to filter logs by.
3149
+
3150
+ Returns:
3151
+ A dictionary containing the retrieved ingestion logs and any associated metadata (such as pagination information).
3152
+
3153
+ Raises:
3154
+ ValueError: Raised if any of the required parameters ('packId', 'organizationId', or 'rootIngestionId') are missing.
3155
+ requests.HTTPError: Raised if the HTTP request to the API endpoint fails with a non-success status code.
3156
+
3157
+ Tags:
3158
+ list, logs, management, async-job, filter, important
3159
+ """
3160
+ if packId is None:
3161
+ raise ValueError("Missing required parameter 'packId'")
3162
+ if organizationId is None:
3163
+ raise ValueError("Missing required parameter 'organizationId'")
3164
+ if rootIngestionId is None:
3165
+ raise ValueError("Missing required parameter 'rootIngestionId'")
3166
+ url = f"{self.base_url}/packs/{packId}/organizationId/{organizationId}/rootIngestionId/{rootIngestionId}/logs"
3167
+ query_params = {
3168
+ k: v
3169
+ for k, v in [
3170
+ ("limit", limit),
3171
+ ("pageToken", pageToken),
3172
+ ("logTypes", logTypes),
3173
+ ("ingestionExecutionId", ingestionExecutionId),
3174
+ ("beforeTimestamp", beforeTimestamp),
3175
+ ("afterTimestamp", afterTimestamp),
3176
+ ("order", order),
3177
+ ("q", q),
3178
+ ("requestIds", requestIds),
3179
+ ]
3180
+ if v is not None
3181
+ }
3182
+ response = self._get(url, params=query_params)
3183
+ response.raise_for_status()
3184
+ return response.json()
3185
+
3186
+ def list_grouped_pack_logs(
3187
+ self,
3188
+ packId,
3189
+ docId,
3190
+ limit=None,
3191
+ pageToken=None,
3192
+ beforeTimestamp=None,
3193
+ afterTimestamp=None,
3194
+ order=None,
3195
+ q=None,
3196
+ ) -> dict[str, Any]:
3197
+ """
3198
+ Retrieves a paginated and filtered list of grouped logs for a specific pack and document.
3199
+
3200
+ Args:
3201
+ packId: str. The unique identifier of the pack. Required.
3202
+ docId: str. The unique identifier of the document within the pack. Required.
3203
+ limit: Optional[int]. The maximum number of log groups to return per page.
3204
+ pageToken: Optional[str]. A token indicating the page of results to retrieve.
3205
+ beforeTimestamp: Optional[str|int]. Only logs before this timestamp are returned.
3206
+ afterTimestamp: Optional[str|int]. Only logs after this timestamp are returned.
3207
+ order: Optional[str]. The sort order of logs (e.g., 'asc', 'desc').
3208
+ q: Optional[str]. Query string to filter logs.
3209
+
3210
+ Returns:
3211
+ dict[str, Any]: A JSON-compatible dictionary containing the grouped log data and pagination information.
3212
+
3213
+ Raises:
3214
+ ValueError: If 'packId' or 'docId' is not provided.
3215
+ requests.HTTPError: If the underlying HTTP request fails or returns an unsuccessful status code.
3216
+
3217
+ Tags:
3218
+ list, logs, grouped, filter, pagination, important
3219
+ """
3220
+ if packId is None:
3221
+ raise ValueError("Missing required parameter 'packId'")
3222
+ if docId is None:
3223
+ raise ValueError("Missing required parameter 'docId'")
3224
+ url = f"{self.base_url}/packs/{packId}/docs/{docId}/groupedLogs"
3225
+ query_params = {
3226
+ k: v
3227
+ for k, v in [
3228
+ ("limit", limit),
3229
+ ("pageToken", pageToken),
3230
+ ("beforeTimestamp", beforeTimestamp),
3231
+ ("afterTimestamp", afterTimestamp),
3232
+ ("order", order),
3233
+ ("q", q),
3234
+ ]
3235
+ if v is not None
3236
+ }
3237
+ response = self._get(url, params=query_params)
3238
+ response.raise_for_status()
3239
+ return response.json()
3240
+
3241
+ def list_grouped_ingestion_logs(
3242
+ self,
3243
+ packId,
3244
+ organizationId,
3245
+ rootIngestionId,
3246
+ limit=None,
3247
+ pageToken=None,
3248
+ ingestionExecutionId=None,
3249
+ beforeTimestamp=None,
3250
+ afterTimestamp=None,
3251
+ order=None,
3252
+ q=None,
3253
+ ) -> dict[str, Any]:
3254
+ """
3255
+ Retrieves grouped ingestion log entries for a specified pack, organization, and root ingestion, supporting filtering and pagination options.
3256
+
3257
+ Args:
3258
+ packId: str. Unique identifier of the pack whose logs are to be retrieved.
3259
+ organizationId: str. Unique identifier of the organization associated with the pack.
3260
+ rootIngestionId: str. Unique identifier for the root ingestion of interest.
3261
+ limit: Optional[int]. Maximum number of log entries to return per page.
3262
+ pageToken: Optional[str]. Token to retrieve the next page of results in a paginated response.
3263
+ ingestionExecutionId: Optional[str]. Identifier to filter logs by a specific ingestion execution.
3264
+ beforeTimestamp: Optional[str]. Only return logs created before this timestamp (ISO 8601 format).
3265
+ afterTimestamp: Optional[str]. Only return logs created after this timestamp (ISO 8601 format).
3266
+ order: Optional[str]. Sort order of the logs, such as 'asc' or 'desc'.
3267
+ q: Optional[str]. Query string to filter logs by custom criteria.
3268
+
3269
+ Returns:
3270
+ dict[str, Any]: A dictionary containing grouped ingestion log entries and associated metadata.
3271
+
3272
+ Raises:
3273
+ ValueError: If any of the required parameters 'packId', 'organizationId', or 'rootIngestionId' is None.
3274
+ requests.HTTPError: If the HTTP request to the server fails or returns an unsuccessful status code.
3275
+
3276
+ Tags:
3277
+ list, ingestion-logs, filter, pagination, ai, important
3278
+ """
3279
+ if packId is None:
3280
+ raise ValueError("Missing required parameter 'packId'")
3281
+ if organizationId is None:
3282
+ raise ValueError("Missing required parameter 'organizationId'")
3283
+ if rootIngestionId is None:
3284
+ raise ValueError("Missing required parameter 'rootIngestionId'")
3285
+ url = f"{self.base_url}/packs/{packId}/organizationId/{organizationId}/rootIngestionId/{rootIngestionId}/groupedLogs"
3286
+ query_params = {
3287
+ k: v
3288
+ for k, v in [
3289
+ ("limit", limit),
3290
+ ("pageToken", pageToken),
3291
+ ("ingestionExecutionId", ingestionExecutionId),
3292
+ ("beforeTimestamp", beforeTimestamp),
3293
+ ("afterTimestamp", afterTimestamp),
3294
+ ("order", order),
3295
+ ("q", q),
3296
+ ]
3297
+ if v is not None
3298
+ }
3299
+ response = self._get(url, params=query_params)
3300
+ response.raise_for_status()
3301
+ return response.json()
3302
+
3303
+ def list_ingestion_executions(
3304
+ self,
3305
+ packId,
3306
+ organizationId,
3307
+ rootIngestionId,
3308
+ limit=None,
3309
+ pageToken=None,
3310
+ beforeTimestamp=None,
3311
+ afterTimestamp=None,
3312
+ order=None,
3313
+ ingestionStatus=None,
3314
+ datasource=None,
3315
+ executionType=None,
3316
+ includeDeletedIngestions=None,
3317
+ csbIngestionId=None,
3318
+ csbIngestionExecutionId=None,
3319
+ ) -> dict[str, Any]:
3320
+ """
3321
+ Retrieves a paginated list of ingestion execution records for a specified pack, organization, and root ingestion, with optional filtering and sorting parameters.
3322
+
3323
+ Args:
3324
+ packId: str. Unique identifier of the ingestion pack.
3325
+ organizationId: str. Identifier for the organization owning the ingestion.
3326
+ rootIngestionId: str. Root identifier for the ingestion batch or group.
3327
+ limit: Optional[int]. Maximum number of records to return per page.
3328
+ pageToken: Optional[str]. Token to fetch a specific page of results.
3329
+ beforeTimestamp: Optional[str]. Return executions created before this timestamp (ISO 8601 format).
3330
+ afterTimestamp: Optional[str]. Return executions created after this timestamp (ISO 8601 format).
3331
+ order: Optional[str]. Sort order for the results (e.g., 'asc' or 'desc').
3332
+ ingestionStatus: Optional[str]. Filter results by ingestion execution status.
3333
+ datasource: Optional[str]. Filter by the data source of the ingestion.
3334
+ executionType: Optional[str]. Filter by the type of ingestion execution.
3335
+ includeDeletedIngestions: Optional[bool]. Whether to include deleted ingestions in the results.
3336
+ csbIngestionId: Optional[str]. Filter by Cloud Service Broker ingestion ID.
3337
+ csbIngestionExecutionId: Optional[str]. Filter by Cloud Service Broker ingestion execution ID.
3338
+
3339
+ Returns:
3340
+ dict[str, Any]: A dictionary containing the paginated list of ingestion executions and associated metadata.
3341
+
3342
+ Raises:
3343
+ ValueError: If any of the required parameters 'packId', 'organizationId', or 'rootIngestionId' are missing.
3344
+ requests.HTTPError: If the HTTP request to the backend service fails or returns a non-2xx status code.
3345
+
3346
+ Tags:
3347
+ list, ingestion, executions, batch, search, management, important
3348
+ """
3349
+ if packId is None:
3350
+ raise ValueError("Missing required parameter 'packId'")
3351
+ if organizationId is None:
3352
+ raise ValueError("Missing required parameter 'organizationId'")
3353
+ if rootIngestionId is None:
3354
+ raise ValueError("Missing required parameter 'rootIngestionId'")
3355
+ url = f"{self.base_url}/packs/{packId}/organizationId/{organizationId}/rootIngestionId/{rootIngestionId}/ingestionExecutions"
3356
+ query_params = {
3357
+ k: v
3358
+ for k, v in [
3359
+ ("limit", limit),
3360
+ ("pageToken", pageToken),
3361
+ ("beforeTimestamp", beforeTimestamp),
3362
+ ("afterTimestamp", afterTimestamp),
3363
+ ("order", order),
3364
+ ("ingestionStatus", ingestionStatus),
3365
+ ("datasource", datasource),
3366
+ ("executionType", executionType),
3367
+ ("includeDeletedIngestions", includeDeletedIngestions),
3368
+ ("csbIngestionId", csbIngestionId),
3369
+ ("csbIngestionExecutionId", csbIngestionExecutionId),
3370
+ ]
3371
+ if v is not None
3372
+ }
3373
+ response = self._get(url, params=query_params)
3374
+ response.raise_for_status()
3375
+ return response.json()
3376
+
3377
+ def list_ingestion_execution_attempts(
3378
+ self,
3379
+ packId,
3380
+ organizationId,
3381
+ rootIngestionId,
3382
+ ingestionExecutionId,
3383
+ limit=None,
3384
+ pageToken=None,
3385
+ order=None,
3386
+ ) -> dict[str, Any]:
3387
+ """
3388
+ Lists execution attempts for a specific ingestion execution within a pack and organization.
3389
+
3390
+ Args:
3391
+ packId: str. Identifier for the pack associated with the ingestion execution.
3392
+ organizationId: str. Identifier for the organization within which the pack operates.
3393
+ rootIngestionId: str. Identifier for the root ingestion job.
3394
+ ingestionExecutionId: str. Identifier for the specific ingestion execution whose attempts are being listed.
3395
+ limit: Optional[int]. Maximum number of attempt records to return in the response.
3396
+ pageToken: Optional[str]. Token for pagination to retrieve the next set of results.
3397
+ order: Optional[str]. Sort order of the listed attempts.
3398
+
3399
+ Returns:
3400
+ dict. JSON response containing attempt records and relevant metadata for the specified ingestion execution.
3401
+
3402
+ Raises:
3403
+ ValueError: Raised if any of the required parameters ('packId', 'organizationId', 'rootIngestionId', 'ingestionExecutionId') is None.
3404
+ HTTPError: Raised if the HTTP request for the execution attempts fails.
3405
+
3406
+ Tags:
3407
+ list, ingestion, execution-attempts, management, important
3408
+ """
3409
+ if packId is None:
3410
+ raise ValueError("Missing required parameter 'packId'")
3411
+ if organizationId is None:
3412
+ raise ValueError("Missing required parameter 'organizationId'")
3413
+ if rootIngestionId is None:
3414
+ raise ValueError("Missing required parameter 'rootIngestionId'")
3415
+ if ingestionExecutionId is None:
3416
+ raise ValueError("Missing required parameter 'ingestionExecutionId'")
3417
+ url = f"{self.base_url}/packs/{packId}/organizationId/{organizationId}/rootIngestionId/{rootIngestionId}/ingestionExecutionId/{ingestionExecutionId}/attempts"
3418
+ query_params = {
3419
+ k: v
3420
+ for k, v in [("limit", limit), ("pageToken", pageToken), ("order", order)]
3421
+ if v is not None
3422
+ }
3423
+ response = self._get(url, params=query_params)
3424
+ response.raise_for_status()
3425
+ return response.json()
3426
+
3427
+ def get_pack_log_details(
3428
+ self, packId, organizationId, rootIngestionId, logId, detailsKey
3429
+ ) -> dict[str, Any]:
3430
+ """
3431
+ Retrieves detailed log information for a specific pack ingestion process by querying the remote service.
3432
+
3433
+ Args:
3434
+ packId: str. Unique identifier of the pack whose log details are to be fetched.
3435
+ organizationId: str. Identifier for the organization associated with the pack.
3436
+ rootIngestionId: str. Root identifier for the ingestion process.
3437
+ logId: str. Unique identifier for the specific log entry.
3438
+ detailsKey: str. Key specifying the set of details to retrieve from the log.
3439
+
3440
+ Returns:
3441
+ dict. JSON object containing the requested log details from the remote service.
3442
+
3443
+ Raises:
3444
+ ValueError: Raised if any of the required parameters (packId, organizationId, rootIngestionId, logId, detailsKey) is None.
3445
+ requests.HTTPError: Raised if the HTTP request to fetch log details fails or returns a non-2xx response.
3446
+
3447
+ Tags:
3448
+ get, log, details, fetch, ai, management, important
3449
+ """
3450
+ if packId is None:
3451
+ raise ValueError("Missing required parameter 'packId'")
3452
+ if organizationId is None:
3453
+ raise ValueError("Missing required parameter 'organizationId'")
3454
+ if rootIngestionId is None:
3455
+ raise ValueError("Missing required parameter 'rootIngestionId'")
3456
+ if logId is None:
3457
+ raise ValueError("Missing required parameter 'logId'")
3458
+ if detailsKey is None:
3459
+ raise ValueError("Missing required parameter 'detailsKey'")
3460
+ url = f"{self.base_url}/packs/{packId}/organizationId/{organizationId}/rootIngestionId/{rootIngestionId}/logs/{logId}"
3461
+ query_params = {k: v for k, v in [("detailsKey", detailsKey)] if v is not None}
3462
+ response = self._get(url, params=query_params)
3463
+ response.raise_for_status()
3464
+ return response.json()
3465
+
3466
+ def list_pack_featured_docs(self, packId) -> dict[str, Any]:
3467
+ """
3468
+ Fetches the featured documents for a specified pack by its ID.
3469
+
3470
+ Args:
3471
+ packId: str. The unique identifier of the pack whose featured documents are to be retrieved.
3472
+
3473
+ Returns:
3474
+ dict[str, Any]: A dictionary containing the featured documents associated with the specified pack.
3475
+
3476
+ Raises:
3477
+ ValueError: If 'packId' is None.
3478
+
3479
+ Tags:
3480
+ list, featured-docs, packs, api-call, important
3481
+ """
3482
+ if packId is None:
3483
+ raise ValueError("Missing required parameter 'packId'")
3484
+ url = f"{self.base_url}/packs/{packId}/featuredDocs"
3485
+ query_params = {}
3486
+ response = self._get(url, params=query_params)
3487
+ response.raise_for_status()
3488
+ return response.json()
3489
+
3490
+ def update_pack_featured_docs(self, packId, items) -> dict[str, Any]:
3491
+ """
3492
+ Updates the featured documents for a specific pack by sending the provided items to the server.
3493
+
3494
+ Args:
3495
+ packId: str. The unique identifier of the pack whose featured documents are to be updated.
3496
+ items: Any. A collection of items representing the featured documents to set for the pack.
3497
+
3498
+ Returns:
3499
+ dict[str, Any]: The server's JSON response confirming the update of featured documents.
3500
+
3501
+ Raises:
3502
+ ValueError: Raised if either 'packId' or 'items' is None.
3503
+ requests.HTTPError: Raised if the HTTP request to update the featured documents fails.
3504
+
3505
+ Tags:
3506
+ update, featured-docs, pack-management, api, important
3507
+ """
3508
+ if packId is None:
3509
+ raise ValueError("Missing required parameter 'packId'")
3510
+ if items is None:
3511
+ raise ValueError("Missing required parameter 'items'")
3512
+ request_body = {
3513
+ "items": items,
3514
+ }
3515
+ request_body = {k: v for k, v in request_body.items() if v is not None}
3516
+ url = f"{self.base_url}/packs/{packId}/featuredDocs"
3517
+ query_params = {}
3518
+ response = self._put(url, data=request_body, params=query_params)
3519
+ response.raise_for_status()
3520
+ return response.json()
3521
+
3522
+ def add_go_link(
3523
+ self,
3524
+ organizationId,
3525
+ name,
3526
+ destinationUrl,
3527
+ description=None,
3528
+ urlPattern=None,
3529
+ creatorEmail=None,
3530
+ ) -> dict[str, Any]:
3531
+ """
3532
+ Creates a new Go Link resource for the specified organization.
3533
+
3534
+ Args:
3535
+ organizationId: str. Unique identifier of the organization where the Go Link will be added.
3536
+ name: str. The name to assign to the Go Link resource.
3537
+ destinationUrl: str. The URL that the Go Link should redirect to.
3538
+ description: Optional[str]. A text description of the Go Link (default: None).
3539
+ urlPattern: Optional[str]. An explicit URL pattern for the Go Link, if applicable (default: None).
3540
+ creatorEmail: Optional[str]. The email address of the Go Link's creator (default: None).
3541
+
3542
+ Returns:
3543
+ dict[str, Any]: A dictionary containing the details of the created Go Link resource as returned by the API.
3544
+
3545
+ Raises:
3546
+ ValueError: Raised if organizationId, name, or destinationUrl are not provided.
3547
+ requests.HTTPError: Raised if the HTTP request to create the Go Link fails (e.g., due to network errors or API validation errors).
3548
+
3549
+ Tags:
3550
+ add, go-link, management, api, important
3551
+ """
3552
+ if organizationId is None:
3553
+ raise ValueError("Missing required parameter 'organizationId'")
3554
+ if name is None:
3555
+ raise ValueError("Missing required parameter 'name'")
3556
+ if destinationUrl is None:
3557
+ raise ValueError("Missing required parameter 'destinationUrl'")
3558
+ request_body = {
3559
+ "name": name,
3560
+ "destinationUrl": destinationUrl,
3561
+ "description": description,
3562
+ "urlPattern": urlPattern,
3563
+ "creatorEmail": creatorEmail,
3564
+ }
3565
+ request_body = {k: v for k, v in request_body.items() if v is not None}
3566
+ url = f"{self.base_url}/organizations/{organizationId}/goLinks"
3567
+ query_params = {}
3568
+ response = self._post(url, data=request_body, params=query_params)
3569
+ response.raise_for_status()
3570
+ return response.json()
3571
+
3572
+ def list_tools(self):
3573
+ return [
3574
+ self.list_categories,
3575
+ self.list_docs,
3576
+ self.create_doc,
3577
+ self.get_doc,
3578
+ self.delete_doc,
3579
+ self.update_doc,
3580
+ self.get_sharing_metadata,
3581
+ self.get_permissions,
3582
+ self.add_permission,
3583
+ self.delete_permission,
3584
+ self.search_principals,
3585
+ self.get_acl_settings,
3586
+ self.update_acl_settings,
3587
+ self.publish_doc,
3588
+ self.unpublish_doc,
3589
+ self.list_pages,
3590
+ self.create_page,
3591
+ self.get_page,
3592
+ self.update_page,
3593
+ self.delete_page,
3594
+ self.begin_page_content_export,
3595
+ self.get_page_content_export_status,
3596
+ self.list_tables,
3597
+ self.get_table,
3598
+ self.list_columns,
3599
+ self.list_rows,
3600
+ self.upsert_rows,
3601
+ self.delete_rows,
3602
+ self.get_row,
3603
+ self.update_row,
3604
+ self.delete_row,
3605
+ self.push_button,
3606
+ self.list_formulas,
3607
+ self.get_formula,
3608
+ self.list_controls,
3609
+ self.get_control,
3610
+ self.list_custom_doc_domains,
3611
+ self.add_custom_doc_domain,
3612
+ self.delete_custom_doc_domain,
3613
+ self.get_custom_doc_domain_provider,
3614
+ self.whoami,
3615
+ self.resolve_browser_link,
3616
+ self.get_mutation_status,
3617
+ self.trigger_webhook_automation,
3618
+ self.list_page_analytics,
3619
+ self.list_doc_analytics_summary,
3620
+ self.list_pack_analytics,
3621
+ self.list_pack_analytics_summary,
3622
+ self.list_pack_formula_analytics,
3623
+ self.get_analytics_last_updated,
3624
+ self.list_workspace_members,
3625
+ self.change_user_role,
3626
+ self.list_workspace_role_activity,
3627
+ self.list_packs,
3628
+ self.create_pack,
3629
+ self.get_pack,
3630
+ self.update_pack,
3631
+ self.delete_pack,
3632
+ self.get_pack_configuration_schema,
3633
+ self.list_pack_versions,
3634
+ self.get_next_pack_version,
3635
+ self.get_pack_version_diffs,
3636
+ self.register_pack_version,
3637
+ self.pack_version_upload_complete,
3638
+ self.create_pack_release,
3639
+ self.list_pack_releases,
3640
+ self.update_pack_release,
3641
+ self.set_pack_oauth_config,
3642
+ self.get_pack_oauth_config,
3643
+ self.set_pack_system_connection,
3644
+ self.get_pack_system_connection,
3645
+ self.get_pack_permissions,
3646
+ self.add_pack_permission,
3647
+ self.delete_pack_permission,
3648
+ self.list_pack_makers,
3649
+ self.add_pack_maker,
3650
+ self.delete_pack_maker,
3651
+ self.list_pack_categories,
3652
+ self.add_pack_category,
3653
+ self.delete_pack_category,
3654
+ self.upload_pack_asset,
3655
+ self.upload_pack_source_code,
3656
+ self.pack_asset_upload_complete,
3657
+ self.pack_source_code_upload_complete,
3658
+ self.get_pack_source_code,
3659
+ self.list_pack_listings,
3660
+ self.get_pack_listing,
3661
+ self.list_pack_logs,
3662
+ self.list_ingestion_logs,
3663
+ self.list_grouped_pack_logs,
3664
+ self.list_grouped_ingestion_logs,
3665
+ self.list_ingestion_executions,
3666
+ self.list_ingestion_execution_attempts,
3667
+ self.get_pack_log_details,
3668
+ self.list_pack_featured_docs,
3669
+ self.update_pack_featured_docs,
3670
+ self.add_go_link,
3671
+ ]