3737from ...._wrappers import ResultWrapper
3838from ....pagination import SyncSinglePage , AsyncSinglePage , SyncV4PagePaginationArray , AsyncV4PagePaginationArray
3939from ...._base_client import AsyncPaginator , make_request_options
40- from ....types .workflows import instance_get_params , instance_bulk_params , instance_list_params , instance_create_params
40+ from ....types .workflows import (
41+ instance_get_params ,
42+ instance_bulk_params ,
43+ instance_list_params ,
44+ instance_step_params ,
45+ instance_create_params ,
46+ )
4147from ....types .workflows .instance_get_response import InstanceGetResponse
4248from ....types .workflows .instance_bulk_response import InstanceBulkResponse
4349from ....types .workflows .instance_list_response import InstanceListResponse
50+ from ....types .workflows .instance_step_response import InstanceStepResponse
4451from ....types .workflows .instance_create_response import InstanceCreateResponse
4552
4653__all__ = ["InstancesResource" , "AsyncInstancesResource" ]
@@ -318,6 +325,80 @@ def get(
318325 cast_to = cast (Type [InstanceGetResponse ], ResultWrapper [InstanceGetResponse ]),
319326 )
320327
328+ def step (
329+ self ,
330+ instance_id : str ,
331+ * ,
332+ account_id : str ,
333+ workflow_name : str ,
334+ name : str ,
335+ type : Literal ["step" , "waitForEvent" ],
336+ attempt : int | Omit = omit ,
337+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
338+ # The extra values given here take precedence over values defined on the client or passed to this method.
339+ extra_headers : Headers | None = None ,
340+ extra_query : Query | None = None ,
341+ extra_body : Body | None = None ,
342+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
343+ ) -> InstanceStepResponse :
344+ """
345+ Retrieves the full, untruncated output for a specific step on a workflow
346+ instance. Returns a flat status-shaped JSON body with step `status` ('running' |
347+ 'waiting' | 'complete' | 'errored'), `error` (nullable), and `output` (the step
348+ value, or null while running/waiting/errored). When the step returned a
349+ ReadableStream from step.do, the response is served as
350+ 'application/octet-stream' with the raw bytes as the body instead of JSON. A
351+ `status='running'` response with non-null `error` indicates the step is
352+ currently retrying after a prior attempt failed.
353+
354+ Args:
355+ name: Exact step name from the instance logs response, including the generated counter
356+ suffix.
357+
358+ type: Step type to disambiguate step.do and waitForEvent entries that share the same
359+ name.
360+
361+ attempt: Specific attempt number to retrieve output or error for.
362+
363+ extra_headers: Send extra headers
364+
365+ extra_query: Add additional query parameters to the request
366+
367+ extra_body: Add additional JSON properties to the request
368+
369+ timeout: Override the client-level default timeout for this request, in seconds
370+ """
371+ if not account_id :
372+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
373+ if not workflow_name :
374+ raise ValueError (f"Expected a non-empty value for `workflow_name` but received { workflow_name !r} " )
375+ if not instance_id :
376+ raise ValueError (f"Expected a non-empty value for `instance_id` but received { instance_id !r} " )
377+ return self ._get (
378+ path_template (
379+ "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/step" ,
380+ account_id = account_id ,
381+ workflow_name = workflow_name ,
382+ instance_id = instance_id ,
383+ ),
384+ options = make_request_options (
385+ extra_headers = extra_headers ,
386+ extra_query = extra_query ,
387+ extra_body = extra_body ,
388+ timeout = timeout ,
389+ query = maybe_transform (
390+ {
391+ "name" : name ,
392+ "type" : type ,
393+ "attempt" : attempt ,
394+ },
395+ instance_step_params .InstanceStepParams ,
396+ ),
397+ post_parser = ResultWrapper [InstanceStepResponse ]._unwrapper ,
398+ ),
399+ cast_to = cast (Type [InstanceStepResponse ], ResultWrapper [InstanceStepResponse ]),
400+ )
401+
321402
322403class AsyncInstancesResource (AsyncAPIResource ):
323404 @cached_property
@@ -591,6 +672,80 @@ async def get(
591672 cast_to = cast (Type [InstanceGetResponse ], ResultWrapper [InstanceGetResponse ]),
592673 )
593674
675+ async def step (
676+ self ,
677+ instance_id : str ,
678+ * ,
679+ account_id : str ,
680+ workflow_name : str ,
681+ name : str ,
682+ type : Literal ["step" , "waitForEvent" ],
683+ attempt : int | Omit = omit ,
684+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
685+ # The extra values given here take precedence over values defined on the client or passed to this method.
686+ extra_headers : Headers | None = None ,
687+ extra_query : Query | None = None ,
688+ extra_body : Body | None = None ,
689+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
690+ ) -> InstanceStepResponse :
691+ """
692+ Retrieves the full, untruncated output for a specific step on a workflow
693+ instance. Returns a flat status-shaped JSON body with step `status` ('running' |
694+ 'waiting' | 'complete' | 'errored'), `error` (nullable), and `output` (the step
695+ value, or null while running/waiting/errored). When the step returned a
696+ ReadableStream from step.do, the response is served as
697+ 'application/octet-stream' with the raw bytes as the body instead of JSON. A
698+ `status='running'` response with non-null `error` indicates the step is
699+ currently retrying after a prior attempt failed.
700+
701+ Args:
702+ name: Exact step name from the instance logs response, including the generated counter
703+ suffix.
704+
705+ type: Step type to disambiguate step.do and waitForEvent entries that share the same
706+ name.
707+
708+ attempt: Specific attempt number to retrieve output or error for.
709+
710+ extra_headers: Send extra headers
711+
712+ extra_query: Add additional query parameters to the request
713+
714+ extra_body: Add additional JSON properties to the request
715+
716+ timeout: Override the client-level default timeout for this request, in seconds
717+ """
718+ if not account_id :
719+ raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
720+ if not workflow_name :
721+ raise ValueError (f"Expected a non-empty value for `workflow_name` but received { workflow_name !r} " )
722+ if not instance_id :
723+ raise ValueError (f"Expected a non-empty value for `instance_id` but received { instance_id !r} " )
724+ return await self ._get (
725+ path_template (
726+ "/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/step" ,
727+ account_id = account_id ,
728+ workflow_name = workflow_name ,
729+ instance_id = instance_id ,
730+ ),
731+ options = make_request_options (
732+ extra_headers = extra_headers ,
733+ extra_query = extra_query ,
734+ extra_body = extra_body ,
735+ timeout = timeout ,
736+ query = await async_maybe_transform (
737+ {
738+ "name" : name ,
739+ "type" : type ,
740+ "attempt" : attempt ,
741+ },
742+ instance_step_params .InstanceStepParams ,
743+ ),
744+ post_parser = ResultWrapper [InstanceStepResponse ]._unwrapper ,
745+ ),
746+ cast_to = cast (Type [InstanceStepResponse ], ResultWrapper [InstanceStepResponse ]),
747+ )
748+
594749
595750class InstancesResourceWithRawResponse :
596751 def __init__ (self , instances : InstancesResource ) -> None :
@@ -608,6 +763,9 @@ def __init__(self, instances: InstancesResource) -> None:
608763 self .get = to_raw_response_wrapper (
609764 instances .get ,
610765 )
766+ self .step = to_raw_response_wrapper (
767+ instances .step ,
768+ )
611769
612770 @cached_property
613771 def status (self ) -> StatusResourceWithRawResponse :
@@ -634,6 +792,9 @@ def __init__(self, instances: AsyncInstancesResource) -> None:
634792 self .get = async_to_raw_response_wrapper (
635793 instances .get ,
636794 )
795+ self .step = async_to_raw_response_wrapper (
796+ instances .step ,
797+ )
637798
638799 @cached_property
639800 def status (self ) -> AsyncStatusResourceWithRawResponse :
@@ -660,6 +821,9 @@ def __init__(self, instances: InstancesResource) -> None:
660821 self .get = to_streamed_response_wrapper (
661822 instances .get ,
662823 )
824+ self .step = to_streamed_response_wrapper (
825+ instances .step ,
826+ )
663827
664828 @cached_property
665829 def status (self ) -> StatusResourceWithStreamingResponse :
@@ -686,6 +850,9 @@ def __init__(self, instances: AsyncInstancesResource) -> None:
686850 self .get = async_to_streamed_response_wrapper (
687851 instances .get ,
688852 )
853+ self .step = async_to_streamed_response_wrapper (
854+ instances .step ,
855+ )
689856
690857 @cached_property
691858 def status (self ) -> AsyncStatusResourceWithStreamingResponse :
0 commit comments