diff --git a/.stats.yml b/.stats.yml
index 1e98c37194c..e163d63cd95 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
configured_endpoints: 1451
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c41d5095ac6ddaaef83c817e3f7a3bbf8d609ee792e4a1f07590fdd6719da1d0.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-811ce6b3fb37e41c31b89ac40edb0f29791c03499a00e728955e3a317e664d82.yml
diff --git a/api.md b/api.md
index d8ca8a5e09d..555759435bf 100644
--- a/api.md
+++ b/api.md
@@ -2588,15 +2588,15 @@ Methods:
Types:
```python
-from cloudflare.types.queues import Queue, QueueCreated, QueueUpdated, QueueDeleteResponse
+from cloudflare.types.queues import Queue, QueueDeleteResponse
```
Methods:
-- client.queues.create(\*, account_id, \*\*params) -> Optional
-- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional
+- client.queues.create(\*, account_id, \*\*params) -> Optional
+- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional
- client.queues.list(\*, account_id) -> SyncSinglePage[Queue]
-- client.queues.delete(queue_id, \*, account_id) -> Optional
+- client.queues.delete(queue_id, \*, account_id) -> QueueDeleteResponse
- client.queues.get(queue_id, \*, account_id) -> Optional
## Consumers
@@ -2604,20 +2604,14 @@ Methods:
Types:
```python
-from cloudflare.types.queues import (
- Consumer,
- ConsumerCreateResponse,
- ConsumerUpdateResponse,
- ConsumerDeleteResponse,
- ConsumerGetResponse,
-)
+from cloudflare.types.queues import Consumer, ConsumerDeleteResponse, ConsumerGetResponse
```
Methods:
-- client.queues.consumers.create(queue_id, \*, account_id, \*\*params) -> Optional
-- client.queues.consumers.update(consumer_id, \*, account_id, queue_id, \*\*params) -> Optional
-- client.queues.consumers.delete(consumer_id, \*, account_id, queue_id) -> Optional
+- client.queues.consumers.create(queue_id, \*, account_id, \*\*params) -> Optional
+- client.queues.consumers.update(consumer_id, \*, account_id, queue_id, \*\*params) -> Optional
+- client.queues.consumers.delete(consumer_id, \*, account_id, queue_id) -> ConsumerDeleteResponse
- client.queues.consumers.get(queue_id, \*, account_id) -> Optional
## Messages
diff --git a/src/cloudflare/resources/queues/consumers.py b/src/cloudflare/resources/queues/consumers.py
index 145b4fe17b7..3eebc7a967a 100644
--- a/src/cloudflare/resources/queues/consumers.py
+++ b/src/cloudflare/resources/queues/consumers.py
@@ -2,12 +2,14 @@
from __future__ import annotations
-from typing import Type, Optional, cast
+from typing import Any, Type, Optional, cast
+from typing_extensions import Literal, overload
import httpx
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
+ required_args,
maybe_transform,
async_maybe_transform,
)
@@ -22,10 +24,9 @@
from ..._wrappers import ResultWrapper
from ..._base_client import make_request_options
from ...types.queues import consumer_create_params, consumer_update_params
+from ...types.queues.consumer import Consumer
from ...types.queues.consumer_get_response import ConsumerGetResponse
-from ...types.queues.consumer_create_response import ConsumerCreateResponse
from ...types.queues.consumer_delete_response import ConsumerDeleteResponse
-from ...types.queues.consumer_update_response import ConsumerUpdateResponse
__all__ = ["ConsumersResource", "AsyncConsumersResource"]
@@ -50,26 +51,64 @@ def with_streaming_response(self) -> ConsumersResourceWithStreamingResponse:
"""
return ConsumersResourceWithStreamingResponse(self)
+ @overload
def create(
self,
queue_id: str,
*,
account_id: str,
- body: object,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_create_params.MqWorkerConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | 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,
- ) -> Optional[ConsumerCreateResponse]:
+ ) -> Optional[Consumer]:
"""
- Creates a new consumer for a queue.
+ Creates a new consumer for a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
+
+ script_name: Name of a Worker
+
+ 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
+ """
+ ...
+
+ @overload
+ def create(
+ self,
+ queue_id: str,
+ *,
+ account_id: str,
+ settings: consumer_create_params.MqHTTPConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
+ """
+ Creates a new consumer for a Queue
+
+ Args:
+ account_id: A Resource identifier.
+
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -79,46 +118,119 @@ def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
+
+ @required_args(["account_id"])
+ def create(
+ self,
+ queue_id: str,
+ *,
+ account_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_create_params.MqWorkerConsumerSettings
+ | consumer_create_params.MqHTTPConsumerSettings
+ | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not queue_id:
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
- return self._post(
- f"/accounts/{account_id}/queues/{queue_id}/consumers",
- body=maybe_transform(body, consumer_create_params.ConsumerCreateParams),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerCreateResponse]]._unwrapper,
+ return cast(
+ Optional[Consumer],
+ self._post(
+ f"/accounts/{account_id}/queues/{queue_id}/consumers",
+ body=maybe_transform(
+ {
+ "script_name": script_name,
+ "settings": settings,
+ "type": type,
+ },
+ consumer_create_params.ConsumerCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[Consumer]]._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[Consumer]
+ ), # Union types cannot be passed in as arguments in the type system
),
- cast_to=cast(Type[Optional[ConsumerCreateResponse]], ResultWrapper[ConsumerCreateResponse]),
)
+ @overload
+ def update(
+ self,
+ consumer_id: str,
+ *,
+ account_id: str,
+ queue_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_update_params.MqWorkerConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | 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,
+ ) -> Optional[Consumer]:
+ """
+ Updates the consumer for a queue, or creates one if it does not exist.
+
+ Args:
+ account_id: A Resource identifier.
+
+ queue_id: A Resource identifier.
+
+ consumer_id: A Resource identifier.
+
+ script_name: Name of a Worker
+
+ 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
+ """
+ ...
+
+ @overload
def update(
self,
consumer_id: str,
*,
account_id: str,
queue_id: str,
- body: object,
+ settings: consumer_update_params.MqHTTPConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["http_pull"] | 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,
- ) -> Optional[ConsumerUpdateResponse]:
+ ) -> Optional[Consumer]:
"""
Updates the consumer for a queue, or creates one if it does not exist.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
- consumer_id: Identifier.
+ consumer_id: A Resource identifier.
extra_headers: Send extra headers
@@ -128,23 +240,56 @@ def update(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
+
+ @required_args(["account_id", "queue_id"])
+ def update(
+ self,
+ consumer_id: str,
+ *,
+ account_id: str,
+ queue_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_update_params.MqWorkerConsumerSettings
+ | consumer_update_params.MqHTTPConsumerSettings
+ | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not queue_id:
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
if not consumer_id:
raise ValueError(f"Expected a non-empty value for `consumer_id` but received {consumer_id!r}")
- return self._put(
- f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
- body=maybe_transform(body, consumer_update_params.ConsumerUpdateParams),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerUpdateResponse]]._unwrapper,
+ return cast(
+ Optional[Consumer],
+ self._put(
+ f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
+ body=maybe_transform(
+ {
+ "script_name": script_name,
+ "settings": settings,
+ "type": type,
+ },
+ consumer_update_params.ConsumerUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[Consumer]]._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[Consumer]
+ ), # Union types cannot be passed in as arguments in the type system
),
- cast_to=cast(Type[Optional[ConsumerUpdateResponse]], ResultWrapper[ConsumerUpdateResponse]),
)
def delete(
@@ -159,16 +304,16 @@ def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[ConsumerDeleteResponse]:
+ ) -> ConsumerDeleteResponse:
"""
Deletes the consumer for a queue.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
- consumer_id: Identifier.
+ consumer_id: A Resource identifier.
extra_headers: Send extra headers
@@ -187,13 +332,9 @@ def delete(
return self._delete(
f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerDeleteResponse]]._unwrapper,
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=cast(Type[Optional[ConsumerDeleteResponse]], ResultWrapper[ConsumerDeleteResponse]),
+ cast_to=ConsumerDeleteResponse,
)
def get(
@@ -209,12 +350,12 @@ def get(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ConsumerGetResponse]:
"""
- Returns the consumers for a queue.
+ Returns the consumers for a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -261,26 +402,64 @@ def with_streaming_response(self) -> AsyncConsumersResourceWithStreamingResponse
"""
return AsyncConsumersResourceWithStreamingResponse(self)
+ @overload
async def create(
self,
queue_id: str,
*,
account_id: str,
- body: object,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_create_params.MqWorkerConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | 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,
- ) -> Optional[ConsumerCreateResponse]:
+ ) -> Optional[Consumer]:
"""
- Creates a new consumer for a queue.
+ Creates a new consumer for a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
+
+ script_name: Name of a Worker
+
+ 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
+ """
+ ...
+
+ @overload
+ async def create(
+ self,
+ queue_id: str,
+ *,
+ account_id: str,
+ settings: consumer_create_params.MqHTTPConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
+ """
+ Creates a new consumer for a Queue
+
+ Args:
+ account_id: A Resource identifier.
+
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -290,46 +469,119 @@ async def create(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
+
+ @required_args(["account_id"])
+ async def create(
+ self,
+ queue_id: str,
+ *,
+ account_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_create_params.MqWorkerConsumerSettings
+ | consumer_create_params.MqHTTPConsumerSettings
+ | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not queue_id:
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
- return await self._post(
- f"/accounts/{account_id}/queues/{queue_id}/consumers",
- body=await async_maybe_transform(body, consumer_create_params.ConsumerCreateParams),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerCreateResponse]]._unwrapper,
+ return cast(
+ Optional[Consumer],
+ await self._post(
+ f"/accounts/{account_id}/queues/{queue_id}/consumers",
+ body=await async_maybe_transform(
+ {
+ "script_name": script_name,
+ "settings": settings,
+ "type": type,
+ },
+ consumer_create_params.ConsumerCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[Consumer]]._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[Consumer]
+ ), # Union types cannot be passed in as arguments in the type system
),
- cast_to=cast(Type[Optional[ConsumerCreateResponse]], ResultWrapper[ConsumerCreateResponse]),
)
+ @overload
+ async def update(
+ self,
+ consumer_id: str,
+ *,
+ account_id: str,
+ queue_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_update_params.MqWorkerConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | 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,
+ ) -> Optional[Consumer]:
+ """
+ Updates the consumer for a queue, or creates one if it does not exist.
+
+ Args:
+ account_id: A Resource identifier.
+
+ queue_id: A Resource identifier.
+
+ consumer_id: A Resource identifier.
+
+ script_name: Name of a Worker
+
+ 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
+ """
+ ...
+
+ @overload
async def update(
self,
consumer_id: str,
*,
account_id: str,
queue_id: str,
- body: object,
+ settings: consumer_update_params.MqHTTPConsumerSettings | NotGiven = NOT_GIVEN,
+ type: Literal["http_pull"] | 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,
- ) -> Optional[ConsumerUpdateResponse]:
+ ) -> Optional[Consumer]:
"""
Updates the consumer for a queue, or creates one if it does not exist.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
- consumer_id: Identifier.
+ consumer_id: A Resource identifier.
extra_headers: Send extra headers
@@ -339,23 +591,56 @@ async def update(
timeout: Override the client-level default timeout for this request, in seconds
"""
+ ...
+
+ @required_args(["account_id", "queue_id"])
+ async def update(
+ self,
+ consumer_id: str,
+ *,
+ account_id: str,
+ queue_id: str,
+ script_name: str | NotGiven = NOT_GIVEN,
+ settings: consumer_update_params.MqWorkerConsumerSettings
+ | consumer_update_params.MqHTTPConsumerSettings
+ | NotGiven = NOT_GIVEN,
+ type: Literal["worker"] | Literal["http_pull"] | 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,
+ ) -> Optional[Consumer]:
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not queue_id:
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
if not consumer_id:
raise ValueError(f"Expected a non-empty value for `consumer_id` but received {consumer_id!r}")
- return await self._put(
- f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
- body=await async_maybe_transform(body, consumer_update_params.ConsumerUpdateParams),
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerUpdateResponse]]._unwrapper,
+ return cast(
+ Optional[Consumer],
+ await self._put(
+ f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
+ body=await async_maybe_transform(
+ {
+ "script_name": script_name,
+ "settings": settings,
+ "type": type,
+ },
+ consumer_update_params.ConsumerUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[Optional[Consumer]]._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[Consumer]
+ ), # Union types cannot be passed in as arguments in the type system
),
- cast_to=cast(Type[Optional[ConsumerUpdateResponse]], ResultWrapper[ConsumerUpdateResponse]),
)
async def delete(
@@ -370,16 +655,16 @@ async def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[ConsumerDeleteResponse]:
+ ) -> ConsumerDeleteResponse:
"""
Deletes the consumer for a queue.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
- consumer_id: Identifier.
+ consumer_id: A Resource identifier.
extra_headers: Send extra headers
@@ -398,13 +683,9 @@ async def delete(
return await self._delete(
f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}",
options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[ConsumerDeleteResponse]]._unwrapper,
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=cast(Type[Optional[ConsumerDeleteResponse]], ResultWrapper[ConsumerDeleteResponse]),
+ cast_to=ConsumerDeleteResponse,
)
async def get(
@@ -420,12 +701,12 @@ async def get(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ConsumerGetResponse]:
"""
- Returns the consumers for a queue.
+ Returns the consumers for a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
diff --git a/src/cloudflare/resources/queues/messages.py b/src/cloudflare/resources/queues/messages.py
index 3438d6f0422..7359826a3b8 100644
--- a/src/cloudflare/resources/queues/messages.py
+++ b/src/cloudflare/resources/queues/messages.py
@@ -63,12 +63,12 @@ def ack(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[MessageAckResponse]:
"""
- Acknowledge + Retry messages from a Queue.
+ Acknowledge + Retry messages from a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -107,7 +107,7 @@ def pull(
*,
account_id: str,
batch_size: float | NotGiven = NOT_GIVEN,
- visibility_timeout: float | NotGiven = NOT_GIVEN,
+ visibility_timeout_ms: float | 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,
@@ -116,16 +116,16 @@ def pull(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[MessagePullResponse]:
"""
- Pull a batch of messages from a Queue.
+ Pull a batch of messages from a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
batch_size: The maximum number of messages to include in a batch.
- visibility_timeout: The number of milliseconds that a message is exclusively leased. After the
+ visibility_timeout_ms: The number of milliseconds that a message is exclusively leased. After the
timeout, the message becomes available for another attempt.
extra_headers: Send extra headers
@@ -145,7 +145,7 @@ def pull(
body=maybe_transform(
{
"batch_size": batch_size,
- "visibility_timeout": visibility_timeout,
+ "visibility_timeout_ms": visibility_timeout_ms,
},
message_pull_params.MessagePullParams,
),
@@ -195,12 +195,12 @@ async def ack(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[MessageAckResponse]:
"""
- Acknowledge + Retry messages from a Queue.
+ Acknowledge + Retry messages from a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -239,7 +239,7 @@ async def pull(
*,
account_id: str,
batch_size: float | NotGiven = NOT_GIVEN,
- visibility_timeout: float | NotGiven = NOT_GIVEN,
+ visibility_timeout_ms: float | 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,
@@ -248,16 +248,16 @@ async def pull(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[MessagePullResponse]:
"""
- Pull a batch of messages from a Queue.
+ Pull a batch of messages from a Queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
batch_size: The maximum number of messages to include in a batch.
- visibility_timeout: The number of milliseconds that a message is exclusively leased. After the
+ visibility_timeout_ms: The number of milliseconds that a message is exclusively leased. After the
timeout, the message becomes available for another attempt.
extra_headers: Send extra headers
@@ -277,7 +277,7 @@ async def pull(
body=await async_maybe_transform(
{
"batch_size": batch_size,
- "visibility_timeout": visibility_timeout,
+ "visibility_timeout_ms": visibility_timeout_ms,
},
message_pull_params.MessagePullParams,
),
diff --git a/src/cloudflare/resources/queues/queues.py b/src/cloudflare/resources/queues/queues.py
index d9d81322385..5345646fe47 100644
--- a/src/cloudflare/resources/queues/queues.py
+++ b/src/cloudflare/resources/queues/queues.py
@@ -40,8 +40,6 @@
from ..._base_client import AsyncPaginator, make_request_options
from ...types.queues import queue_create_params, queue_update_params
from ...types.queues.queue import Queue
-from ...types.queues.queue_created import QueueCreated
-from ...types.queues.queue_updated import QueueUpdated
from ...types.queues.queue_delete_response import QueueDeleteResponse
__all__ = ["QueuesResource", "AsyncQueuesResource"]
@@ -86,12 +84,12 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[QueueCreated]:
+ ) -> Optional[Queue]:
"""
- Creates a new queue.
+ Create a new queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
extra_headers: Send extra headers
@@ -111,9 +109,9 @@ def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueCreated]]._unwrapper,
+ post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
),
- cast_to=cast(Type[Optional[QueueCreated]], ResultWrapper[QueueCreated]),
+ cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
)
def update(
@@ -121,21 +119,25 @@ def update(
queue_id: str,
*,
account_id: str,
- body: object,
+ queue_name: str | NotGiven = NOT_GIVEN,
+ settings: queue_update_params.Settings | 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,
- ) -> Optional[QueueUpdated]:
- """
- Updates a queue.
+ ) -> Optional[Queue]:
+ """Updates a Queue.
+
+ Note that this endpoint does not support partial updates. If
+ successful, the Queue's configuration is overwritten with the supplied
+ configuration.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -151,15 +153,21 @@ def update(
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
return self._put(
f"/accounts/{account_id}/queues/{queue_id}",
- body=maybe_transform(body, queue_update_params.QueueUpdateParams),
+ body=maybe_transform(
+ {
+ "queue_name": queue_name,
+ "settings": settings,
+ },
+ queue_update_params.QueueUpdateParams,
+ ),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueUpdated]]._unwrapper,
+ post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
),
- cast_to=cast(Type[Optional[QueueUpdated]], ResultWrapper[QueueUpdated]),
+ cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
)
def list(
@@ -177,7 +185,7 @@ def list(
Returns the queues owned by an account.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
extra_headers: Send extra headers
@@ -209,14 +217,14 @@ def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[QueueDeleteResponse]:
+ ) -> QueueDeleteResponse:
"""
- Deletes a queue.
+ Deletes a queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -233,13 +241,9 @@ def delete(
return self._delete(
f"/accounts/{account_id}/queues/{queue_id}",
options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueDeleteResponse]]._unwrapper,
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=cast(Type[Optional[QueueDeleteResponse]], ResultWrapper[QueueDeleteResponse]),
+ cast_to=QueueDeleteResponse,
)
def get(
@@ -255,12 +259,12 @@ def get(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[Queue]:
"""
- Get information about a specific queue.
+ Get details about a specific queue.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -326,12 +330,12 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[QueueCreated]:
+ ) -> Optional[Queue]:
"""
- Creates a new queue.
+ Create a new queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
extra_headers: Send extra headers
@@ -351,9 +355,9 @@ async def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueCreated]]._unwrapper,
+ post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
),
- cast_to=cast(Type[Optional[QueueCreated]], ResultWrapper[QueueCreated]),
+ cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
)
async def update(
@@ -361,21 +365,25 @@ async def update(
queue_id: str,
*,
account_id: str,
- body: object,
+ queue_name: str | NotGiven = NOT_GIVEN,
+ settings: queue_update_params.Settings | 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,
- ) -> Optional[QueueUpdated]:
- """
- Updates a queue.
+ ) -> Optional[Queue]:
+ """Updates a Queue.
+
+ Note that this endpoint does not support partial updates. If
+ successful, the Queue's configuration is overwritten with the supplied
+ configuration.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -391,15 +399,21 @@ async def update(
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
return await self._put(
f"/accounts/{account_id}/queues/{queue_id}",
- body=await async_maybe_transform(body, queue_update_params.QueueUpdateParams),
+ body=await async_maybe_transform(
+ {
+ "queue_name": queue_name,
+ "settings": settings,
+ },
+ queue_update_params.QueueUpdateParams,
+ ),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueUpdated]]._unwrapper,
+ post_parser=ResultWrapper[Optional[Queue]]._unwrapper,
),
- cast_to=cast(Type[Optional[QueueUpdated]], ResultWrapper[QueueUpdated]),
+ cast_to=cast(Type[Optional[Queue]], ResultWrapper[Queue]),
)
def list(
@@ -417,7 +431,7 @@ def list(
Returns the queues owned by an account.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
extra_headers: Send extra headers
@@ -449,14 +463,14 @@ async def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Optional[QueueDeleteResponse]:
+ ) -> QueueDeleteResponse:
"""
- Deletes a queue.
+ Deletes a queue
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
@@ -473,13 +487,9 @@ async def delete(
return await self._delete(
f"/accounts/{account_id}/queues/{queue_id}",
options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- post_parser=ResultWrapper[Optional[QueueDeleteResponse]]._unwrapper,
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=cast(Type[Optional[QueueDeleteResponse]], ResultWrapper[QueueDeleteResponse]),
+ cast_to=QueueDeleteResponse,
)
async def get(
@@ -495,12 +505,12 @@ async def get(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[Queue]:
"""
- Get information about a specific queue.
+ Get details about a specific queue.
Args:
- account_id: Identifier.
+ account_id: A Resource identifier.
- queue_id: Identifier.
+ queue_id: A Resource identifier.
extra_headers: Send extra headers
diff --git a/src/cloudflare/types/queues/__init__.py b/src/cloudflare/types/queues/__init__.py
index 7dd8b118bbb..5a2df213bd2 100644
--- a/src/cloudflare/types/queues/__init__.py
+++ b/src/cloudflare/types/queues/__init__.py
@@ -4,8 +4,6 @@
from .queue import Queue as Queue
from .consumer import Consumer as Consumer
-from .queue_created import QueueCreated as QueueCreated
-from .queue_updated import QueueUpdated as QueueUpdated
from .message_ack_params import MessageAckParams as MessageAckParams
from .message_pull_params import MessagePullParams as MessagePullParams
from .queue_create_params import QueueCreateParams as QueueCreateParams
@@ -16,6 +14,4 @@
from .queue_delete_response import QueueDeleteResponse as QueueDeleteResponse
from .consumer_create_params import ConsumerCreateParams as ConsumerCreateParams
from .consumer_update_params import ConsumerUpdateParams as ConsumerUpdateParams
-from .consumer_create_response import ConsumerCreateResponse as ConsumerCreateResponse
from .consumer_delete_response import ConsumerDeleteResponse as ConsumerDeleteResponse
-from .consumer_update_response import ConsumerUpdateResponse as ConsumerUpdateResponse
diff --git a/src/cloudflare/types/queues/consumer.py b/src/cloudflare/types/queues/consumer.py
index 49500bb12a4..9c0070c3734 100644
--- a/src/cloudflare/types/queues/consumer.py
+++ b/src/cloudflare/types/queues/consumer.py
@@ -1,29 +1,88 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import Optional
+from typing import Union, Optional
+from typing_extensions import Literal, TypeAlias
from ..._models import BaseModel
-__all__ = ["Consumer", "Settings"]
+__all__ = ["Consumer", "MqWorkerConsumer", "MqWorkerConsumerSettings", "MqHTTPConsumer", "MqHTTPConsumerSettings"]
-class Settings(BaseModel):
+class MqWorkerConsumerSettings(BaseModel):
batch_size: Optional[float] = None
"""The maximum number of messages to include in a batch."""
+ max_concurrency: Optional[float] = None
+ """Maximum number of concurrent consumers that may consume from this Queue.
+
+ Set to `null` to automatically opt in to the platform's maximum (recommended).
+ """
+
max_retries: Optional[float] = None
"""The maximum number of retries"""
max_wait_time_ms: Optional[float] = None
+ """
+ The number of milliseconds to wait for a batch to fill up before attempting to
+ deliver it
+ """
+
+ retry_delay: Optional[float] = None
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
-class Consumer(BaseModel):
+class MqWorkerConsumer(BaseModel):
+ consumer_id: Optional[str] = None
+ """A Resource identifier."""
+
created_on: Optional[str] = None
- environment: Optional[str] = None
+ queue_id: Optional[str] = None
+ """A Resource identifier."""
+
+ script: Optional[str] = None
+ """Name of a Worker"""
+
+ settings: Optional[MqWorkerConsumerSettings] = None
+
+ type: Optional[Literal["worker"]] = None
+
+
+class MqHTTPConsumerSettings(BaseModel):
+ batch_size: Optional[float] = None
+ """The maximum number of messages to include in a batch."""
+
+ max_retries: Optional[float] = None
+ """The maximum number of retries"""
+
+ retry_delay: Optional[float] = None
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
+
+ visibility_timeout_ms: Optional[float] = None
+ """The number of milliseconds that a message is exclusively leased.
+
+ After the timeout, the message becomes available for another attempt.
+ """
+
+
+class MqHTTPConsumer(BaseModel):
+ consumer_id: Optional[str] = None
+ """A Resource identifier."""
+
+ created_on: Optional[str] = None
+
+ queue_id: Optional[str] = None
+ """A Resource identifier."""
+
+ settings: Optional[MqHTTPConsumerSettings] = None
- queue_name: Optional[str] = None
+ type: Optional[Literal["http_pull"]] = None
- service: Optional[str] = None
- settings: Optional[Settings] = None
+Consumer: TypeAlias = Union[MqWorkerConsumer, MqHTTPConsumer]
diff --git a/src/cloudflare/types/queues/consumer_create_params.py b/src/cloudflare/types/queues/consumer_create_params.py
index 84dd755dbed..4c4f997ffb6 100644
--- a/src/cloudflare/types/queues/consumer_create_params.py
+++ b/src/cloudflare/types/queues/consumer_create_params.py
@@ -2,13 +2,83 @@
from __future__ import annotations
-from typing_extensions import Required, TypedDict
+from typing import Union
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
-__all__ = ["ConsumerCreateParams"]
+__all__ = [
+ "ConsumerCreateParams",
+ "MqWorkerConsumer",
+ "MqWorkerConsumerSettings",
+ "MqHTTPConsumer",
+ "MqHTTPConsumerSettings",
+]
-class ConsumerCreateParams(TypedDict, total=False):
+class MqWorkerConsumer(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
- body: Required[object]
+ script_name: str
+ """Name of a Worker"""
+
+ settings: MqWorkerConsumerSettings
+
+ type: Literal["worker"]
+
+
+class MqWorkerConsumerSettings(TypedDict, total=False):
+ batch_size: float
+ """The maximum number of messages to include in a batch."""
+
+ max_concurrency: float
+ """Maximum number of concurrent consumers that may consume from this Queue.
+
+ Set to `null` to automatically opt in to the platform's maximum (recommended).
+ """
+
+ max_retries: float
+ """The maximum number of retries"""
+
+ max_wait_time_ms: float
+ """
+ The number of milliseconds to wait for a batch to fill up before attempting to
+ deliver it
+ """
+
+ retry_delay: float
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
+
+
+class MqHTTPConsumer(TypedDict, total=False):
+ account_id: Required[str]
+ """A Resource identifier."""
+
+ settings: MqHTTPConsumerSettings
+
+ type: Literal["http_pull"]
+
+
+class MqHTTPConsumerSettings(TypedDict, total=False):
+ batch_size: float
+ """The maximum number of messages to include in a batch."""
+
+ max_retries: float
+ """The maximum number of retries"""
+
+ retry_delay: float
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
+
+ visibility_timeout_ms: float
+ """The number of milliseconds that a message is exclusively leased.
+
+ After the timeout, the message becomes available for another attempt.
+ """
+
+
+ConsumerCreateParams: TypeAlias = Union[MqWorkerConsumer, MqHTTPConsumer]
diff --git a/src/cloudflare/types/queues/consumer_create_response.py b/src/cloudflare/types/queues/consumer_create_response.py
deleted file mode 100644
index d1224bacf7f..00000000000
--- a/src/cloudflare/types/queues/consumer_create_response.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Optional
-
-from ..._models import BaseModel
-
-__all__ = ["ConsumerCreateResponse", "Settings"]
-
-
-class Settings(BaseModel):
- batch_size: Optional[float] = None
- """The maximum number of messages to include in a batch."""
-
- max_retries: Optional[float] = None
- """The maximum number of retries"""
-
- max_wait_time_ms: Optional[float] = None
-
-
-class ConsumerCreateResponse(BaseModel):
- created_on: Optional[str] = None
-
- dead_letter_queue: Optional[str] = None
- """The name of the dead letter queue."""
-
- environment: Optional[str] = None
-
- queue_name: Optional[str] = None
-
- script_name: Optional[str] = None
-
- settings: Optional[Settings] = None
diff --git a/src/cloudflare/types/queues/consumer_delete_response.py b/src/cloudflare/types/queues/consumer_delete_response.py
index 258f3921641..7de9b984436 100644
--- a/src/cloudflare/types/queues/consumer_delete_response.py
+++ b/src/cloudflare/types/queues/consumer_delete_response.py
@@ -1,8 +1,18 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import List
-from typing_extensions import TypeAlias
+from typing import List, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from ..shared.response_info import ResponseInfo
__all__ = ["ConsumerDeleteResponse"]
-ConsumerDeleteResponse: TypeAlias = List[object]
+
+class ConsumerDeleteResponse(BaseModel):
+ errors: Optional[List[ResponseInfo]] = None
+
+ messages: Optional[List[str]] = None
+
+ success: Optional[Literal[True]] = None
+ """Indicates if the API call was successful or not."""
diff --git a/src/cloudflare/types/queues/consumer_update_params.py b/src/cloudflare/types/queues/consumer_update_params.py
index 0fce7fcba21..fedc18d3de1 100644
--- a/src/cloudflare/types/queues/consumer_update_params.py
+++ b/src/cloudflare/types/queues/consumer_update_params.py
@@ -2,16 +2,89 @@
from __future__ import annotations
-from typing_extensions import Required, TypedDict
+from typing import Union
+from typing_extensions import Literal, Required, TypeAlias, TypedDict
-__all__ = ["ConsumerUpdateParams"]
+__all__ = [
+ "ConsumerUpdateParams",
+ "MqWorkerConsumer",
+ "MqWorkerConsumerSettings",
+ "MqHTTPConsumer",
+ "MqHTTPConsumerSettings",
+]
-class ConsumerUpdateParams(TypedDict, total=False):
+class MqWorkerConsumer(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
queue_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
- body: Required[object]
+ script_name: str
+ """Name of a Worker"""
+
+ settings: MqWorkerConsumerSettings
+
+ type: Literal["worker"]
+
+
+class MqWorkerConsumerSettings(TypedDict, total=False):
+ batch_size: float
+ """The maximum number of messages to include in a batch."""
+
+ max_concurrency: float
+ """Maximum number of concurrent consumers that may consume from this Queue.
+
+ Set to `null` to automatically opt in to the platform's maximum (recommended).
+ """
+
+ max_retries: float
+ """The maximum number of retries"""
+
+ max_wait_time_ms: float
+ """
+ The number of milliseconds to wait for a batch to fill up before attempting to
+ deliver it
+ """
+
+ retry_delay: float
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
+
+
+class MqHTTPConsumer(TypedDict, total=False):
+ account_id: Required[str]
+ """A Resource identifier."""
+
+ queue_id: Required[str]
+ """A Resource identifier."""
+
+ settings: MqHTTPConsumerSettings
+
+ type: Literal["http_pull"]
+
+
+class MqHTTPConsumerSettings(TypedDict, total=False):
+ batch_size: float
+ """The maximum number of messages to include in a batch."""
+
+ max_retries: float
+ """The maximum number of retries"""
+
+ retry_delay: float
+ """
+ The number of seconds to delay before making the message available for another
+ attempt.
+ """
+
+ visibility_timeout_ms: float
+ """The number of milliseconds that a message is exclusively leased.
+
+ After the timeout, the message becomes available for another attempt.
+ """
+
+
+ConsumerUpdateParams: TypeAlias = Union[MqWorkerConsumer, MqHTTPConsumer]
diff --git a/src/cloudflare/types/queues/consumer_update_response.py b/src/cloudflare/types/queues/consumer_update_response.py
deleted file mode 100644
index 7a201a4c8da..00000000000
--- a/src/cloudflare/types/queues/consumer_update_response.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Optional
-
-from ..._models import BaseModel
-
-__all__ = ["ConsumerUpdateResponse", "Settings"]
-
-
-class Settings(BaseModel):
- batch_size: Optional[float] = None
-
- max_retries: Optional[float] = None
- """The maximum number of retries"""
-
- max_wait_time_ms: Optional[float] = None
-
-
-class ConsumerUpdateResponse(BaseModel):
- created_on: Optional[str] = None
-
- dead_letter_queue: Optional[str] = None
-
- environment: Optional[str] = None
-
- queue_name: Optional[str] = None
-
- script_name: Optional[str] = None
-
- settings: Optional[Settings] = None
diff --git a/src/cloudflare/types/queues/message_ack_params.py b/src/cloudflare/types/queues/message_ack_params.py
index 5604662d579..144cfac1f2f 100644
--- a/src/cloudflare/types/queues/message_ack_params.py
+++ b/src/cloudflare/types/queues/message_ack_params.py
@@ -10,7 +10,7 @@
class MessageAckParams(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
acks: Iterable[Ack]
@@ -19,7 +19,10 @@ class MessageAckParams(TypedDict, total=False):
class Ack(TypedDict, total=False):
lease_id: str
- """Lease ID for a message to acknowledge."""
+ """An ID that represents an "in-flight" message that has been pulled from a Queue.
+
+ You must hold on to this ID and use it to acknowledge this message.
+ """
class Retry(TypedDict, total=False):
@@ -30,4 +33,7 @@ class Retry(TypedDict, total=False):
"""
lease_id: str
- """Lease ID for a message to retry."""
+ """An ID that represents an "in-flight" message that has been pulled from a Queue.
+
+ You must hold on to this ID and use it to acknowledge this message.
+ """
diff --git a/src/cloudflare/types/queues/message_pull_params.py b/src/cloudflare/types/queues/message_pull_params.py
index a592b19236b..2613f621005 100644
--- a/src/cloudflare/types/queues/message_pull_params.py
+++ b/src/cloudflare/types/queues/message_pull_params.py
@@ -9,12 +9,12 @@
class MessagePullParams(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
batch_size: float
"""The maximum number of messages to include in a batch."""
- visibility_timeout: float
+ visibility_timeout_ms: float
"""The number of milliseconds that a message is exclusively leased.
After the timeout, the message becomes available for another attempt.
diff --git a/src/cloudflare/types/queues/message_pull_response.py b/src/cloudflare/types/queues/message_pull_response.py
index a1bfa17bbcd..39c56cebb19 100644
--- a/src/cloudflare/types/queues/message_pull_response.py
+++ b/src/cloudflare/types/queues/message_pull_response.py
@@ -16,6 +16,10 @@ class MessagePullResponseItem(BaseModel):
body: Optional[str] = None
lease_id: Optional[str] = None
+ """An ID that represents an "in-flight" message that has been pulled from a Queue.
+
+ You must hold on to this ID and use it to acknowledge this message.
+ """
metadata: Optional[object] = None
diff --git a/src/cloudflare/types/queues/queue.py b/src/cloudflare/types/queues/queue.py
index 63269339f7a..c8638ac3f1a 100644
--- a/src/cloudflare/types/queues/queue.py
+++ b/src/cloudflare/types/queues/queue.py
@@ -1,17 +1,35 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import List, Optional
+from typing import List, Union, Optional
+from typing_extensions import Literal, TypeAlias
from .consumer import Consumer
from ..._models import BaseModel
-__all__ = ["Queue", "Producer"]
+__all__ = ["Queue", "Producer", "ProducerMqWorkerProducer", "ProducerMqR2Producer", "Settings"]
-class Producer(BaseModel):
- environment: Optional[str] = None
+class ProducerMqWorkerProducer(BaseModel):
+ script: Optional[str] = None
- service: Optional[str] = None
+ type: Optional[Literal["worker"]] = None
+
+
+class ProducerMqR2Producer(BaseModel):
+ bucket_name: Optional[str] = None
+
+ type: Optional[Literal["r2_bucket"]] = None
+
+
+Producer: TypeAlias = Union[ProducerMqWorkerProducer, ProducerMqR2Producer]
+
+
+class Settings(BaseModel):
+ delivery_delay: Optional[float] = None
+ """Number of seconds to delay delivery of all messages to consumers."""
+
+ message_retention_period: Optional[float] = None
+ """Number of seconds after which an unconsumed message will be delayed."""
class Queue(BaseModel):
@@ -30,3 +48,5 @@ class Queue(BaseModel):
queue_id: Optional[str] = None
queue_name: Optional[str] = None
+
+ settings: Optional[Settings] = None
diff --git a/src/cloudflare/types/queues/queue_create_params.py b/src/cloudflare/types/queues/queue_create_params.py
index c590bda26f3..e14f226a015 100644
--- a/src/cloudflare/types/queues/queue_create_params.py
+++ b/src/cloudflare/types/queues/queue_create_params.py
@@ -9,6 +9,6 @@
class QueueCreateParams(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
queue_name: Required[str]
diff --git a/src/cloudflare/types/queues/queue_created.py b/src/cloudflare/types/queues/queue_created.py
deleted file mode 100644
index 01363715a83..00000000000
--- a/src/cloudflare/types/queues/queue_created.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Optional
-
-from ..._models import BaseModel
-
-__all__ = ["QueueCreated"]
-
-
-class QueueCreated(BaseModel):
- created_on: Optional[str] = None
-
- modified_on: Optional[str] = None
-
- queue_id: Optional[str] = None
-
- queue_name: Optional[str] = None
diff --git a/src/cloudflare/types/queues/queue_delete_response.py b/src/cloudflare/types/queues/queue_delete_response.py
index 78686edcbc8..91079074b40 100644
--- a/src/cloudflare/types/queues/queue_delete_response.py
+++ b/src/cloudflare/types/queues/queue_delete_response.py
@@ -1,8 +1,18 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import List
-from typing_extensions import TypeAlias
+from typing import List, Optional
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+from ..shared.response_info import ResponseInfo
__all__ = ["QueueDeleteResponse"]
-QueueDeleteResponse: TypeAlias = List[object]
+
+class QueueDeleteResponse(BaseModel):
+ errors: Optional[List[ResponseInfo]] = None
+
+ messages: Optional[List[str]] = None
+
+ success: Optional[Literal[True]] = None
+ """Indicates if the API call was successful or not."""
diff --git a/src/cloudflare/types/queues/queue_update_params.py b/src/cloudflare/types/queues/queue_update_params.py
index bcfb690cadf..83a56ea2f6f 100644
--- a/src/cloudflare/types/queues/queue_update_params.py
+++ b/src/cloudflare/types/queues/queue_update_params.py
@@ -4,11 +4,21 @@
from typing_extensions import Required, TypedDict
-__all__ = ["QueueUpdateParams"]
+__all__ = ["QueueUpdateParams", "Settings"]
class QueueUpdateParams(TypedDict, total=False):
account_id: Required[str]
- """Identifier."""
+ """A Resource identifier."""
- body: Required[object]
+ queue_name: str
+
+ settings: Settings
+
+
+class Settings(TypedDict, total=False):
+ delivery_delay: float
+ """Number of seconds to delay delivery of all messages to consumers."""
+
+ message_retention_period: float
+ """Number of seconds after which an unconsumed message will be delayed."""
diff --git a/src/cloudflare/types/queues/queue_updated.py b/src/cloudflare/types/queues/queue_updated.py
deleted file mode 100644
index fae1969ebac..00000000000
--- a/src/cloudflare/types/queues/queue_updated.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Optional
-
-from ..._models import BaseModel
-
-__all__ = ["QueueUpdated"]
-
-
-class QueueUpdated(BaseModel):
- created_on: Optional[str] = None
-
- modified_on: Optional[str] = None
-
- queue_id: Optional[str] = None
-
- queue_name: Optional[str] = None
diff --git a/tests/api_resources/queues/test_consumers.py b/tests/api_resources/queues/test_consumers.py
index 4cca547cf8c..650240c0262 100644
--- a/tests/api_resources/queues/test_consumers.py
+++ b/tests/api_resources/queues/test_consumers.py
@@ -10,10 +10,9 @@
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.queues import (
+ Consumer,
ConsumerGetResponse,
- ConsumerCreateResponse,
ConsumerDeleteResponse,
- ConsumerUpdateResponse,
)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -23,176 +22,271 @@ class TestConsumers:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
- def test_method_create(self, client: Cloudflare) -> None:
+ def test_method_create_overload_1(self, client: Cloudflare) -> None:
consumer = client.queues.consumers.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="my-consumer-worker",
+ settings={
+ "batch_size": 50,
+ "max_concurrency": 10,
+ "max_retries": 3,
+ "max_wait_time_ms": 5000,
+ "retry_delay": 10,
},
+ type="worker",
)
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- def test_raw_response_create(self, client: Cloudflare) -> None:
+ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None:
response = client.queues.consumers.with_raw_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- def test_streaming_response_create(self, client: Cloudflare) -> None:
+ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None:
with client.queues.consumers.with_streaming_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ consumer = response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_create_overload_1(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.queues.consumers.with_raw_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
+ client.queues.consumers.with_raw_response.create(
+ queue_id="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ def test_method_create_overload_2(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ settings={
+ "batch_size": 50,
+ "max_retries": 3,
+ "retry_delay": 10,
+ "visibility_timeout_ms": 6000,
},
+ type="http_pull",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None:
+ response = client.queues.consumers.with_raw_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ consumer = response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None:
+ with client.queues.consumers.with_streaming_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
- def test_path_params_create(self, client: Cloudflare) -> None:
+ def test_path_params_create_overload_2(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.queues.consumers.with_raw_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
client.queues.consumers.with_raw_response.create(
queue_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
@parametrize
- def test_method_update(self, client: Cloudflare) -> None:
+ def test_method_update_overload_1(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None:
consumer = client.queues.consumers.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
+ script_name="my-consumer-worker",
+ settings={
+ "batch_size": 50,
+ "max_concurrency": 10,
+ "max_retries": 3,
+ "max_wait_time_ms": 5000,
+ "retry_delay": 10,
},
+ type="worker",
)
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- def test_raw_response_update(self, client: Cloudflare) -> None:
+ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None:
response = client.queues.consumers.with_raw_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- def test_streaming_response_update(self, client: Cloudflare) -> None:
+ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None:
with client.queues.consumers.with_streaming_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ consumer = response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_update_overload_1(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
+ client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"):
+ client.queues.consumers.with_raw_response.update(
+ consumer_id="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ def test_method_update_overload_2(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> None:
+ consumer = client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ settings={
+ "batch_size": 50,
+ "max_retries": 3,
+ "retry_delay": 10,
+ "visibility_timeout_ms": 6000,
},
+ type="http_pull",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None:
+ response = client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ consumer = response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None:
+ with client.queues.consumers.with_streaming_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
- def test_path_params_update(self, client: Cloudflare) -> None:
+ def test_path_params_update_overload_2(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.queues.consumers.with_raw_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
@@ -200,12 +294,6 @@ def test_path_params_update(self, client: Cloudflare) -> None:
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"):
@@ -213,12 +301,6 @@ def test_path_params_update(self, client: Cloudflare) -> None:
consumer_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
@parametrize
@@ -228,7 +310,7 @@ def test_method_delete(self, client: Cloudflare) -> None:
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
@@ -241,7 +323,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
@@ -254,7 +336,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = response.parse()
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -334,176 +416,271 @@ class TestAsyncConsumers:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
- async def test_method_create(self, async_client: AsyncCloudflare) -> None:
+ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None:
consumer = await async_client.queues.consumers.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ script_name="my-consumer-worker",
+ settings={
+ "batch_size": 50,
+ "max_concurrency": 10,
+ "max_retries": 3,
+ "max_wait_time_ms": 5000,
+ "retry_delay": 10,
},
+ type="worker",
)
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
+ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None:
response = await async_client.queues.consumers.with_raw_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
+ async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None:
async with async_client.queues.consumers.with_streaming_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ consumer = await response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.queues.consumers.with_raw_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
+ await async_client.queues.consumers.with_raw_response.create(
+ queue_id="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ settings={
+ "batch_size": 50,
+ "max_retries": 3,
+ "retry_delay": 10,
+ "visibility_timeout_ms": 6000,
},
+ type="http_pull",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.queues.consumers.with_raw_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ consumer = await response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.queues.consumers.with_streaming_response.create(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
- async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
+ async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.queues.consumers.with_raw_response.create(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
await async_client.queues.consumers.with_raw_response.create(
queue_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {
- "batch_size": 10,
- "max_retries": 3,
- "max_wait_time_ms": 5000,
- },
- "type": "worker",
- },
)
@parametrize
- async def test_method_update(self, async_client: AsyncCloudflare) -> None:
+ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None:
consumer = await async_client.queues.consumers.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
+ script_name="my-consumer-worker",
+ settings={
+ "batch_size": 50,
+ "max_concurrency": 10,
+ "max_retries": 3,
+ "max_wait_time_ms": 5000,
+ "retry_delay": 10,
},
+ type="worker",
)
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
+ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None:
response = await async_client.queues.consumers.with_raw_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
@parametrize
- async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
+ async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None:
async with async_client.queues.consumers.with_streaming_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ consumer = await response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
+ await async_client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"):
+ await async_client.queues.consumers.with_raw_response.update(
+ consumer_id="",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @parametrize
+ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None:
+ consumer = await async_client.queues.consumers.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ settings={
+ "batch_size": 50,
+ "max_retries": 3,
+ "retry_delay": 10,
+ "visibility_timeout_ms": 6000,
},
+ type="http_pull",
+ )
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.queues.consumers.with_raw_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ consumer = await response.parse()
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.queues.consumers.with_streaming_response.update(
+ consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"])
+ assert_matches_type(Optional[Consumer], consumer, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
- async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
+ async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.queues.consumers.with_raw_response.update(
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
@@ -511,12 +688,6 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
consumer_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"):
@@ -524,12 +695,6 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
consumer_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={
- "dead_letter_queue": "updated-example-dlq",
- "environment": "production",
- "script_name": "example-consumer",
- "settings": {"batch_size": 100},
- },
)
@parametrize
@@ -539,7 +704,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
@@ -552,7 +717,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
@@ -565,7 +730,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
consumer = await response.parse()
- assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"])
+ assert_matches_type(ConsumerDeleteResponse, consumer, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/queues/test_messages.py b/tests/api_resources/queues/test_messages.py
index 590687f1f63..d17b7b03a74 100644
--- a/tests/api_resources/queues/test_messages.py
+++ b/tests/api_resources/queues/test_messages.py
@@ -98,7 +98,7 @@ def test_method_pull_with_all_params(self, client: Cloudflare) -> None:
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
batch_size=50,
- visibility_timeout=6000,
+ visibility_timeout_ms=6000,
)
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
@@ -227,7 +227,7 @@ async def test_method_pull_with_all_params(self, async_client: AsyncCloudflare)
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
batch_size=50,
- visibility_timeout=6000,
+ visibility_timeout_ms=6000,
)
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
diff --git a/tests/api_resources/test_queues.py b/tests/api_resources/test_queues.py
index c06566b31fb..210197c9a59 100644
--- a/tests/api_resources/test_queues.py
+++ b/tests/api_resources/test_queues.py
@@ -10,12 +10,7 @@
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
-from cloudflare.types.queues import (
- Queue,
- QueueCreated,
- QueueUpdated,
- QueueDeleteResponse,
-)
+from cloudflare.types.queues import Queue, QueueDeleteResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -29,7 +24,7 @@ def test_method_create(self, client: Cloudflare) -> None:
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_name="example-queue",
)
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
@@ -41,7 +36,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Cloudflare) -> None:
@@ -53,7 +48,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -70,35 +65,45 @@ def test_method_update(self, client: Cloudflare) -> None:
queue = client.queues.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
+ queue = client.queues.update(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_name="example-queue",
+ settings={
+ "delivery_delay": 5,
+ "message_retention_period": 345600,
+ },
+ )
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.queues.with_raw_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.queues.with_streaming_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -108,14 +113,12 @@ def test_path_params_update(self, client: Cloudflare) -> None:
client.queues.with_raw_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
- body={"queue_name": "renamed-example-queue"},
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
client.queues.with_raw_response.update(
queue_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
@parametrize
@@ -162,7 +165,7 @@ def test_method_delete(self, client: Cloudflare) -> None:
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
@@ -174,7 +177,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
@@ -186,7 +189,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -262,7 +265,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
account_id="023e105f4ecef8ad9ca31a8372d0c353",
queue_name="example-queue",
)
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
@@ -274,7 +277,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
@@ -286,7 +289,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueCreated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -303,35 +306,45 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
queue = await async_client.queues.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ queue = await async_client.queues.update(
+ queue_id="023e105f4ecef8ad9ca31a8372d0c353",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ queue_name="example-queue",
+ settings={
+ "delivery_delay": 5,
+ "message_retention_period": 345600,
+ },
+ )
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.queues.with_raw_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
async with async_client.queues.with_streaming_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueUpdated], queue, path=["response"])
+ assert_matches_type(Optional[Queue], queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -341,14 +354,12 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
await async_client.queues.with_raw_response.update(
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="",
- body={"queue_name": "renamed-example-queue"},
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"):
await async_client.queues.with_raw_response.update(
queue_id="",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
- body={"queue_name": "renamed-example-queue"},
)
@parametrize
@@ -395,7 +406,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
@@ -407,7 +418,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
@@ -419,7 +430,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"])
+ assert_matches_type(QueueDeleteResponse, queue, path=["response"])
assert cast(Any, response.is_closed) is True