Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 1680
configured_endpoints: 1681
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-22aa409339ba3ba4e61a86e7e94dc5a66082c5c20615d1d30e3b9499d6407e31.yml
openapi_spec_hash: e5eb84a55caa82c6dfdc82b7fbe3e8aa
config_hash: 713ebf60a015dd910800437b34425bea
config_hash: 6861676932ec6aacb336d1cdc59ca521
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9255,6 +9255,18 @@ Methods:

- <code title="patch /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status">client.workflows.instances.status.<a href="./src/cloudflare/resources/workflows/instances/status.py">edit</a>(instance_id, \*, account_id, workflow_name, \*\*<a href="src/cloudflare/types/workflows/instances/status_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instances/status_edit_response.py">StatusEditResponse</a></code>

### Events

Types:

```python
from cloudflare.types.workflows.instances import EventCreateResponse
```

Methods:

- <code title="post /accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}">client.workflows.instances.events.<a href="./src/cloudflare/resources/workflows/instances/events.py">create</a>(event_type, \*, account_id, workflow_name, instance_id, \*\*<a href="src/cloudflare/types/workflows/instances/event_create_params.py">params</a>) -> <a href="./src/cloudflare/types/workflows/instances/event_create_response.py">object</a></code>

## Versions

Types:
Expand Down
14 changes: 14 additions & 0 deletions src/cloudflare/resources/workflows/instances/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .events import (
EventsResource,
AsyncEventsResource,
EventsResourceWithRawResponse,
AsyncEventsResourceWithRawResponse,
EventsResourceWithStreamingResponse,
AsyncEventsResourceWithStreamingResponse,
)
from .status import (
StatusResource,
AsyncStatusResource,
Expand All @@ -24,6 +32,12 @@
"AsyncStatusResourceWithRawResponse",
"StatusResourceWithStreamingResponse",
"AsyncStatusResourceWithStreamingResponse",
"EventsResource",
"AsyncEventsResource",
"EventsResourceWithRawResponse",
"AsyncEventsResourceWithRawResponse",
"EventsResourceWithStreamingResponse",
"AsyncEventsResourceWithStreamingResponse",
"InstancesResource",
"AsyncInstancesResource",
"InstancesResourceWithRawResponse",
Expand Down
200 changes: 200 additions & 0 deletions src/cloudflare/resources/workflows/instances/events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Type, Optional, cast

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import (
maybe_transform,
async_maybe_transform,
)
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ...._base_client import make_request_options
from ....types.workflows.instances import event_create_params

__all__ = ["EventsResource", "AsyncEventsResource"]


class EventsResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> EventsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
"""
return EventsResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> EventsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
"""
return EventsResourceWithStreamingResponse(self)

def create(
self,
event_type: str,
*,
account_id: str,
workflow_name: str,
instance_id: str,
body: object | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
Send event to instance

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not workflow_name:
raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}")
if not instance_id:
raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}")
if not event_type:
raise ValueError(f"Expected a non-empty value for `event_type` but received {event_type!r}")
return self._post(
f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}",
body=maybe_transform(body, event_create_params.EventCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[object]]._unwrapper,
),
cast_to=cast(Type[object], ResultWrapper[object]),
)


class AsyncEventsResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncEventsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers
"""
return AsyncEventsResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncEventsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response
"""
return AsyncEventsResourceWithStreamingResponse(self)

