airweave-sdk 0.8.63__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.
- airweave/__init__.py +15 -7
- airweave/client.py +19 -0
- airweave/core/client_wrapper.py +2 -2
- airweave/events/__init__.py +4 -0
- airweave/events/client.py +1138 -0
- airweave/events/raw_client.py +1424 -0
- airweave/types/__init__.py +12 -6
- airweave/types/background_task_status.py +5 -0
- airweave/types/background_task_type.py +17 -0
- airweave/types/{create_subscription_request.py → enable_endpoint_request.py} +4 -6
- airweave/types/{patch_subscription_request.py → recover_out.py} +6 -8
- {airweave_sdk-0.8.63.dist-info → airweave_sdk-0.8.65.dist-info}/METADATA +1 -1
- {airweave_sdk-0.8.63.dist-info → airweave_sdk-0.8.65.dist-info}/RECORD +14 -9
- {airweave_sdk-0.8.63.dist-info → airweave_sdk-0.8.65.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1424 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
from json.decoder import JSONDecodeError
|
|
6
|
+
|
|
7
|
+
from ..core.api_error import ApiError
|
|
8
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
10
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
14
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
15
|
+
from ..types.enable_endpoint_request import EnableEndpointRequest
|
|
16
|
+
from ..types.endpoint_out import EndpointOut
|
|
17
|
+
from ..types.endpoint_secret_out import EndpointSecretOut
|
|
18
|
+
from ..types.event_type import EventType
|
|
19
|
+
from ..types.http_validation_error import HttpValidationError
|
|
20
|
+
from ..types.message_attempt_out import MessageAttemptOut
|
|
21
|
+
from ..types.message_out import MessageOut
|
|
22
|
+
from ..types.recover_out import RecoverOut
|
|
23
|
+
from ..types.subscription_with_attempts_out import SubscriptionWithAttemptsOut
|
|
24
|
+
|
|
25
|
+
# this is used as the default value for optional parameters
|
|
26
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class RawEventsClient:
|
|
30
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
31
|
+
self._client_wrapper = client_wrapper
|
|
32
|
+
|
|
33
|
+
def get_messages(
|
|
34
|
+
self,
|
|
35
|
+
*,
|
|
36
|
+
event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
37
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
+
) -> HttpResponse[typing.List[MessageOut]]:
|
|
39
|
+
"""
|
|
40
|
+
Get event messages for the current organization.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
ctx: The API context containing organization info.
|
|
44
|
+
event_types: Optional list of event types to filter by.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
List of event messages.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
52
|
+
|
|
53
|
+
request_options : typing.Optional[RequestOptions]
|
|
54
|
+
Request-specific configuration.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
HttpResponse[typing.List[MessageOut]]
|
|
59
|
+
Successful Response
|
|
60
|
+
"""
|
|
61
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
62
|
+
"events/messages",
|
|
63
|
+
method="GET",
|
|
64
|
+
params={
|
|
65
|
+
"event_types": event_types,
|
|
66
|
+
},
|
|
67
|
+
request_options=request_options,
|
|
68
|
+
)
|
|
69
|
+
try:
|
|
70
|
+
if 200 <= _response.status_code < 300:
|
|
71
|
+
_data = typing.cast(
|
|
72
|
+
typing.List[MessageOut],
|
|
73
|
+
parse_obj_as(
|
|
74
|
+
type_=typing.List[MessageOut], # type: ignore
|
|
75
|
+
object_=_response.json(),
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
return HttpResponse(response=_response, data=_data)
|
|
79
|
+
if _response.status_code == 422:
|
|
80
|
+
raise UnprocessableEntityError(
|
|
81
|
+
headers=dict(_response.headers),
|
|
82
|
+
body=typing.cast(
|
|
83
|
+
HttpValidationError,
|
|
84
|
+
parse_obj_as(
|
|
85
|
+
type_=HttpValidationError, # type: ignore
|
|
86
|
+
object_=_response.json(),
|
|
87
|
+
),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
_response_json = _response.json()
|
|
91
|
+
except JSONDecodeError:
|
|
92
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
93
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
94
|
+
|
|
95
|
+
def get_message(
|
|
96
|
+
self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
97
|
+
) -> HttpResponse[MessageOut]:
|
|
98
|
+
"""
|
|
99
|
+
Get a specific event message by ID.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
message_id: The ID of the message to retrieve.
|
|
103
|
+
ctx: The API context containing organization info.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
The event message with its payload.
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
message_id : str
|
|
111
|
+
|
|
112
|
+
request_options : typing.Optional[RequestOptions]
|
|
113
|
+
Request-specific configuration.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
HttpResponse[MessageOut]
|
|
118
|
+
Successful Response
|
|
119
|
+
"""
|
|
120
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
121
|
+
f"events/messages/{jsonable_encoder(message_id)}",
|
|
122
|
+
method="GET",
|
|
123
|
+
request_options=request_options,
|
|
124
|
+
)
|
|
125
|
+
try:
|
|
126
|
+
if 200 <= _response.status_code < 300:
|
|
127
|
+
_data = typing.cast(
|
|
128
|
+
MessageOut,
|
|
129
|
+
parse_obj_as(
|
|
130
|
+
type_=MessageOut, # type: ignore
|
|
131
|
+
object_=_response.json(),
|
|
132
|
+
),
|
|
133
|
+
)
|
|
134
|
+
return HttpResponse(response=_response, data=_data)
|
|
135
|
+
if _response.status_code == 422:
|
|
136
|
+
raise UnprocessableEntityError(
|
|
137
|
+
headers=dict(_response.headers),
|
|
138
|
+
body=typing.cast(
|
|
139
|
+
HttpValidationError,
|
|
140
|
+
parse_obj_as(
|
|
141
|
+
type_=HttpValidationError, # type: ignore
|
|
142
|
+
object_=_response.json(),
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
_response_json = _response.json()
|
|
147
|
+
except JSONDecodeError:
|
|
148
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
149
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
150
|
+
|
|
151
|
+
def get_message_attempts(
|
|
152
|
+
self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
153
|
+
) -> HttpResponse[typing.List[MessageAttemptOut]]:
|
|
154
|
+
"""
|
|
155
|
+
Get delivery attempts for a specific message.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
message_id: The ID of the message.
|
|
159
|
+
ctx: The API context containing organization info.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
List of delivery attempts for this message.
|
|
163
|
+
|
|
164
|
+
Parameters
|
|
165
|
+
----------
|
|
166
|
+
message_id : str
|
|
167
|
+
|
|
168
|
+
request_options : typing.Optional[RequestOptions]
|
|
169
|
+
Request-specific configuration.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
HttpResponse[typing.List[MessageAttemptOut]]
|
|
174
|
+
Successful Response
|
|
175
|
+
"""
|
|
176
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
177
|
+
f"events/messages/{jsonable_encoder(message_id)}/attempts",
|
|
178
|
+
method="GET",
|
|
179
|
+
request_options=request_options,
|
|
180
|
+
)
|
|
181
|
+
try:
|
|
182
|
+
if 200 <= _response.status_code < 300:
|
|
183
|
+
_data = typing.cast(
|
|
184
|
+
typing.List[MessageAttemptOut],
|
|
185
|
+
parse_obj_as(
|
|
186
|
+
type_=typing.List[MessageAttemptOut], # type: ignore
|
|
187
|
+
object_=_response.json(),
|
|
188
|
+
),
|
|
189
|
+
)
|
|
190
|
+
return HttpResponse(response=_response, data=_data)
|
|
191
|
+
if _response.status_code == 422:
|
|
192
|
+
raise UnprocessableEntityError(
|
|
193
|
+
headers=dict(_response.headers),
|
|
194
|
+
body=typing.cast(
|
|
195
|
+
HttpValidationError,
|
|
196
|
+
parse_obj_as(
|
|
197
|
+
type_=HttpValidationError, # type: ignore
|
|
198
|
+
object_=_response.json(),
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
_response_json = _response.json()
|
|
203
|
+
except JSONDecodeError:
|
|
204
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
205
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
206
|
+
|
|
207
|
+
def get_subscriptions(
|
|
208
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
209
|
+
) -> HttpResponse[typing.List[EndpointOut]]:
|
|
210
|
+
"""
|
|
211
|
+
Get all webhook subscriptions for the current organization.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
ctx: The API context containing organization info.
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
List of webhook subscriptions.
|
|
218
|
+
|
|
219
|
+
Parameters
|
|
220
|
+
----------
|
|
221
|
+
request_options : typing.Optional[RequestOptions]
|
|
222
|
+
Request-specific configuration.
|
|
223
|
+
|
|
224
|
+
Returns
|
|
225
|
+
-------
|
|
226
|
+
HttpResponse[typing.List[EndpointOut]]
|
|
227
|
+
Successful Response
|
|
228
|
+
"""
|
|
229
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
230
|
+
"events/subscriptions",
|
|
231
|
+
method="GET",
|
|
232
|
+
request_options=request_options,
|
|
233
|
+
)
|
|
234
|
+
try:
|
|
235
|
+
if 200 <= _response.status_code < 300:
|
|
236
|
+
_data = typing.cast(
|
|
237
|
+
typing.List[EndpointOut],
|
|
238
|
+
parse_obj_as(
|
|
239
|
+
type_=typing.List[EndpointOut], # type: ignore
|
|
240
|
+
object_=_response.json(),
|
|
241
|
+
),
|
|
242
|
+
)
|
|
243
|
+
return HttpResponse(response=_response, data=_data)
|
|
244
|
+
if _response.status_code == 422:
|
|
245
|
+
raise UnprocessableEntityError(
|
|
246
|
+
headers=dict(_response.headers),
|
|
247
|
+
body=typing.cast(
|
|
248
|
+
HttpValidationError,
|
|
249
|
+
parse_obj_as(
|
|
250
|
+
type_=HttpValidationError, # type: ignore
|
|
251
|
+
object_=_response.json(),
|
|
252
|
+
),
|
|
253
|
+
),
|
|
254
|
+
)
|
|
255
|
+
_response_json = _response.json()
|
|
256
|
+
except JSONDecodeError:
|
|
257
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
258
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
259
|
+
|
|
260
|
+
def create_subscription(
|
|
261
|
+
self,
|
|
262
|
+
*,
|
|
263
|
+
url: str,
|
|
264
|
+
event_types: typing.Sequence[EventType],
|
|
265
|
+
secret: typing.Optional[str] = OMIT,
|
|
266
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
267
|
+
) -> HttpResponse[EndpointOut]:
|
|
268
|
+
"""
|
|
269
|
+
Create a new webhook subscription.
|
|
270
|
+
|
|
271
|
+
Args:
|
|
272
|
+
request: The subscription creation request.
|
|
273
|
+
ctx: The API context containing organization info.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
The created subscription.
|
|
277
|
+
|
|
278
|
+
Parameters
|
|
279
|
+
----------
|
|
280
|
+
url : str
|
|
281
|
+
|
|
282
|
+
event_types : typing.Sequence[EventType]
|
|
283
|
+
|
|
284
|
+
secret : typing.Optional[str]
|
|
285
|
+
|
|
286
|
+
request_options : typing.Optional[RequestOptions]
|
|
287
|
+
Request-specific configuration.
|
|
288
|
+
|
|
289
|
+
Returns
|
|
290
|
+
-------
|
|
291
|
+
HttpResponse[EndpointOut]
|
|
292
|
+
Successful Response
|
|
293
|
+
"""
|
|
294
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
295
|
+
"events/subscriptions",
|
|
296
|
+
method="POST",
|
|
297
|
+
json={
|
|
298
|
+
"url": url,
|
|
299
|
+
"event_types": event_types,
|
|
300
|
+
"secret": secret,
|
|
301
|
+
},
|
|
302
|
+
headers={
|
|
303
|
+
"content-type": "application/json",
|
|
304
|
+
},
|
|
305
|
+
request_options=request_options,
|
|
306
|
+
omit=OMIT,
|
|
307
|
+
)
|
|
308
|
+
try:
|
|
309
|
+
if 200 <= _response.status_code < 300:
|
|
310
|
+
_data = typing.cast(
|
|
311
|
+
EndpointOut,
|
|
312
|
+
parse_obj_as(
|
|
313
|
+
type_=EndpointOut, # type: ignore
|
|
314
|
+
object_=_response.json(),
|
|
315
|
+
),
|
|
316
|
+
)
|
|
317
|
+
return HttpResponse(response=_response, data=_data)
|
|
318
|
+
if _response.status_code == 422:
|
|
319
|
+
raise UnprocessableEntityError(
|
|
320
|
+
headers=dict(_response.headers),
|
|
321
|
+
body=typing.cast(
|
|
322
|
+
HttpValidationError,
|
|
323
|
+
parse_obj_as(
|
|
324
|
+
type_=HttpValidationError, # type: ignore
|
|
325
|
+
object_=_response.json(),
|
|
326
|
+
),
|
|
327
|
+
),
|
|
328
|
+
)
|
|
329
|
+
_response_json = _response.json()
|
|
330
|
+
except JSONDecodeError:
|
|
331
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
332
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
333
|
+
|
|
334
|
+
def get_subscription(
|
|
335
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
336
|
+
) -> HttpResponse[SubscriptionWithAttemptsOut]:
|
|
337
|
+
"""
|
|
338
|
+
Get a specific webhook subscription with its delivery attempts.
|
|
339
|
+
|
|
340
|
+
Args:
|
|
341
|
+
subscription_id: The ID of the subscription to retrieve.
|
|
342
|
+
ctx: The API context containing organization info.
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
The subscription details with message delivery attempts.
|
|
346
|
+
|
|
347
|
+
Parameters
|
|
348
|
+
----------
|
|
349
|
+
subscription_id : str
|
|
350
|
+
|
|
351
|
+
request_options : typing.Optional[RequestOptions]
|
|
352
|
+
Request-specific configuration.
|
|
353
|
+
|
|
354
|
+
Returns
|
|
355
|
+
-------
|
|
356
|
+
HttpResponse[SubscriptionWithAttemptsOut]
|
|
357
|
+
Successful Response
|
|
358
|
+
"""
|
|
359
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
360
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
361
|
+
method="GET",
|
|
362
|
+
request_options=request_options,
|
|
363
|
+
)
|
|
364
|
+
try:
|
|
365
|
+
if 200 <= _response.status_code < 300:
|
|
366
|
+
_data = typing.cast(
|
|
367
|
+
SubscriptionWithAttemptsOut,
|
|
368
|
+
parse_obj_as(
|
|
369
|
+
type_=SubscriptionWithAttemptsOut, # type: ignore
|
|
370
|
+
object_=_response.json(),
|
|
371
|
+
),
|
|
372
|
+
)
|
|
373
|
+
return HttpResponse(response=_response, data=_data)
|
|
374
|
+
if _response.status_code == 422:
|
|
375
|
+
raise UnprocessableEntityError(
|
|
376
|
+
headers=dict(_response.headers),
|
|
377
|
+
body=typing.cast(
|
|
378
|
+
HttpValidationError,
|
|
379
|
+
parse_obj_as(
|
|
380
|
+
type_=HttpValidationError, # type: ignore
|
|
381
|
+
object_=_response.json(),
|
|
382
|
+
),
|
|
383
|
+
),
|
|
384
|
+
)
|
|
385
|
+
_response_json = _response.json()
|
|
386
|
+
except JSONDecodeError:
|
|
387
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
388
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
389
|
+
|
|
390
|
+
def delete_subscription(
|
|
391
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
392
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
393
|
+
"""
|
|
394
|
+
Delete a webhook subscription.
|
|
395
|
+
|
|
396
|
+
Args:
|
|
397
|
+
subscription_id: The ID of the subscription to delete.
|
|
398
|
+
ctx: The API context containing organization info.
|
|
399
|
+
|
|
400
|
+
Parameters
|
|
401
|
+
----------
|
|
402
|
+
subscription_id : str
|
|
403
|
+
|
|
404
|
+
request_options : typing.Optional[RequestOptions]
|
|
405
|
+
Request-specific configuration.
|
|
406
|
+
|
|
407
|
+
Returns
|
|
408
|
+
-------
|
|
409
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
410
|
+
Successful Response
|
|
411
|
+
"""
|
|
412
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
413
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
414
|
+
method="DELETE",
|
|
415
|
+
request_options=request_options,
|
|
416
|
+
)
|
|
417
|
+
try:
|
|
418
|
+
if _response is None or not _response.text.strip():
|
|
419
|
+
return HttpResponse(response=_response, data=None)
|
|
420
|
+
if 200 <= _response.status_code < 300:
|
|
421
|
+
_data = typing.cast(
|
|
422
|
+
typing.Optional[typing.Any],
|
|
423
|
+
parse_obj_as(
|
|
424
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
425
|
+
object_=_response.json(),
|
|
426
|
+
),
|
|
427
|
+
)
|
|
428
|
+
return HttpResponse(response=_response, data=_data)
|
|
429
|
+
if _response.status_code == 422:
|
|
430
|
+
raise UnprocessableEntityError(
|
|
431
|
+
headers=dict(_response.headers),
|
|
432
|
+
body=typing.cast(
|
|
433
|
+
HttpValidationError,
|
|
434
|
+
parse_obj_as(
|
|
435
|
+
type_=HttpValidationError, # type: ignore
|
|
436
|
+
object_=_response.json(),
|
|
437
|
+
),
|
|
438
|
+
),
|
|
439
|
+
)
|
|
440
|
+
_response_json = _response.json()
|
|
441
|
+
except JSONDecodeError:
|
|
442
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
443
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
444
|
+
|
|
445
|
+
def patch_subscription(
|
|
446
|
+
self,
|
|
447
|
+
subscription_id: str,
|
|
448
|
+
*,
|
|
449
|
+
url: typing.Optional[str] = OMIT,
|
|
450
|
+
event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
|
|
451
|
+
disabled: typing.Optional[bool] = OMIT,
|
|
452
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
453
|
+
) -> HttpResponse[EndpointOut]:
|
|
454
|
+
"""
|
|
455
|
+
Update a webhook subscription.
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
subscription_id: The ID of the subscription to update.
|
|
459
|
+
request: The subscription update request.
|
|
460
|
+
ctx: The API context containing organization info.
|
|
461
|
+
|
|
462
|
+
Returns:
|
|
463
|
+
The updated subscription.
|
|
464
|
+
|
|
465
|
+
Parameters
|
|
466
|
+
----------
|
|
467
|
+
subscription_id : str
|
|
468
|
+
|
|
469
|
+
url : typing.Optional[str]
|
|
470
|
+
|
|
471
|
+
event_types : typing.Optional[typing.Sequence[EventType]]
|
|
472
|
+
|
|
473
|
+
disabled : typing.Optional[bool]
|
|
474
|
+
|
|
475
|
+
request_options : typing.Optional[RequestOptions]
|
|
476
|
+
Request-specific configuration.
|
|
477
|
+
|
|
478
|
+
Returns
|
|
479
|
+
-------
|
|
480
|
+
HttpResponse[EndpointOut]
|
|
481
|
+
Successful Response
|
|
482
|
+
"""
|
|
483
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
484
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
485
|
+
method="PATCH",
|
|
486
|
+
json={
|
|
487
|
+
"url": url,
|
|
488
|
+
"event_types": event_types,
|
|
489
|
+
"disabled": disabled,
|
|
490
|
+
},
|
|
491
|
+
headers={
|
|
492
|
+
"content-type": "application/json",
|
|
493
|
+
},
|
|
494
|
+
request_options=request_options,
|
|
495
|
+
omit=OMIT,
|
|
496
|
+
)
|
|
497
|
+
try:
|
|
498
|
+
if 200 <= _response.status_code < 300:
|
|
499
|
+
_data = typing.cast(
|
|
500
|
+
EndpointOut,
|
|
501
|
+
parse_obj_as(
|
|
502
|
+
type_=EndpointOut, # type: ignore
|
|
503
|
+
object_=_response.json(),
|
|
504
|
+
),
|
|
505
|
+
)
|
|
506
|
+
return HttpResponse(response=_response, data=_data)
|
|
507
|
+
if _response.status_code == 422:
|
|
508
|
+
raise UnprocessableEntityError(
|
|
509
|
+
headers=dict(_response.headers),
|
|
510
|
+
body=typing.cast(
|
|
511
|
+
HttpValidationError,
|
|
512
|
+
parse_obj_as(
|
|
513
|
+
type_=HttpValidationError, # type: ignore
|
|
514
|
+
object_=_response.json(),
|
|
515
|
+
),
|
|
516
|
+
),
|
|
517
|
+
)
|
|
518
|
+
_response_json = _response.json()
|
|
519
|
+
except JSONDecodeError:
|
|
520
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
521
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
522
|
+
|
|
523
|
+
def enable_subscription(
|
|
524
|
+
self,
|
|
525
|
+
subscription_id: str,
|
|
526
|
+
*,
|
|
527
|
+
request: typing.Optional[EnableEndpointRequest] = None,
|
|
528
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
529
|
+
) -> HttpResponse[EndpointOut]:
|
|
530
|
+
"""
|
|
531
|
+
Enable a disabled webhook subscription, optionally recovering failed messages.
|
|
532
|
+
|
|
533
|
+
Args:
|
|
534
|
+
subscription_id: The ID of the subscription to enable.
|
|
535
|
+
request: Optional request with recovery time range.
|
|
536
|
+
ctx: The API context containing organization info.
|
|
537
|
+
|
|
538
|
+
Returns:
|
|
539
|
+
The enabled subscription.
|
|
540
|
+
|
|
541
|
+
Parameters
|
|
542
|
+
----------
|
|
543
|
+
subscription_id : str
|
|
544
|
+
|
|
545
|
+
request : typing.Optional[EnableEndpointRequest]
|
|
546
|
+
|
|
547
|
+
request_options : typing.Optional[RequestOptions]
|
|
548
|
+
Request-specific configuration.
|
|
549
|
+
|
|
550
|
+
Returns
|
|
551
|
+
-------
|
|
552
|
+
HttpResponse[EndpointOut]
|
|
553
|
+
Successful Response
|
|
554
|
+
"""
|
|
555
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
556
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/enable",
|
|
557
|
+
method="POST",
|
|
558
|
+
json=convert_and_respect_annotation_metadata(
|
|
559
|
+
object_=request, annotation=EnableEndpointRequest, direction="write"
|
|
560
|
+
),
|
|
561
|
+
headers={
|
|
562
|
+
"content-type": "application/json",
|
|
563
|
+
},
|
|
564
|
+
request_options=request_options,
|
|
565
|
+
omit=OMIT,
|
|
566
|
+
)
|
|
567
|
+
try:
|
|
568
|
+
if 200 <= _response.status_code < 300:
|
|
569
|
+
_data = typing.cast(
|
|
570
|
+
EndpointOut,
|
|
571
|
+
parse_obj_as(
|
|
572
|
+
type_=EndpointOut, # type: ignore
|
|
573
|
+
object_=_response.json(),
|
|
574
|
+
),
|
|
575
|
+
)
|
|
576
|
+
return HttpResponse(response=_response, data=_data)
|
|
577
|
+
if _response.status_code == 422:
|
|
578
|
+
raise UnprocessableEntityError(
|
|
579
|
+
headers=dict(_response.headers),
|
|
580
|
+
body=typing.cast(
|
|
581
|
+
HttpValidationError,
|
|
582
|
+
parse_obj_as(
|
|
583
|
+
type_=HttpValidationError, # type: ignore
|
|
584
|
+
object_=_response.json(),
|
|
585
|
+
),
|
|
586
|
+
),
|
|
587
|
+
)
|
|
588
|
+
_response_json = _response.json()
|
|
589
|
+
except JSONDecodeError:
|
|
590
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
591
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
592
|
+
|
|
593
|
+
def get_subscription_secret(
|
|
594
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
595
|
+
) -> HttpResponse[EndpointSecretOut]:
|
|
596
|
+
"""
|
|
597
|
+
Get the signing secret for a webhook subscription.
|
|
598
|
+
|
|
599
|
+
Args:
|
|
600
|
+
subscription_id: The ID of the subscription.
|
|
601
|
+
ctx: The API context containing organization info.
|
|
602
|
+
|
|
603
|
+
Returns:
|
|
604
|
+
The subscription's signing secret.
|
|
605
|
+
|
|
606
|
+
Parameters
|
|
607
|
+
----------
|
|
608
|
+
subscription_id : str
|
|
609
|
+
|
|
610
|
+
request_options : typing.Optional[RequestOptions]
|
|
611
|
+
Request-specific configuration.
|
|
612
|
+
|
|
613
|
+
Returns
|
|
614
|
+
-------
|
|
615
|
+
HttpResponse[EndpointSecretOut]
|
|
616
|
+
Successful Response
|
|
617
|
+
"""
|
|
618
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
619
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/secret",
|
|
620
|
+
method="GET",
|
|
621
|
+
request_options=request_options,
|
|
622
|
+
)
|
|
623
|
+
try:
|
|
624
|
+
if 200 <= _response.status_code < 300:
|
|
625
|
+
_data = typing.cast(
|
|
626
|
+
EndpointSecretOut,
|
|
627
|
+
parse_obj_as(
|
|
628
|
+
type_=EndpointSecretOut, # type: ignore
|
|
629
|
+
object_=_response.json(),
|
|
630
|
+
),
|
|
631
|
+
)
|
|
632
|
+
return HttpResponse(response=_response, data=_data)
|
|
633
|
+
if _response.status_code == 422:
|
|
634
|
+
raise UnprocessableEntityError(
|
|
635
|
+
headers=dict(_response.headers),
|
|
636
|
+
body=typing.cast(
|
|
637
|
+
HttpValidationError,
|
|
638
|
+
parse_obj_as(
|
|
639
|
+
type_=HttpValidationError, # type: ignore
|
|
640
|
+
object_=_response.json(),
|
|
641
|
+
),
|
|
642
|
+
),
|
|
643
|
+
)
|
|
644
|
+
_response_json = _response.json()
|
|
645
|
+
except JSONDecodeError:
|
|
646
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
647
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
648
|
+
|
|
649
|
+
def recover_failed_messages(
|
|
650
|
+
self,
|
|
651
|
+
subscription_id: str,
|
|
652
|
+
*,
|
|
653
|
+
since: dt.datetime,
|
|
654
|
+
until: typing.Optional[dt.datetime] = OMIT,
|
|
655
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
656
|
+
) -> HttpResponse[RecoverOut]:
|
|
657
|
+
"""
|
|
658
|
+
Recover (retry) failed messages for a webhook subscription.
|
|
659
|
+
|
|
660
|
+
This endpoint triggers a recovery of all failed messages since the specified
|
|
661
|
+
time. Useful after re-enabling a disabled endpoint to retry messages that
|
|
662
|
+
failed while the endpoint was down.
|
|
663
|
+
|
|
664
|
+
Args:
|
|
665
|
+
subscription_id: The ID of the subscription to recover messages for.
|
|
666
|
+
request: The recovery request with time range.
|
|
667
|
+
ctx: The API context containing organization info.
|
|
668
|
+
|
|
669
|
+
Returns:
|
|
670
|
+
Information about the recovery task.
|
|
671
|
+
|
|
672
|
+
Parameters
|
|
673
|
+
----------
|
|
674
|
+
subscription_id : str
|
|
675
|
+
|
|
676
|
+
since : dt.datetime
|
|
677
|
+
|
|
678
|
+
until : typing.Optional[dt.datetime]
|
|
679
|
+
|
|
680
|
+
request_options : typing.Optional[RequestOptions]
|
|
681
|
+
Request-specific configuration.
|
|
682
|
+
|
|
683
|
+
Returns
|
|
684
|
+
-------
|
|
685
|
+
HttpResponse[RecoverOut]
|
|
686
|
+
Successful Response
|
|
687
|
+
"""
|
|
688
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
689
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/recover",
|
|
690
|
+
method="POST",
|
|
691
|
+
json={
|
|
692
|
+
"since": since,
|
|
693
|
+
"until": until,
|
|
694
|
+
},
|
|
695
|
+
headers={
|
|
696
|
+
"content-type": "application/json",
|
|
697
|
+
},
|
|
698
|
+
request_options=request_options,
|
|
699
|
+
omit=OMIT,
|
|
700
|
+
)
|
|
701
|
+
try:
|
|
702
|
+
if 200 <= _response.status_code < 300:
|
|
703
|
+
_data = typing.cast(
|
|
704
|
+
RecoverOut,
|
|
705
|
+
parse_obj_as(
|
|
706
|
+
type_=RecoverOut, # type: ignore
|
|
707
|
+
object_=_response.json(),
|
|
708
|
+
),
|
|
709
|
+
)
|
|
710
|
+
return HttpResponse(response=_response, data=_data)
|
|
711
|
+
if _response.status_code == 422:
|
|
712
|
+
raise UnprocessableEntityError(
|
|
713
|
+
headers=dict(_response.headers),
|
|
714
|
+
body=typing.cast(
|
|
715
|
+
HttpValidationError,
|
|
716
|
+
parse_obj_as(
|
|
717
|
+
type_=HttpValidationError, # type: ignore
|
|
718
|
+
object_=_response.json(),
|
|
719
|
+
),
|
|
720
|
+
),
|
|
721
|
+
)
|
|
722
|
+
_response_json = _response.json()
|
|
723
|
+
except JSONDecodeError:
|
|
724
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
725
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
class AsyncRawEventsClient:
|
|
729
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
730
|
+
self._client_wrapper = client_wrapper
|
|
731
|
+
|
|
732
|
+
async def get_messages(
|
|
733
|
+
self,
|
|
734
|
+
*,
|
|
735
|
+
event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
736
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
737
|
+
) -> AsyncHttpResponse[typing.List[MessageOut]]:
|
|
738
|
+
"""
|
|
739
|
+
Get event messages for the current organization.
|
|
740
|
+
|
|
741
|
+
Args:
|
|
742
|
+
ctx: The API context containing organization info.
|
|
743
|
+
event_types: Optional list of event types to filter by.
|
|
744
|
+
|
|
745
|
+
Returns:
|
|
746
|
+
List of event messages.
|
|
747
|
+
|
|
748
|
+
Parameters
|
|
749
|
+
----------
|
|
750
|
+
event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
751
|
+
|
|
752
|
+
request_options : typing.Optional[RequestOptions]
|
|
753
|
+
Request-specific configuration.
|
|
754
|
+
|
|
755
|
+
Returns
|
|
756
|
+
-------
|
|
757
|
+
AsyncHttpResponse[typing.List[MessageOut]]
|
|
758
|
+
Successful Response
|
|
759
|
+
"""
|
|
760
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
761
|
+
"events/messages",
|
|
762
|
+
method="GET",
|
|
763
|
+
params={
|
|
764
|
+
"event_types": event_types,
|
|
765
|
+
},
|
|
766
|
+
request_options=request_options,
|
|
767
|
+
)
|
|
768
|
+
try:
|
|
769
|
+
if 200 <= _response.status_code < 300:
|
|
770
|
+
_data = typing.cast(
|
|
771
|
+
typing.List[MessageOut],
|
|
772
|
+
parse_obj_as(
|
|
773
|
+
type_=typing.List[MessageOut], # type: ignore
|
|
774
|
+
object_=_response.json(),
|
|
775
|
+
),
|
|
776
|
+
)
|
|
777
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
778
|
+
if _response.status_code == 422:
|
|
779
|
+
raise UnprocessableEntityError(
|
|
780
|
+
headers=dict(_response.headers),
|
|
781
|
+
body=typing.cast(
|
|
782
|
+
HttpValidationError,
|
|
783
|
+
parse_obj_as(
|
|
784
|
+
type_=HttpValidationError, # type: ignore
|
|
785
|
+
object_=_response.json(),
|
|
786
|
+
),
|
|
787
|
+
),
|
|
788
|
+
)
|
|
789
|
+
_response_json = _response.json()
|
|
790
|
+
except JSONDecodeError:
|
|
791
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
792
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
793
|
+
|
|
794
|
+
async def get_message(
|
|
795
|
+
self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
796
|
+
) -> AsyncHttpResponse[MessageOut]:
|
|
797
|
+
"""
|
|
798
|
+
Get a specific event message by ID.
|
|
799
|
+
|
|
800
|
+
Args:
|
|
801
|
+
message_id: The ID of the message to retrieve.
|
|
802
|
+
ctx: The API context containing organization info.
|
|
803
|
+
|
|
804
|
+
Returns:
|
|
805
|
+
The event message with its payload.
|
|
806
|
+
|
|
807
|
+
Parameters
|
|
808
|
+
----------
|
|
809
|
+
message_id : str
|
|
810
|
+
|
|
811
|
+
request_options : typing.Optional[RequestOptions]
|
|
812
|
+
Request-specific configuration.
|
|
813
|
+
|
|
814
|
+
Returns
|
|
815
|
+
-------
|
|
816
|
+
AsyncHttpResponse[MessageOut]
|
|
817
|
+
Successful Response
|
|
818
|
+
"""
|
|
819
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
820
|
+
f"events/messages/{jsonable_encoder(message_id)}",
|
|
821
|
+
method="GET",
|
|
822
|
+
request_options=request_options,
|
|
823
|
+
)
|
|
824
|
+
try:
|
|
825
|
+
if 200 <= _response.status_code < 300:
|
|
826
|
+
_data = typing.cast(
|
|
827
|
+
MessageOut,
|
|
828
|
+
parse_obj_as(
|
|
829
|
+
type_=MessageOut, # type: ignore
|
|
830
|
+
object_=_response.json(),
|
|
831
|
+
),
|
|
832
|
+
)
|
|
833
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
834
|
+
if _response.status_code == 422:
|
|
835
|
+
raise UnprocessableEntityError(
|
|
836
|
+
headers=dict(_response.headers),
|
|
837
|
+
body=typing.cast(
|
|
838
|
+
HttpValidationError,
|
|
839
|
+
parse_obj_as(
|
|
840
|
+
type_=HttpValidationError, # type: ignore
|
|
841
|
+
object_=_response.json(),
|
|
842
|
+
),
|
|
843
|
+
),
|
|
844
|
+
)
|
|
845
|
+
_response_json = _response.json()
|
|
846
|
+
except JSONDecodeError:
|
|
847
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
848
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
849
|
+
|
|
850
|
+
async def get_message_attempts(
|
|
851
|
+
self, message_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
852
|
+
) -> AsyncHttpResponse[typing.List[MessageAttemptOut]]:
|
|
853
|
+
"""
|
|
854
|
+
Get delivery attempts for a specific message.
|
|
855
|
+
|
|
856
|
+
Args:
|
|
857
|
+
message_id: The ID of the message.
|
|
858
|
+
ctx: The API context containing organization info.
|
|
859
|
+
|
|
860
|
+
Returns:
|
|
861
|
+
List of delivery attempts for this message.
|
|
862
|
+
|
|
863
|
+
Parameters
|
|
864
|
+
----------
|
|
865
|
+
message_id : str
|
|
866
|
+
|
|
867
|
+
request_options : typing.Optional[RequestOptions]
|
|
868
|
+
Request-specific configuration.
|
|
869
|
+
|
|
870
|
+
Returns
|
|
871
|
+
-------
|
|
872
|
+
AsyncHttpResponse[typing.List[MessageAttemptOut]]
|
|
873
|
+
Successful Response
|
|
874
|
+
"""
|
|
875
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
876
|
+
f"events/messages/{jsonable_encoder(message_id)}/attempts",
|
|
877
|
+
method="GET",
|
|
878
|
+
request_options=request_options,
|
|
879
|
+
)
|
|
880
|
+
try:
|
|
881
|
+
if 200 <= _response.status_code < 300:
|
|
882
|
+
_data = typing.cast(
|
|
883
|
+
typing.List[MessageAttemptOut],
|
|
884
|
+
parse_obj_as(
|
|
885
|
+
type_=typing.List[MessageAttemptOut], # type: ignore
|
|
886
|
+
object_=_response.json(),
|
|
887
|
+
),
|
|
888
|
+
)
|
|
889
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
890
|
+
if _response.status_code == 422:
|
|
891
|
+
raise UnprocessableEntityError(
|
|
892
|
+
headers=dict(_response.headers),
|
|
893
|
+
body=typing.cast(
|
|
894
|
+
HttpValidationError,
|
|
895
|
+
parse_obj_as(
|
|
896
|
+
type_=HttpValidationError, # type: ignore
|
|
897
|
+
object_=_response.json(),
|
|
898
|
+
),
|
|
899
|
+
),
|
|
900
|
+
)
|
|
901
|
+
_response_json = _response.json()
|
|
902
|
+
except JSONDecodeError:
|
|
903
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
904
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
905
|
+
|
|
906
|
+
async def get_subscriptions(
|
|
907
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
908
|
+
) -> AsyncHttpResponse[typing.List[EndpointOut]]:
|
|
909
|
+
"""
|
|
910
|
+
Get all webhook subscriptions for the current organization.
|
|
911
|
+
|
|
912
|
+
Args:
|
|
913
|
+
ctx: The API context containing organization info.
|
|
914
|
+
|
|
915
|
+
Returns:
|
|
916
|
+
List of webhook subscriptions.
|
|
917
|
+
|
|
918
|
+
Parameters
|
|
919
|
+
----------
|
|
920
|
+
request_options : typing.Optional[RequestOptions]
|
|
921
|
+
Request-specific configuration.
|
|
922
|
+
|
|
923
|
+
Returns
|
|
924
|
+
-------
|
|
925
|
+
AsyncHttpResponse[typing.List[EndpointOut]]
|
|
926
|
+
Successful Response
|
|
927
|
+
"""
|
|
928
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
929
|
+
"events/subscriptions",
|
|
930
|
+
method="GET",
|
|
931
|
+
request_options=request_options,
|
|
932
|
+
)
|
|
933
|
+
try:
|
|
934
|
+
if 200 <= _response.status_code < 300:
|
|
935
|
+
_data = typing.cast(
|
|
936
|
+
typing.List[EndpointOut],
|
|
937
|
+
parse_obj_as(
|
|
938
|
+
type_=typing.List[EndpointOut], # type: ignore
|
|
939
|
+
object_=_response.json(),
|
|
940
|
+
),
|
|
941
|
+
)
|
|
942
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
943
|
+
if _response.status_code == 422:
|
|
944
|
+
raise UnprocessableEntityError(
|
|
945
|
+
headers=dict(_response.headers),
|
|
946
|
+
body=typing.cast(
|
|
947
|
+
HttpValidationError,
|
|
948
|
+
parse_obj_as(
|
|
949
|
+
type_=HttpValidationError, # type: ignore
|
|
950
|
+
object_=_response.json(),
|
|
951
|
+
),
|
|
952
|
+
),
|
|
953
|
+
)
|
|
954
|
+
_response_json = _response.json()
|
|
955
|
+
except JSONDecodeError:
|
|
956
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
957
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
958
|
+
|
|
959
|
+
async def create_subscription(
|
|
960
|
+
self,
|
|
961
|
+
*,
|
|
962
|
+
url: str,
|
|
963
|
+
event_types: typing.Sequence[EventType],
|
|
964
|
+
secret: typing.Optional[str] = OMIT,
|
|
965
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
966
|
+
) -> AsyncHttpResponse[EndpointOut]:
|
|
967
|
+
"""
|
|
968
|
+
Create a new webhook subscription.
|
|
969
|
+
|
|
970
|
+
Args:
|
|
971
|
+
request: The subscription creation request.
|
|
972
|
+
ctx: The API context containing organization info.
|
|
973
|
+
|
|
974
|
+
Returns:
|
|
975
|
+
The created subscription.
|
|
976
|
+
|
|
977
|
+
Parameters
|
|
978
|
+
----------
|
|
979
|
+
url : str
|
|
980
|
+
|
|
981
|
+
event_types : typing.Sequence[EventType]
|
|
982
|
+
|
|
983
|
+
secret : typing.Optional[str]
|
|
984
|
+
|
|
985
|
+
request_options : typing.Optional[RequestOptions]
|
|
986
|
+
Request-specific configuration.
|
|
987
|
+
|
|
988
|
+
Returns
|
|
989
|
+
-------
|
|
990
|
+
AsyncHttpResponse[EndpointOut]
|
|
991
|
+
Successful Response
|
|
992
|
+
"""
|
|
993
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
994
|
+
"events/subscriptions",
|
|
995
|
+
method="POST",
|
|
996
|
+
json={
|
|
997
|
+
"url": url,
|
|
998
|
+
"event_types": event_types,
|
|
999
|
+
"secret": secret,
|
|
1000
|
+
},
|
|
1001
|
+
headers={
|
|
1002
|
+
"content-type": "application/json",
|
|
1003
|
+
},
|
|
1004
|
+
request_options=request_options,
|
|
1005
|
+
omit=OMIT,
|
|
1006
|
+
)
|
|
1007
|
+
try:
|
|
1008
|
+
if 200 <= _response.status_code < 300:
|
|
1009
|
+
_data = typing.cast(
|
|
1010
|
+
EndpointOut,
|
|
1011
|
+
parse_obj_as(
|
|
1012
|
+
type_=EndpointOut, # type: ignore
|
|
1013
|
+
object_=_response.json(),
|
|
1014
|
+
),
|
|
1015
|
+
)
|
|
1016
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1017
|
+
if _response.status_code == 422:
|
|
1018
|
+
raise UnprocessableEntityError(
|
|
1019
|
+
headers=dict(_response.headers),
|
|
1020
|
+
body=typing.cast(
|
|
1021
|
+
HttpValidationError,
|
|
1022
|
+
parse_obj_as(
|
|
1023
|
+
type_=HttpValidationError, # type: ignore
|
|
1024
|
+
object_=_response.json(),
|
|
1025
|
+
),
|
|
1026
|
+
),
|
|
1027
|
+
)
|
|
1028
|
+
_response_json = _response.json()
|
|
1029
|
+
except JSONDecodeError:
|
|
1030
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1031
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1032
|
+
|
|
1033
|
+
async def get_subscription(
|
|
1034
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1035
|
+
) -> AsyncHttpResponse[SubscriptionWithAttemptsOut]:
|
|
1036
|
+
"""
|
|
1037
|
+
Get a specific webhook subscription with its delivery attempts.
|
|
1038
|
+
|
|
1039
|
+
Args:
|
|
1040
|
+
subscription_id: The ID of the subscription to retrieve.
|
|
1041
|
+
ctx: The API context containing organization info.
|
|
1042
|
+
|
|
1043
|
+
Returns:
|
|
1044
|
+
The subscription details with message delivery attempts.
|
|
1045
|
+
|
|
1046
|
+
Parameters
|
|
1047
|
+
----------
|
|
1048
|
+
subscription_id : str
|
|
1049
|
+
|
|
1050
|
+
request_options : typing.Optional[RequestOptions]
|
|
1051
|
+
Request-specific configuration.
|
|
1052
|
+
|
|
1053
|
+
Returns
|
|
1054
|
+
-------
|
|
1055
|
+
AsyncHttpResponse[SubscriptionWithAttemptsOut]
|
|
1056
|
+
Successful Response
|
|
1057
|
+
"""
|
|
1058
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1059
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
1060
|
+
method="GET",
|
|
1061
|
+
request_options=request_options,
|
|
1062
|
+
)
|
|
1063
|
+
try:
|
|
1064
|
+
if 200 <= _response.status_code < 300:
|
|
1065
|
+
_data = typing.cast(
|
|
1066
|
+
SubscriptionWithAttemptsOut,
|
|
1067
|
+
parse_obj_as(
|
|
1068
|
+
type_=SubscriptionWithAttemptsOut, # type: ignore
|
|
1069
|
+
object_=_response.json(),
|
|
1070
|
+
),
|
|
1071
|
+
)
|
|
1072
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1073
|
+
if _response.status_code == 422:
|
|
1074
|
+
raise UnprocessableEntityError(
|
|
1075
|
+
headers=dict(_response.headers),
|
|
1076
|
+
body=typing.cast(
|
|
1077
|
+
HttpValidationError,
|
|
1078
|
+
parse_obj_as(
|
|
1079
|
+
type_=HttpValidationError, # type: ignore
|
|
1080
|
+
object_=_response.json(),
|
|
1081
|
+
),
|
|
1082
|
+
),
|
|
1083
|
+
)
|
|
1084
|
+
_response_json = _response.json()
|
|
1085
|
+
except JSONDecodeError:
|
|
1086
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1087
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1088
|
+
|
|
1089
|
+
async def delete_subscription(
|
|
1090
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1091
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
1092
|
+
"""
|
|
1093
|
+
Delete a webhook subscription.
|
|
1094
|
+
|
|
1095
|
+
Args:
|
|
1096
|
+
subscription_id: The ID of the subscription to delete.
|
|
1097
|
+
ctx: The API context containing organization info.
|
|
1098
|
+
|
|
1099
|
+
Parameters
|
|
1100
|
+
----------
|
|
1101
|
+
subscription_id : str
|
|
1102
|
+
|
|
1103
|
+
request_options : typing.Optional[RequestOptions]
|
|
1104
|
+
Request-specific configuration.
|
|
1105
|
+
|
|
1106
|
+
Returns
|
|
1107
|
+
-------
|
|
1108
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
1109
|
+
Successful Response
|
|
1110
|
+
"""
|
|
1111
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1112
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
1113
|
+
method="DELETE",
|
|
1114
|
+
request_options=request_options,
|
|
1115
|
+
)
|
|
1116
|
+
try:
|
|
1117
|
+
if _response is None or not _response.text.strip():
|
|
1118
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
1119
|
+
if 200 <= _response.status_code < 300:
|
|
1120
|
+
_data = typing.cast(
|
|
1121
|
+
typing.Optional[typing.Any],
|
|
1122
|
+
parse_obj_as(
|
|
1123
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1124
|
+
object_=_response.json(),
|
|
1125
|
+
),
|
|
1126
|
+
)
|
|
1127
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1128
|
+
if _response.status_code == 422:
|
|
1129
|
+
raise UnprocessableEntityError(
|
|
1130
|
+
headers=dict(_response.headers),
|
|
1131
|
+
body=typing.cast(
|
|
1132
|
+
HttpValidationError,
|
|
1133
|
+
parse_obj_as(
|
|
1134
|
+
type_=HttpValidationError, # type: ignore
|
|
1135
|
+
object_=_response.json(),
|
|
1136
|
+
),
|
|
1137
|
+
),
|
|
1138
|
+
)
|
|
1139
|
+
_response_json = _response.json()
|
|
1140
|
+
except JSONDecodeError:
|
|
1141
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1142
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1143
|
+
|
|
1144
|
+
async def patch_subscription(
|
|
1145
|
+
self,
|
|
1146
|
+
subscription_id: str,
|
|
1147
|
+
*,
|
|
1148
|
+
url: typing.Optional[str] = OMIT,
|
|
1149
|
+
event_types: typing.Optional[typing.Sequence[EventType]] = OMIT,
|
|
1150
|
+
disabled: typing.Optional[bool] = OMIT,
|
|
1151
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1152
|
+
) -> AsyncHttpResponse[EndpointOut]:
|
|
1153
|
+
"""
|
|
1154
|
+
Update a webhook subscription.
|
|
1155
|
+
|
|
1156
|
+
Args:
|
|
1157
|
+
subscription_id: The ID of the subscription to update.
|
|
1158
|
+
request: The subscription update request.
|
|
1159
|
+
ctx: The API context containing organization info.
|
|
1160
|
+
|
|
1161
|
+
Returns:
|
|
1162
|
+
The updated subscription.
|
|
1163
|
+
|
|
1164
|
+
Parameters
|
|
1165
|
+
----------
|
|
1166
|
+
subscription_id : str
|
|
1167
|
+
|
|
1168
|
+
url : typing.Optional[str]
|
|
1169
|
+
|
|
1170
|
+
event_types : typing.Optional[typing.Sequence[EventType]]
|
|
1171
|
+
|
|
1172
|
+
disabled : typing.Optional[bool]
|
|
1173
|
+
|
|
1174
|
+
request_options : typing.Optional[RequestOptions]
|
|
1175
|
+
Request-specific configuration.
|
|
1176
|
+
|
|
1177
|
+
Returns
|
|
1178
|
+
-------
|
|
1179
|
+
AsyncHttpResponse[EndpointOut]
|
|
1180
|
+
Successful Response
|
|
1181
|
+
"""
|
|
1182
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1183
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}",
|
|
1184
|
+
method="PATCH",
|
|
1185
|
+
json={
|
|
1186
|
+
"url": url,
|
|
1187
|
+
"event_types": event_types,
|
|
1188
|
+
"disabled": disabled,
|
|
1189
|
+
},
|
|
1190
|
+
headers={
|
|
1191
|
+
"content-type": "application/json",
|
|
1192
|
+
},
|
|
1193
|
+
request_options=request_options,
|
|
1194
|
+
omit=OMIT,
|
|
1195
|
+
)
|
|
1196
|
+
try:
|
|
1197
|
+
if 200 <= _response.status_code < 300:
|
|
1198
|
+
_data = typing.cast(
|
|
1199
|
+
EndpointOut,
|
|
1200
|
+
parse_obj_as(
|
|
1201
|
+
type_=EndpointOut, # type: ignore
|
|
1202
|
+
object_=_response.json(),
|
|
1203
|
+
),
|
|
1204
|
+
)
|
|
1205
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1206
|
+
if _response.status_code == 422:
|
|
1207
|
+
raise UnprocessableEntityError(
|
|
1208
|
+
headers=dict(_response.headers),
|
|
1209
|
+
body=typing.cast(
|
|
1210
|
+
HttpValidationError,
|
|
1211
|
+
parse_obj_as(
|
|
1212
|
+
type_=HttpValidationError, # type: ignore
|
|
1213
|
+
object_=_response.json(),
|
|
1214
|
+
),
|
|
1215
|
+
),
|
|
1216
|
+
)
|
|
1217
|
+
_response_json = _response.json()
|
|
1218
|
+
except JSONDecodeError:
|
|
1219
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1220
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1221
|
+
|
|
1222
|
+
async def enable_subscription(
|
|
1223
|
+
self,
|
|
1224
|
+
subscription_id: str,
|
|
1225
|
+
*,
|
|
1226
|
+
request: typing.Optional[EnableEndpointRequest] = None,
|
|
1227
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1228
|
+
) -> AsyncHttpResponse[EndpointOut]:
|
|
1229
|
+
"""
|
|
1230
|
+
Enable a disabled webhook subscription, optionally recovering failed messages.
|
|
1231
|
+
|
|
1232
|
+
Args:
|
|
1233
|
+
subscription_id: The ID of the subscription to enable.
|
|
1234
|
+
request: Optional request with recovery time range.
|
|
1235
|
+
ctx: The API context containing organization info.
|
|
1236
|
+
|
|
1237
|
+
Returns:
|
|
1238
|
+
The enabled subscription.
|
|
1239
|
+
|
|
1240
|
+
Parameters
|
|
1241
|
+
----------
|
|
1242
|
+
subscription_id : str
|
|
1243
|
+
|
|
1244
|
+
request : typing.Optional[EnableEndpointRequest]
|
|
1245
|
+
|
|
1246
|
+
request_options : typing.Optional[RequestOptions]
|
|
1247
|
+
Request-specific configuration.
|
|
1248
|
+
|
|
1249
|
+
Returns
|
|
1250
|
+
-------
|
|
1251
|
+
AsyncHttpResponse[EndpointOut]
|
|
1252
|
+
Successful Response
|
|
1253
|
+
"""
|
|
1254
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1255
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/enable",
|
|
1256
|
+
method="POST",
|
|
1257
|
+
json=convert_and_respect_annotation_metadata(
|
|
1258
|
+
object_=request, annotation=EnableEndpointRequest, direction="write"
|
|
1259
|
+
),
|
|
1260
|
+
headers={
|
|
1261
|
+
"content-type": "application/json",
|
|
1262
|
+
},
|
|
1263
|
+
request_options=request_options,
|
|
1264
|
+
omit=OMIT,
|
|
1265
|
+
)
|
|
1266
|
+
try:
|
|
1267
|
+
if 200 <= _response.status_code < 300:
|
|
1268
|
+
_data = typing.cast(
|
|
1269
|
+
EndpointOut,
|
|
1270
|
+
parse_obj_as(
|
|
1271
|
+
type_=EndpointOut, # type: ignore
|
|
1272
|
+
object_=_response.json(),
|
|
1273
|
+
),
|
|
1274
|
+
)
|
|
1275
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1276
|
+
if _response.status_code == 422:
|
|
1277
|
+
raise UnprocessableEntityError(
|
|
1278
|
+
headers=dict(_response.headers),
|
|
1279
|
+
body=typing.cast(
|
|
1280
|
+
HttpValidationError,
|
|
1281
|
+
parse_obj_as(
|
|
1282
|
+
type_=HttpValidationError, # type: ignore
|
|
1283
|
+
object_=_response.json(),
|
|
1284
|
+
),
|
|
1285
|
+
),
|
|
1286
|
+
)
|
|
1287
|
+
_response_json = _response.json()
|
|
1288
|
+
except JSONDecodeError:
|
|
1289
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1290
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1291
|
+
|
|
1292
|
+
async def get_subscription_secret(
|
|
1293
|
+
self, subscription_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1294
|
+
) -> AsyncHttpResponse[EndpointSecretOut]:
|
|
1295
|
+
"""
|
|
1296
|
+
Get the signing secret for a webhook subscription.
|
|
1297
|
+
|
|
1298
|
+
Args:
|
|
1299
|
+
subscription_id: The ID of the subscription.
|
|
1300
|
+
ctx: The API context containing organization info.
|
|
1301
|
+
|
|
1302
|
+
Returns:
|
|
1303
|
+
The subscription's signing secret.
|
|
1304
|
+
|
|
1305
|
+
Parameters
|
|
1306
|
+
----------
|
|
1307
|
+
subscription_id : str
|
|
1308
|
+
|
|
1309
|
+
request_options : typing.Optional[RequestOptions]
|
|
1310
|
+
Request-specific configuration.
|
|
1311
|
+
|
|
1312
|
+
Returns
|
|
1313
|
+
-------
|
|
1314
|
+
AsyncHttpResponse[EndpointSecretOut]
|
|
1315
|
+
Successful Response
|
|
1316
|
+
"""
|
|
1317
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1318
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/secret",
|
|
1319
|
+
method="GET",
|
|
1320
|
+
request_options=request_options,
|
|
1321
|
+
)
|
|
1322
|
+
try:
|
|
1323
|
+
if 200 <= _response.status_code < 300:
|
|
1324
|
+
_data = typing.cast(
|
|
1325
|
+
EndpointSecretOut,
|
|
1326
|
+
parse_obj_as(
|
|
1327
|
+
type_=EndpointSecretOut, # type: ignore
|
|
1328
|
+
object_=_response.json(),
|
|
1329
|
+
),
|
|
1330
|
+
)
|
|
1331
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1332
|
+
if _response.status_code == 422:
|
|
1333
|
+
raise UnprocessableEntityError(
|
|
1334
|
+
headers=dict(_response.headers),
|
|
1335
|
+
body=typing.cast(
|
|
1336
|
+
HttpValidationError,
|
|
1337
|
+
parse_obj_as(
|
|
1338
|
+
type_=HttpValidationError, # type: ignore
|
|
1339
|
+
object_=_response.json(),
|
|
1340
|
+
),
|
|
1341
|
+
),
|
|
1342
|
+
)
|
|
1343
|
+
_response_json = _response.json()
|
|
1344
|
+
except JSONDecodeError:
|
|
1345
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1346
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1347
|
+
|
|
1348
|
+
async def recover_failed_messages(
|
|
1349
|
+
self,
|
|
1350
|
+
subscription_id: str,
|
|
1351
|
+
*,
|
|
1352
|
+
since: dt.datetime,
|
|
1353
|
+
until: typing.Optional[dt.datetime] = OMIT,
|
|
1354
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1355
|
+
) -> AsyncHttpResponse[RecoverOut]:
|
|
1356
|
+
"""
|
|
1357
|
+
Recover (retry) failed messages for a webhook subscription.
|
|
1358
|
+
|
|
1359
|
+
This endpoint triggers a recovery of all failed messages since the specified
|
|
1360
|
+
time. Useful after re-enabling a disabled endpoint to retry messages that
|
|
1361
|
+
failed while the endpoint was down.
|
|
1362
|
+
|
|
1363
|
+
Args:
|
|
1364
|
+
subscription_id: The ID of the subscription to recover messages for.
|
|
1365
|
+
request: The recovery request with time range.
|
|
1366
|
+
ctx: The API context containing organization info.
|
|
1367
|
+
|
|
1368
|
+
Returns:
|
|
1369
|
+
Information about the recovery task.
|
|
1370
|
+
|
|
1371
|
+
Parameters
|
|
1372
|
+
----------
|
|
1373
|
+
subscription_id : str
|
|
1374
|
+
|
|
1375
|
+
since : dt.datetime
|
|
1376
|
+
|
|
1377
|
+
until : typing.Optional[dt.datetime]
|
|
1378
|
+
|
|
1379
|
+
request_options : typing.Optional[RequestOptions]
|
|
1380
|
+
Request-specific configuration.
|
|
1381
|
+
|
|
1382
|
+
Returns
|
|
1383
|
+
-------
|
|
1384
|
+
AsyncHttpResponse[RecoverOut]
|
|
1385
|
+
Successful Response
|
|
1386
|
+
"""
|
|
1387
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1388
|
+
f"events/subscriptions/{jsonable_encoder(subscription_id)}/recover",
|
|
1389
|
+
method="POST",
|
|
1390
|
+
json={
|
|
1391
|
+
"since": since,
|
|
1392
|
+
"until": until,
|
|
1393
|
+
},
|
|
1394
|
+
headers={
|
|
1395
|
+
"content-type": "application/json",
|
|
1396
|
+
},
|
|
1397
|
+
request_options=request_options,
|
|
1398
|
+
omit=OMIT,
|
|
1399
|
+
)
|
|
1400
|
+
try:
|
|
1401
|
+
if 200 <= _response.status_code < 300:
|
|
1402
|
+
_data = typing.cast(
|
|
1403
|
+
RecoverOut,
|
|
1404
|
+
parse_obj_as(
|
|
1405
|
+
type_=RecoverOut, # type: ignore
|
|
1406
|
+
object_=_response.json(),
|
|
1407
|
+
),
|
|
1408
|
+
)
|
|
1409
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1410
|
+
if _response.status_code == 422:
|
|
1411
|
+
raise UnprocessableEntityError(
|
|
1412
|
+
headers=dict(_response.headers),
|
|
1413
|
+
body=typing.cast(
|
|
1414
|
+
HttpValidationError,
|
|
1415
|
+
parse_obj_as(
|
|
1416
|
+
type_=HttpValidationError, # type: ignore
|
|
1417
|
+
object_=_response.json(),
|
|
1418
|
+
),
|
|
1419
|
+
),
|
|
1420
|
+
)
|
|
1421
|
+
_response_json = _response.json()
|
|
1422
|
+
except JSONDecodeError:
|
|
1423
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1424
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|