Skip to content

Commit 37c7d9d

Browse files
feat(api): add webhook endpoint
1 parent ee41408 commit 37c7d9d

13 files changed

Lines changed: 564 additions & 7 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 64
1+
configured_endpoints: 65
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/sgp/agentex-sdk-cd43ba4b554ca024dd7ee7b74e4f4700a743282c17def704a0967e6ff251c09b.yml
33
openapi_spec_hash: 9369ccc9c0289e9d6f641a526d244d1c
4-
config_hash: 138b7c0b394e7393133c8ff16a6d0eb3
4+
config_hash: 1ae003838971335aac550f3ad5872f54

api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,15 @@ Methods:
245245
- <code title="post /checkpoints/get-tuple">client.checkpoints.<a href="./src/agentex/resources/checkpoints.py">get_tuple</a>(\*\*<a href="src/agentex/types/checkpoint_get_tuple_params.py">params</a>) -> <a href="./src/agentex/types/checkpoint_get_tuple_response.py">Optional[CheckpointGetTupleResponse]</a></code>
246246
- <code title="post /checkpoints/put">client.checkpoints.<a href="./src/agentex/resources/checkpoints.py">put</a>(\*\*<a href="src/agentex/types/checkpoint_put_params.py">params</a>) -> <a href="./src/agentex/types/checkpoint_put_response.py">CheckpointPutResponse</a></code>
247247
- <code title="post /checkpoints/put-writes">client.checkpoints.<a href="./src/agentex/resources/checkpoints.py">put_writes</a>(\*\*<a href="src/agentex/types/checkpoint_put_writes_params.py">params</a>) -> None</code>
248+
249+
# Webhooks
250+
251+
Types:
252+
253+
```python
254+
from agentex.types import WebhookCreateWebhookTriggerResponse
255+
```
256+
257+
Methods:
258+
259+
- <code title="post /agent_api_keys/webhook-trigger">client.webhooks.<a href="./src/agentex/resources/webhooks.py">create_webhook_trigger</a>(\*\*<a href="src/agentex/types/webhook_create_webhook_trigger_params.py">params</a>) -> <a href="./src/agentex/types/webhook_create_webhook_trigger_response.py">WebhookCreateWebhookTriggerResponse</a></code>

src/agentex/_client.py

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

3737
if TYPE_CHECKING:
38-
from .resources import spans, tasks, agents, events, states, tracker, messages, checkpoints, deployment_history
38+
from .resources import (
39+
spans,
40+
tasks,
41+
agents,
42+
events,
43+
states,
44+
tracker,
45+
messages,
46+
webhooks,
47+
checkpoints,
48+
deployment_history,
49+
)
3950
from .resources.spans import SpansResource, AsyncSpansResource
4051
from .resources.tasks import TasksResource, AsyncTasksResource
4152
from .resources.events import EventsResource, AsyncEventsResource
4253
from .resources.states import StatesResource, AsyncStatesResource
4354
from .resources.tracker import TrackerResource, AsyncTrackerResource
55+
from .resources.webhooks import WebhooksResource, AsyncWebhooksResource
4456
from .resources.checkpoints import CheckpointsResource, AsyncCheckpointsResource
4557
from .resources.agents.agents import AgentsResource, AsyncAgentsResource
4658
from .resources.messages.messages import MessagesResource, AsyncMessagesResource
@@ -202,6 +214,12 @@ def checkpoints(self) -> CheckpointsResource:
202214

203215
return CheckpointsResource(self)
204216

217+
@cached_property
218+
def webhooks(self) -> WebhooksResource:
219+
from .resources.webhooks import WebhooksResource
220+
221+
return WebhooksResource(self)
222+
205223
@cached_property
206224
def with_raw_response(self) -> AgentexWithRawResponse:
207225
return AgentexWithRawResponse(self)
@@ -457,6 +475,12 @@ def checkpoints(self) -> AsyncCheckpointsResource:
457475

