Skip to content

Commit 454cce4

Browse files
fix: Add after_sequence param to axon subscribe (#8497)
1 parent 08e6a25 commit 454cce4

6 files changed

Lines changed: 67 additions & 14 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 116
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-8ea4486cd6de6410a6648545710d617f175994f8d12753783585029ce22c225c.yml
3-
openapi_spec_hash: fcb07ce127f4290f1dac51db130365aa
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-77cfebef736250545ee47fa63d2210f323f096f0cbff4194c4a460a4d0328fd3.yml
3+
openapi_spec_hash: 33b5de41f43ca91cd3c745b048e68856
44
config_hash: 6649774d90af30c3559d6a242b6cb4b0

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Methods:
109109
- <code title="get /v1/axons/{id}">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">retrieve</a>(id) -> <a href="./src/runloop_api_client/types/axon_view.py">AxonView</a></code>
110110
- <code title="get /v1/axons">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">list</a>(\*\*<a href="src/runloop_api_client/types/axon_list_params.py">params</a>) -> <a href="./src/runloop_api_client/types/axon_view.py">SyncAxonsCursorIDPage[AxonView]</a></code>
111111
- <code title="post /v1/axons/{id}/publish">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">publish</a>(id, \*\*<a href="src/runloop_api_client/types/axon_publish_params.py">params</a>) -> <a href="./src/runloop_api_client/types/publish_result_view.py">PublishResultView</a></code>
112-
- <code title="get /v1/axons/{id}/subscribe/sse">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">subscribe_sse</a>(id) -> <a href="./src/runloop_api_client/types/axon_event_view.py">AxonEventView</a></code>
112+
- <code title="get /v1/axons/{id}/subscribe/sse">client.axons.<a href="./src/runloop_api_client/resources/axons/axons.py">subscribe_sse</a>(id, \*\*<a href="src/runloop_api_client/types/axon_subscribe_sse_params.py">params</a>) -> <a href="./src/runloop_api_client/types/axon_event_view.py">AxonEventView</a></code>
113113

114114
## Sql
115115

src/runloop_api_client/resources/axons/axons.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
SqlResourceWithStreamingResponse,
1616
AsyncSqlResourceWithStreamingResponse,
1717
)
18-
from ...types import axon_list_params, axon_create_params, axon_publish_params
18+
from ...types import axon_list_params, axon_create_params, axon_publish_params, axon_subscribe_sse_params
1919
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
2020
from ..._utils import path_template, maybe_transform, async_maybe_transform
2121
from ..._compat import cached_property
@@ -259,6 +259,7 @@ def subscribe_sse(
259259
self,
260260
id: str,
261261
*,
262+
after_sequence: int | Omit = omit,
262263
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
263264
# The extra values given here take precedence over values defined on the client or passed to this method.
264265
extra_headers: Headers | None = None,
@@ -270,6 +271,9 @@ def subscribe_sse(
270271
[Beta] Subscribe to an axon event stream via server-sent events.
271272
272273
Args:
274+
after_sequence: Sequence number after which to start streaming. Events with sequence > this
275+
value are returned. If unset, replay from the beginning.
276+
273277
extra_headers: Send extra headers
274278
275279
extra_query: Add additional query parameters to the request
@@ -285,7 +289,13 @@ def subscribe_sse(
285289
return self._get(
286290
path_template("/v1/axons/{id}/subscribe/sse", id=id),
287291
options=make_request_options(
288-
extra_headers=merged_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
292+
extra_headers=merged_headers,
293+
extra_query=extra_query,
294+
extra_body=extra_body,
295+
timeout=timeout,
296+
query=maybe_transform(
297+
{"after_sequence": after_sequence}, axon_subscribe_sse_params.AxonSubscribeSseParams
298+
),
289299
),
290300
cast_to=AxonEventView,
291301
stream=True,
@@ -516,6 +526,7 @@ async def subscribe_sse(
516526
self,
517527
id: str,
518528
*,
529+
after_sequence: int | Omit = omit,
519530
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
520531
# The extra values given here take precedence over values defined on the client or passed to this method.
521532
extra_headers: Headers | None = None,
@@ -527,6 +538,9 @@ async def subscribe_sse(
527538
[Beta] Subscribe to an axon event stream via server-sent events.
528539
529540
Args:
541+
after_sequence: Sequence number after which to start streaming. Events with sequence > this
542+
value are returned. If unset, replay from the beginning.
543+
530544
extra_headers: Send extra headers
531545
532546
extra_query: Add additional query parameters to the request
@@ -542,7 +556,13 @@ async def subscribe_sse(
542556
return await self._get(
543557
path_template("/v1/axons/{id}/subscribe/sse", id=id),
544558
options=make_request_options(
545-
extra_headers=merged_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
559+
extra_headers=merged_headers,
560+
extra_query=extra_query,
561+
extra_body=extra_body,
562+
timeout=timeout,
563+
query=await async_maybe_transform(
564+
{"after_sequence": after_sequence}, axon_subscribe_sse_params.AxonSubscribeSseParams
565+
),
546566
),
547567
cast_to=AxonEventView,
548568
stream=True,

src/runloop_api_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
from .mcp_config_update_params import McpConfigUpdateParams as McpConfigUpdateParams
8383
from .network_policy_list_view import NetworkPolicyListView as NetworkPolicyListView
8484
from .object_download_url_view import ObjectDownloadURLView as ObjectDownloadURLView
85+
from .axon_subscribe_sse_params import AxonSubscribeSseParams as AxonSubscribeSseParams
8586
from .benchmark_job_list_params import BenchmarkJobListParams as BenchmarkJobListParams
8687
from .benchmark_run_list_params import BenchmarkRunListParams as BenchmarkRunListParams
8788
from .devbox_send_std_in_result import DevboxSendStdInResult as DevboxSendStdInResult
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import TypedDict
6+
7+
__all__ = ["AxonSubscribeSseParams"]
8+
9+
10+
class AxonSubscribeSseParams(TypedDict, total=False):
11+
after_sequence: int
12+
"""Sequence number after which to start streaming.
13+
14+
Events with sequence > this value are returned. If unset, replay from the
15+
beginning.
16+
"""

tests/api_resources/test_axons.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,22 @@ def test_path_params_publish(self, client: Runloop) -> None:
184184
@parametrize
185185
def test_method_subscribe_sse(self, client: Runloop) -> None:
186186
axon_stream = client.axons.subscribe_sse(
187-
"id",
187+
id="id",
188+
)
189+
axon_stream.response.close()
190+
191+
@parametrize
192+
def test_method_subscribe_sse_with_all_params(self, client: Runloop) -> None:
193+
axon_stream = client.axons.subscribe_sse(
194+
id="id",
195+
after_sequence=0,
188196
)
189197
axon_stream.response.close()
190198

191199
@parametrize
192200
def test_raw_response_subscribe_sse(self, client: Runloop) -> None:
193201
response = client.axons.with_raw_response.subscribe_sse(
194-
"id",
202+
id="id",
195203
)
196204

197205
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -201,7 +209,7 @@ def test_raw_response_subscribe_sse(self, client: Runloop) -> None:
201209
@parametrize
202210
def test_streaming_response_subscribe_sse(self, client: Runloop) -> None:
203211
with client.axons.with_streaming_response.subscribe_sse(
204-
"id",
212+
id="id",
205213
) as response:
206214
assert not response.is_closed
207215
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -215,7 +223,7 @@ def test_streaming_response_subscribe_sse(self, client: Runloop) -> None:
215223
def test_path_params_subscribe_sse(self, client: Runloop) -> None:
216224
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
217225
client.axons.with_raw_response.subscribe_sse(
218-
"",
226+
id="",
219227
)
220228

221229

@@ -387,14 +395,22 @@ async def test_path_params_publish(self, async_client: AsyncRunloop) -> None:
387395
@parametrize
388396
async def test_method_subscribe_sse(self, async_client: AsyncRunloop) -> None:
389397
axon_stream = await async_client.axons.subscribe_sse(
390-
"id",
398+
id="id",
399+
)
400+
await axon_stream.response.aclose()
401+
402+
@parametrize
403+
async def test_method_subscribe_sse_with_all_params(self, async_client: AsyncRunloop) -> None:
404+
axon_stream = await async_client.axons.subscribe_sse(
405+
id="id",
406+
after_sequence=0,
391407
)
392408
await axon_stream.response.aclose()
393409

394410
@parametrize
395411
async def test_raw_response_subscribe_sse(self, async_client: AsyncRunloop) -> None:
396412
response = await async_client.axons.with_raw_response.subscribe_sse(
397-
"id",
413+
id="id",
398414
)
399415

400416
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -404,7 +420,7 @@ async def test_raw_response_subscribe_sse(self, async_client: AsyncRunloop) -> N
404420
@parametrize
405421
async def test_streaming_response_subscribe_sse(self, async_client: AsyncRunloop) -> None:
406422
async with async_client.axons.with_streaming_response.subscribe_sse(
407-
"id",
423+
id="id",
408424
) as response:
409425
assert not response.is_closed
410426
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -418,5 +434,5 @@ async def test_streaming_response_subscribe_sse(self, async_client: AsyncRunloop
418434
async def test_path_params_subscribe_sse(self, async_client: AsyncRunloop) -> None:
419435
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
420436
await async_client.axons.with_raw_response.subscribe_sse(
421-
"",
437+
id="",
422438
)

0 commit comments

Comments
 (0)