Skip to content

Commit 3b219e5

Browse files
author
stlc-bot
committed
feat(webhooks): add configurable retries and manual replay
Stainless-Generated-From: cca1358
1 parent d7c835b commit 3b219e5

37 files changed

Lines changed: 1781 additions & 5 deletions

‎.stats.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 41
1+
configured_endpoints: 45

‎api.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,36 @@ Methods:
167167
- <code title="get /batch/{batch_id}/results">client.batch.<a href="./src/context/dev/resources/batch.py">get_results</a>(batch_id, \*\*<a href="src/context/dev/types/batch_get_results_params.py">params</a>) -> <a href="./src/context/dev/types/batch_get_results_response.py">BatchGetResultsResponse</a></code>
168168
- <code title="post /batch/submit">client.batch.<a href="./src/context/dev/resources/batch.py">submit</a>(\*\*<a href="src/context/dev/types/batch_submit_params.py">params</a>) -> <a href="./src/context/dev/types/batch_submit_response.py">BatchSubmitResponse</a></code>
169169

170+
# Webhooks
171+
172+
Types:
173+
174+
```python
175+
from context.dev.types import RetryConfig
176+
```
177+
178+
## Deliveries
179+
180+
Types:
181+
182+
```python
183+
from context.dev.types.webhooks import (
184+
Attempt,
185+
Delivery,
186+
DeliveryRetrieveResponse,
187+
DeliveryListResponse,
188+
DeliveryListAttemptsResponse,
189+
DeliveryRetryResponse,
190+
)
191+
```
192+
193+
Methods:
194+
195+
- <code title="get /webhooks/deliveries/{delivery_id}">client.webhooks.deliveries.<a href="./src/context/dev/resources/webhooks/deliveries.py">retrieve</a>(delivery_id, \*\*<a href="src/context/dev/types/webhooks/delivery_retrieve_params.py">params</a>) -> <a href="./src/context/dev/types/webhooks/delivery_retrieve_response.py">DeliveryRetrieveResponse</a></code>
196+
- <code title="get /webhooks/deliveries">client.webhooks.deliveries.<a href="./src/context/dev/resources/webhooks/deliveries.py">list</a>(\*\*<a href="src/context/dev/types/webhooks/delivery_list_params.py">params</a>) -> <a href="./src/context/dev/types/webhooks/delivery_list_response.py">DeliveryListResponse</a></code>
197+
- <code title="get /webhooks/deliveries/{delivery_id}/attempts">client.webhooks.deliveries.<a href="./src/context/dev/resources/webhooks/deliveries.py">list_attempts</a>(delivery_id, \*\*<a href="src/context/dev/types/webhooks/delivery_list_attempts_params.py">params</a>) -> <a href="./src/context/dev/types/webhooks/delivery_list_attempts_response.py">DeliveryListAttemptsResponse</a></code>
198+
- <code title="post /webhooks/deliveries/{delivery_id}/retry">client.webhooks.deliveries.<a href="./src/context/dev/resources/webhooks/deliveries.py">retry</a>(delivery_id, \*\*<a href="src/context/dev/types/webhooks/delivery_retry_params.py">params</a>) -> <a href="./src/context/dev/types/webhooks/delivery_retry_response.py">DeliveryRetryResponse</a></code>
199+
170200
# People
171201

172202
Types:

‎src/context/dev/_client.py‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
)
3636

3737
if TYPE_CHECKING:
38-
from .resources import ai, web, news, batch, brand, parse, people, utility, industry, monitors
38+
from .resources import ai, web, news, batch, brand, parse, people, utility, industry, monitors, webhooks
3939
from .resources.ai import AIResource, AsyncAIResource
4040
from .resources.web import WebResource, AsyncWebResource
4141
from .resources.news import NewsResource, AsyncNewsResource
@@ -46,6 +46,7 @@
4646
from .resources.utility import UtilityResource, AsyncUtilityResource
4747
from .resources.industry import IndustryResource, AsyncIndustryResource
4848
from .resources.monitors import MonitorsResource, AsyncMonitorsResource
49+
from .resources.webhooks.webhooks import WebhooksResource, AsyncWebhooksResource
4950

