diff --git a/.stats.yml b/.stats.yml index 2883f485f23..0b1cc6b8170 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/api.md b/api.md index e437eb28cb4..5c637c1451b 100644 --- a/api.md +++ b/api.md @@ -2144,6 +2144,7 @@ Methods: - client.waiting_rooms.create(\*, zone_id, \*\*params) -> WaitingRoom - client.waiting_rooms.update(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom +- client.waiting_rooms.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[WaitingRoom] - client.waiting_rooms.delete(waiting_room_id, \*, zone_id) -> WaitingRoomDeleteResponse - client.waiting_rooms.edit(waiting_room_id, \*, zone_id, \*\*params) -> WaitingRoom - client.waiting_rooms.get(waiting_room_id, \*, zone_id) -> WaitingRoom diff --git a/src/cloudflare/resources/waiting_rooms/waiting_rooms.py b/src/cloudflare/resources/waiting_rooms/waiting_rooms.py index d8e1eb52252..59847bca5ed 100644 --- a/src/cloudflare/resources/waiting_rooms/waiting_rooms.py +++ b/src/cloudflare/resources/waiting_rooms/waiting_rooms.py @@ -53,6 +53,7 @@ async_to_streamed_response_wrapper, ) from ..._wrappers import ResultWrapper +from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from .events.events import ( EventsResource, AsyncEventsResource, @@ -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, ) @@ -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, @@ -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, @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) diff --git a/src/cloudflare/types/waiting_rooms/__init__.py b/src/cloudflare/types/waiting_rooms/__init__.py index 2515f745a0a..63ac8eb3b82 100644 --- a/src/cloudflare/types/waiting_rooms/__init__.py +++ b/src/cloudflare/types/waiting_rooms/__init__.py @@ -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 diff --git a/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py b/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py new file mode 100644 index 00000000000..cc9bc3ad63e --- /dev/null +++ b/src/cloudflare/types/waiting_rooms/waiting_room_list_params.py @@ -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.""" diff --git a/tests/api_resources/test_waiting_rooms.py b/tests/api_resources/test_waiting_rooms.py index 43641dd9ef0..bac49b7d16f 100644 --- a/tests/api_resources/test_waiting_rooms.py +++ b/tests/api_resources/test_waiting_rooms.py @@ -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, @@ -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( @@ -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(