Skip to content

Commit 87add37

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

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
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">SyncSinglePage[QueueListResponse]</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>
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

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

@@ -168,7 +166,7 @@ def list(
168166
extra_query: Query | None = None,
169167
extra_body: Body | None = None,
170168
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
171-
) -> SyncSinglePage[QueueListResponse]:
169+
) -> Optional[QueueListResponse]:
172170
"""
173171
Returns the queues owned by an account.
174172
@@ -185,13 +183,16 @@ def list(
185183
"""
186184
if not account_id:
187185
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
188-
return self._get_api_list(
186+
return self._get(
189187
f"/accounts/{account_id}/queues",
190-
page=SyncSinglePage[QueueListResponse],
191188
options=make_request_options(
192-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
189+
extra_headers=extra_headers,
190+
extra_query=extra_query,
191+
extra_body=extra_body,
192+
timeout=timeout,
193+
post_parser=ResultWrapper._unwrapper,
193194
),
194-
model=QueueListResponse,
195+
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
195196
)
196197

197198
def delete(
@@ -392,7 +393,7 @@ async def update(
392393
cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]),
393394
)
394395

395-
def list(
396+
async def list(
396397
self,
397398
*,
398399
account_id: str,
@@ -402,7 +403,7 @@ def list(
402403
extra_query: Query | None = None,
403404
extra_body: Body | None = None,
404405
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
405-
) -> AsyncPaginator[QueueListResponse, AsyncSinglePage[QueueListResponse]]:
406+
) -> Optional[QueueListResponse]:
406407
"""
407408
Returns the queues owned by an account.
408409
@@ -419,13 +420,16 @@ def list(
419420
"""
420421
if not account_id:
421422
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
422-
return self._get_api_list(
423+
return await self._get(
423424
f"/accounts/{account_id}/queues",
424-
page=AsyncSinglePage[QueueListResponse],
425425
options=make_request_options(
426-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
426+
extra_headers=extra_headers,
427+
extra_query=extra_query,
428+
extra_body=extra_body,
429+
timeout=timeout,
430+
post_parser=ResultWrapper._unwrapper,
427431
),
428-
model=QueueListResponse,
432+
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
429433
)
430434

431435
async def delete(

src/cloudflare/types/queue_list_response.py

+6-3
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__ = ["QueueListResponse"]
7+
__all__ = ["QueueListResponse", "QueueListResponseItem"]
88

99

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

1313
consumers_total_count: Optional[object] = None
@@ -23,3 +23,6 @@ class QueueListResponse(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

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

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

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

138137
@pytest.mark.skip()
139138
@parametrize
@@ -145,7 +144,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None:
145144
assert response.is_closed is True
146145
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
147146
queue = response.parse()
148-
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
147+
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
149148

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

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

162161
assert cast(Any, response.is_closed) is True
163162

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

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

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

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

415414
assert cast(Any, response.is_closed) is True
416415

0 commit comments

Comments
 (0)