5051
__all__ = [
5152
"Timeout",
@@ -175,6 +176,12 @@ def batch(self) -> BatchResource:
175176

176177
return BatchResource(self)
177178

179+
@cached_property
180+
def webhooks(self) -> WebhooksResource:
181+
from .resources.webhooks import WebhooksResource
182+
183+
return WebhooksResource(self)
184+
178185
@cached_property
179186
def people(self) -> PeopleResource:
180187
from .resources.people import PeopleResource
@@ -417,6 +424,12 @@ def batch(self) -> AsyncBatchResource:
417424

418425
return AsyncBatchResource(self)
419426

427+
@cached_property
428+
def webhooks(self) -> AsyncWebhooksResource:
429+
from .resources.webhooks import AsyncWebhooksResource
430+
431+
return AsyncWebhooksResource(self)
432+
420433
@cached_property
421434
def people(self) -> AsyncPeopleResource:
422435
from .resources.people import AsyncPeopleResource
@@ -601,6 +614,12 @@ def batch(self) -> batch.BatchResourceWithRawResponse:
601614

602615
return BatchResourceWithRawResponse(self._client.batch)
603616

617+
@cached_property
618+
def webhooks(self) -> webhooks.WebhooksResourceWithRawResponse:
619+
from .resources.webhooks import WebhooksResourceWithRawResponse
620+
621+
return WebhooksResourceWithRawResponse(self._client.webhooks)
622+
604623
@cached_property
605624
def people(self) -> people.PeopleResourceWithRawResponse:
606625
from .resources.people import PeopleResourceWithRawResponse
@@ -673,6 +692,12 @@ def batch(self) -> batch.AsyncBatchResourceWithRawResponse:
673692

674693
return AsyncBatchResourceWithRawResponse(self._client.batch)
675694

695+
@cached_property
696+
def webhooks(self) -> webhooks.AsyncWebhooksResourceWithRawResponse:
697+
from .resources.webhooks import AsyncWebhooksResourceWithRawResponse
698+
699+
return AsyncWebhooksResourceWithRawResponse(self._client.webhooks)
700+
676701
@cached_property
677702
def people(self) -> people.AsyncPeopleResourceWithRawResponse:
678703
from .resources.people import AsyncPeopleResourceWithRawResponse
@@ -745,6 +770,12 @@ def batch(self) -> batch.BatchResourceWithStreamingResponse:
745770

746771
return BatchResourceWithStreamingResponse(self._client.batch)
747772

773+
@cached_property
774+
def webhooks(self) -> webhooks.WebhooksResourceWithStreamingResponse:
775+
from .resources.webhooks import WebhooksResourceWithStreamingResponse
776+
777+
return WebhooksResourceWithStreamingResponse(self._client.webhooks)
778+
748779
@cached_property
749780
def people(self) -> people.PeopleResourceWithStreamingResponse:
750781
from .resources.people import PeopleResourceWithStreamingResponse
@@ -817,6 +848,12 @@ def batch(self) -> batch.AsyncBatchResourceWithStreamingResponse:
817848

818849
return AsyncBatchResourceWithStreamingResponse(self._client.batch)
819850

851+
@cached_property
852+
def webhooks(self) -> webhooks.AsyncWebhooksResourceWithStreamingResponse:
853+
from .resources.webhooks import AsyncWebhooksResourceWithStreamingResponse
854+
855+
return AsyncWebhooksResourceWithStreamingResponse(self._client.webhooks)
856+
820857
@cached_property
821858
def people(self) -> people.AsyncPeopleResourceWithStreamingResponse:
822859
from .resources.people import AsyncPeopleResourceWithStreamingResponse

‎src/context/dev/resources/__init__.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
MonitorsResourceWithStreamingResponse,
8181
AsyncMonitorsResourceWithStreamingResponse,
8282
)
83+
from .webhooks import (
84+
WebhooksResource,
85+
AsyncWebhooksResource,
86+
WebhooksResourceWithRawResponse,
87+
AsyncWebhooksResourceWithRawResponse,
88+
WebhooksResourceWithStreamingResponse,
89+
AsyncWebhooksResourceWithStreamingResponse,
90+
)
8391

