Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1575
configured_endpoints: 1576
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-631fbdf54fd976bda40c2ca2faf1070662d412482a32092bf54671975300491c.yml
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,7 @@ Methods:

- <code title="post /zones/{zone_id}/waiting_rooms">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/waiting_rooms/waiting_room_create_params.py">params</a>) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room.py">WaitingRoom</a></code>
- <code title="put /zones/{zone_id}/waiting_rooms/{waiting_room_id}">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">update</a>(waiting_room_id, \*, zone_id, \*\*<a href="src/cloudflare/types/waiting_rooms/waiting_room_update_params.py">params</a>) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room.py">WaitingRoom</a></code>
- <code title="get /{accounts_or_zones}/{account_or_zone_id}/waiting_rooms">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">list</a>(\*, account_id, zone_id, \*\*<a href="src/cloudflare/types/waiting_rooms/waiting_room_list_params.py">params</a>) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room.py">SyncV4PagePaginationArray[WaitingRoom]</a></code>
- <code title="delete /zones/{zone_id}/waiting_rooms/{waiting_room_id}">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">delete</a>(waiting_room_id, \*, zone_id) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room_delete_response.py">WaitingRoomDeleteResponse</a></code>
- <code title="patch /zones/{zone_id}/waiting_rooms/{waiting_room_id}">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">edit</a>(waiting_room_id, \*, zone_id, \*\*<a href="src/cloudflare/types/waiting_rooms/waiting_room_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room.py">WaitingRoom</a></code>
- <code title="get /zones/{zone_id}/waiting_rooms/{waiting_room_id}">client.waiting_rooms.<a href="./src/cloudflare/resources/waiting_rooms/waiting_rooms.py">get</a>(waiting_room_id, \*, zone_id) -> <a href="./src/cloudflare/types/waiting_rooms/waiting_room.py">WaitingRoom</a></code>
Expand Down
146 changes: 145 additions & 1 deletion src/cloudflare/resources/waiting_rooms/waiting_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from .events.events import (
EventsResource,
AsyncEventsResource,
Expand All @@ -61,9 +62,10 @@
EventsResourceWithStreamingResponse,
AsyncEventsResourceWithStreamingResponse,
)
from ..._base_client import make_request_options
from ..._base_client import AsyncPaginator, make_request_options
from ...types.waiting_rooms import (
waiting_room_edit_params,
waiting_room_list_params,
waiting_room_create_params,
waiting_room_update_params,
)
Expand Down Expand Up @@ -912,6 +914,71 @@ def update(
cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]),
)

def list(
self,
*,
account_id: str | NotGiven = NOT_GIVEN,
zone_id: str | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncV4PagePaginationArray[WaitingRoom]:
"""
Lists waiting rooms for account or zone.

Args:
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

page: Page number of paginated results.

per_page: Maximum number of results per page. Must be a multiple of 5.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if account_id and zone_id:
raise ValueError("You cannot provide both account_id and zone_id")

if account_id:
account_or_zone = "accounts"
account_or_zone_id = account_id
else:
if not zone_id:
raise ValueError("You must provide either account_id or zone_id")

account_or_zone = "zones"
account_or_zone_id = zone_id
return self._get_api_list(
f"/{account_or_zone}/{account_or_zone_id}/waiting_rooms",
page=SyncV4PagePaginationArray[WaitingRoom],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"page": page,
"per_page": per_page,
},
waiting_room_list_params.WaitingRoomListParams,
),
),
model=WaitingRoom,
)

def delete(
self,
waiting_room_id: str,
Expand Down Expand Up @@ -2234,6 +2301,71 @@ async def update(
cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]),
)

def list(
self,
*,
account_id: str | NotGiven = NOT_GIVEN,
zone_id: str | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[WaitingRoom, AsyncV4PagePaginationArray[WaitingRoom]]:
"""
Lists waiting rooms for account or zone.

Args:
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.

zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.

page: Page number of paginated results.

per_page: Maximum number of results per page. Must be a multiple of 5.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if account_id and zone_id:
raise ValueError("You cannot provide both account_id and zone_id")

if account_id:
account_or_zone = "accounts"
account_or_zone_id = account_id
else:
if not zone_id:
raise ValueError("You must provide either account_id or zone_id")

account_or_zone = "zones"
account_or_zone_id = zone_id
return self._get_api_list(
f"/{account_or_zone}/{account_or_zone_id}/waiting_rooms",
page=AsyncV4PagePaginationArray[WaitingRoom],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"page": page,
"per_page": per_page,
},
waiting_room_list_params.WaitingRoomListParams,
),
),
model=WaitingRoom,
)

