Skip to content

Commit 033c962

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): update via SDK Studio (#210)
1 parent 70bd1e4 commit 033c962

File tree

4 files changed

+24
-30
lines changed

4 files changed

+24
-30
lines changed

api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2960,7 +2960,7 @@ Methods:
29602960

29612961
- <code title="post /accounts/{account_id}/queues">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/queue_create_params.py">params</a>) -> <a href="./src/cloudflare/types/queue_create_response.py">Optional</a></code>
29622962
- <code title="put /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">update</a>(queue_id, \*, account_id, \*\*<a href="src/cloudflare/types/queue_update_params.py">params</a>) -> <a href="./src/cloudflare/types/queue_update_response.py">Optional</a></code>
2963-
- <code title="get /accounts/{account_id}/queues">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/queue_list_response.py">Optional</a></code>
2963+
- <code title="get /accounts/{account_id}/queues">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/queue_list_response.py">SyncSinglePage[QueueListResponse]</a></code>
29642964
- <code title="delete /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">delete</a>(queue_id, \*, account_id) -> <a href="./src/cloudflare/types/queue_delete_response.py">Optional</a></code>
29652965
- <code title="get /accounts/{account_id}/queues/{queue_id}">client.queues.<a href="./src/cloudflare/resources/queues/queues.py">get</a>(queue_id, \*, account_id) -> <a href="./src/cloudflare/types/queue_get_response.py">Optional</a></code>
29662966

src/cloudflare/resources/queues/queues.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
async_to_streamed_response_wrapper,
4646
)
4747
from ..._wrappers import ResultWrapper
48+
from ...pagination import SyncSinglePage, AsyncSinglePage
4849
from ..._base_client import (
50+
AsyncPaginator,
4951
make_request_options,
5052
)
5153

@@ -166,7 +168,7 @@ def list(
166168
extra_query: Query | None = None,
167169
extra_body: Body | None = None,
168170
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
169-
) -> Optional[QueueListResponse]:
171+
) -> SyncSinglePage[QueueListResponse]:
170172
"""
171173
Returns the queues owned by an account.
172174
@@ -183,16 +185,13 @@ def list(
183185
"""
184186
if not account_id:
185187
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
186-
return self._get(
188+
return self._get_api_list(
187189
f"/accounts/{account_id}/queues",
190+
page=SyncSinglePage[QueueListResponse],
188191
options=make_request_options(
189-
extra_headers=extra_headers,
190-
extra_query=extra_query,
191-
extra_body=extra_body,
192-
timeout=timeout,
193-
post_parser=ResultWrapper._unwrapper,
192+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
194193
),
195-
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
194+
model=QueueListResponse,
196195
)
197196

198197
def delete(
@@ -393,7 +392,7 @@ async def update(
393392
cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]),
394393
)
395394

396-
async def list(
395+
def list(
397396
self,
398397
*,
399398
account_id: str,
@@ -403,7 +402,7 @@ async def list(
403402
extra_query: Query | None = None,
404403
extra_body: Body | None = None,
405404
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
406-
) -> Optional[QueueListResponse]:
405+
) -> AsyncPaginator[QueueListResponse, AsyncSinglePage[QueueListResponse]]:
407406
"""
408407
Returns the queues owned by an account.
409408
@@ -420,16 +419,13 @@ async def list(
420419
"""
421420
if not account_id:
422421
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
423-
return await self._get(
422+
return self._get_api_list(
424423
f"/accounts/{account_id}/queues",
424+
page=AsyncSinglePage[QueueListResponse],
425425
options=make_request_options(
426-
extra_headers=extra_headers,
427-
extra_query=extra_query,
428-
extra_body=extra_body,
429-
timeout=timeout,
430-
post_parser=ResultWrapper._unwrapper,
426+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
431427
),
432-
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
428+
model=QueueListResponse,
433429
)
434430

435431
async def delete(

src/cloudflare/types/queue_list_response.py

+3-6
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 List, Optional
3+
from typing import Optional
44

55
from .._models import BaseModel
66

7-
__all__ = ["QueueListResponse", "QueueListResponseItem"]
7+
__all__ = ["QueueListResponse"]
88

99

10-
class QueueListResponseItem(BaseModel):
10+
class QueueListResponse(BaseModel):
1111
consumers: Optional[object] = None
1212

1313
consumers_total_count: Optional[object] = None
@@ -23,6 +23,3 @@ class QueueListResponseItem(BaseModel):
2323
queue_id: Optional[str] = None
2424

2525
queue_name: Optional[str] = None
26-
27-
28-
QueueListResponse = List[QueueListResponseItem]

tests/api_resources/test_queues.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
QueueDeleteResponse,
1717
QueueUpdateResponse,
1818
)
19+
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
1920

2021
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
2122

@@ -132,7 +133,7 @@ def test_method_list(self, client: Cloudflare) -> None:
132133
queue = client.queues.list(
133134
account_id="023e105f4ecef8ad9ca31a8372d0c353",
134135
)
135-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
136+
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
136137

137138
@pytest.mark.skip()
138139
@parametrize
@@ -144,7 +145,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None:
144145
assert response.is_closed is True
145146
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
146147
queue = response.parse()
147-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
148+
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
148149

149150
@pytest.mark.skip()
150151
@parametrize
@@ -156,7 +157,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
156157
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
157158

158159
queue = response.parse()
159-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
160+
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
160161

161162
assert cast(Any, response.is_closed) is True
162163

@@ -385,7 +386,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
385386
queue = await async_client.queues.list(
386387
account_id="023e105f4ecef8ad9ca31a8372d0c353",
387388
)
388-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
389+
assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])
389390

390391
@pytest.mark.skip()
391392
@parametrize
@@ -397,7 +398,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
397398
assert response.is_closed is True
398399
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
399400
queue = await response.parse()
400-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
401+
assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])
401402

402403
@pytest.mark.skip()
403404
@parametrize
@@ -409,7 +410,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
409410
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
410411

411412
queue = await response.parse()
412-
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
413+
assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])
413414

414415
assert cast(Any, response.is_closed) is True
415416

0 commit comments

Comments
 (0)