Skip to content

Commit d10fb45

Browse files
feat(waiting_rooms): add account level list API (#2524)
1 parent 1e5eedc commit d10fb45

File tree

6 files changed

+274
-2
lines changed

6 files changed

+274
-2
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1575
1+
configured_endpoints: 1576
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-631fbdf54fd976bda40c2ca2faf1070662d412482a32092bf54671975300491c.yml

api.md

+1
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,7 @@ Methods:
21442144

21452145
- <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>
21462146
- <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>
2147+
- <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>
21472148
- <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>
21482149
- <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>
21492150
- <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>

src/cloudflare/resources/waiting_rooms/waiting_rooms.py

+145-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
async_to_streamed_response_wrapper,
5454
)
5555
from ..._wrappers import ResultWrapper
56+
from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
5657
from .events.events import (
5758
EventsResource,
5859
AsyncEventsResource,
@@ -61,9 +62,10 @@
6162
EventsResourceWithStreamingResponse,
6263
AsyncEventsResourceWithStreamingResponse,
6364
)
64-
from ..._base_client import make_request_options
65+
from ..._base_client import AsyncPaginator, make_request_options
6566
from ...types.waiting_rooms import (
6667
waiting_room_edit_params,
68+
waiting_room_list_params,
6769
waiting_room_create_params,
6870
waiting_room_update_params,
6971
)
@@ -912,6 +914,71 @@ def update(
912914
cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]),
913915
)
914916