async def delete(
self,
waiting_room_id: str,
Expand Down Expand Up @@ -2729,6 +2861,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None:
self.update = to_raw_response_wrapper(
waiting_rooms.update,
)
self.list = to_raw_response_wrapper(
waiting_rooms.list,
)
self.delete = to_raw_response_wrapper(
waiting_rooms.delete,
)
Expand Down Expand Up @@ -2770,6 +2905,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None:
self.update = async_to_raw_response_wrapper(
waiting_rooms.update,
)
self.list = async_to_raw_response_wrapper(
waiting_rooms.list,
)
self.delete = async_to_raw_response_wrapper(
waiting_rooms.delete,
)
Expand Down Expand Up @@ -2811,6 +2949,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None:
self.update = to_streamed_response_wrapper(
waiting_rooms.update,
)
self.list = to_streamed_response_wrapper(
waiting_rooms.list,
)
self.delete = to_streamed_response_wrapper(
waiting_rooms.delete,
)
Expand Down Expand Up @@ -2852,6 +2993,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None:
self.update = async_to_streamed_response_wrapper(
waiting_rooms.update,
)
self.list = async_to_streamed_response_wrapper(
waiting_rooms.list,
)
self.delete = async_to_streamed_response_wrapper(
waiting_rooms.delete,
)
Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/waiting_rooms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .cookie_attributes_param import CookieAttributesParam as CookieAttributesParam
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
from .waiting_room_edit_params import WaitingRoomEditParams as WaitingRoomEditParams
from .waiting_room_list_params import WaitingRoomListParams as WaitingRoomListParams
from .waiting_room_create_params import WaitingRoomCreateParams as WaitingRoomCreateParams
from .waiting_room_update_params import WaitingRoomUpdateParams as WaitingRoomUpdateParams
from .waiting_room_delete_response import WaitingRoomDeleteResponse as WaitingRoomDeleteResponse
21 changes: 21 additions & 0 deletions src/cloudflare/types/waiting_rooms/waiting_room_list_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import TypedDict

__all__ = ["WaitingRoomListParams"]


class WaitingRoomListParams(TypedDict, total=False):
account_id: str
"""The Account ID to use for this endpoint. Mutually exclusive with the Zone ID."""

zone_id: str
"""The Zone ID to use for this endpoint. Mutually exclusive with the Account ID."""

page: float
"""Page number of paginated results."""

per_page: float
"""Maximum number of results per page. Must be a multiple of 5."""
105 changes: 105 additions & 0 deletions tests/api_resources/test_waiting_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.waiting_rooms import (
WaitingRoom,
WaitingRoomDeleteResponse,
Expand Down Expand Up @@ -215,6 +216,58 @@ def test_path_params_update(self, client: Cloudflare) -> None:
total_active_users=200,
)

@parametrize
def test_method_list(self, client: Cloudflare) -> None:
waiting_room = client.waiting_rooms.list(
account_id="account_id",
)
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
waiting_room = client.waiting_rooms.list(
account_id="account_id",
page=1,
per_page=5,
)
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
response = client.waiting_rooms.with_raw_response.list(
account_id="account_id",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
waiting_room = response.parse()
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
with client.waiting_rooms.with_streaming_response.list(
account_id="account_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

waiting_room = response.parse()
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
def test_path_params_list(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
client.waiting_rooms.with_raw_response.list(
account_id="",
)

with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
client.waiting_rooms.with_raw_response.list(
account_id="account_id",
)

@parametrize
def test_method_delete(self, client: Cloudflare) -> None:
waiting_room = client.waiting_rooms.delete(
Expand Down Expand Up @@ -615,6 +668,58 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
total_active_users=200,
)

@parametrize
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
waiting_room = await async_client.waiting_rooms.list(
account_id="account_id",
)
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
waiting_room = await async_client.waiting_rooms.list(
account_id="account_id",
page=1,
per_page=5,
)
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
response = await async_client.waiting_rooms.with_raw_response.list(
account_id="account_id",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
waiting_room = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
async with async_client.waiting_rooms.with_streaming_response.list(
account_id="account_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

waiting_room = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
await async_client.waiting_rooms.with_raw_response.list(
account_id="",
)

with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
await async_client.waiting_rooms.with_raw_response.list(
account_id="account_id",
)

@parametrize
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
waiting_room = await async_client.waiting_rooms.delete(
Expand Down