supermemory 3.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. supermemory/__init__.py +102 -0
  2. supermemory/_base_client.py +1995 -0
  3. supermemory/_client.py +683 -0
  4. supermemory/_compat.py +219 -0
  5. supermemory/_constants.py +14 -0
  6. supermemory/_exceptions.py +108 -0
  7. supermemory/_files.py +123 -0
  8. supermemory/_models.py +857 -0
  9. supermemory/_qs.py +150 -0
  10. supermemory/_resource.py +43 -0
  11. supermemory/_response.py +832 -0
  12. supermemory/_streaming.py +331 -0
  13. supermemory/_types.py +260 -0
  14. supermemory/_utils/__init__.py +64 -0
  15. supermemory/_utils/_compat.py +45 -0
  16. supermemory/_utils/_datetime_parse.py +136 -0
  17. supermemory/_utils/_logs.py +25 -0
  18. supermemory/_utils/_proxy.py +65 -0
  19. supermemory/_utils/_reflection.py +42 -0
  20. supermemory/_utils/_resources_proxy.py +24 -0
  21. supermemory/_utils/_streams.py +12 -0
  22. supermemory/_utils/_sync.py +58 -0
  23. supermemory/_utils/_transform.py +457 -0
  24. supermemory/_utils/_typing.py +156 -0
  25. supermemory/_utils/_utils.py +421 -0
  26. supermemory/_version.py +4 -0
  27. supermemory/lib/.keep +4 -0
  28. supermemory/py.typed +0 -0
  29. supermemory/resources/__init__.py +75 -0
  30. supermemory/resources/connections.py +807 -0
  31. supermemory/resources/documents.py +830 -0
  32. supermemory/resources/memories.py +830 -0
  33. supermemory/resources/search.py +657 -0
  34. supermemory/resources/settings.py +278 -0
  35. supermemory/types/__init__.py +51 -0
  36. supermemory/types/add_response.py +13 -0
  37. supermemory/types/client_add_params.py +36 -0
  38. supermemory/types/client_profile_params.py +21 -0
  39. supermemory/types/connection_create_params.py +21 -0
  40. supermemory/types/connection_create_response.py +19 -0
  41. supermemory/types/connection_delete_by_id_response.py +11 -0
  42. supermemory/types/connection_delete_by_provider_params.py +15 -0
  43. supermemory/types/connection_delete_by_provider_response.py +11 -0
  44. supermemory/types/connection_get_by_id_response.py +25 -0
  45. supermemory/types/connection_get_by_tags_params.py +15 -0
  46. supermemory/types/connection_get_by_tags_response.py +25 -0
  47. supermemory/types/connection_import_params.py +15 -0
  48. supermemory/types/connection_import_response.py +7 -0
  49. supermemory/types/connection_list_documents_params.py +15 -0
  50. supermemory/types/connection_list_documents_response.py +29 -0
  51. supermemory/types/connection_list_params.py +15 -0
  52. supermemory/types/connection_list_response.py +29 -0
  53. supermemory/types/document_add_params.py +36 -0
  54. supermemory/types/document_add_response.py +13 -0
  55. supermemory/types/document_get_response.py +103 -0
  56. supermemory/types/document_list_params.py +52 -0
  57. supermemory/types/document_list_response.py +94 -0
  58. supermemory/types/document_update_params.py +55 -0
  59. supermemory/types/document_update_response.py +13 -0
  60. supermemory/types/document_upload_file_params.py +44 -0
  61. supermemory/types/document_upload_file_response.py +13 -0
  62. supermemory/types/memory_add_params.py +36 -0
  63. supermemory/types/memory_add_response.py +13 -0
  64. supermemory/types/memory_get_response.py +103 -0
  65. supermemory/types/memory_list_params.py +52 -0
  66. supermemory/types/memory_list_response.py +94 -0
  67. supermemory/types/memory_update_params.py +55 -0
  68. supermemory/types/memory_update_response.py +13 -0
  69. supermemory/types/memory_upload_file_params.py +44 -0
  70. supermemory/types/memory_upload_file_response.py +13 -0
  71. supermemory/types/profile_response.py +35 -0
  72. supermemory/types/search_documents_params.py +93 -0
  73. supermemory/types/search_documents_response.py +60 -0
  74. supermemory/types/search_execute_params.py +93 -0
  75. supermemory/types/search_execute_response.py +60 -0
  76. supermemory/types/search_memories_params.py +75 -0
  77. supermemory/types/search_memories_response.py +123 -0
  78. supermemory/types/setting_get_response.py +43 -0
  79. supermemory/types/setting_update_params.py +44 -0
  80. supermemory/types/setting_update_response.py +51 -0
  81. supermemory-3.7.0.dist-info/METADATA +447 -0
  82. supermemory-3.7.0.dist-info/RECORD +84 -0
  83. supermemory-3.7.0.dist-info/WHEEL +4 -0
  84. supermemory-3.7.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,807 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict, Union, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..types import (
11
+ connection_list_params,
12
+ connection_create_params,
13
+ connection_import_params,
14
+ connection_get_by_tags_params,
15
+ connection_list_documents_params,
16
+ connection_delete_by_provider_params,
17
+ )
18
+ from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
19
+ from .._utils import maybe_transform, async_maybe_transform
20
+ from .._compat import cached_property
21
+ from .._resource import SyncAPIResource, AsyncAPIResource
22
+ from .._response import (
23
+ to_raw_response_wrapper,
24
+ to_streamed_response_wrapper,
25
+ async_to_raw_response_wrapper,
26
+ async_to_streamed_response_wrapper,
27
+ )
28
+ from .._base_client import make_request_options
29
+ from ..types.connection_list_response import ConnectionListResponse
30
+ from ..types.connection_create_response import ConnectionCreateResponse
31
+ from ..types.connection_get_by_id_response import ConnectionGetByIDResponse
32
+ from ..types.connection_get_by_tags_response import ConnectionGetByTagsResponse
33
+ from ..types.connection_delete_by_id_response import ConnectionDeleteByIDResponse
34
+ from ..types.connection_list_documents_response import ConnectionListDocumentsResponse
35
+ from ..types.connection_delete_by_provider_response import ConnectionDeleteByProviderResponse
36
+
37
+ __all__ = ["ConnectionsResource", "AsyncConnectionsResource"]
38
+
39
+
40
+ class ConnectionsResource(SyncAPIResource):
41
+ @cached_property
42
+ def with_raw_response(self) -> ConnectionsResourceWithRawResponse:
43
+ """
44
+ This property can be used as a prefix for any HTTP method call to return
45
+ the raw response object instead of the parsed content.
46
+
47
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
48
+ """
49
+ return ConnectionsResourceWithRawResponse(self)
50
+
51
+ @cached_property
52
+ def with_streaming_response(self) -> ConnectionsResourceWithStreamingResponse:
53
+ """
54
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
55
+
56
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
57
+ """
58
+ return ConnectionsResourceWithStreamingResponse(self)
59
+
60
+ def create(
61
+ self,
62
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
63
+ *,
64
+ container_tags: SequenceNotStr[str] | Omit = omit,
65
+ document_limit: int | Omit = omit,
66
+ metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
67
+ redirect_url: str | Omit = omit,
68
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
69
+ # The extra values given here take precedence over values defined on the client or passed to this method.
70
+ extra_headers: Headers | None = None,
71
+ extra_query: Query | None = None,
72
+ extra_body: Body | None = None,
73
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
74
+ ) -> ConnectionCreateResponse:
75
+ """
76
+ Initialize connection and get authorization URL
77
+
78
+ Args:
79
+ extra_headers: Send extra headers
80
+
81
+ extra_query: Add additional query parameters to the request
82
+
83
+ extra_body: Add additional JSON properties to the request
84
+
85
+ timeout: Override the client-level default timeout for this request, in seconds
86
+ """
87
+ if not provider:
88
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
89
+ return self._post(
90
+ f"/v3/connections/{provider}",
91
+ body=maybe_transform(
92
+ {
93
+ "container_tags": container_tags,
94
+ "document_limit": document_limit,
95
+ "metadata": metadata,
96
+ "redirect_url": redirect_url,
97
+ },
98
+ connection_create_params.ConnectionCreateParams,
99
+ ),
100
+ options=make_request_options(
101
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
102
+ ),
103
+ cast_to=ConnectionCreateResponse,
104
+ )
105
+
106
+ def list(
107
+ self,
108
+ *,
109
+ container_tags: SequenceNotStr[str] | Omit = omit,
110
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
111
+ # The extra values given here take precedence over values defined on the client or passed to this method.
112
+ extra_headers: Headers | None = None,
113
+ extra_query: Query | None = None,
114
+ extra_body: Body | None = None,
115
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
116
+ ) -> ConnectionListResponse:
117
+ """
118
+ List all connections
119
+
120
+ Args:
121
+ container_tags: Optional comma-separated list of container tags to filter documents by
122
+
123
+ extra_headers: Send extra headers
124
+
125
+ extra_query: Add additional query parameters to the request
126
+
127
+ extra_body: Add additional JSON properties to the request
128
+
129
+ timeout: Override the client-level default timeout for this request, in seconds
130
+ """
131
+ return self._post(
132
+ "/v3/connections/list",
133
+ body=maybe_transform({"container_tags": container_tags}, connection_list_params.ConnectionListParams),
134
+ options=make_request_options(
135
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
136
+ ),
137
+ cast_to=ConnectionListResponse,
138
+ )
139
+
140
+ def delete_by_id(
141
+ self,
142
+ connection_id: str,
143
+ *,
144
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
145
+ # The extra values given here take precedence over values defined on the client or passed to this method.
146
+ extra_headers: Headers | None = None,
147
+ extra_query: Query | None = None,
148
+ extra_body: Body | None = None,
149
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
150
+ ) -> ConnectionDeleteByIDResponse:
151
+ """
152
+ Delete a specific connection by ID
153
+
154
+ Args:
155
+ extra_headers: Send extra headers
156
+
157
+ extra_query: Add additional query parameters to the request
158
+
159
+ extra_body: Add additional JSON properties to the request
160
+
161
+ timeout: Override the client-level default timeout for this request, in seconds
162
+ """
163
+ if not connection_id:
164
+ raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}")
165
+ return self._delete(
166
+ f"/v3/connections/{connection_id}",
167
+ options=make_request_options(
168
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
169
+ ),
170
+ cast_to=ConnectionDeleteByIDResponse,
171
+ )
172
+
173
+ def delete_by_provider(
174
+ self,
175
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
176
+ *,
177
+ container_tags: SequenceNotStr[str],
178
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
179
+ # The extra values given here take precedence over values defined on the client or passed to this method.
180
+ extra_headers: Headers | None = None,
181
+ extra_query: Query | None = None,
182
+ extra_body: Body | None = None,
183
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
184
+ ) -> ConnectionDeleteByProviderResponse:
185
+ """
186
+ Delete connection for a specific provider and container tags
187
+
188
+ Args:
189
+ container_tags: Optional comma-separated list of container tags to filter connections by
190
+
191
+ extra_headers: Send extra headers
192
+
193
+ extra_query: Add additional query parameters to the request
194
+
195
+ extra_body: Add additional JSON properties to the request
196
+
197
+ timeout: Override the client-level default timeout for this request, in seconds
198
+ """
199
+ if not provider:
200
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
201
+ return self._delete(
202
+ f"/v3/connections/{provider}",
203
+ body=maybe_transform(
204
+ {"container_tags": container_tags},
205
+ connection_delete_by_provider_params.ConnectionDeleteByProviderParams,
206
+ ),
207
+ options=make_request_options(
208
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
209
+ ),
210
+ cast_to=ConnectionDeleteByProviderResponse,
211
+ )
212
+
213
+ def get_by_id(
214
+ self,
215
+ connection_id: str,
216
+ *,
217
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
218
+ # The extra values given here take precedence over values defined on the client or passed to this method.
219
+ extra_headers: Headers | None = None,
220
+ extra_query: Query | None = None,
221
+ extra_body: Body | None = None,
222
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
223
+ ) -> ConnectionGetByIDResponse:
224
+ """
225
+ Get connection details with id
226
+
227
+ Args:
228
+ extra_headers: Send extra headers
229
+
230
+ extra_query: Add additional query parameters to the request
231
+
232
+ extra_body: Add additional JSON properties to the request
233
+
234
+ timeout: Override the client-level default timeout for this request, in seconds
235
+ """
236
+ if not connection_id:
237
+ raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}")
238
+ return self._get(
239
+ f"/v3/connections/{connection_id}",
240
+ options=make_request_options(
241
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
242
+ ),
243
+ cast_to=ConnectionGetByIDResponse,
244
+ )
245
+
246
+ def get_by_tags(
247
+ self,
248
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
249
+ *,
250
+ container_tags: SequenceNotStr[str],
251
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
252
+ # The extra values given here take precedence over values defined on the client or passed to this method.
253
+ extra_headers: Headers | None = None,
254
+ extra_query: Query | None = None,
255
+ extra_body: Body | None = None,
256
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
257
+ ) -> ConnectionGetByTagsResponse:
258
+ """
259
+ Get connection details with provider and container tags
260
+
261
+ Args:
262
+ container_tags: Comma-separated list of container tags to filter connection by
263
+
264
+ extra_headers: Send extra headers
265
+
266
+ extra_query: Add additional query parameters to the request
267
+
268
+ extra_body: Add additional JSON properties to the request
269
+
270
+ timeout: Override the client-level default timeout for this request, in seconds
271
+ """
272
+ if not provider:
273
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
274
+ return self._post(
275
+ f"/v3/connections/{provider}/connection",
276
+ body=maybe_transform(
277
+ {"container_tags": container_tags}, connection_get_by_tags_params.ConnectionGetByTagsParams
278
+ ),
279
+ options=make_request_options(
280
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
281
+ ),
282
+ cast_to=ConnectionGetByTagsResponse,
283
+ )
284
+
285
+ def import_(
286
+ self,
287
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
288
+ *,
289
+ container_tags: SequenceNotStr[str] | Omit = omit,
290
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
291
+ # The extra values given here take precedence over values defined on the client or passed to this method.
292
+ extra_headers: Headers | None = None,
293
+ extra_query: Query | None = None,
294
+ extra_body: Body | None = None,
295
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
296
+ ) -> str:
297
+ """
298
+ Initiate a manual sync of connections
299
+
300
+ Args:
301
+ container_tags: Optional comma-separated list of container tags to filter connections by
302
+
303
+ extra_headers: Send extra headers
304
+
305
+ extra_query: Add additional query parameters to the request
306
+
307
+ extra_body: Add additional JSON properties to the request
308
+
309
+ timeout: Override the client-level default timeout for this request, in seconds
310
+ """
311
+ if not provider:
312
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
313
+ extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
314
+ return self._post(
315
+ f"/v3/connections/{provider}/import",
316
+ body=maybe_transform({"container_tags": container_tags}, connection_import_params.ConnectionImportParams),
317
+ options=make_request_options(
318
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
319
+ ),
320
+ cast_to=str,
321
+ )
322
+
323
+ def list_documents(
324
+ self,
325
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
326
+ *,
327
+ container_tags: SequenceNotStr[str] | Omit = omit,
328
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
329
+ # The extra values given here take precedence over values defined on the client or passed to this method.
330
+ extra_headers: Headers | None = None,
331
+ extra_query: Query | None = None,
332
+ extra_body: Body | None = None,
333
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
334
+ ) -> ConnectionListDocumentsResponse:
335
+ """
336
+ List documents indexed for a provider and container tags
337
+
338
+ Args:
339
+ container_tags: Optional comma-separated list of container tags to filter documents by
340
+
341
+ extra_headers: Send extra headers
342
+
343
+ extra_query: Add additional query parameters to the request
344
+
345
+ extra_body: Add additional JSON properties to the request
346
+
347
+ timeout: Override the client-level default timeout for this request, in seconds
348
+ """
349
+ if not provider:
350
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
351
+ return self._post(
352
+ f"/v3/connections/{provider}/documents",
353
+ body=maybe_transform(
354
+ {"container_tags": container_tags}, connection_list_documents_params.ConnectionListDocumentsParams
355
+ ),
356
+ options=make_request_options(
357
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
358
+ ),
359
+ cast_to=ConnectionListDocumentsResponse,
360
+ )
361
+
362
+
363
+ class AsyncConnectionsResource(AsyncAPIResource):
364
+ @cached_property
365
+ def with_raw_response(self) -> AsyncConnectionsResourceWithRawResponse:
366
+ """
367
+ This property can be used as a prefix for any HTTP method call to return
368
+ the raw response object instead of the parsed content.
369
+
370
+ For more information, see https://www.github.com/supermemoryai/python-sdk#accessing-raw-response-data-eg-headers
371
+ """
372
+ return AsyncConnectionsResourceWithRawResponse(self)
373
+
374
+ @cached_property
375
+ def with_streaming_response(self) -> AsyncConnectionsResourceWithStreamingResponse:
376
+ """
377
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
378
+
379
+ For more information, see https://www.github.com/supermemoryai/python-sdk#with_streaming_response
380
+ """
381
+ return AsyncConnectionsResourceWithStreamingResponse(self)
382
+
383
+ async def create(
384
+ self,
385
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
386
+ *,
387
+ container_tags: SequenceNotStr[str] | Omit = omit,
388
+ document_limit: int | Omit = omit,
389
+ metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
390
+ redirect_url: str | Omit = omit,
391
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
392
+ # The extra values given here take precedence over values defined on the client or passed to this method.
393
+ extra_headers: Headers | None = None,
394
+ extra_query: Query | None = None,
395
+ extra_body: Body | None = None,
396
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
397
+ ) -> ConnectionCreateResponse:
398
+ """
399
+ Initialize connection and get authorization URL
400
+
401
+ Args:
402
+ extra_headers: Send extra headers
403
+
404
+ extra_query: Add additional query parameters to the request
405
+
406
+ extra_body: Add additional JSON properties to the request
407
+
408
+ timeout: Override the client-level default timeout for this request, in seconds
409
+ """
410
+ if not provider:
411
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
412
+ return await self._post(
413
+ f"/v3/connections/{provider}",
414
+ body=await async_maybe_transform(
415
+ {
416
+ "container_tags": container_tags,
417
+ "document_limit": document_limit,
418
+ "metadata": metadata,
419
+ "redirect_url": redirect_url,
420
+ },
421
+ connection_create_params.ConnectionCreateParams,
422
+ ),
423
+ options=make_request_options(
424
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
425
+ ),
426
+ cast_to=ConnectionCreateResponse,
427
+ )
428
+
429
+ async def list(
430
+ self,
431
+ *,
432
+ container_tags: SequenceNotStr[str] | Omit = omit,
433
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
434
+ # The extra values given here take precedence over values defined on the client or passed to this method.
435
+ extra_headers: Headers | None = None,
436
+ extra_query: Query | None = None,
437
+ extra_body: Body | None = None,
438
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
439
+ ) -> ConnectionListResponse:
440
+ """
441
+ List all connections
442
+
443
+ Args:
444
+ container_tags: Optional comma-separated list of container tags to filter documents by
445
+
446
+ extra_headers: Send extra headers
447
+
448
+ extra_query: Add additional query parameters to the request
449
+
450
+ extra_body: Add additional JSON properties to the request
451
+
452
+ timeout: Override the client-level default timeout for this request, in seconds
453
+ """
454
+ return await self._post(
455
+ "/v3/connections/list",
456
+ body=await async_maybe_transform(
457
+ {"container_tags": container_tags}, connection_list_params.ConnectionListParams
458
+ ),
459
+ options=make_request_options(
460
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
461
+ ),
462
+ cast_to=ConnectionListResponse,
463
+ )
464
+
465
+ async def delete_by_id(
466
+ self,
467
+ connection_id: str,
468
+ *,
469
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
470
+ # The extra values given here take precedence over values defined on the client or passed to this method.
471
+ extra_headers: Headers | None = None,
472
+ extra_query: Query | None = None,
473
+ extra_body: Body | None = None,
474
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
475
+ ) -> ConnectionDeleteByIDResponse:
476
+ """
477
+ Delete a specific connection by ID
478
+
479
+ Args:
480
+ extra_headers: Send extra headers
481
+
482
+ extra_query: Add additional query parameters to the request
483
+
484
+ extra_body: Add additional JSON properties to the request
485
+
486
+ timeout: Override the client-level default timeout for this request, in seconds
487
+ """
488
+ if not connection_id:
489
+ raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}")
490
+ return await self._delete(
491
+ f"/v3/connections/{connection_id}",
492
+ options=make_request_options(
493
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
494
+ ),
495
+ cast_to=ConnectionDeleteByIDResponse,
496
+ )
497
+
498
+ async def delete_by_provider(
499
+ self,
500
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
501
+ *,
502
+ container_tags: SequenceNotStr[str],
503
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
504
+ # The extra values given here take precedence over values defined on the client or passed to this method.
505
+ extra_headers: Headers | None = None,
506
+ extra_query: Query | None = None,
507
+ extra_body: Body | None = None,
508
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
509
+ ) -> ConnectionDeleteByProviderResponse:
510
+ """
511
+ Delete connection for a specific provider and container tags
512
+
513
+ Args:
514
+ container_tags: Optional comma-separated list of container tags to filter connections by
515
+
516
+ extra_headers: Send extra headers
517
+
518
+ extra_query: Add additional query parameters to the request
519
+
520
+ extra_body: Add additional JSON properties to the request
521
+
522
+ timeout: Override the client-level default timeout for this request, in seconds
523
+ """
524
+ if not provider:
525
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
526
+ return await self._delete(
527
+ f"/v3/connections/{provider}",
528
+ body=await async_maybe_transform(
529
+ {"container_tags": container_tags},
530
+ connection_delete_by_provider_params.ConnectionDeleteByProviderParams,
531
+ ),
532
+ options=make_request_options(
533
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
534
+ ),
535
+ cast_to=ConnectionDeleteByProviderResponse,
536
+ )
537
+
538
+ async def get_by_id(
539
+ self,
540
+ connection_id: str,
541
+ *,
542
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
543
+ # The extra values given here take precedence over values defined on the client or passed to this method.
544
+ extra_headers: Headers | None = None,
545
+ extra_query: Query | None = None,
546
+ extra_body: Body | None = None,
547
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
548
+ ) -> ConnectionGetByIDResponse:
549
+ """
550
+ Get connection details with id
551
+
552
+ Args:
553
+ extra_headers: Send extra headers
554
+
555
+ extra_query: Add additional query parameters to the request
556
+
557
+ extra_body: Add additional JSON properties to the request
558
+
559
+ timeout: Override the client-level default timeout for this request, in seconds
560
+ """
561
+ if not connection_id:
562
+ raise ValueError(f"Expected a non-empty value for `connection_id` but received {connection_id!r}")
563
+ return await self._get(
564
+ f"/v3/connections/{connection_id}",
565
+ options=make_request_options(
566
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
567
+ ),
568
+ cast_to=ConnectionGetByIDResponse,
569
+ )
570
+
571
+ async def get_by_tags(
572
+ self,
573
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
574
+ *,
575
+ container_tags: SequenceNotStr[str],
576
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
577
+ # The extra values given here take precedence over values defined on the client or passed to this method.
578
+ extra_headers: Headers | None = None,
579
+ extra_query: Query | None = None,
580
+ extra_body: Body | None = None,
581
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
582
+ ) -> ConnectionGetByTagsResponse:
583
+ """
584
+ Get connection details with provider and container tags
585
+
586
+ Args:
587
+ container_tags: Comma-separated list of container tags to filter connection by
588
+
589
+ extra_headers: Send extra headers
590
+
591
+ extra_query: Add additional query parameters to the request
592
+
593
+ extra_body: Add additional JSON properties to the request
594
+
595
+ timeout: Override the client-level default timeout for this request, in seconds
596
+ """
597
+ if not provider:
598
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
599
+ return await self._post(
600
+ f"/v3/connections/{provider}/connection",
601
+ body=await async_maybe_transform(
602
+ {"container_tags": container_tags}, connection_get_by_tags_params.ConnectionGetByTagsParams
603
+ ),
604
+ options=make_request_options(
605
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
606
+ ),
607
+ cast_to=ConnectionGetByTagsResponse,
608
+ )
609
+
610
+ async def import_(
611
+ self,
612
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
613
+ *,
614
+ container_tags: SequenceNotStr[str] | Omit = omit,
615
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
616
+ # The extra values given here take precedence over values defined on the client or passed to this method.
617
+ extra_headers: Headers | None = None,
618
+ extra_query: Query | None = None,
619
+ extra_body: Body | None = None,
620
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
621
+ ) -> str:
622
+ """
623
+ Initiate a manual sync of connections
624
+
625
+ Args:
626
+ container_tags: Optional comma-separated list of container tags to filter connections by
627
+
628
+ extra_headers: Send extra headers
629
+
630
+ extra_query: Add additional query parameters to the request
631
+
632
+ extra_body: Add additional JSON properties to the request
633
+
634
+ timeout: Override the client-level default timeout for this request, in seconds
635
+ """
636
+ if not provider:
637
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
638
+ extra_headers = {"Accept": "text/plain", **(extra_headers or {})}
639
+ return await self._post(
640
+ f"/v3/connections/{provider}/import",
641
+ body=await async_maybe_transform(
642
+ {"container_tags": container_tags}, connection_import_params.ConnectionImportParams
643
+ ),
644
+ options=make_request_options(
645
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
646
+ ),
647
+ cast_to=str,
648
+ )
649
+
650
+ async def list_documents(
651
+ self,
652
+ provider: Literal["notion", "google-drive", "onedrive", "web-crawler"],
653
+ *,
654
+ container_tags: SequenceNotStr[str] | Omit = omit,
655
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
656
+ # The extra values given here take precedence over values defined on the client or passed to this method.
657
+ extra_headers: Headers | None = None,
658
+ extra_query: Query | None = None,
659
+ extra_body: Body | None = None,
660
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
661
+ ) -> ConnectionListDocumentsResponse:
662
+ """
663
+ List documents indexed for a provider and container tags
664
+
665
+ Args:
666
+ container_tags: Optional comma-separated list of container tags to filter documents by
667
+
668
+ extra_headers: Send extra headers
669
+
670
+ extra_query: Add additional query parameters to the request
671
+
672
+ extra_body: Add additional JSON properties to the request
673
+
674
+ timeout: Override the client-level default timeout for this request, in seconds
675
+ """
676
+ if not provider:
677
+ raise ValueError(f"Expected a non-empty value for `provider` but received {provider!r}")
678
+ return await self._post(
679
+ f"/v3/connections/{provider}/documents",
680
+ body=await async_maybe_transform(
681
+ {"container_tags": container_tags}, connection_list_documents_params.ConnectionListDocumentsParams
682
+ ),
683
+ options=make_request_options(
684
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
685
+ ),
686
+ cast_to=ConnectionListDocumentsResponse,
687
+ )
688
+
689
+
690
+ class ConnectionsResourceWithRawResponse:
691
+ def __init__(self, connections: ConnectionsResource) -> None:
692
+ self._connections = connections
693
+
694
+ self.create = to_raw_response_wrapper(
695
+ connections.create,
696
+ )
697
+ self.list = to_raw_response_wrapper(
698
+ connections.list,
699
+ )
700
+ self.delete_by_id = to_raw_response_wrapper(
701
+ connections.delete_by_id,
702
+ )
703
+ self.delete_by_provider = to_raw_response_wrapper(
704
+ connections.delete_by_provider,
705
+ )
706
+ self.get_by_id = to_raw_response_wrapper(
707
+ connections.get_by_id,
708
+ )
709
+ self.get_by_tags = to_raw_response_wrapper(
710
+ connections.get_by_tags,
711
+ )
712
+ self.import_ = to_raw_response_wrapper(
713
+ connections.import_,
714
+ )
715
+ self.list_documents = to_raw_response_wrapper(
716
+ connections.list_documents,
717
+ )
718
+
719
+
720
+ class AsyncConnectionsResourceWithRawResponse:
721
+ def __init__(self, connections: AsyncConnectionsResource) -> None:
722
+ self._connections = connections
723
+
724
+ self.create = async_to_raw_response_wrapper(
725
+ connections.create,
726
+ )
727
+ self.list = async_to_raw_response_wrapper(
728
+ connections.list,
729
+ )
730
+ self.delete_by_id = async_to_raw_response_wrapper(
731
+ connections.delete_by_id,
732
+ )
733
+ self.delete_by_provider = async_to_raw_response_wrapper(
734
+ connections.delete_by_provider,
735
+ )
736
+ self.get_by_id = async_to_raw_response_wrapper(
737
+ connections.get_by_id,
738
+ )
739
+ self.get_by_tags = async_to_raw_response_wrapper(
740
+ connections.get_by_tags,
741
+ )
742
+ self.import_ = async_to_raw_response_wrapper(
743
+ connections.import_,
744
+ )
745
+ self.list_documents = async_to_raw_response_wrapper(
746
+ connections.list_documents,
747
+ )
748
+
749
+
750
+ class ConnectionsResourceWithStreamingResponse:
751
+ def __init__(self, connections: ConnectionsResource) -> None:
752
+ self._connections = connections
753
+
754
+ self.create = to_streamed_response_wrapper(
755
+ connections.create,
756
+ )
757
+ self.list = to_streamed_response_wrapper(
758
+ connections.list,
759
+ )
760
+ self.delete_by_id = to_streamed_response_wrapper(
761
+ connections.delete_by_id,
762
+ )
763
+ self.delete_by_provider = to_streamed_response_wrapper(
764
+ connections.delete_by_provider,
765
+ )
766
+ self.get_by_id = to_streamed_response_wrapper(
767
+ connections.get_by_id,
768
+ )
769
+ self.get_by_tags = to_streamed_response_wrapper(
770
+ connections.get_by_tags,
771
+ )
772
+ self.import_ = to_streamed_response_wrapper(
773
+ connections.import_,
774
+ )
775
+ self.list_documents = to_streamed_response_wrapper(
776
+ connections.list_documents,
777
+ )
778
+
779
+
780
+ class AsyncConnectionsResourceWithStreamingResponse:
781
+ def __init__(self, connections: AsyncConnectionsResource) -> None:
782
+ self._connections = connections
783
+
784
+ self.create = async_to_streamed_response_wrapper(
785
+ connections.create,
786
+ )
787
+ self.list = async_to_streamed_response_wrapper(
788
+ connections.list,
789
+ )
790
+ self.delete_by_id = async_to_streamed_response_wrapper(
791
+ connections.delete_by_id,
792
+ )
793
+ self.delete_by_provider = async_to_streamed_response_wrapper(
794
+ connections.delete_by_provider,
795
+ )
796
+ self.get_by_id = async_to_streamed_response_wrapper(
797
+ connections.get_by_id,
798
+ )
799
+ self.get_by_tags = async_to_streamed_response_wrapper(
800
+ connections.get_by_tags,
801
+ )
802
+ self.import_ = async_to_streamed_response_wrapper(
803
+ connections.import_,
804
+ )
805
+ self.list_documents = async_to_streamed_response_wrapper(
806
+ connections.list_documents,
807
+ )