2020from ...._wrappers import ResultWrapper
2121from ....pagination import SyncSinglePage , AsyncSinglePage
2222from ...._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+ )
2430from ....types .workers .observability .telemetry_keys_response import TelemetryKeysResponse
2531from ....types .workers .observability .telemetry_query_response import TelemetryQueryResponse
2632from ....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 )
0 commit comments