From a27315b7604ab25f9bcf9402e13309aa4a0bb13f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:41:03 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#176) --- .stats.yml | 2 +- api.md | 43 ++- src/cloudflare/resources/queues/__init__.py | 14 + src/cloudflare/resources/queues/consumers.py | 132 +++++--- src/cloudflare/resources/queues/messages.py | 318 +++++++++++++++++ src/cloudflare/resources/queues/queues.py | 130 ++++--- src/cloudflare/types/__init__.py | 6 +- ...ue_created.py => queue_create_response.py} | 4 +- ...workers_queue.py => queue_get_response.py} | 6 +- src/cloudflare/types/queue_list_response.py | 27 +- ...ue_updated.py => queue_update_response.py} | 4 +- src/cloudflare/types/queues/__init__.py | 9 +- ...updated.py => consumer_create_response.py} | 5 +- .../types/queues/consumer_get_response.py | 30 +- .../types/queues/consumer_update_params.py | 3 +- ...created.py => consumer_update_response.py} | 4 +- .../types/queues/message_ack_params.py | 33 ++ .../types/queues/message_ack_response.py | 19 ++ .../types/queues/message_pull_params.py | 21 ++ .../types/queues/message_pull_response.py | 24 ++ .../types/queues/workers_consumer.py | 27 -- tests/api_resources/queues/test_consumers.py | 172 +++++----- tests/api_resources/queues/test_messages.py | 320 ++++++++++++++++++ tests/api_resources/test_queues.py | 102 +++--- 24 files changed, 1156 insertions(+), 299 deletions(-) create mode 100644 src/cloudflare/resources/queues/messages.py rename src/cloudflare/types/{workers_queue_created.py => queue_create_response.py} (81%) rename src/cloudflare/types/{workers_queue.py => queue_get_response.py} (81%) rename src/cloudflare/types/{workers_queue_updated.py => queue_update_response.py} (81%) rename src/cloudflare/types/queues/{workers_consumer_updated.py => consumer_create_response.py} (78%) rename src/cloudflare/types/queues/{workers_consumer_created.py => consumer_update_response.py} (86%) create mode 100644 src/cloudflare/types/queues/message_ack_params.py create mode 100644 src/cloudflare/types/queues/message_ack_response.py create mode 100644 src/cloudflare/types/queues/message_pull_params.py create mode 100644 src/cloudflare/types/queues/message_pull_response.py delete mode 100644 src/cloudflare/types/queues/workers_consumer.py create mode 100644 tests/api_resources/queues/test_messages.py diff --git a/.stats.yml b/.stats.yml index 81d04672fb2..de12921cd5a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1290 +configured_endpoints: 1292 diff --git a/api.md b/api.md index 8e1d82588b6..772bbed26a2 100644 --- a/api.md +++ b/api.md @@ -2990,39 +2990,60 @@ from cloudflare.types import ( WorkersQueue, WorkersQueueCreated, WorkersQueueUpdated, + QueueCreateResponse, + QueueUpdateResponse, QueueListResponse, QueueDeleteResponse, + QueueGetResponse, ) ``` Methods: -- client.queues.create(\*, account_id, \*\*params) -> Optional -- client.queues.update(name, \*, account_id, \*\*params) -> Optional -- client.queues.list(\*, account_id) -> Optional -- client.queues.delete(name, \*, account_id) -> Optional -- client.queues.get(name, \*, account_id) -> Optional +- client.queues.create(\*, account_id, \*\*params) -> Optional +- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional +- client.queues.list(\*, account_id) -> Optional +- client.queues.delete(queue_id, \*, account_id) -> Optional +- client.queues.get(queue_id, \*, account_id) -> Optional ## Consumers Types: +```python +from cloudflare.types.queues import ( + ConsumerCreateResponse, + ConsumerUpdateResponse, + 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.get(queue_id, \*, account_id) -> Optional + +## Messages + +Types: + ```python from cloudflare.types.queues import ( WorkersConsumer, WorkersConsumerCreated, WorkersConsumerUpdated, - ConsumerDeleteResponse, - ConsumerGetResponse, + MessageAckResponse, + MessagePullResponse, ) ``` Methods: -- client.queues.consumers.create(name, \*, account_id, \*\*params) -> Optional -- client.queues.consumers.update(consumer_name, \*, account_id, name, \*\*params) -> Optional -- client.queues.consumers.delete(consumer_name, \*, account_id, name) -> Optional -- client.queues.consumers.get(name, \*, account_id) -> Optional +- client.queues.messages.ack(queue_id, \*, account_id, \*\*params) -> Optional +- client.queues.messages.pull(queue_id, \*, account_id, \*\*params) -> Optional # ManagedHeaders diff --git a/src/cloudflare/resources/queues/__init__.py b/src/cloudflare/resources/queues/__init__.py index 162a3b42484..6c53c636c3f 100644 --- a/src/cloudflare/resources/queues/__init__.py +++ b/src/cloudflare/resources/queues/__init__.py @@ -8,6 +8,14 @@ QueuesWithStreamingResponse, AsyncQueuesWithStreamingResponse, ) +from .messages import ( + Messages, + AsyncMessages, + MessagesWithRawResponse, + AsyncMessagesWithRawResponse, + MessagesWithStreamingResponse, + AsyncMessagesWithStreamingResponse, +) from .consumers import ( Consumers, AsyncConsumers, @@ -24,6 +32,12 @@ "AsyncConsumersWithRawResponse", "ConsumersWithStreamingResponse", "AsyncConsumersWithStreamingResponse", + "Messages", + "AsyncMessages", + "MessagesWithRawResponse", + "AsyncMessagesWithRawResponse", + "MessagesWithStreamingResponse", + "AsyncMessagesWithStreamingResponse", "Queues", "AsyncQueues", "QueuesWithRawResponse", diff --git a/src/cloudflare/resources/queues/consumers.py b/src/cloudflare/resources/queues/consumers.py index 59dd045052e..a5c9097bba5 100644 --- a/src/cloudflare/resources/queues/consumers.py +++ b/src/cloudflare/resources/queues/consumers.py @@ -25,9 +25,9 @@ ) from ...types.queues import ( ConsumerGetResponse, + ConsumerCreateResponse, ConsumerDeleteResponse, - WorkersConsumerCreated, - WorkersConsumerUpdated, + ConsumerUpdateResponse, consumer_create_params, consumer_update_params, ) @@ -46,7 +46,7 @@ def with_streaming_response(self) -> ConsumersWithStreamingResponse: def create( self, - name: str, + queue_id: str, *, account_id: str, body: object, @@ -56,13 +56,15 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersConsumerCreated]: + ) -> Optional[ConsumerCreateResponse]: """ Creates a new consumer for a queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -73,10 +75,10 @@ def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!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}/workers/queues/{name}/consumers", + f"/accounts/{account_id}/queues/{queue_id}/consumers", body=maybe_transform(body, consumer_create_params.ConsumerCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -85,15 +87,15 @@ def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersConsumerCreated]], ResultWrapper[WorkersConsumerCreated]), + cast_to=cast(Type[Optional[ConsumerCreateResponse]], ResultWrapper[ConsumerCreateResponse]), ) def update( self, - consumer_name: str, + consumer_id: str, *, account_id: str, - name: str, + queue_id: str, body: object, # 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. @@ -101,13 +103,17 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersConsumerUpdated]: + ) -> Optional[ConsumerUpdateResponse]: """ Updates the consumer for a queue, or creates one if it does not exist. Args: account_id: Identifier + queue_id: Identifier + + consumer_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -118,12 +124,12 @@ def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - if not consumer_name: - raise ValueError(f"Expected a non-empty value for `consumer_name` but received {consumer_name!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}/workers/queues/{name}/consumers/{consumer_name}", + 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, @@ -132,15 +138,15 @@ def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersConsumerUpdated]], ResultWrapper[WorkersConsumerUpdated]), + cast_to=cast(Type[Optional[ConsumerUpdateResponse]], ResultWrapper[ConsumerUpdateResponse]), ) def delete( self, - consumer_name: str, + consumer_id: str, *, account_id: str, - name: str, + queue_id: str, # 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, @@ -154,6 +160,10 @@ def delete( Args: account_id: Identifier + queue_id: Identifier + + consumer_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -164,14 +174,14 @@ def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - if not consumer_name: - raise ValueError(f"Expected a non-empty value for `consumer_name` but received {consumer_name!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 cast( Optional[ConsumerDeleteResponse], self._delete( - f"/accounts/{account_id}/workers/queues/{name}/consumers/{consumer_name}", + f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -187,7 +197,7 @@ def delete( def get( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -203,6 +213,8 @@ def get( Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -213,10 +225,10 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get( - f"/accounts/{account_id}/workers/queues/{name}/consumers", + f"/accounts/{account_id}/queues/{queue_id}/consumers", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -239,7 +251,7 @@ def with_streaming_response(self) -> AsyncConsumersWithStreamingResponse: async def create( self, - name: str, + queue_id: str, *, account_id: str, body: object, @@ -249,13 +261,15 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersConsumerCreated]: + ) -> Optional[ConsumerCreateResponse]: """ Creates a new consumer for a queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -266,10 +280,10 @@ async def create( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!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}/workers/queues/{name}/consumers", + 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, @@ -278,15 +292,15 @@ async def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersConsumerCreated]], ResultWrapper[WorkersConsumerCreated]), + cast_to=cast(Type[Optional[ConsumerCreateResponse]], ResultWrapper[ConsumerCreateResponse]), ) async def update( self, - consumer_name: str, + consumer_id: str, *, account_id: str, - name: str, + queue_id: str, body: object, # 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. @@ -294,13 +308,17 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersConsumerUpdated]: + ) -> Optional[ConsumerUpdateResponse]: """ Updates the consumer for a queue, or creates one if it does not exist. Args: account_id: Identifier + queue_id: Identifier + + consumer_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -311,12 +329,12 @@ async def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - if not consumer_name: - raise ValueError(f"Expected a non-empty value for `consumer_name` but received {consumer_name!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}/workers/queues/{name}/consumers/{consumer_name}", + 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, @@ -325,15 +343,15 @@ async def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersConsumerUpdated]], ResultWrapper[WorkersConsumerUpdated]), + cast_to=cast(Type[Optional[ConsumerUpdateResponse]], ResultWrapper[ConsumerUpdateResponse]), ) async def delete( self, - consumer_name: str, + consumer_id: str, *, account_id: str, - name: str, + queue_id: str, # 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, @@ -347,6 +365,10 @@ async def delete( Args: account_id: Identifier + queue_id: Identifier + + consumer_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -357,14 +379,14 @@ async def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") - if not consumer_name: - raise ValueError(f"Expected a non-empty value for `consumer_name` but received {consumer_name!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 cast( Optional[ConsumerDeleteResponse], await self._delete( - f"/accounts/{account_id}/workers/queues/{name}/consumers/{consumer_name}", + f"/accounts/{account_id}/queues/{queue_id}/consumers/{consumer_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -380,7 +402,7 @@ async def delete( async def get( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -396,6 +418,8 @@ async def get( Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -406,10 +430,10 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._get( - f"/accounts/{account_id}/workers/queues/{name}/consumers", + f"/accounts/{account_id}/queues/{queue_id}/consumers", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/queues/messages.py b/src/cloudflare/resources/queues/messages.py new file mode 100644 index 00000000000..f1f51247dc1 --- /dev/null +++ b/src/cloudflare/resources/queues/messages.py @@ -0,0 +1,318 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import ( + make_request_options, +) +from ...types.queues import MessageAckResponse, MessagePullResponse, message_ack_params, message_pull_params + +__all__ = ["Messages", "AsyncMessages"] + + +class Messages(SyncAPIResource): + @cached_property + def with_raw_response(self) -> MessagesWithRawResponse: + return MessagesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MessagesWithStreamingResponse: + return MessagesWithStreamingResponse(self) + + def ack( + self, + queue_id: str, + *, + account_id: str, + acks: Iterable[message_ack_params.Ack] | NotGiven = NOT_GIVEN, + retries: Iterable[message_ack_params.Retry] | 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[MessageAckResponse]: + """ + Acknowledge + Retry messages from a Queue. + + Args: + account_id: Identifier + + queue_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}/messages/ack", + body=maybe_transform( + { + "acks": acks, + "retries": retries, + }, + message_ack_params.MessageAckParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[MessageAckResponse]], ResultWrapper[MessageAckResponse]), + ) + + def pull( + self, + queue_id: str, + *, + account_id: str, + batch_size: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[MessagePullResponse]: + """ + Pull a batch of messages from a Queue. + + Args: + account_id: Identifier + + queue_id: Identifier + + batch_size: The maximum number of messages to include in a batch + + 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 + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}/messages/pull", + body=maybe_transform( + { + "batch_size": batch_size, + "visibility_timeout_ms": visibility_timeout_ms, + }, + message_pull_params.MessagePullParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[MessagePullResponse]], ResultWrapper[MessagePullResponse]), + ) + + +class AsyncMessages(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncMessagesWithRawResponse: + return AsyncMessagesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMessagesWithStreamingResponse: + return AsyncMessagesWithStreamingResponse(self) + + async def ack( + self, + queue_id: str, + *, + account_id: str, + acks: Iterable[message_ack_params.Ack] | NotGiven = NOT_GIVEN, + retries: Iterable[message_ack_params.Retry] | 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[MessageAckResponse]: + """ + Acknowledge + Retry messages from a Queue. + + Args: + account_id: Identifier + + queue_id: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}/messages/ack", + body=await async_maybe_transform( + { + "acks": acks, + "retries": retries, + }, + message_ack_params.MessageAckParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[MessageAckResponse]], ResultWrapper[MessageAckResponse]), + ) + + async def pull( + self, + queue_id: str, + *, + account_id: str, + batch_size: 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[MessagePullResponse]: + """ + Pull a batch of messages from a Queue. + + Args: + account_id: Identifier + + queue_id: Identifier + + batch_size: The maximum number of messages to include in a batch + + 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 + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not 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}/messages/pull", + body=await async_maybe_transform( + { + "batch_size": batch_size, + "visibility_timeout_ms": visibility_timeout_ms, + }, + message_pull_params.MessagePullParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[Optional[MessagePullResponse]], ResultWrapper[MessagePullResponse]), + ) + + +class MessagesWithRawResponse: + def __init__(self, messages: Messages) -> None: + self._messages = messages + + self.ack = to_raw_response_wrapper( + messages.ack, + ) + self.pull = to_raw_response_wrapper( + messages.pull, + ) + + +class AsyncMessagesWithRawResponse: + def __init__(self, messages: AsyncMessages) -> None: + self._messages = messages + + self.ack = async_to_raw_response_wrapper( + messages.ack, + ) + self.pull = async_to_raw_response_wrapper( + messages.pull, + ) + + +class MessagesWithStreamingResponse: + def __init__(self, messages: Messages) -> None: + self._messages = messages + + self.ack = to_streamed_response_wrapper( + messages.ack, + ) + self.pull = to_streamed_response_wrapper( + messages.pull, + ) + + +class AsyncMessagesWithStreamingResponse: + def __init__(self, messages: AsyncMessages) -> None: + self._messages = messages + + self.ack = async_to_streamed_response_wrapper( + messages.ack, + ) + self.pull = async_to_streamed_response_wrapper( + messages.pull, + ) diff --git a/src/cloudflare/resources/queues/queues.py b/src/cloudflare/resources/queues/queues.py index aebfddd8517..5f3220b8cbb 100644 --- a/src/cloudflare/resources/queues/queues.py +++ b/src/cloudflare/resources/queues/queues.py @@ -7,11 +7,11 @@ import httpx from ...types import ( - WorkersQueue, + QueueGetResponse, QueueListResponse, + QueueCreateResponse, QueueDeleteResponse, - WorkersQueueCreated, - WorkersQueueUpdated, + QueueUpdateResponse, queue_create_params, queue_update_params, ) @@ -20,6 +20,14 @@ maybe_transform, async_maybe_transform, ) +from .messages import ( + Messages, + AsyncMessages, + MessagesWithRawResponse, + AsyncMessagesWithRawResponse, + MessagesWithStreamingResponse, + AsyncMessagesWithStreamingResponse, +) from ..._compat import cached_property from .consumers import ( Consumers, @@ -49,6 +57,10 @@ class Queues(SyncAPIResource): def consumers(self) -> Consumers: return Consumers(self._client) + @cached_property + def messages(self) -> Messages: + return Messages(self._client) + @cached_property def with_raw_response(self) -> QueuesWithRawResponse: return QueuesWithRawResponse(self) @@ -68,7 +80,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueueCreated]: + ) -> Optional[QueueCreateResponse]: """ Creates a new queue. @@ -86,7 +98,7 @@ def create( if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._post( - f"/accounts/{account_id}/workers/queues", + f"/accounts/{account_id}/queues", body=maybe_transform(body, queue_create_params.QueueCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -95,12 +107,12 @@ def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueueCreated]], ResultWrapper[WorkersQueueCreated]), + cast_to=cast(Type[Optional[QueueCreateResponse]], ResultWrapper[QueueCreateResponse]), ) def update( self, - name: str, + queue_id: str, *, account_id: str, body: object, @@ -110,13 +122,15 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueueUpdated]: + ) -> Optional[QueueUpdateResponse]: """ Updates a queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -127,10 +141,10 @@ def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._put( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", body=maybe_transform(body, queue_update_params.QueueUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -139,7 +153,7 @@ def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueueUpdated]], ResultWrapper[WorkersQueueUpdated]), + cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]), ) def list( @@ -170,7 +184,7 @@ def list( if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get( - f"/accounts/{account_id}/workers/queues", + f"/accounts/{account_id}/queues", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -183,7 +197,7 @@ def list( def delete( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -199,6 +213,8 @@ def delete( Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -209,12 +225,12 @@ def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return cast( Optional[QueueDeleteResponse], self._delete( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -230,7 +246,7 @@ def delete( def get( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -239,13 +255,15 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueue]: + ) -> Optional[QueueGetResponse]: """ Get information about a specific queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -256,10 +274,10 @@ def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return self._get( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -267,7 +285,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueue]], ResultWrapper[WorkersQueue]), + cast_to=cast(Type[Optional[QueueGetResponse]], ResultWrapper[QueueGetResponse]), ) @@ -276,6 +294,10 @@ class AsyncQueues(AsyncAPIResource): def consumers(self) -> AsyncConsumers: return AsyncConsumers(self._client) + @cached_property + def messages(self) -> AsyncMessages: + return AsyncMessages(self._client) + @cached_property def with_raw_response(self) -> AsyncQueuesWithRawResponse: return AsyncQueuesWithRawResponse(self) @@ -295,7 +317,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueueCreated]: + ) -> Optional[QueueCreateResponse]: """ Creates a new queue. @@ -313,7 +335,7 @@ async def create( if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._post( - f"/accounts/{account_id}/workers/queues", + f"/accounts/{account_id}/queues", body=await async_maybe_transform(body, queue_create_params.QueueCreateParams), options=make_request_options( extra_headers=extra_headers, @@ -322,12 +344,12 @@ async def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueueCreated]], ResultWrapper[WorkersQueueCreated]), + cast_to=cast(Type[Optional[QueueCreateResponse]], ResultWrapper[QueueCreateResponse]), ) async def update( self, - name: str, + queue_id: str, *, account_id: str, body: object, @@ -337,13 +359,15 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueueUpdated]: + ) -> Optional[QueueUpdateResponse]: """ Updates a queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -354,10 +378,10 @@ async def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._put( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", body=await async_maybe_transform(body, queue_update_params.QueueUpdateParams), options=make_request_options( extra_headers=extra_headers, @@ -366,7 +390,7 @@ async def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueueUpdated]], ResultWrapper[WorkersQueueUpdated]), + cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]), ) async def list( @@ -397,7 +421,7 @@ async def list( if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return await self._get( - f"/accounts/{account_id}/workers/queues", + f"/accounts/{account_id}/queues", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -410,7 +434,7 @@ async def list( async def delete( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -426,6 +450,8 @@ async def delete( Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -436,12 +462,12 @@ async def delete( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return cast( Optional[QueueDeleteResponse], await self._delete( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -457,7 +483,7 @@ async def delete( async def get( self, - name: str, + queue_id: str, *, account_id: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -466,13 +492,15 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[WorkersQueue]: + ) -> Optional[QueueGetResponse]: """ Get information about a specific queue. Args: account_id: Identifier + queue_id: Identifier + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -483,10 +511,10 @@ async def get( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not name: - raise ValueError(f"Expected a non-empty value for `name` but received {name!r}") + if not queue_id: + raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}") return await self._get( - f"/accounts/{account_id}/workers/queues/{name}", + f"/accounts/{account_id}/queues/{queue_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -494,7 +522,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[WorkersQueue]], ResultWrapper[WorkersQueue]), + cast_to=cast(Type[Optional[QueueGetResponse]], ResultWrapper[QueueGetResponse]), ) @@ -522,6 +550,10 @@ def __init__(self, queues: Queues) -> None: def consumers(self) -> ConsumersWithRawResponse: return ConsumersWithRawResponse(self._queues.consumers) + @cached_property + def messages(self) -> MessagesWithRawResponse: + return MessagesWithRawResponse(self._queues.messages) + class AsyncQueuesWithRawResponse: def __init__(self, queues: AsyncQueues) -> None: @@ -547,6 +579,10 @@ def __init__(self, queues: AsyncQueues) -> None: def consumers(self) -> AsyncConsumersWithRawResponse: return AsyncConsumersWithRawResponse(self._queues.consumers) + @cached_property + def messages(self) -> AsyncMessagesWithRawResponse: + return AsyncMessagesWithRawResponse(self._queues.messages) + class QueuesWithStreamingResponse: def __init__(self, queues: Queues) -> None: @@ -572,6 +608,10 @@ def __init__(self, queues: Queues) -> None: def consumers(self) -> ConsumersWithStreamingResponse: return ConsumersWithStreamingResponse(self._queues.consumers) + @cached_property + def messages(self) -> MessagesWithStreamingResponse: + return MessagesWithStreamingResponse(self._queues.messages) + class AsyncQueuesWithStreamingResponse: def __init__(self, queues: AsyncQueues) -> None: @@ -596,3 +636,7 @@ def __init__(self, queues: AsyncQueues) -> None: @cached_property def consumers(self) -> AsyncConsumersWithStreamingResponse: return AsyncConsumersWithStreamingResponse(self._queues.consumers) + + @cached_property + def messages(self) -> AsyncMessagesWithStreamingResponse: + return AsyncMessagesWithStreamingResponse(self._queues.messages) diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index c4af458470e..302dcfb7a30 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -13,7 +13,6 @@ from .dnssec_dnssec import DNSSECDNSSEC as DNSSECDNSSEC from .load_balancer import LoadBalancer as LoadBalancer from .stream_videos import StreamVideos as StreamVideos -from .workers_queue import WorkersQueue as WorkersQueue from .ip_list_params import IPListParams as IPListParams from .zones_page_rule import ZonesPageRule as ZonesPageRule from .ip_list_response import IPListResponse as IPListResponse @@ -33,6 +32,7 @@ from .pcap_create_params import PCAPCreateParams as PCAPCreateParams from .pcap_list_response import PCAPListResponse as PCAPListResponse from .plan_list_response import PlanListResponse as PlanListResponse +from .queue_get_response import QueueGetResponse as QueueGetResponse from .stream_list_params import StreamListParams as StreamListParams from .user_edit_response import UserEditResponse as UserEditResponse from .zone_create_params import ZoneCreateParams as ZoneCreateParams @@ -56,14 +56,14 @@ from .calls_app_with_secret import CallsAppWithSecret as CallsAppWithSecret from .origin_ca_certificate import OriginCACertificate as OriginCACertificate from .pagerule_get_response import PageruleGetResponse as PageruleGetResponse +from .queue_create_response import QueueCreateResponse as QueueCreateResponse from .queue_delete_response import QueueDeleteResponse as QueueDeleteResponse +from .queue_update_response import QueueUpdateResponse as QueueUpdateResponse from .ruleset_create_params import RulesetCreateParams as RulesetCreateParams from .ruleset_update_params import RulesetUpdateParams as RulesetUpdateParams from .snippet_list_response import SnippetListResponse as SnippetListResponse from .snippet_update_params import SnippetUpdateParams as SnippetUpdateParams from .speed_delete_response import SpeedDeleteResponse as SpeedDeleteResponse -from .workers_queue_created import WorkersQueueCreated as WorkersQueueCreated -from .workers_queue_updated import WorkersQueueUpdated as WorkersQueueUpdated from .dnssec_delete_response import DNSSECDeleteResponse as DNSSECDeleteResponse from .filter_create_response import FilterCreateResponse as FilterCreateResponse from .membership_list_params import MembershipListParams as MembershipListParams diff --git a/src/cloudflare/types/workers_queue_created.py b/src/cloudflare/types/queue_create_response.py similarity index 81% rename from src/cloudflare/types/workers_queue_created.py rename to src/cloudflare/types/queue_create_response.py index a51bee0dd68..1a1c3b8d771 100644 --- a/src/cloudflare/types/workers_queue_created.py +++ b/src/cloudflare/types/queue_create_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["WorkersQueueCreated"] +__all__ = ["QueueCreateResponse"] -class WorkersQueueCreated(BaseModel): +class QueueCreateResponse(BaseModel): created_on: Optional[object] = None modified_on: Optional[object] = None diff --git a/src/cloudflare/types/workers_queue.py b/src/cloudflare/types/queue_get_response.py similarity index 81% rename from src/cloudflare/types/workers_queue.py rename to src/cloudflare/types/queue_get_response.py index 570fb72da70..c7b3d43ad11 100644 --- a/src/cloudflare/types/workers_queue.py +++ b/src/cloudflare/types/queue_get_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["WorkersQueue"] +__all__ = ["QueueGetResponse"] -class WorkersQueue(BaseModel): +class QueueGetResponse(BaseModel): consumers: Optional[object] = None consumers_total_count: Optional[object] = None @@ -20,6 +20,6 @@ class WorkersQueue(BaseModel): producers_total_count: Optional[object] = None - queue_id: Optional[object] = None + queue_id: Optional[str] = None queue_name: Optional[str] = None diff --git a/src/cloudflare/types/queue_list_response.py b/src/cloudflare/types/queue_list_response.py index 38292ecb7cb..9b0038b8c4d 100644 --- a/src/cloudflare/types/queue_list_response.py +++ b/src/cloudflare/types/queue_list_response.py @@ -1,9 +1,28 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List +from typing import List, Optional -from .workers_queue import WorkersQueue +from .._models import BaseModel -__all__ = ["QueueListResponse"] +__all__ = ["QueueListResponse", "QueueListResponseItem"] -QueueListResponse = List[WorkersQueue] + +class QueueListResponseItem(BaseModel): + consumers: Optional[object] = None + + consumers_total_count: Optional[object] = None + + created_on: Optional[object] = None + + modified_on: Optional[object] = None + + producers: Optional[object] = None + + producers_total_count: Optional[object] = None + + queue_id: Optional[str] = None + + queue_name: Optional[str] = None + + +QueueListResponse = List[QueueListResponseItem] diff --git a/src/cloudflare/types/workers_queue_updated.py b/src/cloudflare/types/queue_update_response.py similarity index 81% rename from src/cloudflare/types/workers_queue_updated.py rename to src/cloudflare/types/queue_update_response.py index 95514245ef3..032b4f22b2d 100644 --- a/src/cloudflare/types/workers_queue_updated.py +++ b/src/cloudflare/types/queue_update_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["WorkersQueueUpdated"] +__all__ = ["QueueUpdateResponse"] -class WorkersQueueUpdated(BaseModel): +class QueueUpdateResponse(BaseModel): created_on: Optional[object] = None modified_on: Optional[object] = None diff --git a/src/cloudflare/types/queues/__init__.py b/src/cloudflare/types/queues/__init__.py index 7319b069d4f..bd13e89010f 100644 --- a/src/cloudflare/types/queues/__init__.py +++ b/src/cloudflare/types/queues/__init__.py @@ -2,10 +2,13 @@ from __future__ import annotations -from .workers_consumer import WorkersConsumer as WorkersConsumer +from .message_ack_params import MessageAckParams as MessageAckParams +from .message_pull_params import MessagePullParams as MessagePullParams +from .message_ack_response import MessageAckResponse as MessageAckResponse from .consumer_get_response import ConsumerGetResponse as ConsumerGetResponse +from .message_pull_response import MessagePullResponse as MessagePullResponse 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 .workers_consumer_created import WorkersConsumerCreated as WorkersConsumerCreated -from .workers_consumer_updated import WorkersConsumerUpdated as WorkersConsumerUpdated +from .consumer_update_response import ConsumerUpdateResponse as ConsumerUpdateResponse diff --git a/src/cloudflare/types/queues/workers_consumer_updated.py b/src/cloudflare/types/queues/consumer_create_response.py similarity index 78% rename from src/cloudflare/types/queues/workers_consumer_updated.py rename to src/cloudflare/types/queues/consumer_create_response.py index 826273761fc..14efd41f1da 100644 --- a/src/cloudflare/types/queues/workers_consumer_updated.py +++ b/src/cloudflare/types/queues/consumer_create_response.py @@ -4,18 +4,19 @@ from ..._models import BaseModel -__all__ = ["WorkersConsumerUpdated", "Settings"] +__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 max_wait_time_ms: Optional[float] = None -class WorkersConsumerUpdated(BaseModel): +class ConsumerCreateResponse(BaseModel): created_on: Optional[object] = None dead_letter_queue: Optional[str] = None diff --git a/src/cloudflare/types/queues/consumer_get_response.py b/src/cloudflare/types/queues/consumer_get_response.py index 598c5b3bdec..8a00b17a127 100644 --- a/src/cloudflare/types/queues/consumer_get_response.py +++ b/src/cloudflare/types/queues/consumer_get_response.py @@ -1,9 +1,31 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List +from typing import List, Optional -from .workers_consumer import WorkersConsumer +from ..._models import BaseModel -__all__ = ["ConsumerGetResponse"] +__all__ = ["ConsumerGetResponse", "ConsumerGetResponseItem", "ConsumerGetResponseItemSettings"] -ConsumerGetResponse = List[WorkersConsumer] + +class ConsumerGetResponseItemSettings(BaseModel): + batch_size: Optional[float] = None + """The maximum number of messages to include in a batch""" + + max_retries: Optional[float] = None + + max_wait_time_ms: Optional[float] = None + + +class ConsumerGetResponseItem(BaseModel): + created_on: Optional[object] = None + + environment: Optional[object] = None + + queue_name: Optional[object] = None + + service: Optional[object] = None + + settings: Optional[ConsumerGetResponseItemSettings] = None + + +ConsumerGetResponse = List[ConsumerGetResponseItem] diff --git a/src/cloudflare/types/queues/consumer_update_params.py b/src/cloudflare/types/queues/consumer_update_params.py index 340f2d05e8f..a741a247317 100644 --- a/src/cloudflare/types/queues/consumer_update_params.py +++ b/src/cloudflare/types/queues/consumer_update_params.py @@ -11,6 +11,7 @@ class ConsumerUpdateParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - name: Required[str] + queue_id: Required[str] + """Identifier""" body: Required[object] diff --git a/src/cloudflare/types/queues/workers_consumer_created.py b/src/cloudflare/types/queues/consumer_update_response.py similarity index 86% rename from src/cloudflare/types/queues/workers_consumer_created.py rename to src/cloudflare/types/queues/consumer_update_response.py index d280dc893ef..5ce387b1acf 100644 --- a/src/cloudflare/types/queues/workers_consumer_created.py +++ b/src/cloudflare/types/queues/consumer_update_response.py @@ -4,7 +4,7 @@ from ..._models import BaseModel -__all__ = ["WorkersConsumerCreated", "Settings"] +__all__ = ["ConsumerUpdateResponse", "Settings"] class Settings(BaseModel): @@ -15,7 +15,7 @@ class Settings(BaseModel): max_wait_time_ms: Optional[float] = None -class WorkersConsumerCreated(BaseModel): +class ConsumerUpdateResponse(BaseModel): created_on: Optional[object] = None dead_letter_queue: Optional[str] = None diff --git a/src/cloudflare/types/queues/message_ack_params.py b/src/cloudflare/types/queues/message_ack_params.py new file mode 100644 index 00000000000..a076ef3df88 --- /dev/null +++ b/src/cloudflare/types/queues/message_ack_params.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +__all__ = ["MessageAckParams", "Ack", "Retry"] + + +class MessageAckParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + acks: Iterable[Ack] + + retries: Iterable[Retry] + + +class Ack(TypedDict, total=False): + lease_id: str + """Lease ID for a message to acknowledge.""" + + +class Retry(TypedDict, total=False): + delay_seconds: float + """ + The number of seconds to delay before making the message available for another + attempt. + """ + + lease_id: str + """Lease ID for a message to retry.""" diff --git a/src/cloudflare/types/queues/message_ack_response.py b/src/cloudflare/types/queues/message_ack_response.py new file mode 100644 index 00000000000..c668fad5379 --- /dev/null +++ b/src/cloudflare/types/queues/message_ack_response.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["MessageAckResponse"] + + +class MessageAckResponse(BaseModel): + ack_count: Optional[float] = FieldInfo(alias="ackCount", default=None) + """The number of messages that were succesfully acknowledged""" + + retry_count: Optional[float] = FieldInfo(alias="retryCount", default=None) + """The number of messages that were succesfully retried""" + + warnings: Optional[List[str]] = None diff --git a/src/cloudflare/types/queues/message_pull_params.py b/src/cloudflare/types/queues/message_pull_params.py new file mode 100644 index 00000000000..02f48d4faec --- /dev/null +++ b/src/cloudflare/types/queues/message_pull_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["MessagePullParams"] + + +class MessagePullParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + batch_size: float + """The maximum number of messages to include in a batch""" + + 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 new file mode 100644 index 00000000000..7944734a2cb --- /dev/null +++ b/src/cloudflare/types/queues/message_pull_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel + +__all__ = ["MessagePullResponse", "MessagePullResponseItem"] + + +class MessagePullResponseItem(BaseModel): + id: Optional[str] = None + + attempts: Optional[float] = None + + body: Optional[str] = None + + lease_id: Optional[str] = None + + metadata: Optional[object] = None + + timestamp_ms: Optional[float] = None + + +MessagePullResponse = List[MessagePullResponseItem] diff --git a/src/cloudflare/types/queues/workers_consumer.py b/src/cloudflare/types/queues/workers_consumer.py deleted file mode 100644 index f7586f8ed48..00000000000 --- a/src/cloudflare/types/queues/workers_consumer.py +++ /dev/null @@ -1,27 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["WorkersConsumer", "Settings"] - - -class Settings(BaseModel): - batch_size: Optional[float] = None - - max_retries: Optional[float] = None - - max_wait_time_ms: Optional[float] = None - - -class WorkersConsumer(BaseModel): - created_on: Optional[object] = None - - environment: Optional[object] = None - - queue_name: Optional[object] = None - - service: Optional[object] = None - - settings: Optional[Settings] = None diff --git a/tests/api_resources/queues/test_consumers.py b/tests/api_resources/queues/test_consumers.py index 8e654703d04..7c1c4a3c952 100644 --- a/tests/api_resources/queues/test_consumers.py +++ b/tests/api_resources/queues/test_consumers.py @@ -11,9 +11,9 @@ from tests.utils import assert_matches_type from cloudflare.types.queues import ( ConsumerGetResponse, + ConsumerCreateResponse, ConsumerDeleteResponse, - WorkersConsumerCreated, - WorkersConsumerUpdated, + ConsumerUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -26,7 +26,7 @@ class TestConsumers: @parametrize def test_method_create(self, client: Cloudflare) -> None: consumer = client.queues.consumers.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -39,13 +39,13 @@ def test_method_create(self, client: Cloudflare) -> None: }, }, ) - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.queues.consumers.with_raw_response.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -62,13 +62,13 @@ 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" consumer = response.parse() - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.queues.consumers.with_streaming_response.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -85,7 +85,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" consumer = response.parse() - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) assert cast(Any, response.is_closed) is True @@ -94,7 +94,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: def test_path_params_create(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( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", body={ "dead_letter_queue": "example-dlq", @@ -108,7 +108,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.consumers.with_raw_response.create( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -128,9 +128,9 @@ def test_path_params_create(self, client: Cloudflare) -> None: @parametrize def test_method_update(self, client: Cloudflare) -> None: consumer = client.queues.consumers.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -138,15 +138,15 @@ def test_method_update(self, client: Cloudflare) -> None: "settings": {"batch_size": 100}, }, ) - assert_matches_type(Optional[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.queues.consumers.with_raw_response.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -158,15 +158,15 @@ def test_raw_response_update(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[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.queues.consumers.with_streaming_response.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -178,7 +178,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" consumer = response.parse() - assert_matches_type(Optional[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) assert cast(Any, response.is_closed) is True @@ -187,9 +187,9 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: def test_path_params_update(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( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -198,11 +198,11 @@ def test_path_params_update(self, client: Cloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.consumers.with_raw_response.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="", + queue_id="", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -211,11 +211,11 @@ def test_path_params_update(self, client: Cloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"): client.queues.consumers.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -228,9 +228,9 @@ def test_path_params_update(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: consumer = client.queues.consumers.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"]) @@ -238,9 +238,9 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.queues.consumers.with_raw_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -252,9 +252,9 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.queues.consumers.with_streaming_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -269,30 +269,30 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: def test_path_params_delete(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.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.consumers.with_raw_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="", + queue_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"): client.queues.consumers.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) @pytest.mark.skip() @parametrize def test_method_get(self, client: Cloudflare) -> None: consumer = client.queues.consumers.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[ConsumerGetResponse], consumer, path=["response"]) @@ -301,7 +301,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.queues.consumers.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -314,7 +314,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.queues.consumers.with_streaming_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -330,11 +330,11 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(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.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.consumers.with_raw_response.get( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -348,7 +348,7 @@ class TestAsyncConsumers: @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: consumer = await async_client.queues.consumers.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -361,13 +361,13 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: }, }, ) - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.consumers.with_raw_response.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -384,13 +384,13 @@ 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" consumer = await response.parse() - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.consumers.with_streaming_response.create( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "example-dlq", @@ -407,7 +407,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" consumer = await response.parse() - assert_matches_type(Optional[WorkersConsumerCreated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerCreateResponse], consumer, path=["response"]) assert cast(Any, response.is_closed) is True @@ -416,7 +416,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> async def test_path_params_create(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( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", body={ "dead_letter_queue": "example-dlq", @@ -430,7 +430,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + 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( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -450,9 +450,9 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: consumer = await async_client.queues.consumers.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -460,15 +460,15 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "settings": {"batch_size": 100}, }, ) - assert_matches_type(Optional[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.consumers.with_raw_response.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -480,15 +480,15 @@ async def test_raw_response_update(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[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) @pytest.mark.skip() @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.consumers.with_streaming_response.update( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -500,7 +500,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" consumer = await response.parse() - assert_matches_type(Optional[WorkersConsumerUpdated], consumer, path=["response"]) + assert_matches_type(Optional[ConsumerUpdateResponse], consumer, path=["response"]) assert cast(Any, response.is_closed) is True @@ -509,9 +509,9 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> async def test_path_params_update(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( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -520,11 +520,11 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + 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( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="", + queue_id="", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -533,11 +533,11 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: }, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_name` but received ''"): + 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( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", body={ "dead_letter_queue": "updated-example-dlq", "environment": "production", @@ -550,9 +550,9 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: consumer = await async_client.queues.consumers.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[ConsumerDeleteResponse], consumer, path=["response"]) @@ -560,9 +560,9 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.consumers.with_raw_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True @@ -574,9 +574,9 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.consumers.with_streaming_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -591,30 +591,30 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> async def test_path_params_delete(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.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): await async_client.queues.consumers.with_raw_response.delete( - "example-consumer", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="", + queue_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `consumer_id` but received ''"): await async_client.queues.consumers.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", - name="example-queue", + queue_id="023e105f4ecef8ad9ca31a8372d0c353", ) @pytest.mark.skip() @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: consumer = await async_client.queues.consumers.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[ConsumerGetResponse], consumer, path=["response"]) @@ -623,7 +623,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.consumers.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -636,7 +636,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.consumers.with_streaming_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -652,11 +652,11 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(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.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): await async_client.queues.consumers.with_raw_response.get( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", diff --git a/tests/api_resources/queues/test_messages.py b/tests/api_resources/queues/test_messages.py new file mode 100644 index 00000000000..1e24941e1b8 --- /dev/null +++ b/tests/api_resources/queues/test_messages.py @@ -0,0 +1,320 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.queues import MessageAckResponse, MessagePullResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestMessages: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_ack(self, client: Cloudflare) -> None: + message = client.queues.messages.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_ack_with_all_params(self, client: Cloudflare) -> None: + message = client.queues.messages.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + acks=[ + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + ], + retries=[ + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + ], + ) + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_ack(self, client: Cloudflare) -> None: + response = client.queues.messages.with_raw_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = response.parse() + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_ack(self, client: Cloudflare) -> None: + with client.queues.messages.with_streaming_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = response.parse() + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_ack(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.queues.messages.with_raw_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + client.queues.messages.with_raw_response.ack( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_pull(self, client: Cloudflare) -> None: + message = client.queues.messages.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_pull_with_all_params(self, client: Cloudflare) -> None: + message = client.queues.messages.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + batch_size=10, + visibility_timeout_ms=1000, + ) + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_pull(self, client: Cloudflare) -> None: + response = client.queues.messages.with_raw_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = response.parse() + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_pull(self, client: Cloudflare) -> None: + with client.queues.messages.with_streaming_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = response.parse() + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_pull(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.queues.messages.with_raw_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + client.queues.messages.with_raw_response.pull( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncMessages: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_ack(self, async_client: AsyncCloudflare) -> None: + message = await async_client.queues.messages.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_ack_with_all_params(self, async_client: AsyncCloudflare) -> None: + message = await async_client.queues.messages.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + acks=[ + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + { + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0" + }, + ], + retries=[ + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + { + "delay_seconds": 10, + "lease_id": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0..Q8p21d7dceR6vUfwftONdQ.JVqZgAS-Zk7MqmqccYtTHeeMElNHaOMigeWdb8LyMOg.T2_HV99CYzGaQuhTyW8RsgbnpTRZHRM6N7UoSaAKeK0", + }, + ], + ) + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_ack(self, async_client: AsyncCloudflare) -> None: + response = await async_client.queues.messages.with_raw_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = await response.parse() + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_ack(self, async_client: AsyncCloudflare) -> None: + async with async_client.queues.messages.with_streaming_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = await response.parse() + assert_matches_type(Optional[MessageAckResponse], message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_ack(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.messages.with_raw_response.ack( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + await async_client.queues.messages.with_raw_response.ack( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_pull(self, async_client: AsyncCloudflare) -> None: + message = await async_client.queues.messages.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_pull_with_all_params(self, async_client: AsyncCloudflare) -> None: + message = await async_client.queues.messages.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + batch_size=10, + visibility_timeout_ms=1000, + ) + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_pull(self, async_client: AsyncCloudflare) -> None: + response = await async_client.queues.messages.with_raw_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + message = await response.parse() + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_pull(self, async_client: AsyncCloudflare) -> None: + async with async_client.queues.messages.with_streaming_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + message = await response.parse() + assert_matches_type(Optional[MessagePullResponse], message, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_pull(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.messages.with_raw_response.pull( + "023e105f4ecef8ad9ca31a8372d0c353", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): + await async_client.queues.messages.with_raw_response.pull( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/test_queues.py b/tests/api_resources/test_queues.py index cd0a812f7c0..0d2b8b65738 100644 --- a/tests/api_resources/test_queues.py +++ b/tests/api_resources/test_queues.py @@ -10,11 +10,11 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types import ( - WorkersQueue, + QueueGetResponse, QueueListResponse, + QueueCreateResponse, QueueDeleteResponse, - WorkersQueueCreated, - WorkersQueueUpdated, + QueueUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "example-queue"}, ) - assert_matches_type(Optional[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize @@ -43,7 +43,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[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize @@ -56,7 +56,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[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -73,17 +73,17 @@ def test_path_params_create(self, client: Cloudflare) -> None: @parametrize def test_method_update(self, client: Cloudflare) -> None: queue = client.queues.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) - assert_matches_type(Optional[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.queues.with_raw_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) @@ -91,13 +91,13 @@ def test_raw_response_update(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[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.queues.with_streaming_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) as response: @@ -105,7 +105,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" queue = response.parse() - assert_matches_type(Optional[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -114,12 +114,12 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.queues.with_raw_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", body={"queue_name": "renamed-example-queue"}, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -172,7 +172,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: @parametrize def test_method_delete(self, client: Cloudflare) -> None: queue = client.queues.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"]) @@ -181,7 +181,7 @@ def test_method_delete(self, client: Cloudflare) -> None: @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.queues.with_raw_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -194,7 +194,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.queues.with_streaming_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -210,11 +210,11 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.queues.with_raw_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -224,36 +224,36 @@ def test_path_params_delete(self, client: Cloudflare) -> None: @parametrize def test_method_get(self, client: Cloudflare) -> None: queue = client.queues.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.queues.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" queue = response.parse() - assert_matches_type(Optional[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.queues.with_streaming_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" queue = response.parse() - assert_matches_type(Optional[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -262,11 +262,11 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.queues.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): client.queues.with_raw_response.get( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -283,7 +283,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "example-queue"}, ) - assert_matches_type(Optional[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize @@ -296,7 +296,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[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize @@ -309,7 +309,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[WorkersQueueCreated], queue, path=["response"]) + assert_matches_type(Optional[QueueCreateResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -326,17 +326,17 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: queue = await async_client.queues.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) - assert_matches_type(Optional[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.with_raw_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) @@ -344,13 +344,13 @@ async def test_raw_response_update(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[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.with_streaming_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={"queue_name": "renamed-example-queue"}, ) as response: @@ -358,7 +358,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" queue = await response.parse() - assert_matches_type(Optional[WorkersQueueUpdated], queue, path=["response"]) + assert_matches_type(Optional[QueueUpdateResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -367,12 +367,12 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> async def test_path_params_update(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.with_raw_response.update( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", body={"queue_name": "renamed-example-queue"}, ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): await async_client.queues.with_raw_response.update( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -425,7 +425,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: queue = await async_client.queues.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert_matches_type(Optional[QueueDeleteResponse], queue, path=["response"]) @@ -434,7 +434,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.with_raw_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) @@ -447,7 +447,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.with_streaming_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) as response: assert not response.is_closed @@ -463,11 +463,11 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> async def test_path_params_delete(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.with_raw_response.delete( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): await async_client.queues.with_raw_response.delete( "", account_id="023e105f4ecef8ad9ca31a8372d0c353", @@ -477,36 +477,36 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: queue = await async_client.queues.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.queues.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" queue = await response.parse() - assert_matches_type(Optional[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) @pytest.mark.skip() @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.queues.with_streaming_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) 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[WorkersQueue], queue, path=["response"]) + assert_matches_type(Optional[QueueGetResponse], queue, path=["response"]) assert cast(Any, response.is_closed) is True @@ -515,11 +515,11 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(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.with_raw_response.get( - "example-queue", + "023e105f4ecef8ad9ca31a8372d0c353", account_id="", ) - with pytest.raises(ValueError, match=r"Expected a non-empty value for `name` but received ''"): + with pytest.raises(ValueError, match=r"Expected a non-empty value for `queue_id` but received ''"): await async_client.queues.with_raw_response.get( "", account_id="023e105f4ecef8ad9ca31a8372d0c353",