8492
__all__ = [
8593
"ParseResource",
@@ -130,6 +138,12 @@
130138
"AsyncBatchResourceWithRawResponse",
131139
"BatchResourceWithStreamingResponse",
132140
"AsyncBatchResourceWithStreamingResponse",
141+
"WebhooksResource",
142+
"AsyncWebhooksResource",
143+
"WebhooksResourceWithRawResponse",
144+
"AsyncWebhooksResourceWithRawResponse",
145+
"WebhooksResourceWithStreamingResponse",
146+
"AsyncWebhooksResourceWithStreamingResponse",
133147
"PeopleResource",
134148
"AsyncPeopleResource",
135149
"PeopleResourceWithRawResponse",

‎src/context/dev/resources/batch.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def submit(
283283
*,
284284
input: batch_submit_params.Input,
285285
tags: SequenceNotStr[str] | Omit = omit,
286+
webhook: batch_submit_params.Webhook | Omit = omit,
286287
webhook_url: str | Omit = omit,
287288
idempotency_key: str | Omit = omit,
288289
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -300,7 +301,11 @@ def submit(
300301

301302
tags: Tags stored on the batch. Filter the batch list by them later.
302303

303-
webhook_url: URL notified when the batch finishes.
304+
webhook: Completion webhook settings. Cannot be combined with webhookUrl. Omitting retry
305+
preserves legacy delivery; retry: {} opts into durable retries.
306+
307+
webhook_url: Legacy URL notified when the batch finishes. Preserves one best-effort attempt.
308+
Cannot be combined with webhook.
304309

305310
idempotency_key: Any string unique to this submission. Retries with the same key return the
306311
original batch.
@@ -320,6 +325,7 @@ def submit(
320325
{
321326
"input": input,
322327
"tags": tags,
328+
"webhook": webhook,
323329
"webhook_url": webhook_url,
324330
},
325331
batch_submit_params.BatchSubmitParams,
@@ -586,6 +592,7 @@ async def submit(
586592
*,
587593
input: batch_submit_params.Input,
588594
tags: SequenceNotStr[str] | Omit = omit,
595+
webhook: batch_submit_params.Webhook | Omit = omit,
589596
webhook_url: str | Omit = omit,
590597
idempotency_key: str | Omit = omit,
591598
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -603,7 +610,11 @@ async def submit(
603610

604611
tags: Tags stored on the batch. Filter the batch list by them later.
605612

606-
webhook_url: URL notified when the batch finishes.
613+
webhook: Completion webhook settings. Cannot be combined with webhookUrl. Omitting retry
614+
preserves legacy delivery; retry: {} opts into durable retries.
615+
616+
webhook_url: Legacy URL notified when the batch finishes. Preserves one best-effort attempt.
617+
Cannot be combined with webhook.
607618

608619
idempotency_key: Any string unique to this submission. Retries with the same key return the
609620
original batch.
@@ -623,6 +634,7 @@ async def submit(
623634
{
624635
"input": input,
625636
"tags": tags,
637+
"webhook": webhook,
626638
"webhook_url": webhook_url,
627639
},
628640
batch_submit_params.BatchSubmitParams,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .webhooks import (
4+
WebhooksResource,
5+
AsyncWebhooksResource,
6+
WebhooksResourceWithRawResponse,
7+
AsyncWebhooksResourceWithRawResponse,
8+
WebhooksResourceWithStreamingResponse,
9+
AsyncWebhooksResourceWithStreamingResponse,
10+
)
11+
from .deliveries import (
12+
DeliveriesResource,
13+
AsyncDeliveriesResource,
14+
DeliveriesResourceWithRawResponse,
15+
AsyncDeliveriesResourceWithRawResponse,
16+
DeliveriesResourceWithStreamingResponse,
17+
AsyncDeliveriesResourceWithStreamingResponse,
18+
)
19+
20+
__all__ = [
21+
"DeliveriesResource",
22+
"AsyncDeliveriesResource",
23+
"DeliveriesResourceWithRawResponse",
24+
"AsyncDeliveriesResourceWithRawResponse",
25+
"DeliveriesResourceWithStreamingResponse",
26+
"AsyncDeliveriesResourceWithStreamingResponse",
27+
"WebhooksResource",
28+
"AsyncWebhooksResource",
29+
"WebhooksResourceWithRawResponse",
30+
"AsyncWebhooksResourceWithRawResponse",
31+
"WebhooksResourceWithStreamingResponse",
32+
"AsyncWebhooksResourceWithStreamingResponse",
33+
]

0 commit comments

Comments
 (0)