diff --git a/.stats.yml b/.stats.yml index 8200d3d0354..113f130f454 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1266 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-c4098fcb3861719a0115fe0bd93ede436f466e42ea623f1ed1feeb1f126d9c3d.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4f0694869a2da3cbfcc749f0c718b6f45464c72e586046527d6e04c06210b0ca.yml diff --git a/api.md b/api.md index 5acd8c6e580..9effe79ab7b 100644 --- a/api.md +++ b/api.md @@ -7152,8 +7152,8 @@ from cloudflare.types.bot_management import ( Methods: -- client.bot_management.update(\*, zone_id, \*\*params) -> Optional -- client.bot_management.get(\*, zone_id) -> Optional +- client.bot_management.update(\*, zone_id, \*\*params) -> BotManagementUpdateResponse +- client.bot_management.get(\*, zone_id) -> BotManagementGetResponse # OriginPostQuantumEncryption diff --git a/src/cloudflare/resources/bot_management.py b/src/cloudflare/resources/bot_management.py index e53c10a35f6..a0e2d7d637e 100644 --- a/src/cloudflare/resources/bot_management.py +++ b/src/cloudflare/resources/bot_management.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Optional, cast, overload +from typing import Any, cast, overload from typing_extensions import Literal import httpx @@ -54,7 +54,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -101,7 +101,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -157,7 +157,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -212,7 +212,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -268,11 +268,11 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - Optional[BotManagementUpdateResponse], + BotManagementUpdateResponse, self._put( f"/zones/{zone_id}/bot_management", body=maybe_transform( @@ -294,7 +294,7 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[BotManagementUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[BotManagementUpdateResponse]._unwrapper, ), cast_to=cast( Any, ResultWrapper[BotManagementUpdateResponse] @@ -312,7 +312,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementGetResponse]: + ) -> BotManagementGetResponse: """ Retrieve a zone's Bot Management Config @@ -330,7 +330,7 @@ def get( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - Optional[BotManagementGetResponse], + BotManagementGetResponse, self._get( f"/zones/{zone_id}/bot_management", options=make_request_options( @@ -338,7 +338,7 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[BotManagementGetResponse]]._unwrapper, + post_parser=ResultWrapper[BotManagementGetResponse]._unwrapper, ), cast_to=cast( Any, ResultWrapper[BotManagementGetResponse] @@ -369,7 +369,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -416,7 +416,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -472,7 +472,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -527,7 +527,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: """ Updates the Bot Management configuration for a zone. @@ -583,11 +583,11 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementUpdateResponse]: + ) -> BotManagementUpdateResponse: if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - Optional[BotManagementUpdateResponse], + BotManagementUpdateResponse, await self._put( f"/zones/{zone_id}/bot_management", body=await async_maybe_transform( @@ -609,7 +609,7 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[BotManagementUpdateResponse]]._unwrapper, + post_parser=ResultWrapper[BotManagementUpdateResponse]._unwrapper, ), cast_to=cast( Any, ResultWrapper[BotManagementUpdateResponse] @@ -627,7 +627,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[BotManagementGetResponse]: + ) -> BotManagementGetResponse: """ Retrieve a zone's Bot Management Config @@ -645,7 +645,7 @@ async def get( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - Optional[BotManagementGetResponse], + BotManagementGetResponse, await self._get( f"/zones/{zone_id}/bot_management", options=make_request_options( @@ -653,7 +653,7 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[BotManagementGetResponse]]._unwrapper, + post_parser=ResultWrapper[BotManagementGetResponse]._unwrapper, ), cast_to=cast( Any, ResultWrapper[BotManagementGetResponse] diff --git a/tests/api_resources/test_bot_management.py b/tests/api_resources/test_bot_management.py index fd585293649..89ed539135b 100644 --- a/tests/api_resources/test_bot_management.py +++ b/tests/api_resources/test_bot_management.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest @@ -26,7 +26,7 @@ def test_method_update_overload_1(self, client: Cloudflare) -> None: bot_management = client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -36,7 +36,7 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N enable_js=True, fight_mode=True, ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -48,7 +48,7 @@ def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -60,7 +60,7 @@ def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -78,7 +78,7 @@ def test_method_update_overload_2(self, client: Cloudflare) -> None: bot_management = client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -91,7 +91,7 @@ def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> N sbfm_static_resource_protection=True, sbfm_verified_bots="allow", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -103,7 +103,7 @@ def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -115,7 +115,7 @@ def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -133,7 +133,7 @@ def test_method_update_overload_3(self, client: Cloudflare) -> None: bot_management = client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -147,7 +147,7 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N sbfm_static_resource_protection=True, sbfm_verified_bots="allow", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -159,7 +159,7 @@ def test_raw_response_update_overload_3(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -171,7 +171,7 @@ def test_streaming_response_update_overload_3(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -189,7 +189,7 @@ def test_method_update_overload_4(self, client: Cloudflare) -> None: bot_management = client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -200,7 +200,7 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N enable_js=True, suppress_session_score=False, ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -212,7 +212,7 @@ def test_raw_response_update_overload_4(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -224,7 +224,7 @@ def test_streaming_response_update_overload_4(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -242,7 +242,7 @@ def test_method_get(self, client: Cloudflare) -> None: bot_management = client.bot_management.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -254,7 +254,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" bot_management = response.parse() - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -266,7 +266,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = response.parse() - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -288,7 +288,7 @@ async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> bot_management = await async_client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -298,7 +298,7 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn enable_js=True, fight_mode=True, ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -310,7 +310,7 @@ async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -322,7 +322,7 @@ async def test_streaming_response_update_overload_1(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -340,7 +340,7 @@ async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> bot_management = await async_client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -353,7 +353,7 @@ async def test_method_update_with_all_params_overload_2(self, async_client: Asyn sbfm_static_resource_protection=True, sbfm_verified_bots="allow", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -365,7 +365,7 @@ async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -377,7 +377,7 @@ async def test_streaming_response_update_overload_2(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -395,7 +395,7 @@ async def test_method_update_overload_3(self, async_client: AsyncCloudflare) -> bot_management = await async_client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -409,7 +409,7 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn sbfm_static_resource_protection=True, sbfm_verified_bots="allow", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -421,7 +421,7 @@ async def test_raw_response_update_overload_3(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -433,7 +433,7 @@ async def test_streaming_response_update_overload_3(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -451,7 +451,7 @@ async def test_method_update_overload_4(self, async_client: AsyncCloudflare) -> bot_management = await async_client.bot_management.update( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -462,7 +462,7 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn enable_js=True, suppress_session_score=False, ) - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -474,7 +474,7 @@ async def test_raw_response_update_overload_4(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -486,7 +486,7 @@ async def test_streaming_response_update_overload_4(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementUpdateResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementUpdateResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: bot_management = await async_client.bot_management.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -516,7 +516,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" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) @pytest.mark.skip() @parametrize @@ -528,7 +528,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" bot_management = await response.parse() - assert_matches_type(Optional[BotManagementGetResponse], bot_management, path=["response"]) + assert_matches_type(BotManagementGetResponse, bot_management, path=["response"]) assert cast(Any, response.is_closed) is True