Skip to content

Commit 6a13d99

Browse files
feat: feat(workers): adds Workers > Observability > Live Tail resources
* feat(workers): adds Workers > Observability > Live Tail resources Add live_tail and live_tail_heartbeat methods to the existing telemetry subresource under workers.observability in openapi.stainless.yml. Endpoints added: - live_tail: POST /accounts/{account_id}/workers/observability/telemetry/live-tail - live_tail_heartbeat: POST /accounts/{account_id}/workers/observability/telemetry/live-tail/heartbeat
1 parent 5ea6509 commit 6a13d99

8 files changed

Lines changed: 698 additions & 3 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 2284
1+
configured_endpoints: 2286
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a6c352830d1270d0abb5bb983058ea21815e1bb7d2e163965335dcb0e706f057.yml
33
openapi_spec_hash: a16b95a38a0bcd8cdf50db63a134c8e5
4-
config_hash: da2dc3241e27d1ad4b69d3308e9a967d
4+
config_hash: ba6cf073c640c5e37cacad354448483c

src/cloudflare/resources/workers/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ Types:
307307
```python
308308
from cloudflare.types.workers.observability import (
309309
TelemetryKeysResponse,
310+
TelemetryLiveTailResponse,
310311
TelemetryQueryResponse,
311312
TelemetryValuesResponse,
312313
)
@@ -315,6 +316,8 @@ from cloudflare.types.workers.observability import (
315316
Methods:
316317

317318
- <code title="post /accounts/{account_id}/workers/observability/telemetry/keys">client.workers.observability.telemetry.<a href="./src/cloudflare/resources/workers/observability/telemetry.py">keys</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/observability/telemetry_keys_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/observability/telemetry_keys_response.py">SyncSinglePage[TelemetryKeysResponse]</a></code>
319+
- <code title="post /accounts/{account_id}/workers/observability/telemetry/live-tail">client.workers.observability.telemetry.<a href="./src/cloudflare/resources/workers/observability/telemetry.py">live_tail</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/observability/telemetry_live_tail_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/observability/telemetry_live_tail_response.py">TelemetryLiveTailResponse</a></code>
320+
- <code title="post /accounts/{account_id}/workers/observability/telemetry/live-tail/heartbeat">client.workers.observability.telemetry.<a href="./src/cloudflare/resources/workers/observability/telemetry.py">live_tail_heartbeat</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/observability/telemetry_live_tail_heartbeat_params.py">params</a>) -> object</code>
318321
- <code title="post /accounts/{account_id}/workers/observability/telemetry/query">client.workers.observability.telemetry.<a href="./src/cloudflare/resources/workers/observability/telemetry.py">query</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/observability/telemetry_query_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/observability/telemetry_query_response.py">TelemetryQueryResponse</a></code>
319322
- <code title="post /accounts/{account_id}/workers/observability/telemetry/values">client.workers.observability.telemetry.<a href="./src/cloudflare/resources/workers/observability/telemetry.py">values</a>(\*, account_id, \*\*<a href="src/cloudflare/types/workers/observability/telemetry_values_params.py">params</a>) -> <a href="./src/cloudflare/types/workers/observability/telemetry_values_response.py">SyncSinglePage[TelemetryValuesResponse]</a></code>
320323

src/cloudflare/resources/workers/observability/telemetry.py

Lines changed: 222 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@
2020
from ...._wrappers import ResultWrapper
2121
from ....pagination import SyncSinglePage, AsyncSinglePage
2222
from ...._base_client import AsyncPaginator, make_request_options
23-
from ....types.workers.observability import telemetry_keys_params, telemetry_query_params, telemetry_values_params
23+
from ....types.workers.observability import (
24+
telemetry_keys_params,
25+
telemetry_query_params,
26+
telemetry_values_params,
27+
telemetry_live_tail_params,
28+
telemetry_live_tail_heartbeat_params,
29+
)
2430
from ....types.workers.observability.telemetry_keys_response import TelemetryKeysResponse
2531
from ....types.workers.observability.telemetry_query_response import TelemetryQueryResponse
2632
from ....types.workers.observability.telemetry_values_response import TelemetryValuesResponse
33+
from ....types.workers.observability.telemetry_live_tail_response import TelemetryLiveTailResponse
2734

2835
__all__ = ["TelemetryResource", "AsyncTelemetryResource"]
2936

@@ -115,6 +122,101 @@ def keys(
115122
method="post",
116123
)
117124

125+
def live_tail(
126+
self,
127+
*,
128+
account_id: str,
129+
filter_combination: Literal["and", "or", "AND", "OR"] | Omit = omit,
130+
filters: Iterable[telemetry_live_tail_params.Filter] | Omit = omit,
131+
script_id: str | Omit = omit,
132+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
133+
# The extra values given here take precedence over values defined on the client or passed to this method.
134+
extra_headers: Headers | None = None,
135+
extra_query: Query | None = None,
136+
extra_body: Body | None = None,
137+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
138+
) -> TelemetryLiveTailResponse:
139+
"""
140+
Prepare websocket server for live tail.
141+
142+
Args:
143+
filter_combination: Set a flag to describe how to combine the filters on the query.
144+
145+
filters: Apply filters to the query. Supports nested groups via kind: 'group'.
146+
147+
extra_headers: Send extra headers
148+
149+
extra_query: Add additional query parameters to the request
150+
151+
extra_body: Add additional JSON properties to the request
152+
153+
timeout: Override the client-level default timeout for this request, in seconds
154+
"""
155+
if not account_id:
156+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
157+
return self._post(
158+
path_template("/accounts/{account_id}/workers/observability/telemetry/live-tail", account_id=account_id),
159+
body=maybe_transform(
160+
{
161+
"filter_combination": filter_combination,
162+
"filters": filters,
163+
"script_id": script_id,
164+
},
165+
telemetry_live_tail_params.TelemetryLiveTailParams,
166+
),
167+
options=make_request_options(
168+
extra_headers=extra_headers,
169+
extra_query=extra_query,
170+
extra_body=extra_body,
171+
timeout=timeout,
172+
post_parser=ResultWrapper[TelemetryLiveTailResponse]._unwrapper,
173+
),
174+
cast_to=cast(Type[TelemetryLiveTailResponse], ResultWrapper[TelemetryLiveTailResponse]),
175+
)
176+
177+
def live_tail_heartbeat(
178+
self,
179+
*,
180+
account_id: str,
181+
script_id: str | Omit = omit,
182+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
183+
# The extra values given here take precedence over values defined on the client or passed to this method.
184+
extra_headers: Headers | None = None,
185+
extra_query: Query | None = None,
186+
extra_body: Body | None = None,
187+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
188+
) -> object:
189+
"""
190+
Notify live tail that user is still eligible to receive live events.
191+
192+
Args:
193+
extra_headers: Send extra headers
194+
195+
extra_query: Add additional query parameters to the request
196+
197+
extra_body: Add additional JSON properties to the request
198+
199+
timeout: Override the client-level default timeout for this request, in seconds
200+
"""
201+
if not account_id:
202+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
203+
return self._post(
204+
path_template(
205+
"/accounts/{account_id}/workers/observability/telemetry/live-tail/heartbeat", account_id=account_id
206+
),
207+
body=maybe_transform(
208+
{"script_id": script_id}, telemetry_live_tail_heartbeat_params.TelemetryLiveTailHeartbeatParams
209+
),
210+
options=make_request_options(
211+
extra_headers=extra_headers,
212+
extra_query=extra_query,
213+
extra_body=extra_body,
214+
timeout=timeout,
215+
post_parser=ResultWrapper[object]._unwrapper,
216+
),
217+
cast_to=cast(Type[object], ResultWrapper[object]),
218+
)
219+
118220
def query(
119221
self,
120222
*,
@@ -377,6 +479,101 @@ def keys(
377479
method="post",
378480
)
379481

482+
async def live_tail(
483+
self,
484+
*,
485+
account_id: str,
486+
filter_combination: Literal["and", "or", "AND", "OR"] | Omit = omit,
487+
filters: Iterable[telemetry_live_tail_params.Filter] | Omit = omit,
488+
script_id: str | Omit = omit,
489+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
490+
# The extra values given here take precedence over values defined on the client or passed to this method.
491+
extra_headers: Headers | None = None,
492+
extra_query: Query | None = None,
493+
extra_body: Body | None = None,
494+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
495+
) -> TelemetryLiveTailResponse:
496+
"""
497+
Prepare websocket server for live tail.
498+
499+
Args:
500+
filter_combination: Set a flag to describe how to combine the filters on the query.
501+
502+
filters: Apply filters to the query. Supports nested groups via kind: 'group'.
503+
504+
extra_headers: Send extra headers
505+
506+
extra_query: Add additional query parameters to the request
507+
508+
extra_body: Add additional JSON properties to the request
509+
510+
timeout: Override the client-level default timeout for this request, in seconds
511+
"""
512+
if not account_id:
513+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
514+
return await self._post(
515+
path_template("/accounts/{account_id}/workers/observability/telemetry/live-tail", account_id=account_id),
516+
body=await async_maybe_transform(
517+
{
518+
"filter_combination": filter_combination,
519+
"filters": filters,
520+
"script_id": script_id,
521+
},
522+
telemetry_live_tail_params.TelemetryLiveTailParams,
523+
),
524+
options=make_request_options(
525+
extra_headers=extra_headers,
526+
extra_query=extra_query,
527+
extra_body=extra_body,
528+
timeout=timeout,
529+
post_parser=ResultWrapper[TelemetryLiveTailResponse]._unwrapper,
530+
),
531+
cast_to=cast(Type[TelemetryLiveTailResponse], ResultWrapper[TelemetryLiveTailResponse]),
532+
)
533+
534+
async def live_tail_heartbeat(
535+
self,
536+
*,
537+
account_id: str,
538+
script_id: str | Omit = omit,
539+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
540+
# The extra values given here take precedence over values defined on the client or passed to this method.
541+
extra_headers: Headers | None = None,
542+
extra_query: Query | None = None,
543+
extra_body: Body | None = None,
544+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
545+
) -> object:
546+
"""
547+
Notify live tail that user is still eligible to receive live events.
548+
549+
Args:
550+
extra_headers: Send extra headers
551+
552+
extra_query: Add additional query parameters to the request
553+
554+
extra_body: Add additional JSON properties to the request
555+
556+
timeout: Override the client-level default timeout for this request, in seconds
557+
"""
558+
if not account_id:
559+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
560+
return await self._post(
561+
path_template(
562+
"/accounts/{account_id}/workers/observability/telemetry/live-tail/heartbeat", account_id=account_id
563+
),
564+
body=await async_maybe_transform(
565+
{"script_id": script_id}, telemetry_live_tail_heartbeat_params.TelemetryLiveTailHeartbeatParams
566+
),
567+
options=make_request_options(
568+
extra_headers=extra_headers,
569+
extra_query=extra_query,
570+
extra_body=extra_body,
571+
timeout=timeout,
572+
post_parser=ResultWrapper[object]._unwrapper,
573+
),
574+
cast_to=cast(Type[object], ResultWrapper[object]),
575+
)
576+
380577
async def query(
381578
self,
382579
*,
@@ -559,6 +756,12 @@ def __init__(self, telemetry: TelemetryResource) -> None:
559756
self.keys = to_raw_response_wrapper(
560757
telemetry.keys,
561758
)
759+
self.live_tail = to_raw_response_wrapper(
760+
telemetry.live_tail,
761+
)
762+
self.live_tail_heartbeat = to_raw_response_wrapper(
763+
telemetry.live_tail_heartbeat,
764+
)
562765
self.query = to_raw_response_wrapper(
563766
telemetry.query,
564767
)
@@ -574,6 +777,12 @@ def __init__(self, telemetry: AsyncTelemetryResource) -> None:
574777
self.keys = async_to_raw_response_wrapper(
575778
telemetry.keys,
576779
)
780+
self.live_tail = async_to_raw_response_wrapper(
781+
telemetry.live_tail,
782+
)
783+
self.live_tail_heartbeat = async_to_raw_response_wrapper(
784+
telemetry.live_tail_heartbeat,
785+
)
577786
self.query = async_to_raw_response_wrapper(
578787
telemetry.query,
579788
)
@@ -589,6 +798,12 @@ def __init__(self, telemetry: TelemetryResource) -> None:
589798
self.keys = to_streamed_response_wrapper(
590799
telemetry.keys,
591800
)
801+
self.live_tail = to_streamed_response_wrapper(
802+
telemetry.live_tail,
803+
)
804+
self.live_tail_heartbeat = to_streamed_response_wrapper(
805+
telemetry.live_tail_heartbeat,
806+
)
592807
self.query = to_streamed_response_wrapper(
593808
telemetry.query,
594809
)
@@ -604,6 +819,12 @@ def __init__(self, telemetry: AsyncTelemetryResource) -> None:
604819
self.keys = async_to_streamed_response_wrapper(
605820
telemetry.keys,
606821
)
822+
self.live_tail = async_to_streamed_response_wrapper(
823+
telemetry.live_tail,
824+
)
825+
self.live_tail_heartbeat = async_to_streamed_response_wrapper(
826+
telemetry.live_tail_heartbeat,
827+
)
607828
self.query = async_to_streamed_response_wrapper(
608829
telemetry.query,
609830
)

src/cloudflare/types/workers/observability/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from .destination_list_response import DestinationListResponse as DestinationListResponse
1717
from .destination_update_params import DestinationUpdateParams as DestinationUpdateParams
1818
from .telemetry_values_response import TelemetryValuesResponse as TelemetryValuesResponse
19+
from .telemetry_live_tail_params import TelemetryLiveTailParams as TelemetryLiveTailParams
1920
from .destination_create_response import DestinationCreateResponse as DestinationCreateResponse
2021
from .destination_delete_response import DestinationDeleteResponse as DestinationDeleteResponse
2122
from .destination_update_response import DestinationUpdateResponse as DestinationUpdateResponse
23+
from .telemetry_live_tail_response import TelemetryLiveTailResponse as TelemetryLiveTailResponse
24+
from .telemetry_live_tail_heartbeat_params import TelemetryLiveTailHeartbeatParams as TelemetryLiveTailHeartbeatParams
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 Required, Annotated, TypedDict
6+
7+
from ...._utils import PropertyInfo
8+
9+
__all__ = ["TelemetryLiveTailHeartbeatParams"]
10+
11+
12+
class TelemetryLiveTailHeartbeatParams(TypedDict, total=False):
13+
account_id: Required[str]
14+
15+
script_id: Annotated[str, PropertyInfo(alias="scriptId")]

0 commit comments

Comments
 (0)