917+
def list(
918+
self,
919+
*,
920+
account_id: str | NotGiven = NOT_GIVEN,
921+
zone_id: str | NotGiven = NOT_GIVEN,
922+
page: float | NotGiven = NOT_GIVEN,
923+
per_page: float | NotGiven = NOT_GIVEN,
924+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
925+
# The extra values given here take precedence over values defined on the client or passed to this method.
926+
extra_headers: Headers | None = None,
927+
extra_query: Query | None = None,
928+
extra_body: Body | None = None,
929+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
930+
) -> SyncV4PagePaginationArray[WaitingRoom]:
931+
"""
932+
Lists waiting rooms for account or zone.
933+
934+
Args:
935+
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
936+
937+
zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
938+
939+
page: Page number of paginated results.
940+
941+
per_page: Maximum number of results per page. Must be a multiple of 5.
942+
943+
extra_headers: Send extra headers
944+
945+
extra_query: Add additional query parameters to the request
946+
947+
extra_body: Add additional JSON properties to the request
948+
949+
timeout: Override the client-level default timeout for this request, in seconds
950+
"""
951+
if account_id and zone_id:
952+
raise ValueError("You cannot provide both account_id and zone_id")
953+
954+
if account_id:
955+
account_or_zone = "accounts"
956+
account_or_zone_id = account_id
957+
else:
958+
if not zone_id:
959+
raise ValueError("You must provide either account_id or zone_id")
960+
961+
account_or_zone = "zones"
962+
account_or_zone_id = zone_id
963+
return self._get_api_list(
964+
f"/{account_or_zone}/{account_or_zone_id}/waiting_rooms",
965+
page=SyncV4PagePaginationArray[WaitingRoom],
966+
options=make_request_options(
967+
extra_headers=extra_headers,
968+
extra_query=extra_query,
969+
extra_body=extra_body,
970+
timeout=timeout,
971+
query=maybe_transform(
972+
{
973+
"page": page,
974+
"per_page": per_page,
975+
},
976+
waiting_room_list_params.WaitingRoomListParams,
977+
),
978+
),
979+
model=WaitingRoom,
980+
)
981+
915982
def delete(
916983
self,
917984
waiting_room_id: str,
@@ -2234,6 +2301,71 @@ async def update(
22342301
cast_to=cast(Type[WaitingRoom], ResultWrapper[WaitingRoom]),
22352302
)
22362303

2304+
def list(
2305+
self,
2306+
*,
2307+
account_id: str | NotGiven = NOT_GIVEN,
2308+
zone_id: str | NotGiven = NOT_GIVEN,
2309+
page: float | NotGiven = NOT_GIVEN,
2310+
per_page: float | NotGiven = NOT_GIVEN,
2311+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
2312+
# The extra values given here take precedence over values defined on the client or passed to this method.
2313+
extra_headers: Headers | None = None,
2314+
extra_query: Query | None = None,
2315+
extra_body: Body | None = None,
2316+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
2317+
) -> AsyncPaginator[WaitingRoom, AsyncV4PagePaginationArray[WaitingRoom]]:
2318+
"""
2319+
Lists waiting rooms for account or zone.
2320+
2321+
Args:
2322+
account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
2323+
2324+
zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
2325+
2326+
page: Page number of paginated results.
2327+
2328+
per_page: Maximum number of results per page. Must be a multiple of 5.
2329+
2330+
extra_headers: Send extra headers
2331+
2332+
extra_query: Add additional query parameters to the request
2333+
2334+
extra_body: Add additional JSON properties to the request
2335+
2336+
timeout: Override the client-level default timeout for this request, in seconds
2337+
"""
2338+
if account_id and zone_id:
2339+
raise ValueError("You cannot provide both account_id and zone_id")
2340+
2341+
if account_id:
2342+
account_or_zone = "accounts"
2343+
account_or_zone_id = account_id
2344+
else:
2345+
if not zone_id:
2346+
raise ValueError("You must provide either account_id or zone_id")
2347+
2348+
account_or_zone = "zones"
2349+
account_or_zone_id = zone_id
2350+
return self._get_api_list(
2351+
f"/{account_or_zone}/{account_or_zone_id}/waiting_rooms",
2352+
page=AsyncV4PagePaginationArray[WaitingRoom],
2353+
options=make_request_options(
2354+
extra_headers=extra_headers,
2355+
extra_query=extra_query,
2356+
extra_body=extra_body,
2357+
timeout=timeout,
2358+
query=maybe_transform(
2359+
{
2360+
"page": page,
2361+
"per_page": per_page,
2362+
},
2363+
waiting_room_list_params.WaitingRoomListParams,
2364+
),
2365+
),
2366+
model=WaitingRoom,
2367+
)
2368+
22372369
async def delete(
22382370
self,
22392371
waiting_room_id: str,
@@ -2729,6 +2861,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None:
27292861
self.update = to_raw_response_wrapper(
27302862
waiting_rooms.update,
27312863
)
2864+
self.list = to_raw_response_wrapper(
2865+
waiting_rooms.list,
2866+
)
27322867
self.delete = to_raw_response_wrapper(
27332868
waiting_rooms.delete,
27342869
)
@@ -2770,6 +2905,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None:
27702905
self.update = async_to_raw_response_wrapper(
27712906
waiting_rooms.update,
27722907
)
2908+
self.list = async_to_raw_response_wrapper(
2909+
waiting_rooms.list,
2910+
)
27732911
self.delete = async_to_raw_response_wrapper(
27742912
waiting_rooms.delete,
27752913
)
@@ -2811,6 +2949,9 @@ def __init__(self, waiting_rooms: WaitingRoomsResource) -> None:
28112949
self.update = to_streamed_response_wrapper(
28122950
waiting_rooms.update,
28132951
)
2952+
self.list = to_streamed_response_wrapper(
2953+
waiting_rooms.list,
2954+
)
28142955
self.delete = to_streamed_response_wrapper(
28152956
waiting_rooms.delete,
28162957
)
@@ -2852,6 +2993,9 @@ def __init__(self, waiting_rooms: AsyncWaitingRoomsResource) -> None:
28522993
self.update = async_to_streamed_response_wrapper(
28532994
waiting_rooms.update,
28542995
)
2996+
self.list = async_to_streamed_response_wrapper(
2997+
waiting_rooms.list,
2998+
)
28552999
self.delete = async_to_streamed_response_wrapper(
28563000
waiting_rooms.delete,
28573001
)

src/cloudflare/types/waiting_rooms/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .cookie_attributes_param import CookieAttributesParam as CookieAttributesParam
2727
from .setting_update_response import SettingUpdateResponse as SettingUpdateResponse
2828
from .waiting_room_edit_params import WaitingRoomEditParams as WaitingRoomEditParams
29+
from .waiting_room_list_params import WaitingRoomListParams as WaitingRoomListParams
2930
from .waiting_room_create_params import WaitingRoomCreateParams as WaitingRoomCreateParams
3031
from .waiting_room_update_params import WaitingRoomUpdateParams as WaitingRoomUpdateParams
3132
from .waiting_room_delete_response import WaitingRoomDeleteResponse as WaitingRoomDeleteResponse
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import TypedDict
6+
7+
__all__ = ["WaitingRoomListParams"]
8+
9+
10+
class WaitingRoomListParams(TypedDict, total=False):
11+
account_id: str
12+
"""The Account ID to use for this endpoint. Mutually exclusive with the Zone ID."""
13+
14+
zone_id: str
15+
"""The Zone ID to use for this endpoint. Mutually exclusive with the Account ID."""
16+
17+
page: float
18+
"""Page number of paginated results."""
19+
20+
per_page: float
21+
"""Maximum number of results per page. Must be a multiple of 5."""

tests/api_resources/test_waiting_rooms.py

+105
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
12+
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
1213
from cloudflare.types.waiting_rooms import (
1314
WaitingRoom,
1415
WaitingRoomDeleteResponse,
@@ -215,6 +216,58 @@ def test_path_params_update(self, client: Cloudflare) -> None:
215216
total_active_users=200,
216217
)
217218

219+
@parametrize
220+
def test_method_list(self, client: Cloudflare) -> None:
221+
waiting_room = client.waiting_rooms.list(
222+
account_id="account_id",
223+
)
224+
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
225+
226+
@parametrize
227+
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
228+
waiting_room = client.waiting_rooms.list(
229+
account_id="account_id",
230+
page=1,
231+
per_page=5,
232+
)
233+
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
234+
235+
@parametrize
236+
def test_raw_response_list(self, client: Cloudflare) -> None:
237+
response = client.waiting_rooms.with_raw_response.list(
238+
account_id="account_id",
239+
)
240+
241+
assert response.is_closed is True
242+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
243+
waiting_room = response.parse()
244+
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
245+
246+
@parametrize
247+
def test_streaming_response_list(self, client: Cloudflare) -> None:
248+
with client.waiting_rooms.with_streaming_response.list(
249+
account_id="account_id",
250+
) as response:
251+
assert not response.is_closed
252+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
253+
254+
waiting_room = response.parse()
255+
assert_matches_type(SyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
256+
257+
assert cast(Any, response.is_closed) is True
258+
259+
@parametrize
260+
def test_path_params_list(self, client: Cloudflare) -> None:
261+
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
262+
client.waiting_rooms.with_raw_response.list(
263+
account_id="",
264+
)
265+
266+
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
267+
client.waiting_rooms.with_raw_response.list(
268+
account_id="account_id",
269+
)
270+
218271
@parametrize
219272
def test_method_delete(self, client: Cloudflare) -> None:
220273
waiting_room = client.waiting_rooms.delete(
@@ -615,6 +668,58 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
615668
total_active_users=200,
616669
)
617670

671+
@parametrize
672+
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
673+
waiting_room = await async_client.waiting_rooms.list(
674+
account_id="account_id",
675+
)
676+
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
677+
678+
@parametrize
679+
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
680+
waiting_room = await async_client.waiting_rooms.list(
681+
account_id="account_id",
682+
page=1,
683+
per_page=5,
684+
)
685+
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
686+
687+
@parametrize
688+
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
689+
response = await async_client.waiting_rooms.with_raw_response.list(
690+
account_id="account_id",
691+
)
692+
693+
assert response.is_closed is True
694+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
695+
waiting_room = await response.parse()
696+
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
697+
698+
@parametrize
699+
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
700+
async with async_client.waiting_rooms.with_streaming_response.list(
701+
account_id="account_id",
702+
) as response:
703+
assert not response.is_closed
704+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
705+
706+
waiting_room = await response.parse()
707+
assert_matches_type(AsyncV4PagePaginationArray[WaitingRoom], waiting_room, path=["response"])
708+
709+
assert cast(Any, response.is_closed) is True
710+
711+
@parametrize
712+
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
713+
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
714+
await async_client.waiting_rooms.with_raw_response.list(
715+
account_id="",
716+
)
717+
718+
with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"):
719+
await async_client.waiting_rooms.with_raw_response.list(
720+
account_id="account_id",
721+
)
722+
618723
@parametrize
619724
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
620725
waiting_room = await async_client.waiting_rooms.delete(

0 commit comments

Comments
 (0)