Skip to content

Commit 5a5d64f

Browse files
feat: Add order=desc pagination to telemetry event reads
1 parent bd4f0ff commit 5a5d64f

4 files changed

Lines changed: 45 additions & 12 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: 125
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-ea36e417a5dbc80a7dab65b38bd6c892520929d31363e626a3341436d697a17c.yml
3-
openapi_spec_hash: fb15f771cbf9c937a4674f23f9a56050
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-ebbe079bb2542625826422afd876a3e8b499c579cf45efc5fd50e7982d34df7d.yml
3+
openapi_spec_hash: db850b61a0d71fe9f4b642df8782d7ae
44
config_hash: 06186eb40e0058a2a87ac251fc07415d

src/kernel/resources/browsers/telemetry.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def events(
7070
| Omit = omit,
7171
limit: int | Omit = omit,
7272
offset: int | Omit = omit,
73+
order: str | Omit = omit,
7374
since: str | Omit = omit,
7475
until: str | Omit = omit,
7576
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -79,11 +80,12 @@ def events(
7980
extra_body: Body | None = None,
8081
timeout: float | httpx.Timeout | None | NotGiven = not_given,
8182
) -> SyncOffsetPagination[TelemetryEventsResponse]:
82-
"""
83-
Reads a page of telemetry events for the browser session in ascending sequence
84-
order. To page through results, pass the X-Next-Offset value from the previous
85-
response as offset and repeat while X-Has-More is true. Returns an empty list
86-
when telemetry data is unavailable.
83+
"""Reads a page of telemetry events for the browser session.
84+
85+
To page through
86+
results, pass the X-Next-Offset value from the previous response as offset and
87+
repeat while X-Has-More is true. Returns an empty list when telemetry data is
88+
unavailable.
8789
8890
Args:
8991
category: Restrict results to these event categories. Repeat the parameter for multiple
@@ -96,6 +98,13 @@ def events(
9698
since is ignored, while until still bounds the page. It is not an event's seq
9799
field, so do not derive it from the response body.
98100
101+
order: Read direction. asc (default) reads oldest first, starting from since or the
102+
offset cursor. desc reads newest first: each request returns one page of up to
103+
limit records ending at the offset cursor (or until, or the newest archived
104+
event); combining desc with since is rejected with a 400. In either direction
105+
the category filter applies within the page, so a filtered page may be empty
106+
while X-Has-More is true.
107+
99108
since: Start of the window: an RFC-3339 timestamp, or a duration like 5m meaning that
100109
long ago. Defaults to 5m. Ignored when offset is set.
101110
@@ -125,6 +134,7 @@ def events(
125134
"category": category,
126135
"limit": limit,
127136
"offset": offset,
137+
"order": order,
128138
"since": since,
129139
"until": until,
130140
},
@@ -234,6 +244,7 @@ def events(
234244
| Omit = omit,
235245
limit: int | Omit = omit,
236246
offset: int | Omit = omit,
247+
order: str | Omit = omit,
237248
since: str | Omit = omit,
238249
until: str | Omit = omit,
239250
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -243,11 +254,12 @@ def events(
243254
extra_body: Body | None = None,
244255
timeout: float | httpx.Timeout | None | NotGiven = not_given,
245256
) -> AsyncPaginator[TelemetryEventsResponse, AsyncOffsetPagination[TelemetryEventsResponse]]:
246-
"""
247-
Reads a page of telemetry events for the browser session in ascending sequence
248-
order. To page through results, pass the X-Next-Offset value from the previous
249-
response as offset and repeat while X-Has-More is true. Returns an empty list
250-
when telemetry data is unavailable.
257+
"""Reads a page of telemetry events for the browser session.
258+
259+
To page through
260+
results, pass the X-Next-Offset value from the previous response as offset and
261+
repeat while X-Has-More is true. Returns an empty list when telemetry data is
262+
unavailable.
251263
252264
Args:
253265
category: Restrict results to these event categories. Repeat the parameter for multiple
@@ -260,6 +272,13 @@ def events(
260272
since is ignored, while until still bounds the page. It is not an event's seq
261273
field, so do not derive it from the response body.
262274
275+
order: Read direction. asc (default) reads oldest first, starting from since or the
276+
offset cursor. desc reads newest first: each request returns one page of up to
277+
limit records ending at the offset cursor (or until, or the newest archived
278+
event); combining desc with since is rejected with a 400. In either direction
279+
the category filter applies within the page, so a filtered page may be empty
280+
while X-Has-More is true.
281+
263282
since: Start of the window: an RFC-3339 timestamp, or a duration like 5m meaning that
264283
long ago. Defaults to 5m. Ignored when offset is set.
265284
@@ -289,6 +308,7 @@ def events(
289308
"category": category,
290309
"limit": limit,
291310
"offset": offset,
311+
"order": order,
292312
"since": since,
293313
"until": until,
294314
},

src/kernel/types/browsers/telemetry_events_params.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ class TelemetryEventsParams(TypedDict, total=False):
3939
field, so do not derive it from the response body.
4040
"""
4141

42+
order: str
43+
"""Read direction.
44+
45+
asc (default) reads oldest first, starting from since or the offset cursor. desc
46+
reads newest first: each request returns one page of up to limit records ending
47+
at the offset cursor (or until, or the newest archived event); combining desc
48+
with since is rejected with a 400. In either direction the category filter
49+
applies within the page, so a filtered page may be empty while X-Has-More is
50+
true.
51+
"""
52+
4253
since: str
4354
"""
4455
Start of the window: an RFC-3339 timestamp, or a duration like 5m meaning that

tests/api_resources/browsers/test_telemetry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_method_events_with_all_params(self, client: Kernel) -> None:
3434
category=["console"],
3535
limit=1,
3636
offset=0,
37+
order="order",
3738
since="since",
3839
until="until",
3940
)
@@ -146,6 +147,7 @@ async def test_method_events_with_all_params(self, async_client: AsyncKernel) ->
146147
category=["console"],
147148
limit=1,
148149
offset=0,
150+
order="order",
149151
since="since",
150152
until="until",
151153
)

0 commit comments

Comments
 (0)