Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 5, 2024
1 parent 6c374ec commit 6393d6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 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">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="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: 13 additions & 17 deletions src/cloudflare/resources/queues/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
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 @@ -166,7 +168,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[QueueListResponse]:
) -> SyncSinglePage[QueueListResponse]:
"""
Returns the queues owned by an account.
Expand All @@ -183,16 +185,13 @@ 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(
return self._get_api_list(
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,
post_parser=ResultWrapper._unwrapper,
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
model=QueueListResponse,
)

def delete(
Expand Down Expand Up @@ -393,7 +392,7 @@ async def update(
cast_to=cast(Type[Optional[QueueUpdateResponse]], ResultWrapper[QueueUpdateResponse]),
)

async def list(
def list(
self,
*,
account_id: str,
Expand All @@ -403,7 +402,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[QueueListResponse]:
) -> AsyncPaginator[QueueListResponse, AsyncSinglePage[QueueListResponse]]:
"""
Returns the queues owned by an account.
Expand All @@ -420,16 +419,13 @@ async def list(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._get(
return self._get_api_list(
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,
post_parser=ResultWrapper._unwrapper,
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Type[Optional[QueueListResponse]], ResultWrapper[QueueListResponse]),
model=QueueListResponse,
)

async def delete(
Expand Down
9 changes: 3 additions & 6 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 List, Optional
from typing import Optional

from .._models import BaseModel

__all__ = ["QueueListResponse", "QueueListResponseItem"]
__all__ = ["QueueListResponse"]


class QueueListResponseItem(BaseModel):
class QueueListResponse(BaseModel):
consumers: Optional[object] = None

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

queue_name: Optional[str] = None


QueueListResponse = List[QueueListResponseItem]
13 changes: 7 additions & 6 deletions tests/api_resources/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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 @@ -132,7 +133,7 @@ def test_method_list(self, client: Cloudflare) -> None:
queue = client.queues.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[QueueListResponse], queue, path=["response"])
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -144,7 +145,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(Optional[QueueListResponse], queue, path=["response"])
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -156,7 +157,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(Optional[QueueListResponse], queue, path=["response"])
assert_matches_type(SyncSinglePage[QueueListResponse], queue, path=["response"])

assert cast(Any, response.is_closed) is True

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

@pytest.mark.skip()
@parametrize
Expand All @@ -397,7 +398,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(Optional[QueueListResponse], queue, path=["response"])
assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])

@pytest.mark.skip()
@parametrize
Expand All @@ -409,7 +410,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(Optional[QueueListResponse], queue, path=["response"])
assert_matches_type(AsyncSinglePage[QueueListResponse], queue, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down

0 comments on commit 6393d6d

Please sign in to comment.