Skip to content

Commit 78d01a7

Browse files
feat(api): api update
1 parent bea2538 commit 78d01a7

File tree

5 files changed

+40
-31
lines changed

5 files changed

+40
-31
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1734
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d5e9a5f8f3f612c25db8c16420f383742353ef7498fff7d053941ffe104056cd.yml
3-
openapi_spec_hash: 1fd0448a000ae00795284903c0cc240e
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d93c74b07b7ff242a14162d8afcf07aa1f29e3202d4e005c073a2d2e7dbf99e.yml
3+
openapi_spec_hash: f30eba752a22db6a739dff48b749ed0b
44
config_hash: ab6d922663ab4c7b89e22975f70d50d8

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,7 @@ Methods:
27012701

27022702
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/ack">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">ack</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_ack_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_ack_response.py">Optional[MessageAckResponse]</a></code>
27032703
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/batch">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">bulk_push</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_bulk_push_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_bulk_push_response.py">MessageBulkPushResponse</a></code>
2704-
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/pull">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">pull</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_pull_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_pull_response.py">SyncSinglePage[MessagePullResponse]</a></code>
2704+
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages/pull">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">pull</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_pull_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_pull_response.py">Optional[MessagePullResponse]</a></code>
27052705
- <code title="post /accounts/{account_id}/queues/{queue_id}/messages">client.queues.messages.<a href="./src/cloudflare/resources/queues/messages.py">push</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queues/message_push_params.py">params</a>) -> <a href="./src/cloudflare/types/queues/message_push_response.py">MessagePushResponse</a></code>
27062706

27072707
## Purge

