From 44a5be1ea3484e0f3d2d72a56eff62935e51bbc4 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Wed, 3 Apr 2024 05:03:52 +0000
Subject: [PATCH] feat(api): update via SDK Studio (#211)
---
api.md | 2 +-
src/cloudflare/resources/queues/queues.py | 30 ++++++++++++---------
src/cloudflare/types/queue_list_response.py | 9 ++++---
tests/api_resources/test_queues.py | 13 +++++----
4 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/api.md b/api.md
index c085adab0bf0..479c140dede1 100644
--- a/api.md
+++ b/api.md
@@ -2960,7 +2960,7 @@ Methods:
- client.queues.create(\*, account_id, \*\*params) -> Optional
- client.queues.update(queue_id, \*, account_id, \*\*params) -> Optional
-- client.queues.list(\*, account_id) -> SyncSinglePage[QueueListResponse]
+- client.queues.list(\*, account_id) -> Optional
- client.queues.delete(queue_id, \*, account_id) -> Optional
- client.queues.get(queue_id, \*, account_id) -> Optional
diff --git a/src/cloudflare/resources/queues/queues.py b/src/cloudflare/resources/queues/queues.py
index 0f3f2a0c7fe1..5f3220b8cbb7 100644
--- a/src/cloudflare/resources/queues/queues.py
+++ b/src/cloudflare/resources/queues/queues.py
@@ -45,9 +45,7 @@
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
-from ...pagination import SyncSinglePage, AsyncSinglePage
from ..._base_client import (
- AsyncPaginator,
make_request_options,
)
@@ -168,7 +166,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SyncSinglePage[QueueListResponse]:
+ ) -> Optional[QueueListResponse]:
"""
Returns the queues owned by an account.
@@ -185,13 +183,16 @@ 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_api_list(
+ return self._get(
f"/accounts/{account_id}/queues",
- page=SyncSinglePage[QueueListResponse],
options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
),
- model=QueueListResponse,
+ cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
)
def delete(
@@ -392,7 +393,7 @@ async def update(
cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]),
)
- def list(
+ async def list(
self,
*,
account_id: str,
@@ -402,7 +403,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AsyncPaginator[QueueListResponse, AsyncSinglePage[QueueListResponse]]:
+ ) -> Optional[QueueListResponse]:
"""
Returns the queues owned by an account.
@@ -419,13 +420,16 @@ 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_api_list(
+ return await self._get(
f"/accounts/{account_id}/queues",
- page=AsyncSinglePage[QueueListResponse],
options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
),
- model=QueueListResponse,
+ cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
)
async def delete(
diff --git a/src/cloudflare/types/queue_list_response.py b/src/cloudflare/types/queue_list_response.py
index 1ccfe1e6e71e..9b0038b8c4df 100644
--- a/src/cloudflare/types/queue_list_response.py
+++ b/src/cloudflare/types/queue_list_response.py
@@ -1,13 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import Optional
+from typing import List, Optional
from .._models import BaseModel
-__all__ = ["QueueListResponse"]
+__all__ = ["QueueListResponse", "QueueListResponseItem"]
-class QueueListResponse(BaseModel):
+class QueueListResponseItem(BaseModel):
consumers: Optional[object] = None
consumers_total_count: Optional[object] = None
@@ -23,3 +23,6 @@ class QueueListResponse(BaseModel):
queue_id: Optional[str] = None
queue_name: Optional[str] = None
+
+
+QueueListResponse = List[QueueListResponseItem]
diff --git a/tests/api_resources/test_queues.py b/tests/api_resources/test_queues.py
index 2204fc81cdbb..0d2b8b65738f 100644
--- a/tests/api_resources/test_queues.py
+++ b/tests/api_resources/test_queues.py
@@ -16,7 +16,6 @@
QueueDeleteResponse,
QueueUpdateResponse,
)
-from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -133,7 +132,7 @@ def test_method_list(self, client: Cloudflare) -> None:
queue = client.queues.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -145,7 +144,7 @@ def test_raw_response_list(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(SyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -157,7 +156,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = response.parse()
- assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -386,7 +385,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
queue = await async_client.queues.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
- assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -398,7 +397,7 @@ async def test_raw_response_list(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(AsyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
@pytest.mark.skip()
@parametrize
@@ -410,7 +409,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
queue = await response.parse()
- assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])
+ assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
assert cast(Any, response.is_closed) is True