async def create(
self,
event_type: str,
*,
account_id: str,
workflow_name: str,
instance_id: str,
body: object | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
Send event to instance

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not workflow_name:
raise ValueError(f"Expected a non-empty value for `workflow_name` but received {workflow_name!r}")
if not instance_id:
raise ValueError(f"Expected a non-empty value for `instance_id` but received {instance_id!r}")
if not event_type:
raise ValueError(f"Expected a non-empty value for `event_type` but received {event_type!r}")
return await self._post(
f"/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}",
body=await async_maybe_transform(body, event_create_params.EventCreateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[Optional[object]]._unwrapper,
),
cast_to=cast(Type[object], ResultWrapper[object]),
)


class EventsResourceWithRawResponse:
def __init__(self, events: EventsResource) -> None:
self._events = events

self.create = to_raw_response_wrapper(
events.create,
)


class AsyncEventsResourceWithRawResponse:
def __init__(self, events: AsyncEventsResource) -> None:
self._events = events

self.create = async_to_raw_response_wrapper(
events.create,
)


class EventsResourceWithStreamingResponse:
def __init__(self, events: EventsResource) -> None:
self._events = events

self.create = to_streamed_response_wrapper(
events.create,
)


class AsyncEventsResourceWithStreamingResponse:
def __init__(self, events: AsyncEventsResource) -> None:
self._events = events

self.create = async_to_streamed_response_wrapper(
events.create,
)
32 changes: 32 additions & 0 deletions src/cloudflare/resources/workflows/instances/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

import httpx

from .events import (
EventsResource,
AsyncEventsResource,
EventsResourceWithRawResponse,
AsyncEventsResourceWithRawResponse,
EventsResourceWithStreamingResponse,
AsyncEventsResourceWithStreamingResponse,
)
from .status import (
StatusResource,
AsyncStatusResource,
Expand Down Expand Up @@ -46,6 +54,10 @@ class InstancesResource(SyncAPIResource):
def status(self) -> StatusResource:
return StatusResource(self._client)

@cached_property
def events(self) -> EventsResource:
return EventsResource(self._client)

@cached_property
def with_raw_response(self) -> InstancesResourceWithRawResponse:
"""
Expand Down Expand Up @@ -265,6 +277,10 @@ class AsyncInstancesResource(AsyncAPIResource):
def status(self) -> AsyncStatusResource:
return AsyncStatusResource(self._client)

@cached_property
def events(self) -> AsyncEventsResource:
return AsyncEventsResource(self._client)

@cached_property
def with_raw_response(self) -> AsyncInstancesResourceWithRawResponse:
"""
Expand Down Expand Up @@ -500,6 +516,10 @@ def __init__(self, instances: InstancesResource) -> None:
def status(self) -> StatusResourceWithRawResponse:
return StatusResourceWithRawResponse(self._instances.status)

@cached_property
def events(self) -> EventsResourceWithRawResponse:
return EventsResourceWithRawResponse(self._instances.events)


class AsyncInstancesResourceWithRawResponse:
def __init__(self, instances: AsyncInstancesResource) -> None:
Expand All @@ -522,6 +542,10 @@ def __init__(self, instances: AsyncInstancesResource) -> None:
def status(self) -> AsyncStatusResourceWithRawResponse:
return AsyncStatusResourceWithRawResponse(self._instances.status)

@cached_property
def events(self) -> AsyncEventsResourceWithRawResponse:
return AsyncEventsResourceWithRawResponse(self._instances.events)


class InstancesResourceWithStreamingResponse:
def __init__(self, instances: InstancesResource) -> None:
Expand All @@ -544,6 +568,10 @@ def __init__(self, instances: InstancesResource) -> None:
def status(self) -> StatusResourceWithStreamingResponse:
return StatusResourceWithStreamingResponse(self._instances.status)

@cached_property
def events(self) -> EventsResourceWithStreamingResponse:
return EventsResourceWithStreamingResponse(self._instances.events)


class AsyncInstancesResourceWithStreamingResponse:
def __init__(self, instances: AsyncInstancesResource) -> None:
Expand All @@ -565,3 +593,7 @@ def __init__(self, instances: AsyncInstancesResource) -> None:
@cached_property
def status(self) -> AsyncStatusResourceWithStreamingResponse:
return AsyncStatusResourceWithStreamingResponse(self._instances.status)

@cached_property
def events(self) -> AsyncEventsResourceWithStreamingResponse:
return AsyncEventsResourceWithStreamingResponse(self._instances.events)
1 change: 1 addition & 0 deletions src/cloudflare/types/workflows/instances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
from __future__ import annotations

from .status_edit_params import StatusEditParams as StatusEditParams
from .event_create_params import EventCreateParams as EventCreateParams
from .status_edit_response import StatusEditResponse as StatusEditResponse
17 changes: 17 additions & 0 deletions src/cloudflare/types/workflows/instances/event_create_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Required, TypedDict

__all__ = ["EventCreateParams"]


class EventCreateParams(TypedDict, total=False):
account_id: Required[str]

workflow_name: Required[str]

instance_id: Required[str]

body: object
Loading