src/cloudflare/resources/queues/messages.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from ..._wrappers import ResultWrapper
21-
from ...pagination import SyncSinglePage, AsyncSinglePage
22-
from ..._base_client import AsyncPaginator, make_request_options
21+
from ..._base_client import make_request_options
2322
from ...types.queues import message_ack_params, message_pull_params, message_push_params, message_bulk_push_params
2423
from ...types.queues.message_ack_response import MessageAckResponse
2524
from ...types.queues.message_pull_response import MessagePullResponse
@@ -166,7 +165,7 @@ def pull(
166165
extra_query: Query | None = None,
167166
extra_body: Body | None = None,
168167
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
169-
) -> SyncSinglePage[MessagePullResponse]:
168+
) -> Optional[MessagePullResponse]:
170169
"""
171170
Pull a batch of messages from a Queue
172171
@@ -192,9 +191,8 @@ def pull(
192191
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
193192
if not queue_id:
194193
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
195-
return self._get_api_list(
194+
return self._post(
196195
f"/accounts/{account_id}/queues/{queue_id}/messages/pull",
197-
page=SyncSinglePage[MessagePullResponse],
198196
body=maybe_transform(
199197
{
200198
"batch_size": batch_size,
@@ -203,10 +201,13 @@ def pull(
203201
message_pull_params.MessagePullParams,
204202
),
205203
options=make_request_options(
206-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
204+
extra_headers=extra_headers,
205+
extra_query=extra_query,
206+
extra_body=extra_body,
207+
timeout=timeout,
208+
post_parser=ResultWrapper[Optional[MessagePullResponse]]._unwrapper,
207209
),
208-
model=MessagePullResponse,
209-
method="post",
210+
cast_to=cast(Type[Optional[MessagePullResponse]], ResultWrapper[MessagePullResponse]),
210211
)
211212

212213
@overload
@@ -444,7 +445,7 @@ async def bulk_push(
444445
cast_to=MessageBulkPushResponse,
445446
)
446447

447-
def pull(
448+
async def pull(
448449
self,
449450
queue_id: str,
450451
*,
@@ -457,7 +458,7 @@ def pull(
457458
extra_query: Query | None = None,
458459
extra_body: Body | None = None,
459460
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
460-
) -> AsyncPaginator[MessagePullResponse, AsyncSinglePage[MessagePullResponse]]:
461+
) -> Optional[MessagePullResponse]:
461462
"""
462463
Pull a batch of messages from a Queue
463464
@@ -483,21 +484,23 @@ def pull(
483484
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
484485
if not queue_id:
485486
raise ValueError(f"Expected a non-empty value for `queue_id` but received {queue_id!r}")
486-
return self._get_api_list(
487+
return await self._post(
487488
f"/accounts/{account_id}/queues/{queue_id}/messages/pull",
488-
page=AsyncSinglePage[MessagePullResponse],
489-
body=maybe_transform(
489+
body=await async_maybe_transform(
490490
{
491491
"batch_size": batch_size,
492492
"visibility_timeout_ms": visibility_timeout_ms,
493493
},
494494
message_pull_params.MessagePullParams,
495495
),
496496
options=make_request_options(
497-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
497+
extra_headers=extra_headers,
498+
extra_query=extra_query,
499+
extra_body=extra_body,
500+
timeout=timeout,
501+
post_parser=ResultWrapper[Optional[MessagePullResponse]]._unwrapper,
498502
),
499-
model=MessagePullResponse,
500-
method="post",
503+
cast_to=cast(Type[Optional[MessagePullResponse]], ResultWrapper[MessagePullResponse]),
501504
)
502505

503506
@overload

src/cloudflare/types/queues/message_pull_response.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
3+
from typing import List, Optional
44

55
from ..._models import BaseModel
66

7-
__all__ = ["MessagePullResponse"]
7+
__all__ = ["MessagePullResponse", "Message"]
88

99

10-
class MessagePullResponse(BaseModel):
10+
class Message(BaseModel):
1111
id: Optional[str] = None
1212

1313
attempts: Optional[float] = None
@@ -23,3 +23,10 @@ class MessagePullResponse(BaseModel):
2323
metadata: Optional[object] = None
2424

2525
timestamp_ms: Optional[float] = None
26+
27+
28+
class MessagePullResponse(BaseModel):
29+
message_backlog_count: Optional[float] = None
30+
"""The number of unacknowledged messages in the queue"""
31+
32+
messages: Optional[List[Message]] = None

tests/api_resources/queues/test_messages.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12-
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
1312
from cloudflare.types.queues import (
1413
MessageAckResponse,
1514
MessagePullResponse,
@@ -160,7 +159,7 @@ def test_method_pull(self, client: Cloudflare) -> None:
160159
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
161160
account_id="023e105f4ecef8ad9ca31a8372d0c353",
162161
)
163-
assert_matches_type(SyncSinglePage[MessagePullResponse], message, path=["response"])
162+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
164163

165164
@parametrize
166165
def test_method_pull_with_all_params(self, client: Cloudflare) -> None:
@@ -170,7 +169,7 @@ def test_method_pull_with_all_params(self, client: Cloudflare) -> None:
170169
batch_size=50,
171170
visibility_timeout_ms=6000,
172171
)
173-
assert_matches_type(SyncSinglePage[MessagePullResponse], message, path=["response"])
172+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
174173

175174
@parametrize
176175
def test_raw_response_pull(self, client: Cloudflare) -> None:
@@ -182,7 +181,7 @@ def test_raw_response_pull(self, client: Cloudflare) -> None:
182181
assert response.is_closed is True
183182
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
184183
message = response.parse()
185-
assert_matches_type(SyncSinglePage[MessagePullResponse], message, path=["response"])
184+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
186185

187186
@parametrize
188187
def test_streaming_response_pull(self, client: Cloudflare) -> None:
@@ -194,7 +193,7 @@ def test_streaming_response_pull(self, client: Cloudflare) -> None:
194193
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
195194

196195
message = response.parse()
197-
assert_matches_type(SyncSinglePage[MessagePullResponse], message, path=["response"])
196+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
198197

199198
assert cast(Any, response.is_closed) is True
200199

@@ -471,7 +470,7 @@ async def test_method_pull(self, async_client: AsyncCloudflare) -> None:
471470
queue_id="023e105f4ecef8ad9ca31a8372d0c353",
472471
account_id="023e105f4ecef8ad9ca31a8372d0c353",
473472
)
474-
assert_matches_type(AsyncSinglePage[MessagePullResponse], message, path=["response"])
473+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
475474

476475
@parametrize
477476
async def test_method_pull_with_all_params(self, async_client: AsyncCloudflare) -> None:
@@ -481,7 +480,7 @@ async def test_method_pull_with_all_params(self, async_client: AsyncCloudflare)
481480
batch_size=50,
482481
visibility_timeout_ms=6000,
483482
)
484-
assert_matches_type(AsyncSinglePage[MessagePullResponse], message, path=["response"])
483+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
485484

486485
@parametrize
487486
async def test_raw_response_pull(self, async_client: AsyncCloudflare) -> None:
@@ -493,7 +492,7 @@ async def test_raw_response_pull(self, async_client: AsyncCloudflare) -> None:
493492
assert response.is_closed is True
494493
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
495494
message = await response.parse()
496-
assert_matches_type(AsyncSinglePage[MessagePullResponse], message, path=["response"])
495+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
497496

498497
@parametrize
499498
async def test_streaming_response_pull(self, async_client: AsyncCloudflare) -> None:
@@ -505,7 +504,7 @@ async def test_streaming_response_pull(self, async_client: AsyncCloudflare) -> N
505504
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
506505

507506
message = await response.parse()
508-
assert_matches_type(AsyncSinglePage[MessagePullResponse], message, path=["response"])
507+
assert_matches_type(Optional[MessagePullResponse], message, path=["response"])
509508

510509
assert cast(Any, response.is_closed) is True
511510

0 commit comments

Comments
 (0)