Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 3, 2024
1 parent d894cba commit 44a5be1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,7 @@ Methods:

- <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>
- <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>
- <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>
- <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>
- <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>
- <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>

Expand Down
30 changes: 17 additions & 13 deletions src/cloudflare/resources/queues/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -392,7 +393,7 @@ async def update(
cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]),
)

def list(
async def list(
self,
*,
account_id: str,
Expand All @@ -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.
Expand All @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions src/cloudflare/types/queue_list_response.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,3 +23,6 @@ class QueueListResponse(BaseModel):
queue_id: Optional[str] = None

queue_name: Optional[str] = None


QueueListResponse = List[QueueListResponseItem]
13 changes: 6 additions & 7 deletions tests/api_resources/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 44a5be1

Please sign in to comment.