458476
return AsyncCheckpointsResource(self)
459477

478+
@cached_property
479+
def webhooks(self) -> AsyncWebhooksResource:
480+
from .resources.webhooks import AsyncWebhooksResource
481+
482+
return AsyncWebhooksResource(self)
483+
460484
@cached_property
461485
def with_raw_response(self) -> AsyncAgentexWithRawResponse:
462486
return AsyncAgentexWithRawResponse(self)
@@ -634,6 +658,12 @@ def checkpoints(self) -> checkpoints.CheckpointsResourceWithRawResponse:
634658

635659
return CheckpointsResourceWithRawResponse(self._client.checkpoints)
636660

661+
@cached_property
662+
def webhooks(self) -> webhooks.WebhooksResourceWithRawResponse:
663+
from .resources.webhooks import WebhooksResourceWithRawResponse
664+
665+
return WebhooksResourceWithRawResponse(self._client.webhooks)
666+
637667

638668
class AsyncAgentexWithRawResponse:
639669
_client: AsyncAgentex
@@ -695,6 +725,12 @@ def checkpoints(self) -> checkpoints.AsyncCheckpointsResourceWithRawResponse:
695725

696726
return AsyncCheckpointsResourceWithRawResponse(self._client.checkpoints)
697727

728+
@cached_property
729+
def webhooks(self) -> webhooks.AsyncWebhooksResourceWithRawResponse:
730+
from .resources.webhooks import AsyncWebhooksResourceWithRawResponse
731+
732+
return AsyncWebhooksResourceWithRawResponse(self._client.webhooks)
733+
698734

699735
class AgentexWithStreamedResponse:
700736
_client: Agentex
@@ -756,6 +792,12 @@ def checkpoints(self) -> checkpoints.CheckpointsResourceWithStreamingResponse:
756792

757793
return CheckpointsResourceWithStreamingResponse(self._client.checkpoints)
758794

795+
@cached_property
796+
def webhooks(self) -> webhooks.WebhooksResourceWithStreamingResponse:
797+
from .resources.webhooks import WebhooksResourceWithStreamingResponse
798+
799+
return WebhooksResourceWithStreamingResponse(self._client.webhooks)
800+
759801

760802
class AsyncAgentexWithStreamedResponse:
761803
_client: AsyncAgentex
@@ -817,6 +859,12 @@ def checkpoints(self) -> checkpoints.AsyncCheckpointsResourceWithStreamingRespon
817859

818860
return AsyncCheckpointsResourceWithStreamingResponse(self._client.checkpoints)
819861

862+
@cached_property
863+
def webhooks(self) -> webhooks.AsyncWebhooksResourceWithStreamingResponse:
864+
from .resources.webhooks import AsyncWebhooksResourceWithStreamingResponse
865+
866+
return AsyncWebhooksResourceWithStreamingResponse(self._client.webhooks)
867+
820868

821869
Client = Agentex
822870

src/agentex/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
MessagesResourceWithStreamingResponse,
5757
AsyncMessagesResourceWithStreamingResponse,
5858
)
59+
from .webhooks import (
60+
WebhooksResource,
61+
AsyncWebhooksResource,
62+
WebhooksResourceWithRawResponse,
63+
AsyncWebhooksResourceWithRawResponse,
64+
WebhooksResourceWithStreamingResponse,
65+
AsyncWebhooksResourceWithStreamingResponse,
66+
)
5967
from .checkpoints import (
6068
CheckpointsResource,
6169
AsyncCheckpointsResource,
@@ -128,4 +136,10 @@
128136
"AsyncCheckpointsResourceWithRawResponse",
129137
"CheckpointsResourceWithStreamingResponse",
130138
"AsyncCheckpointsResourceWithStreamingResponse",
139+
"WebhooksResource",
140+
"AsyncWebhooksResource",
141+
"WebhooksResourceWithRawResponse",
142+
"AsyncWebhooksResourceWithRawResponse",
143+
"WebhooksResourceWithStreamingResponse",
144+
"AsyncWebhooksResourceWithStreamingResponse",
131145
]

