Skip to content

Commit ab25412

Browse files
feat: feat(api): sync workflows API endpoints (2 new)
* feat(api): sync workflows API endpoints (2 new) * chore: drop TODO(linguini) stub comments * chore: drop instances/terminate stub (now skipped from sync) * chore: sync workflows API endpoints into stainless config
1 parent 46c3cec commit ab25412

10 files changed

Lines changed: 1019 additions & 6 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 2323
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare/cloudflare-baa9c57c8cec8fa2999dd365dc419d59f0c5be8b772344ceb722e4cd08563c6f.yml
1+
configured_endpoints: 2325
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare/cloudflare-eeab7a57d84f76af6bb611b6eb115f3ab818505d7f8d09c35751d4ba4bb0788e.yml
33
openapi_spec_hash: 63308a10826084e5f64b82f361d8dcd2
4-
config_hash: d356305f9e4bef414359ff0156867a23
4+
config_hash: 3e02eec9f8dbb1c042399a4bea3363d2

src/cloudflare/resources/workflows/api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ from cloudflare.types.workflows import (
2828
InstanceListResponse,
2929
InstanceBulkResponse,
3030
InstanceGetResponse,
31+
InstanceStepResponse,
3132
)
3233
```
3334

@@ -37,6 +38,7 @@ Methods:
3738
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/instances">client.workflows.instances.<a href="./src/cloudflare/resources/workflows/instances/instances.py">list</a>(workflow_name, \*, account_id, \*\*<a href="src/cloudflare/types/workflows/instance_list_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instance_list_response.py">SyncV4PagePaginationArray[InstanceListResponse]</a></code>
3839
- <code title="post /accounts/{account_id}/workflows/{workflow_name}/instances/batch">client.workflows.instances.<a href="./src/cloudflare/resources/workflows/instances/instances.py">bulk</a>(workflow_name, \*, account_id, \*\*<a href="src/cloudflare/types/workflows/instance_bulk_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instance_bulk_response.py">SyncSinglePage[InstanceBulkResponse]</a></code>
3940
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}">client.workflows.instances.<a href="./src/cloudflare/resources/workflows/instances/instances.py">get</a>(instance_id, \*, account_id, workflow_name, \*\*<a href="src/cloudflare/types/workflows/instance_get_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instance_get_response.py">InstanceGetResponse</a></code>
41+
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/step">client.workflows.instances.<a href="./src/cloudflare/resources/workflows/instances/instances.py">step</a>(instance_id, \*, account_id, workflow_name, \*\*<a href="src/cloudflare/types/workflows/instance_step_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instance_step_response.py">InstanceStepResponse</a></code>
4042

4143
### Status
4244

@@ -61,10 +63,11 @@ Methods:
6163
Types:
6264

6365
```python
64-
from cloudflare.types.workflows import VersionListResponse, VersionGetResponse
66+
from cloudflare.types.workflows import VersionListResponse, VersionGetResponse, VersionGraphResponse
6567
```
6668

6769
Methods:
6870

6971
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/versions">client.workflows.versions.<a href="./src/cloudflare/resources/workflows/versions.py">list</a>(workflow_name, \*, account_id, \*\*<a href="src/cloudflare/types/workflows/version_list_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/version_list_response.py">SyncV4PagePaginationArray[VersionListResponse]</a></code>
7072
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}">client.workflows.versions.<a href="./src/cloudflare/resources/workflows/versions.py">get</a>(version_id, \*, account_id, workflow_name) -> <a href="./src/cloudflare/types/workflows/version_get_response.py">VersionGetResponse</a></code>
73+
- <code title="get /accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}/graph">client.workflows.versions.<a href="./src/cloudflare/resources/workflows/versions.py">graph</a>(version_id, \*, account_id, workflow_name) -> <a href="./src/cloudflare/types/workflows/version_graph_response.py">VersionGraphResponse</a></code>

src/cloudflare/resources/workflows/instances/instances.py

Lines changed: 168 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@
3737
from ...._wrappers import ResultWrapper
3838
from ....pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray
3939
from ...._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+
)
4147
from ....types.workflows.instance_get_response import InstanceGetResponse
4248
from ....types.workflows.instance_bulk_response import InstanceBulkResponse
4349
from ....types.workflows.instance_list_response import InstanceListResponse
50+
from ....types.workflows.instance_step_response import InstanceStepResponse
4451
from ....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

322403
class 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

595750
class 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

Comments
 (0)