1919from ..._constants import DEFAULT_TIMEOUT
2020from ..._exceptions import APIStatusError , APITimeoutError
2121from ...lib .polling import PollingConfig , poll_until
22+ from ..._streaming import Stream , AsyncStream
2223from ..._base_client import make_request_options
23- from ...types .devboxes import execution_retrieve_params , execution_execute_sync_params , execution_execute_async_params
24+ from ...types .devboxes import (
25+ execution_kill_params ,
26+ execution_retrieve_params ,
27+ execution_execute_sync_params ,
28+ execution_execute_async_params ,
29+ execution_stream_updates_params ,
30+ )
2431from ...lib .polling_async import async_poll_until
2532from ...types .devbox_execution_detail_view import DevboxExecutionDetailView
33+ from ...types .devboxes .execution_update_chunk import ExecutionUpdateChunk
2634from ...types .devbox_async_execution_detail_view import DevboxAsyncExecutionDetailView
2735
2836__all__ = ["ExecutionsResource" , "AsyncExecutionsResource" ]
@@ -277,6 +285,7 @@ def kill(
277285 execution_id : str ,
278286 * ,
279287 devbox_id : str ,
288+ kill_process_group : Optional [bool ] | NotGiven = NOT_GIVEN ,
280289 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
281290 # The extra values given here take precedence over values defined on the client or passed to this method.
282291 extra_headers : Headers | None = None ,
@@ -287,7 +296,7 @@ def kill(
287296 ) -> DevboxAsyncExecutionDetailView :
288297 """
289298 Kill a previously launched asynchronous execution if it is still running by
290- killing the launched process.
299+ killing the launched process. Optionally kill the entire process group.
291300
292301 Args:
293302 extra_headers: Send extra headers
@@ -306,6 +315,7 @@ def kill(
306315 raise ValueError (f"Expected a non-empty value for `execution_id` but received { execution_id !r} " )
307316 return self ._post (
308317 f"/v1/devboxes/{ devbox_id } /executions/{ execution_id } /kill" ,
318+ body = maybe_transform ({"kill_process_group" : kill_process_group }, execution_kill_params .ExecutionKillParams ),
309319 options = make_request_options (
310320 extra_headers = extra_headers ,
311321 extra_query = extra_query ,
@@ -316,6 +326,51 @@ def kill(
316326 cast_to = DevboxAsyncExecutionDetailView ,
317327 )
318328
329+ def stream_updates (
330+ self ,
331+ execution_id : str ,
332+ * ,
333+ devbox_id : str ,
334+ offset : str | NotGiven = NOT_GIVEN ,
335+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
336+ # The extra values given here take precedence over values defined on the client or passed to this method.
337+ extra_headers : Headers | None = None ,
338+ extra_query : Query | None = None ,
339+ extra_body : Body | None = None ,
340+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
341+ ) -> Stream [ExecutionUpdateChunk ]:
342+ """
343+ Tails the logs for the given execution with SSE streaming
344+
345+ Args:
346+ offset: The byte offset to start the stream from
347+
348+ extra_headers: Send extra headers
349+
350+ extra_query: Add additional query parameters to the request
351+
352+ extra_body: Add additional JSON properties to the request
353+
354+ timeout: Override the client-level default timeout for this request, in seconds
355+ """
356+ if not devbox_id :
357+ raise ValueError (f"Expected a non-empty value for `devbox_id` but received { devbox_id !r} " )
358+ if not execution_id :
359+ raise ValueError (f"Expected a non-empty value for `execution_id` but received { execution_id !r} " )
360+ return self ._get (
361+ f"/v1/devboxes/{ devbox_id } /executions/{ execution_id } /stream_updates" ,
362+ options = make_request_options (
363+ extra_headers = extra_headers ,
364+ extra_query = extra_query ,
365+ extra_body = extra_body ,
366+ timeout = timeout ,
367+ query = maybe_transform ({"offset" : offset }, execution_stream_updates_params .ExecutionStreamUpdatesParams ),
368+ ),
369+ cast_to = DevboxAsyncExecutionDetailView ,
370+ stream = True ,
371+ stream_cls = Stream [ExecutionUpdateChunk ],
372+ )
373+
319374
320375class AsyncExecutionsResource (AsyncAPIResource ):
321376 @cached_property
@@ -554,6 +609,7 @@ async def kill(
554609 execution_id : str ,
555610 * ,
556611 devbox_id : str ,
612+ kill_process_group : Optional [bool ] | NotGiven = NOT_GIVEN ,
557613 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
558614 # The extra values given here take precedence over values defined on the client or passed to this method.
559615 extra_headers : Headers | None = None ,
@@ -564,7 +620,7 @@ async def kill(
564620 ) -> DevboxAsyncExecutionDetailView :
565621 """
566622 Kill a previously launched asynchronous execution if it is still running by
567- killing the launched process.
623+ killing the launched process. Optionally kill the entire process group.
568624
569625 Args:
570626 extra_headers: Send extra headers
@@ -583,6 +639,9 @@ async def kill(
583639 raise ValueError (f"Expected a non-empty value for `execution_id` but received { execution_id !r} " )
584640 return await self ._post (
585641 f"/v1/devboxes/{ devbox_id } /executions/{ execution_id } /kill" ,
642+ body = await async_maybe_transform (
643+ {"kill_process_group" : kill_process_group }, execution_kill_params .ExecutionKillParams
644+ ),
586645 options = make_request_options (
587646 extra_headers = extra_headers ,
588647 extra_query = extra_query ,
@@ -593,6 +652,53 @@ async def kill(
593652 cast_to = DevboxAsyncExecutionDetailView ,
594653 )
595654
655+ async def stream_updates (
656+ self ,
657+ execution_id : str ,
658+ * ,
659+ devbox_id : str ,
660+ offset : str | NotGiven = NOT_GIVEN ,
661+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
662+ # The extra values given here take precedence over values defined on the client or passed to this method.
663+ extra_headers : Headers | None = None ,
664+ extra_query : Query | None = None ,
665+ extra_body : Body | None = None ,
666+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
667+ ) -> AsyncStream [ExecutionUpdateChunk ]:
668+ """
669+ Tails the logs for the given execution with SSE streaming
670+
671+ Args:
672+ offset: The byte offset to start the stream from
673+
674+ extra_headers: Send extra headers
675+
676+ extra_query: Add additional query parameters to the request
677+
678+ extra_body: Add additional JSON properties to the request
679+
680+ timeout: Override the client-level default timeout for this request, in seconds
681+ """
682+ if not devbox_id :
683+ raise ValueError (f"Expected a non-empty value for `devbox_id` but received { devbox_id !r} " )
684+ if not execution_id :
685+ raise ValueError (f"Expected a non-empty value for `execution_id` but received { execution_id !r} " )
686+ return await self ._get (
687+ f"/v1/devboxes/{ devbox_id } /executions/{ execution_id } /stream_updates" ,
688+ options = make_request_options (
689+ extra_headers = extra_headers ,
690+ extra_query = extra_query ,
691+ extra_body = extra_body ,
692+ timeout = timeout ,
693+ query = await async_maybe_transform (
694+ {"offset" : offset }, execution_stream_updates_params .ExecutionStreamUpdatesParams
695+ ),
696+ ),
697+ cast_to = DevboxAsyncExecutionDetailView ,
698+ stream = True ,
699+ stream_cls = AsyncStream [ExecutionUpdateChunk ],
700+ )
701+
596702
597703class ExecutionsResourceWithRawResponse :
598704 def __init__ (self , executions : ExecutionsResource ) -> None :
@@ -610,6 +716,9 @@ def __init__(self, executions: ExecutionsResource) -> None:
610716 self .kill = to_raw_response_wrapper (
611717 executions .kill ,
612718 )
719+ self .stream_updates = to_raw_response_wrapper (
720+ executions .stream_updates ,
721+ )
613722
614723
615724class AsyncExecutionsResourceWithRawResponse :
@@ -628,6 +737,9 @@ def __init__(self, executions: AsyncExecutionsResource) -> None:
628737 self .kill = async_to_raw_response_wrapper (
629738 executions .kill ,
630739 )
740+ self .stream_updates = async_to_raw_response_wrapper (
741+ executions .stream_updates ,
742+ )
631743
632744
633745class ExecutionsResourceWithStreamingResponse :
@@ -646,6 +758,9 @@ def __init__(self, executions: ExecutionsResource) -> None:
646758 self .kill = to_streamed_response_wrapper (
647759 executions .kill ,
648760 )
761+ self .stream_updates = to_streamed_response_wrapper (
762+ executions .stream_updates ,
763+ )
649764
650765
651766class AsyncExecutionsResourceWithStreamingResponse :
@@ -664,3 +779,6 @@ def __init__(self, executions: AsyncExecutionsResource) -> None:
664779 self .kill = async_to_streamed_response_wrapper (
665780 executions .kill ,
666781 )
782+ self .stream_updates = async_to_streamed_response_wrapper (
783+ executions .stream_updates ,
784+ )
0 commit comments