src/agentex/resources/tasks.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ def update_by_id(
554554
self,
555555
task_id: str,
556556
*,
557+
merge_params: Optional[Dict[str, object]] | Omit = omit,
557558
task_metadata: Optional[Dict[str, object]] | Omit = omit,
558559
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
559560
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -578,7 +579,13 @@ def update_by_id(
578579
raise ValueError(f"Expected a non-empty value for `task_id` but received {task_id!r}")
579580
return self._put(
580581
path_template("/tasks/{task_id}", task_id=task_id),
581-
body=maybe_transform({"task_metadata": task_metadata}, task_update_by_id_params.TaskUpdateByIDParams),
582+
body=maybe_transform(
583+
{
584+
"merge_params": merge_params,
585+
"task_metadata": task_metadata,
586+
},
587+
task_update_by_id_params.TaskUpdateByIDParams,
588+
),
582589
options=make_request_options(
583590
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
584591
),
@@ -589,6 +596,7 @@ def update_by_name(
589596
self,
590597
task_name: str,
591598
*,
599+
merge_params: Optional[Dict[str, object]] | Omit = omit,
592600
task_metadata: Optional[Dict[str, object]] | Omit = omit,
593601
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
594602
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -613,7 +621,13 @@ def update_by_name(
613621
raise ValueError(f"Expected a non-empty value for `task_name` but received {task_name!r}")
614622
return self._put(
615623
path_template("/tasks/name/{task_name}", task_name=task_name),
616-
body=maybe_transform({"task_metadata": task_metadata}, task_update_by_name_params.TaskUpdateByNameParams),
624+
body=maybe_transform(
625+
{
626+
"merge_params": merge_params,
627+
"task_metadata": task_metadata,
628+
},
629+
task_update_by_name_params.TaskUpdateByNameParams,
630+
),
617631
options=make_request_options(
618632
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
619633
),
@@ -1136,6 +1150,7 @@ async def update_by_id(
11361150
self,
11371151
task_id: str,
11381152
*,
1153+
merge_params: Optional[Dict[str, object]] | Omit = omit,
11391154
task_metadata: Optional[Dict[str, object]] | Omit = omit,
11401155
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
11411156
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1161,7 +1176,11 @@ async def update_by_id(
11611176
return await self._put(
11621177
path_template("/tasks/{task_id}", task_id=task_id),
11631178
body=await async_maybe_transform(
1164-
{"task_metadata": task_metadata}, task_update_by_id_params.TaskUpdateByIDParams
1179+
{
1180+
"merge_params": merge_params,
1181+
"task_metadata": task_metadata,
1182+
},
1183+
task_update_by_id_params.TaskUpdateByIDParams,
11651184
),
11661185
options=make_request_options(
11671186
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
@@ -1173,6 +1192,7 @@ async def update_by_name(
11731192
self,
11741193
task_name: str,
11751194
*,
1195+
merge_params: Optional[Dict[str, object]] | Omit = omit,
11761196
task_metadata: Optional[Dict[str, object]] | Omit = omit,
11771197
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
11781198
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -1198,7 +1218,11 @@ async def update_by_name(
11981218
return await self._put(
11991219
path_template("/tasks/name/{task_name}", task_name=task_name),
12001220
body=await async_maybe_transform(
1201-
{"task_metadata": task_metadata}, task_update_by_name_params.TaskUpdateByNameParams
1221+
{
1222+
"merge_params": merge_params,
1223+
"task_metadata": task_metadata,
1224+
},
1225+
task_update_by_name_params.TaskUpdateByNameParams,
12021226
),
12031227
options=make_request_options(
12041228
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout

0 commit comments

Comments
 (0)