airweave-sdk 0.8.64__py3-none-any.whl → 0.8.65__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.
@@ -0,0 +1,1138 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
+ from ..core.request_options import RequestOptions
8
+ from ..types.enable_endpoint_request import EnableEndpointRequest
9
+ from ..types.endpoint_out import EndpointOut
10
+ from ..types.endpoint_secret_out import EndpointSecretOut
11
+ from ..types.event_type import EventType
12
+ from ..types.message_attempt_out import MessageAttemptOut
13
+ from ..types.message_out import MessageOut
14
+ from ..types.recover_out import RecoverOut
15
+ from ..types.subscription_with_attempts_out import SubscriptionWithAttemptsOut
16
+ from .raw_client import AsyncRawEventsClient, RawEventsClient
17
+
18
+ # this is used as the default value for optional parameters
19
+ OMIT = typing.cast(typing.Any, ...)
20
+
21
+
22
+ class EventsClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._raw_client = RawEventsClient(client_wrapper=client_wrapper)
25
+
26
+ @property
27
+ def with_raw_response(self) -> RawEventsClient:
28
+ """
29
+ Retrieves a raw implementation of this client that returns raw responses.
30
+
31
+ Returns
32
+ -------
33
+ RawEventsClient
34
+ """
35
+ return self._raw_client
36
+
37
+ def get_messages(
38
+ self,
39
+ *,
40
+ event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
41
+ request_options: typing.Optional[RequestOptions] = None,
42
+ ) -> typing.List[MessageOut]:
43
+ """
44
+ Get event messages for the current organization.
45
+
46
+ Args:
47
+ ctx: The API context containing organization info.
48
+ event_types: Optional list of event types to filter by.
49
+
50
+ Returns:
51
+ List of event messages.
52
+
53
+ Parameters
54
+ ----------
55
+ event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
56
+
57
+ request_options : typing.Optional[RequestOptions]
58
+ Request-specific configuration.
59
+
60
+ Returns
61
+ -------
62
+ typing.List[MessageOut]
63
+ Successful Response
64
+
65
+ Examples
66
+ --------
67
+ from airweave import AirweaveSDK
68
+
69
+ client = AirweaveSDK(
70
+ framework_name="YOUR_FRAMEWORK_NAME",
71
+ framework_version="YOUR_FRAMEWORK_VERSION",
72
+ api_key="YOUR_API_KEY",
73
+ )
74
+ client.events.get_messages()
75
+ """
76
+ _response = self._raw_client.get_messages(event_types=event_types, request_options=request_options)
77
+ return _response.data
78
+
79
+ def get_message(self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> MessageOut:
80
+ """
81
+ Get a specific event message by ID.
82
+
83
+ Args:
84
+ message_id: The ID of the message to retrieve.
85
+ ctx: The API context containing organization info.
86
+
87
+ Returns:
88
+ The event message with its payload.
89
+
90
+ Parameters
91
+ ----------
92
+ message_id : str
93
+
94
+ request_options : typing.Optional[RequestOptions]
95
+ Request-specific configuration.
96
+
97
+ Returns
98
+ -------
99
+ MessageOut
100
+ Successful Response
101
+
102
+ Examples
103
+ --------
104
+ from airweave import AirweaveSDK
105
+
106
+ client = AirweaveSDK(
107
+ framework_name="YOUR_FRAMEWORK_NAME",
108
+ framework_version="YOUR_FRAMEWORK_VERSION",
109
+ api_key="YOUR_API_KEY",
110
+ )
111
+ client.events.get_message(
112
+ message_id="message_id",
113
+ )
114
+ """
115
+ _response = self._raw_client.get_message(message_id, request_options=request_options)
116
+ return _response.data
117
+
118
+ def get_message_attempts(
119
+ self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
120
+ ) -> typing.List[MessageAttemptOut]:
121
+ """
122
+ Get delivery attempts for a specific message.
123
+
124
+ Args:
125
+ message_id: The ID of the message.
126
+ ctx: The API context containing organization info.
127
+
128
+ Returns:
129
+ List of delivery attempts for this message.
130
+
131
+ Parameters
132
+ ----------
133
+ message_id : str
134
+
135
+ request_options : typing.Optional[RequestOptions]
136
+ Request-specific configuration.
137
+
138
+ Returns
139
+ -------
140
+ typing.List[MessageAttemptOut]
141
+ Successful Response
142
+
143
+ Examples
144
+ --------
145
+ from airweave import AirweaveSDK
146
+
147
+ client = AirweaveSDK(
148
+ framework_name="YOUR_FRAMEWORK_NAME",
149
+ framework_version="YOUR_FRAMEWORK_VERSION",
150
+ api_key="YOUR_API_KEY",
151
+ )
152
+ client.events.get_message_attempts(
153
+ message_id="message_id",
154
+ )
155
+ """
156
+ _response = self._raw_client.get_message_attempts(message_id, request_options=request_options)
157
+ return _response.data
158
+
159
+ def get_subscriptions(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[EndpointOut]:
160
+ """
161
+ Get all webhook subscriptions for the current organization.
162
+
163
+ Args:
164
+ ctx: The API context containing organization info.
165
+
166
+ Returns:
167
+ List of webhook subscriptions.
168
+
169
+ Parameters
170
+ ----------
171
+ request_options : typing.Optional[RequestOptions]
172
+ Request-specific configuration.
173
+
174
+ Returns
175
+ -------
176
+ typing.List[EndpointOut]
177
+ Successful Response
178
+
179
+ Examples
180
+ --------
181
+ from airweave import AirweaveSDK
182
+
183
+ client = AirweaveSDK(
184
+ framework_name="YOUR_FRAMEWORK_NAME",
185
+ framework_version="YOUR_FRAMEWORK_VERSION",
186
+ api_key="YOUR_API_KEY",
187
+ )
188
+ client.events.get_subscriptions()
189
+ """
190
+ _response = self._raw_client.get_subscriptions(request_options=request_options)
191
+ return _response.data
192
+
193
+ def create_subscription(
194
+ self,
195
+ *,
196
+ url: str,
197
+ event_types: typing.Sequence[EventType],
198
+ secret: typing.Optional[str] = OMIT,
199
+ request_options: typing.Optional[RequestOptions] = None,
200
+ ) -> EndpointOut:
201
+ """
202
+ Create a new webhook subscription.
203
+
204
+ Args:
205
+ request: The subscription creation request.
206
+ ctx: The API context containing organization info.
207
+
208
+ Returns:
209
+ The created subscription.
210
+
211
+ Parameters
212
+ ----------
213
+ url : str
214
+
215
+ event_types : typing.Sequence[EventType]
216
+
217
+ secret : typing.Optional[str]
218
+
219
+ request_options : typing.Optional[RequestOptions]
220
+ Request-specific configuration.
221
+
222
+ Returns
223
+ -------
224
+ EndpointOut
225
+ Successful Response
226
+
227
+ Examples
228
+ --------
229
+ from airweave import AirweaveSDK
230
+
231
+ client = AirweaveSDK(
232
+ framework_name="YOUR_FRAMEWORK_NAME",
233
+ framework_version="YOUR_FRAMEWORK_VERSION",
234
+ api_key="YOUR_API_KEY",
235
+ )
236
+ client.events.create_subscription(
237
+ url="url",
238
+ event_types=["sync.pending"],
239
+ )
240
+ """
241
+ _response = self._raw_client.create_subscription(
242
+ url=url, event_types=event_types, secret=secret, request_options=request_options
243
+ )
244
+ return _response.data
245
+
246
+ def get_subscription(
247
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
248
+ ) -> SubscriptionWithAttemptsOut:
249
+ """
250
+ Get a specific webhook subscription with its delivery attempts.
251
+
252
+ Args:
253
+ subscription_id: The ID of the subscription to retrieve.
254
+ ctx: The API context containing organization info.
255
+
256
+ Returns:
257
+ The subscription details with message delivery attempts.
258
+
259
+ Parameters
260
+ ----------
261
+ subscription_id : str
262
+
263
+ request_options : typing.Optional[RequestOptions]
264
+ Request-specific configuration.
265
+
266
+ Returns
267
+ -------
268
+ SubscriptionWithAttemptsOut
269
+ Successful Response
270
+
271
+ Examples
272
+ --------
273
+ from airweave import AirweaveSDK
274
+
275
+ client = AirweaveSDK(
276
+ framework_name="YOUR_FRAMEWORK_NAME",
277
+ framework_version="YOUR_FRAMEWORK_VERSION",
278
+ api_key="YOUR_API_KEY",
279
+ )
280
+ client.events.get_subscription(
281
+ subscription_id="subscription_id",
282
+ )
283
+ """
284
+ _response = self._raw_client.get_subscription(subscription_id, request_options=request_options)
285
+ return _response.data
286
+
287
+ def delete_subscription(
288
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
289
+ ) -> typing.Optional[typing.Any]:
290
+ """
291
+ Delete a webhook subscription.
292
+
293
+ Args:
294
+ subscription_id: The ID of the subscription to delete.
295
+ ctx: The API context containing organization info.
296
+
297
+ Parameters
298
+ ----------
299
+ subscription_id : str
300
+
301
+ request_options : typing.Optional[RequestOptions]
302
+ Request-specific configuration.
303
+
304
+ Returns
305
+ -------
306
+ typing.Optional[typing.Any]
307
+ Successful Response
308
+
309
+ Examples
310
+ --------
311
+ from airweave import AirweaveSDK
312
+
313
+ client = AirweaveSDK(
314
+ framework_name="YOUR_FRAMEWORK_NAME",
315
+ framework_version="YOUR_FRAMEWORK_VERSION",
316
+ api_key="YOUR_API_KEY",
317
+ )
318
+ client.events.delete_subscription(
319
+ subscription_id="subscription_id",
320
+ )
321
+ """
322
+ _response = self._raw_client.delete_subscription(subscription_id, request_options=request_options)
323
+ return _response.data
324
+
325
+ def patch_subscription(
326
+ self,
327
+ subscription_id: str,
328
+ *,
329
+ url: typing.Optional[str] = OMIT,
330
+ event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
331
+ disabled: typing.Optional[bool] = OMIT,
332
+ request_options: typing.Optional[RequestOptions] = None,
333
+ ) -> EndpointOut:
334
+ """
335
+ Update a webhook subscription.
336
+
337
+ Args:
338
+ subscription_id: The ID of the subscription to update.
339
+ request: The subscription update request.
340
+ ctx: The API context containing organization info.
341
+
342
+ Returns:
343
+ The updated subscription.
344
+
345
+ Parameters
346
+ ----------
347
+ subscription_id : str
348
+
349
+ url : typing.Optional[str]
350
+
351
+ event_types : typing.Optional[typing.Sequence[EventType]]
352
+
353
+ disabled : typing.Optional[bool]
354
+
355
+ request_options : typing.Optional[RequestOptions]
356
+ Request-specific configuration.
357
+
358
+ Returns
359
+ -------
360
+ EndpointOut
361
+ Successful Response
362
+
363
+ Examples
364
+ --------
365
+ from airweave import AirweaveSDK
366
+
367
+ client = AirweaveSDK(
368
+ framework_name="YOUR_FRAMEWORK_NAME",
369
+ framework_version="YOUR_FRAMEWORK_VERSION",
370
+ api_key="YOUR_API_KEY",
371
+ )
372
+ client.events.patch_subscription(
373
+ subscription_id="subscription_id",
374
+ )
375
+ """
376
+ _response = self._raw_client.patch_subscription(
377
+ subscription_id, url=url, event_types=event_types, disabled=disabled, request_options=request_options
378
+ )
379
+ return _response.data
380
+
381
+ def enable_subscription(
382
+ self,
383
+ subscription_id: str,
384
+ *,
385
+ request: typing.Optional[EnableEndpointRequest] = None,
386
+ request_options: typing.Optional[RequestOptions] = None,
387
+ ) -> EndpointOut:
388
+ """
389
+ Enable a disabled webhook subscription, optionally recovering failed messages.
390
+
391
+ Args:
392
+ subscription_id: The ID of the subscription to enable.
393
+ request: Optional request with recovery time range.
394
+ ctx: The API context containing organization info.
395
+
396
+ Returns:
397
+ The enabled subscription.
398
+
399
+ Parameters
400
+ ----------
401
+ subscription_id : str
402
+
403
+ request : typing.Optional[EnableEndpointRequest]
404
+
405
+ request_options : typing.Optional[RequestOptions]
406
+ Request-specific configuration.
407
+
408
+ Returns
409
+ -------
410
+ EndpointOut
411
+ Successful Response
412
+
413
+ Examples
414
+ --------
415
+ from airweave import AirweaveSDK, EnableEndpointRequest
416
+
417
+ client = AirweaveSDK(
418
+ framework_name="YOUR_FRAMEWORK_NAME",
419
+ framework_version="YOUR_FRAMEWORK_VERSION",
420
+ api_key="YOUR_API_KEY",
421
+ )
422
+ client.events.enable_subscription(
423
+ subscription_id="subscription_id",
424
+ request=EnableEndpointRequest(),
425
+ )
426
+ """
427
+ _response = self._raw_client.enable_subscription(
428
+ subscription_id, request=request, request_options=request_options
429
+ )
430
+ return _response.data
431
+
432
+ def get_subscription_secret(
433
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
434
+ ) -> EndpointSecretOut:
435
+ """
436
+ Get the signing secret for a webhook subscription.
437
+
438
+ Args:
439
+ subscription_id: The ID of the subscription.
440
+ ctx: The API context containing organization info.
441
+
442
+ Returns:
443
+ The subscription's signing secret.
444
+
445
+ Parameters
446
+ ----------
447
+ subscription_id : str
448
+
449
+ request_options : typing.Optional[RequestOptions]
450
+ Request-specific configuration.
451
+
452
+ Returns
453
+ -------
454
+ EndpointSecretOut
455
+ Successful Response
456
+
457
+ Examples
458
+ --------
459
+ from airweave import AirweaveSDK
460
+
461
+ client = AirweaveSDK(
462
+ framework_name="YOUR_FRAMEWORK_NAME",
463
+ framework_version="YOUR_FRAMEWORK_VERSION",
464
+ api_key="YOUR_API_KEY",
465
+ )
466
+ client.events.get_subscription_secret(
467
+ subscription_id="subscription_id",
468
+ )
469
+ """
470
+ _response = self._raw_client.get_subscription_secret(subscription_id, request_options=request_options)
471
+ return _response.data
472
+
473
+ def recover_failed_messages(
474
+ self,
475
+ subscription_id: str,
476
+ *,
477
+ since: dt.datetime,
478
+ until: typing.Optional[dt.datetime] = OMIT,
479
+ request_options: typing.Optional[RequestOptions] = None,
480
+ ) -> RecoverOut:
481
+ """
482
+ Recover (retry) failed messages for a webhook subscription.
483
+
484
+ This endpoint triggers a recovery of all failed messages since the specified
485
+ time. Useful after re-enabling a disabled endpoint to retry messages that
486
+ failed while the endpoint was down.
487
+
488
+ Args:
489
+ subscription_id: The ID of the subscription to recover messages for.
490
+ request: The recovery request with time range.
491
+ ctx: The API context containing organization info.
492
+
493
+ Returns:
494
+ Information about the recovery task.
495
+
496
+ Parameters
497
+ ----------
498
+ subscription_id : str
499
+
500
+ since : dt.datetime
501
+
502
+ until : typing.Optional[dt.datetime]
503
+
504
+ request_options : typing.Optional[RequestOptions]
505
+ Request-specific configuration.
506
+
507
+ Returns
508
+ -------
509
+ RecoverOut
510
+ Successful Response
511
+
512
+ Examples
513
+ --------
514
+ import datetime
515
+
516
+ from airweave import AirweaveSDK
517
+
518
+ client = AirweaveSDK(
519
+ framework_name="YOUR_FRAMEWORK_NAME",
520
+ framework_version="YOUR_FRAMEWORK_VERSION",
521
+ api_key="YOUR_API_KEY",
522
+ )
523
+ client.events.recover_failed_messages(
524
+ subscription_id="subscription_id",
525
+ since=datetime.datetime.fromisoformat(
526
+ "2024-01-15 09:30:00+00:00",
527
+ ),
528
+ )
529
+ """
530
+ _response = self._raw_client.recover_failed_messages(
531
+ subscription_id, since=since, until=until, request_options=request_options
532
+ )
533
+ return _response.data
534
+
535
+
536
+ class AsyncEventsClient:
537
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
538
+ self._raw_client = AsyncRawEventsClient(client_wrapper=client_wrapper)
539
+
540
+ @property
541
+ def with_raw_response(self) -> AsyncRawEventsClient:
542
+ """
543
+ Retrieves a raw implementation of this client that returns raw responses.
544
+
545
+ Returns
546
+ -------
547
+ AsyncRawEventsClient
548
+ """
549
+ return self._raw_client
550
+
551
+ async def get_messages(
552
+ self,
553
+ *,
554
+ event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
555
+ request_options: typing.Optional[RequestOptions] = None,
556
+ ) -> typing.List[MessageOut]:
557
+ """
558
+ Get event messages for the current organization.
559
+
560
+ Args:
561
+ ctx: The API context containing organization info.
562
+ event_types: Optional list of event types to filter by.
563
+
564
+ Returns:
565
+ List of event messages.
566
+
567
+ Parameters
568
+ ----------
569
+ event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
570
+
571
+ request_options : typing.Optional[RequestOptions]
572
+ Request-specific configuration.
573
+
574
+ Returns
575
+ -------
576
+ typing.List[MessageOut]
577
+ Successful Response
578
+
579
+ Examples
580
+ --------
581
+ import asyncio
582
+
583
+ from airweave import AsyncAirweaveSDK
584
+
585
+ client = AsyncAirweaveSDK(
586
+ framework_name="YOUR_FRAMEWORK_NAME",
587
+ framework_version="YOUR_FRAMEWORK_VERSION",
588
+ api_key="YOUR_API_KEY",
589
+ )
590
+
591
+
592
+ async def main() -> None:
593
+ await client.events.get_messages()
594
+
595
+
596
+ asyncio.run(main())
597
+ """
598
+ _response = await self._raw_client.get_messages(event_types=event_types, request_options=request_options)
599
+ return _response.data
600
+
601
+ async def get_message(
602
+ self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
603
+ ) -> MessageOut:
604
+ """
605
+ Get a specific event message by ID.
606
+
607
+ Args:
608
+ message_id: The ID of the message to retrieve.
609
+ ctx: The API context containing organization info.
610
+
611
+ Returns:
612
+ The event message with its payload.
613
+
614
+ Parameters
615
+ ----------
616
+ message_id : str
617
+
618
+ request_options : typing.Optional[RequestOptions]
619
+ Request-specific configuration.
620
+
621
+ Returns
622
+ -------
623
+ MessageOut
624
+ Successful Response
625
+
626
+ Examples
627
+ --------
628
+ import asyncio
629
+
630
+ from airweave import AsyncAirweaveSDK
631
+
632
+ client = AsyncAirweaveSDK(
633
+ framework_name="YOUR_FRAMEWORK_NAME",
634
+ framework_version="YOUR_FRAMEWORK_VERSION",
635
+ api_key="YOUR_API_KEY",
636
+ )
637
+
638
+
639
+ async def main() -> None:
640
+ await client.events.get_message(
641
+ message_id="message_id",
642
+ )
643
+
644
+
645
+ asyncio.run(main())
646
+ """
647
+ _response = await self._raw_client.get_message(message_id, request_options=request_options)
648
+ return _response.data
649
+
650
+ async def get_message_attempts(
651
+ self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
652
+ ) -> typing.List[MessageAttemptOut]:
653
+ """
654
+ Get delivery attempts for a specific message.
655
+
656
+ Args:
657
+ message_id: The ID of the message.
658
+ ctx: The API context containing organization info.
659
+
660
+ Returns:
661
+ List of delivery attempts for this message.
662
+
663
+ Parameters
664
+ ----------
665
+ message_id : str
666
+
667
+ request_options : typing.Optional[RequestOptions]
668
+ Request-specific configuration.
669
+
670
+ Returns
671
+ -------
672
+ typing.List[MessageAttemptOut]
673
+ Successful Response
674
+
675
+ Examples
676
+ --------
677
+ import asyncio
678
+
679
+ from airweave import AsyncAirweaveSDK
680
+
681
+ client = AsyncAirweaveSDK(
682
+ framework_name="YOUR_FRAMEWORK_NAME",
683
+ framework_version="YOUR_FRAMEWORK_VERSION",
684
+ api_key="YOUR_API_KEY",
685
+ )
686
+
687
+
688
+ async def main() -> None:
689
+ await client.events.get_message_attempts(
690
+ message_id="message_id",
691
+ )
692
+
693
+
694
+ asyncio.run(main())
695
+ """
696
+ _response = await self._raw_client.get_message_attempts(message_id, request_options=request_options)
697
+ return _response.data
698
+
699
+ async def get_subscriptions(
700
+ self, *, request_options: typing.Optional[RequestOptions] = None
701
+ ) -> typing.List[EndpointOut]:
702
+ """
703
+ Get all webhook subscriptions for the current organization.
704
+
705
+ Args:
706
+ ctx: The API context containing organization info.
707
+
708
+ Returns:
709
+ List of webhook subscriptions.
710
+
711
+ Parameters
712
+ ----------
713
+ request_options : typing.Optional[RequestOptions]
714
+ Request-specific configuration.
715
+
716
+ Returns
717
+ -------
718
+ typing.List[EndpointOut]
719
+ Successful Response
720
+
721
+ Examples
722
+ --------
723
+ import asyncio
724
+
725
+ from airweave import AsyncAirweaveSDK
726
+
727
+ client = AsyncAirweaveSDK(
728
+ framework_name="YOUR_FRAMEWORK_NAME",
729
+ framework_version="YOUR_FRAMEWORK_VERSION",
730
+ api_key="YOUR_API_KEY",
731
+ )
732
+
733
+
734
+ async def main() -> None:
735
+ await client.events.get_subscriptions()
736
+
737
+
738
+ asyncio.run(main())
739
+ """
740
+ _response = await self._raw_client.get_subscriptions(request_options=request_options)
741
+ return _response.data
742
+
743
+ async def create_subscription(
744
+ self,
745
+ *,
746
+ url: str,
747
+ event_types: typing.Sequence[EventType],
748
+ secret: typing.Optional[str] = OMIT,
749
+ request_options: typing.Optional[RequestOptions] = None,
750
+ ) -> EndpointOut:
751
+ """
752
+ Create a new webhook subscription.
753
+
754
+ Args:
755
+ request: The subscription creation request.
756
+ ctx: The API context containing organization info.
757
+
758
+ Returns:
759
+ The created subscription.
760
+
761
+ Parameters
762
+ ----------
763
+ url : str
764
+
765
+ event_types : typing.Sequence[EventType]
766
+
767
+ secret : typing.Optional[str]
768
+
769
+ request_options : typing.Optional[RequestOptions]
770
+ Request-specific configuration.
771
+
772
+ Returns
773
+ -------
774
+ EndpointOut
775
+ Successful Response
776
+
777
+ Examples
778
+ --------
779
+ import asyncio
780
+
781
+ from airweave import AsyncAirweaveSDK
782
+
783
+ client = AsyncAirweaveSDK(
784
+ framework_name="YOUR_FRAMEWORK_NAME",
785
+ framework_version="YOUR_FRAMEWORK_VERSION",
786
+ api_key="YOUR_API_KEY",
787
+ )
788
+
789
+
790
+ async def main() -> None:
791
+ await client.events.create_subscription(
792
+ url="url",
793
+ event_types=["sync.pending"],
794
+ )
795
+
796
+
797
+ asyncio.run(main())
798
+ """
799
+ _response = await self._raw_client.create_subscription(
800
+ url=url, event_types=event_types, secret=secret, request_options=request_options
801
+ )
802
+ return _response.data
803
+
804
+ async def get_subscription(
805
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
806
+ ) -> SubscriptionWithAttemptsOut:
807
+ """
808
+ Get a specific webhook subscription with its delivery attempts.
809
+
810
+ Args:
811
+ subscription_id: The ID of the subscription to retrieve.
812
+ ctx: The API context containing organization info.
813
+
814
+ Returns:
815
+ The subscription details with message delivery attempts.
816
+
817
+ Parameters
818
+ ----------
819
+ subscription_id : str
820
+
821
+ request_options : typing.Optional[RequestOptions]
822
+ Request-specific configuration.
823
+
824
+ Returns
825
+ -------
826
+ SubscriptionWithAttemptsOut
827
+ Successful Response
828
+
829
+ Examples
830
+ --------
831
+ import asyncio
832
+
833
+ from airweave import AsyncAirweaveSDK
834
+
835
+ client = AsyncAirweaveSDK(
836
+ framework_name="YOUR_FRAMEWORK_NAME",
837
+ framework_version="YOUR_FRAMEWORK_VERSION",
838
+ api_key="YOUR_API_KEY",
839
+ )
840
+
841
+
842
+ async def main() -> None:
843
+ await client.events.get_subscription(
844
+ subscription_id="subscription_id",
845
+ )
846
+
847
+
848
+ asyncio.run(main())
849
+ """
850
+ _response = await self._raw_client.get_subscription(subscription_id, request_options=request_options)
851
+ return _response.data
852
+
853
+ async def delete_subscription(
854
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
855
+ ) -> typing.Optional[typing.Any]:
856
+ """
857
+ Delete a webhook subscription.
858
+
859
+ Args:
860
+ subscription_id: The ID of the subscription to delete.
861
+ ctx: The API context containing organization info.
862
+
863
+ Parameters
864
+ ----------
865
+ subscription_id : str
866
+
867
+ request_options : typing.Optional[RequestOptions]
868
+ Request-specific configuration.
869
+
870
+ Returns
871
+ -------
872
+ typing.Optional[typing.Any]
873
+ Successful Response
874
+
875
+ Examples
876
+ --------
877
+ import asyncio
878
+
879
+ from airweave import AsyncAirweaveSDK
880
+
881
+ client = AsyncAirweaveSDK(
882
+ framework_name="YOUR_FRAMEWORK_NAME",
883
+ framework_version="YOUR_FRAMEWORK_VERSION",
884
+ api_key="YOUR_API_KEY",
885
+ )
886
+
887
+
888
+ async def main() -> None:
889
+ await client.events.delete_subscription(
890
+ subscription_id="subscription_id",
891
+ )
892
+
893
+
894
+ asyncio.run(main())
895
+ """
896
+ _response = await self._raw_client.delete_subscription(subscription_id, request_options=request_options)
897
+ return _response.data
898
+
899
+ async def patch_subscription(
900
+ self,
901
+ subscription_id: str,
902
+ *,
903
+ url: typing.Optional[str] = OMIT,
904
+ event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
905
+ disabled: typing.Optional[bool] = OMIT,
906
+ request_options: typing.Optional[RequestOptions] = None,
907
+ ) -> EndpointOut:
908
+ """
909
+ Update a webhook subscription.
910
+
911
+ Args:
912
+ subscription_id: The ID of the subscription to update.
913
+ request: The subscription update request.
914
+ ctx: The API context containing organization info.
915
+
916
+ Returns:
917
+ The updated subscription.
918
+
919
+ Parameters
920
+ ----------
921
+ subscription_id : str
922
+
923
+ url : typing.Optional[str]
924
+
925
+ event_types : typing.Optional[typing.Sequence[EventType]]
926
+
927
+ disabled : typing.Optional[bool]
928
+
929
+ request_options : typing.Optional[RequestOptions]
930
+ Request-specific configuration.
931
+
932
+ Returns
933
+ -------
934
+ EndpointOut
935
+ Successful Response
936
+
937
+ Examples
938
+ --------
939
+ import asyncio
940
+
941
+ from airweave import AsyncAirweaveSDK
942
+
943
+ client = AsyncAirweaveSDK(
944
+ framework_name="YOUR_FRAMEWORK_NAME",
945
+ framework_version="YOUR_FRAMEWORK_VERSION",
946
+ api_key="YOUR_API_KEY",
947
+ )
948
+
949
+
950
+ async def main() -> None:
951
+ await client.events.patch_subscription(
952
+ subscription_id="subscription_id",
953
+ )
954
+
955
+
956
+ asyncio.run(main())
957
+ """
958
+ _response = await self._raw_client.patch_subscription(
959
+ subscription_id, url=url, event_types=event_types, disabled=disabled, request_options=request_options
960
+ )
961
+ return _response.data
962
+
963
+ async def enable_subscription(
964
+ self,
965
+ subscription_id: str,
966
+ *,
967
+ request: typing.Optional[EnableEndpointRequest] = None,
968
+ request_options: typing.Optional[RequestOptions] = None,
969
+ ) -> EndpointOut:
970
+ """
971
+ Enable a disabled webhook subscription, optionally recovering failed messages.
972
+
973
+ Args:
974
+ subscription_id: The ID of the subscription to enable.
975
+ request: Optional request with recovery time range.
976
+ ctx: The API context containing organization info.
977
+
978
+ Returns:
979
+ The enabled subscription.
980
+
981
+ Parameters
982
+ ----------
983
+ subscription_id : str
984
+
985
+ request : typing.Optional[EnableEndpointRequest]
986
+
987
+ request_options : typing.Optional[RequestOptions]
988
+ Request-specific configuration.
989
+
990
+ Returns
991
+ -------
992
+ EndpointOut
993
+ Successful Response
994
+
995
+ Examples
996
+ --------
997
+ import asyncio
998
+
999
+ from airweave import AsyncAirweaveSDK, EnableEndpointRequest
1000
+
1001
+ client = AsyncAirweaveSDK(
1002
+ framework_name="YOUR_FRAMEWORK_NAME",
1003
+ framework_version="YOUR_FRAMEWORK_VERSION",
1004
+ api_key="YOUR_API_KEY",
1005
+ )
1006
+
1007
+
1008
+ async def main() -> None:
1009
+ await client.events.enable_subscription(
1010
+ subscription_id="subscription_id",
1011
+ request=EnableEndpointRequest(),
1012
+ )
1013
+
1014
+
1015
+ asyncio.run(main())
1016
+ """
1017
+ _response = await self._raw_client.enable_subscription(
1018
+ subscription_id, request=request, request_options=request_options
1019
+ )
1020
+ return _response.data
1021
+
1022
+ async def get_subscription_secret(
1023
+ self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
1024
+ ) -> EndpointSecretOut:
1025
+ """
1026
+ Get the signing secret for a webhook subscription.
1027
+
1028
+ Args:
1029
+ subscription_id: The ID of the subscription.
1030
+ ctx: The API context containing organization info.
1031
+
1032
+ Returns:
1033
+ The subscription's signing secret.
1034
+
1035
+ Parameters
1036
+ ----------
1037
+ subscription_id : str
1038
+
1039
+ request_options : typing.Optional[RequestOptions]
1040
+ Request-specific configuration.
1041
+
1042
+ Returns
1043
+ -------
1044
+ EndpointSecretOut
1045
+ Successful Response
1046
+
1047
+ Examples
1048
+ --------
1049
+ import asyncio
1050
+
1051
+ from airweave import AsyncAirweaveSDK
1052
+
1053
+ client = AsyncAirweaveSDK(
1054
+ framework_name="YOUR_FRAMEWORK_NAME",
1055
+ framework_version="YOUR_FRAMEWORK_VERSION",
1056
+ api_key="YOUR_API_KEY",
1057
+ )
1058
+
1059
+
1060
+ async def main() -> None:
1061
+ await client.events.get_subscription_secret(
1062
+ subscription_id="subscription_id",
1063
+ )
1064
+
1065
+
1066
+ asyncio.run(main())
1067
+ """
1068
+ _response = await self._raw_client.get_subscription_secret(subscription_id, request_options=request_options)
1069
+ return _response.data
1070
+
1071
+ async def recover_failed_messages(
1072
+ self,
1073
+ subscription_id: str,
1074
+ *,
1075
+ since: dt.datetime,
1076
+ until: typing.Optional[dt.datetime] = OMIT,
1077
+ request_options: typing.Optional[RequestOptions] = None,
1078
+ ) -> RecoverOut:
1079
+ """
1080
+ Recover (retry) failed messages for a webhook subscription.
1081
+
1082
+ This endpoint triggers a recovery of all failed messages since the specified
1083
+ time. Useful after re-enabling a disabled endpoint to retry messages that
1084
+ failed while the endpoint was down.
1085
+
1086
+ Args:
1087
+ subscription_id: The ID of the subscription to recover messages for.
1088
+ request: The recovery request with time range.
1089
+ ctx: The API context containing organization info.
1090
+
1091
+ Returns:
1092
+ Information about the recovery task.
1093
+
1094
+ Parameters
1095
+ ----------
1096
+ subscription_id : str
1097
+
1098
+ since : dt.datetime
1099
+
1100
+ until : typing.Optional[dt.datetime]
1101
+
1102
+ request_options : typing.Optional[RequestOptions]
1103
+ Request-specific configuration.
1104
+
1105
+ Returns
1106
+ -------
1107
+ RecoverOut
1108
+ Successful Response
1109
+
1110
+ Examples
1111
+ --------
1112
+ import asyncio
1113
+ import datetime
1114
+
1115
+ from airweave import AsyncAirweaveSDK
1116
+
1117
+ client = AsyncAirweaveSDK(
1118
+ framework_name="YOUR_FRAMEWORK_NAME",
1119
+ framework_version="YOUR_FRAMEWORK_VERSION",
1120
+ api_key="YOUR_API_KEY",
1121
+ )
1122
+
1123
+
1124
+ async def main() -> None:
1125
+ await client.events.recover_failed_messages(
1126
+ subscription_id="subscription_id",
1127
+ since=datetime.datetime.fromisoformat(
1128
+ "2024-01-15 09:30:00+00:00",
1129
+ ),
1130
+ )
1131
+
1132
+
1133
+ asyncio.run(main())
1134
+ """
1135
+ _response = await self._raw_client.recover_failed_messages(
1136
+ subscription_id, since=since, until=until, request_options=request_options
1137
+ )
1138
+ return _response.data