From d0a2f9ba55dffc7d7f95d34380d1f2aaa17c98d7 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Wed, 10 Apr 2024 21:53:41 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- api.md | 10 +-- src/cloudflare/resources/rules/lists/lists.py | 40 ++++++------ src/cloudflare/types/rules/__init__.py | 2 +- .../types/rules/{list.py => rule_list.py} | 6 +- tests/api_resources/rules/test_lists.py | 61 ++++++++++--------- 5 files changed, 61 insertions(+), 58 deletions(-) rename src/cloudflare/types/rules/{list.py => rule_list.py} (93%) diff --git a/api.md b/api.md index e40255dcac4..ca3f10eb557 100644 --- a/api.md +++ b/api.md @@ -4178,16 +4178,16 @@ Methods: Types: ```python -from cloudflare.types.rules import Hostname, List, Redirect, ListDeleteResponse +from cloudflare.types.rules import Hostname, Redirect, RuleList, ListDeleteResponse ``` Methods: -- client.rules.lists.create(\*, account_id, \*\*params) -> Optional -- client.rules.lists.update(list_id, \*, account_id, \*\*params) -> Optional -- client.rules.lists.list(\*, account_id) -> SyncSinglePage[List] +- client.rules.lists.create(\*, account_id, \*\*params) -> Optional +- client.rules.lists.update(list_id, \*, account_id, \*\*params) -> Optional +- client.rules.lists.list(\*, account_id) -> SyncSinglePage[RuleList] - client.rules.lists.delete(list_id, \*, account_id, \*\*params) -> Optional -- client.rules.lists.get(list_id, \*, account_id) -> Optional +- client.rules.lists.get(list_id, \*, account_id) -> Optional ### BulkOperations diff --git a/src/cloudflare/resources/rules/lists/lists.py b/src/cloudflare/resources/rules/lists/lists.py index c0152f80f77..66838e9460e 100644 --- a/src/cloudflare/resources/rules/lists/lists.py +++ b/src/cloudflare/resources/rules/lists/lists.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import Type, Optional, cast from typing_extensions import Literal import httpx @@ -30,7 +30,7 @@ ) from ...._wrappers import ResultWrapper from ....pagination import SyncSinglePage, AsyncSinglePage -from ....types.rules import List, ListDeleteResponse, list_create_params, list_delete_params, list_update_params +from ....types.rules import RuleList, ListDeleteResponse, list_create_params, list_delete_params, list_update_params from ...._base_client import ( AsyncPaginator, make_request_options, @@ -77,7 +77,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Creates a new list of the specified type. @@ -118,7 +118,7 @@ def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) def update( @@ -133,7 +133,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Updates the description of a list. @@ -166,7 +166,7 @@ def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) def list( @@ -179,7 +179,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[List]: + ) -> SyncSinglePage[RuleList]: """ Fetches all lists in the account. @@ -198,11 +198,11 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/rules/lists", - page=SyncSinglePage[List], + page=SyncSinglePage[RuleList], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=List, + model=RuleList, ) def delete( @@ -262,7 +262,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Fetches the details of a list. @@ -292,7 +292,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) @@ -326,7 +326,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Creates a new list of the specified type. @@ -367,7 +367,7 @@ async def create( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) async def update( @@ -382,7 +382,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Updates the description of a list. @@ -415,7 +415,7 @@ async def update( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) def list( @@ -428,7 +428,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[List, AsyncSinglePage[List]]: + ) -> AsyncPaginator[RuleList, AsyncSinglePage[RuleList]]: """ Fetches all lists in the account. @@ -447,11 +447,11 @@ def list( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") return self._get_api_list( f"/accounts/{account_id}/rules/lists", - page=AsyncSinglePage[List], + page=AsyncSinglePage[RuleList], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - model=List, + model=RuleList, ) async def delete( @@ -511,7 +511,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[List]: + ) -> Optional[RuleList]: """ Fetches the details of a list. @@ -541,7 +541,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[Optional[List]], ResultWrapper[List]), + cast_to=cast(Type[Optional[RuleList]], ResultWrapper[RuleList]), ) diff --git a/src/cloudflare/types/rules/__init__.py b/src/cloudflare/types/rules/__init__.py index 5afdefca7d7..00341b404f2 100644 --- a/src/cloudflare/types/rules/__init__.py +++ b/src/cloudflare/types/rules/__init__.py @@ -2,9 +2,9 @@ from __future__ import annotations -from .list import List as List from .hostname import Hostname as Hostname from .redirect import Redirect as Redirect +from .rule_list import RuleList as RuleList from .hostname_param import HostnameParam as HostnameParam from .redirect_param import RedirectParam as RedirectParam from .list_create_params import ListCreateParams as ListCreateParams diff --git a/src/cloudflare/types/rules/list.py b/src/cloudflare/types/rules/rule_list.py similarity index 93% rename from src/cloudflare/types/rules/list.py rename to src/cloudflare/types/rules/rule_list.py index d5e6b46e413..8c2b3e5e13c 100644 --- a/src/cloudflare/types/rules/list.py +++ b/src/cloudflare/types/rules/rule_list.py @@ -1,14 +1,14 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Optional from typing_extensions import Literal from ..._models import BaseModel -__all__ = ["List"] +__all__ = ["RuleList"] -class List(BaseModel): +class RuleList(BaseModel): id: Optional[str] = None """The unique ID of the list.""" diff --git a/tests/api_resources/rules/test_lists.py b/tests/api_resources/rules/test_lists.py index f99b2f44efb..6d24dbac266 100644 --- a/tests/api_resources/rules/test_lists.py +++ b/tests/api_resources/rules/test_lists.py @@ -10,7 +10,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.rules import List, ListDeleteResponse +from cloudflare.types.rules import ( + RuleList, + ListDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -26,7 +29,7 @@ def test_method_create(self, client: Cloudflare) -> None: kind="ip", name="list1", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -37,7 +40,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: name="list1", description="This is a note", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -51,7 +54,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -65,7 +68,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +89,7 @@ def test_method_update(self, client: Cloudflare) -> None: "2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -96,7 +99,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", description="This is a note", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -109,7 +112,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -122,7 +125,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -147,7 +150,7 @@ def test_method_list(self, client: Cloudflare) -> None: list = client.rules.lists.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(SyncSinglePage[List], list, path=["response"]) + assert_matches_type(SyncSinglePage[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -159,7 +162,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" list = response.parse() - assert_matches_type(SyncSinglePage[List], list, path=["response"]) + assert_matches_type(SyncSinglePage[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -171,7 +174,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(SyncSinglePage[List], list, path=["response"]) + assert_matches_type(SyncSinglePage[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -247,7 +250,7 @@ def test_method_get(self, client: Cloudflare) -> None: "2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -260,7 +263,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -273,7 +276,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -304,7 +307,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: kind="ip", name="list1", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -315,7 +318,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare name="list1", description="This is a note", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -329,7 +332,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -343,7 +346,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -364,7 +367,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -374,7 +377,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", description="This is a note", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -387,7 +390,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -400,7 +403,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -425,7 +428,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: list = await async_client.rules.lists.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(AsyncSinglePage[List], list, path=["response"]) + assert_matches_type(AsyncSinglePage[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -437,7 +440,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" list = await response.parse() - assert_matches_type(AsyncSinglePage[List], list, path=["response"]) + assert_matches_type(AsyncSinglePage[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -449,7 +452,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(AsyncSinglePage[List], list, path=["response"]) + assert_matches_type(AsyncSinglePage[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True @@ -525,7 +528,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "2c0fc9fa937b11eaa1b71c4d701ab86e", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -538,7 +541,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) @pytest.mark.skip() @parametrize @@ -551,7 +554,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" list = await response.parse() - assert_matches_type(Optional[List], list, path=["response"]) + assert_matches_type(Optional[RuleList], list, path=["response"]) assert cast(Any, response.is_closed) is True