diff --git a/api.md b/api.md index b610facf969..bc3718ff6b4 100644 --- a/api.md +++ b/api.md @@ -3043,17 +3043,18 @@ Methods: ## Settings -### SchemaValidation - Types: ```python -from cloudflare.types.api_gateway.settings import Settings +from cloudflare.types.api_gateway import Settings ``` +### SchemaValidation + Methods: - client.api_gateway.settings.schema_validation.update(\*, zone_id, \*\*params) -> Settings +- client.api_gateway.settings.schema_validation.edit(\*, zone_id, \*\*params) -> Settings - client.api_gateway.settings.schema_validation.get(\*, zone_id) -> Settings ## UserSchemas @@ -3089,12 +3090,6 @@ Methods: - client.api_gateway.user_schemas.operations.list(schema_id, \*, zone_id, \*\*params) -> SyncSinglePage[OperationListResponse] -## SchemaValidation - -Methods: - -- client.api_gateway.schema_validation.edit(\*, zone_id, \*\*params) -> Settings - # ManagedHeaders Types: diff --git a/src/cloudflare/resources/api_gateway/__init__.py b/src/cloudflare/resources/api_gateway/__init__.py index 4adb2b18211..c92d2837cfb 100644 --- a/src/cloudflare/resources/api_gateway/__init__.py +++ b/src/cloudflare/resources/api_gateway/__init__.py @@ -56,14 +56,6 @@ ConfigurationsResourceWithStreamingResponse, AsyncConfigurationsResourceWithStreamingResponse, ) -from .schema_validation import ( - SchemaValidationResource, - AsyncSchemaValidationResource, - SchemaValidationResourceWithRawResponse, - AsyncSchemaValidationResourceWithRawResponse, - SchemaValidationResourceWithStreamingResponse, - AsyncSchemaValidationResourceWithStreamingResponse, -) __all__ = [ "ConfigurationsResource", @@ -102,12 +94,6 @@ "AsyncUserSchemasResourceWithRawResponse", "UserSchemasResourceWithStreamingResponse", "AsyncUserSchemasResourceWithStreamingResponse", - "SchemaValidationResource", - "AsyncSchemaValidationResource", - "SchemaValidationResourceWithRawResponse", - "AsyncSchemaValidationResourceWithRawResponse", - "SchemaValidationResourceWithStreamingResponse", - "AsyncSchemaValidationResourceWithStreamingResponse", "APIGatewayResource", "AsyncAPIGatewayResource", "APIGatewayResourceWithRawResponse", diff --git a/src/cloudflare/resources/api_gateway/api_gateway.py b/src/cloudflare/resources/api_gateway/api_gateway.py index baae4ee7e3b..5df1917d66b 100644 --- a/src/cloudflare/resources/api_gateway/api_gateway.py +++ b/src/cloudflare/resources/api_gateway/api_gateway.py @@ -52,14 +52,6 @@ ConfigurationsResourceWithStreamingResponse, AsyncConfigurationsResourceWithStreamingResponse, ) -from .schema_validation import ( - SchemaValidationResource, - AsyncSchemaValidationResource, - SchemaValidationResourceWithRawResponse, - AsyncSchemaValidationResourceWithRawResponse, - SchemaValidationResourceWithStreamingResponse, - AsyncSchemaValidationResourceWithStreamingResponse, -) from .settings.settings import SettingsResource, AsyncSettingsResource from .discovery.discovery import DiscoveryResource, AsyncDiscoveryResource from .operations.operations import OperationsResource, AsyncOperationsResource @@ -93,10 +85,6 @@ def settings(self) -> SettingsResource: def user_schemas(self) -> UserSchemasResource: return UserSchemasResource(self._client) - @cached_property - def schema_validation(self) -> SchemaValidationResource: - return SchemaValidationResource(self._client) - @cached_property def with_raw_response(self) -> APIGatewayResourceWithRawResponse: return APIGatewayResourceWithRawResponse(self) @@ -131,10 +119,6 @@ def settings(self) -> AsyncSettingsResource: def user_schemas(self) -> AsyncUserSchemasResource: return AsyncUserSchemasResource(self._client) - @cached_property - def schema_validation(self) -> AsyncSchemaValidationResource: - return AsyncSchemaValidationResource(self._client) - @cached_property def with_raw_response(self) -> AsyncAPIGatewayResourceWithRawResponse: return AsyncAPIGatewayResourceWithRawResponse(self) @@ -172,10 +156,6 @@ def settings(self) -> SettingsResourceWithRawResponse: def user_schemas(self) -> UserSchemasResourceWithRawResponse: return UserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) - @cached_property - def schema_validation(self) -> SchemaValidationResourceWithRawResponse: - return SchemaValidationResourceWithRawResponse(self._api_gateway.schema_validation) - class AsyncAPIGatewayResourceWithRawResponse: def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: @@ -205,10 +185,6 @@ def settings(self) -> AsyncSettingsResourceWithRawResponse: def user_schemas(self) -> AsyncUserSchemasResourceWithRawResponse: return AsyncUserSchemasResourceWithRawResponse(self._api_gateway.user_schemas) - @cached_property - def schema_validation(self) -> AsyncSchemaValidationResourceWithRawResponse: - return AsyncSchemaValidationResourceWithRawResponse(self._api_gateway.schema_validation) - class APIGatewayResourceWithStreamingResponse: def __init__(self, api_gateway: APIGatewayResource) -> None: @@ -238,10 +214,6 @@ def settings(self) -> SettingsResourceWithStreamingResponse: def user_schemas(self) -> UserSchemasResourceWithStreamingResponse: return UserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) - @cached_property - def schema_validation(self) -> SchemaValidationResourceWithStreamingResponse: - return SchemaValidationResourceWithStreamingResponse(self._api_gateway.schema_validation) - class AsyncAPIGatewayResourceWithStreamingResponse: def __init__(self, api_gateway: AsyncAPIGatewayResource) -> None: @@ -270,7 +242,3 @@ def settings(self) -> AsyncSettingsResourceWithStreamingResponse: @cached_property def user_schemas(self) -> AsyncUserSchemasResourceWithStreamingResponse: return AsyncUserSchemasResourceWithStreamingResponse(self._api_gateway.user_schemas) - - @cached_property - def schema_validation(self) -> AsyncSchemaValidationResourceWithStreamingResponse: - return AsyncSchemaValidationResourceWithStreamingResponse(self._api_gateway.schema_validation) diff --git a/src/cloudflare/resources/api_gateway/schema_validation.py b/src/cloudflare/resources/api_gateway/schema_validation.py deleted file mode 100644 index e1d210edd73..00000000000 --- a/src/cloudflare/resources/api_gateway/schema_validation.py +++ /dev/null @@ -1,211 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Optional -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._base_client import ( - make_request_options, -) -from ...types.api_gateway import schema_validation_edit_params -from ...types.api_gateway.settings.settings import Settings - -__all__ = ["SchemaValidationResource", "AsyncSchemaValidationResource"] - - -class SchemaValidationResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> SchemaValidationResourceWithRawResponse: - return SchemaValidationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SchemaValidationResourceWithStreamingResponse: - return SchemaValidationResourceWithStreamingResponse(self) - - def edit( - self, - *, - zone_id: str, - validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, - ) -> Settings: - """ - Updates zone level schema validation settings on the zone - - Args: - zone_id: Identifier - - validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on - the operation Mitigation actions are as follows: - - - `log` - log request when request does not conform to schema - - `block` - deny access to the site when request does not conform to schema - - A special value of of `none` will skip running schema validation entirely for - the request when there is no mitigation action defined on the operation - - `null` will have no effect. - - validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. - - - `none` will skip running schema validation entirely for the request - - To clear any override, use the special value `disable_override` - - `null` will have no effect. - - 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 not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._patch( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", - body=maybe_transform( - { - "validation_default_mitigation_action": validation_default_mitigation_action, - "validation_override_mitigation_action": validation_override_mitigation_action, - }, - schema_validation_edit_params.SchemaValidationEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Settings, - ) - - -class AsyncSchemaValidationResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncSchemaValidationResourceWithRawResponse: - return AsyncSchemaValidationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSchemaValidationResourceWithStreamingResponse: - return AsyncSchemaValidationResourceWithStreamingResponse(self) - - async def edit( - self, - *, - zone_id: str, - validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, - validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, - ) -> Settings: - """ - Updates zone level schema validation settings on the zone - - Args: - zone_id: Identifier - - validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on - the operation Mitigation actions are as follows: - - - `log` - log request when request does not conform to schema - - `block` - deny access to the site when request does not conform to schema - - A special value of of `none` will skip running schema validation entirely for - the request when there is no mitigation action defined on the operation - - `null` will have no effect. - - validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. - - - `none` will skip running schema validation entirely for the request - - To clear any override, use the special value `disable_override` - - `null` will have no effect. - - 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 not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return await self._patch( - f"/zones/{zone_id}/api_gateway/settings/schema_validation", - body=await async_maybe_transform( - { - "validation_default_mitigation_action": validation_default_mitigation_action, - "validation_override_mitigation_action": validation_override_mitigation_action, - }, - schema_validation_edit_params.SchemaValidationEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Settings, - ) - - -class SchemaValidationResourceWithRawResponse: - def __init__(self, schema_validation: SchemaValidationResource) -> None: - self._schema_validation = schema_validation - - self.edit = to_raw_response_wrapper( - schema_validation.edit, - ) - - -class AsyncSchemaValidationResourceWithRawResponse: - def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: - self._schema_validation = schema_validation - - self.edit = async_to_raw_response_wrapper( - schema_validation.edit, - ) - - -class SchemaValidationResourceWithStreamingResponse: - def __init__(self, schema_validation: SchemaValidationResource) -> None: - self._schema_validation = schema_validation - - self.edit = to_streamed_response_wrapper( - schema_validation.edit, - ) - - -class AsyncSchemaValidationResourceWithStreamingResponse: - def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: - self._schema_validation = schema_validation - - self.edit = async_to_streamed_response_wrapper( - schema_validation.edit, - ) diff --git a/src/cloudflare/resources/api_gateway/settings/schema_validation.py b/src/cloudflare/resources/api_gateway/settings/schema_validation.py index f750f0775b3..74acb51c4a5 100644 --- a/src/cloudflare/resources/api_gateway/settings/schema_validation.py +++ b/src/cloudflare/resources/api_gateway/settings/schema_validation.py @@ -23,7 +23,7 @@ from ...._base_client import ( make_request_options, ) -from ....types.api_gateway.settings import schema_validation_update_params +from ....types.api_gateway.settings import schema_validation_edit_params, schema_validation_update_params from ....types.api_gateway.settings.settings import Settings __all__ = ["SchemaValidationResource", "AsyncSchemaValidationResource"] @@ -100,6 +100,69 @@ def update( cast_to=Settings, ) + def edit( + self, + *, + zone_id: str, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + `null` will have no effect. + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + + To clear any override, use the special value `disable_override` + + `null` will have no effect. + + 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 not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return self._patch( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_edit_params.SchemaValidationEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + def get( self, *, @@ -207,6 +270,69 @@ async def update( cast_to=Settings, ) + async def edit( + self, + *, + zone_id: str, + validation_default_mitigation_action: Optional[Literal["none", "log", "block"]] | NotGiven = NOT_GIVEN, + validation_override_mitigation_action: Optional[Literal["none", "disable_override"]] | 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, + ) -> Settings: + """ + Updates zone level schema validation settings on the zone + + Args: + zone_id: Identifier + + validation_default_mitigation_action: The default mitigation action used when there is no mitigation action defined on + the operation Mitigation actions are as follows: + + - `log` - log request when request does not conform to schema + - `block` - deny access to the site when request does not conform to schema + + A special value of of `none` will skip running schema validation entirely for + the request when there is no mitigation action defined on the operation + + `null` will have no effect. + + validation_override_mitigation_action: When set, this overrides both zone level and operation level mitigation actions. + + - `none` will skip running schema validation entirely for the request + + To clear any override, use the special value `disable_override` + + `null` will have no effect. + + 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 not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return await self._patch( + f"/zones/{zone_id}/api_gateway/settings/schema_validation", + body=await async_maybe_transform( + { + "validation_default_mitigation_action": validation_default_mitigation_action, + "validation_override_mitigation_action": validation_override_mitigation_action, + }, + schema_validation_edit_params.SchemaValidationEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Settings, + ) + async def get( self, *, @@ -250,6 +376,9 @@ def __init__(self, schema_validation: SchemaValidationResource) -> None: self.update = to_raw_response_wrapper( schema_validation.update, ) + self.edit = to_raw_response_wrapper( + schema_validation.edit, + ) self.get = to_raw_response_wrapper( schema_validation.get, ) @@ -262,6 +391,9 @@ def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self.update = async_to_raw_response_wrapper( schema_validation.update, ) + self.edit = async_to_raw_response_wrapper( + schema_validation.edit, + ) self.get = async_to_raw_response_wrapper( schema_validation.get, ) @@ -274,6 +406,9 @@ def __init__(self, schema_validation: SchemaValidationResource) -> None: self.update = to_streamed_response_wrapper( schema_validation.update, ) + self.edit = to_streamed_response_wrapper( + schema_validation.edit, + ) self.get = to_streamed_response_wrapper( schema_validation.get, ) @@ -286,6 +421,9 @@ def __init__(self, schema_validation: AsyncSchemaValidationResource) -> None: self.update = async_to_streamed_response_wrapper( schema_validation.update, ) + self.edit = async_to_streamed_response_wrapper( + schema_validation.edit, + ) self.get = async_to_streamed_response_wrapper( schema_validation.get, ) diff --git a/src/cloudflare/types/api_gateway/__init__.py b/src/cloudflare/types/api_gateway/__init__.py index 15e921a339f..03e7d8be4f3 100644 --- a/src/cloudflare/types/api_gateway/__init__.py +++ b/src/cloudflare/types/api_gateway/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations from .message import Message as Message +from .settings import Settings as Settings from .api_shield import APIShield as APIShield from .configuration import Configuration as Configuration from .public_schema import PublicSchema as PublicSchema @@ -24,4 +25,3 @@ from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams from .user_schema_delete_response import UserSchemaDeleteResponse as UserSchemaDeleteResponse from .configuration_update_response import ConfigurationUpdateResponse as ConfigurationUpdateResponse -from .schema_validation_edit_params import SchemaValidationEditParams as SchemaValidationEditParams diff --git a/src/cloudflare/types/api_gateway/settings/__init__.py b/src/cloudflare/types/api_gateway/settings/__init__.py index 6bf117b4acd..4a0d2fe1880 100644 --- a/src/cloudflare/types/api_gateway/settings/__init__.py +++ b/src/cloudflare/types/api_gateway/settings/__init__.py @@ -3,4 +3,5 @@ from __future__ import annotations from .settings import Settings as Settings +from .schema_validation_edit_params import SchemaValidationEditParams as SchemaValidationEditParams from .schema_validation_update_params import SchemaValidationUpdateParams as SchemaValidationUpdateParams diff --git a/src/cloudflare/types/api_gateway/schema_validation_edit_params.py b/src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py similarity index 100% rename from src/cloudflare/types/api_gateway/schema_validation_edit_params.py rename to src/cloudflare/types/api_gateway/settings/schema_validation_edit_params.py diff --git a/tests/api_resources/api_gateway/settings/test_schema_validation.py b/tests/api_resources/api_gateway/settings/test_schema_validation.py index f0d5bb47925..2441b86a24c 100644 --- a/tests/api_resources/api_gateway/settings/test_schema_validation.py +++ b/tests/api_resources/api_gateway/settings/test_schema_validation.py @@ -9,7 +9,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.api_gateway.settings import Settings +from cloudflare.types.api_gateway.settings import ( + Settings, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -68,6 +70,53 @@ def test_path_params_update(self, client: Cloudflare) -> None: validation_default_mitigation_action="block", ) + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.settings.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + schema_validation = client.api_gateway.settings.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.api_gateway.settings.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.api_gateway.settings.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.api_gateway.settings.schema_validation.with_raw_response.edit( + zone_id="", + ) + @parametrize def test_method_get(self, client: Cloudflare) -> None: schema_validation = client.api_gateway.settings.schema_validation.get( @@ -161,6 +210,53 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: validation_default_mitigation_action="block", ) + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.settings.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + schema_validation = await async_client.api_gateway.settings.schema_validation.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + validation_default_mitigation_action="block", + validation_override_mitigation_action="none", + ) + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.api_gateway.settings.schema_validation.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.api_gateway.settings.schema_validation.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schema_validation = await response.parse() + assert_matches_type(Settings, schema_validation, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.api_gateway.settings.schema_validation.with_raw_response.edit( + zone_id="", + ) + @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: schema_validation = await async_client.api_gateway.settings.schema_validation.get( diff --git a/tests/api_resources/api_gateway/test_schema_validation.py b/tests/api_resources/api_gateway/test_schema_validation.py deleted file mode 100644 index dbe446a6c02..00000000000 --- a/tests/api_resources/api_gateway/test_schema_validation.py +++ /dev/null @@ -1,116 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.types.api_gateway.settings import Settings - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSchemaValidation: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - schema_validation = client.api_gateway.schema_validation.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - schema_validation = client.api_gateway.schema_validation.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - validation_default_mitigation_action="block", - validation_override_mitigation_action="none", - ) - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.api_gateway.schema_validation.with_raw_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema_validation = response.parse() - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.api_gateway.schema_validation.with_streaming_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema_validation = response.parse() - assert_matches_type(Settings, schema_validation, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.api_gateway.schema_validation.with_raw_response.edit( - zone_id="", - ) - - -class TestAsyncSchemaValidation: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - schema_validation = await async_client.api_gateway.schema_validation.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - schema_validation = await async_client.api_gateway.schema_validation.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - validation_default_mitigation_action="block", - validation_override_mitigation_action="none", - ) - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.api_gateway.schema_validation.with_raw_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema_validation = await response.parse() - assert_matches_type(Settings, schema_validation, path=["response"]) - - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.api_gateway.schema_validation.with_streaming_response.edit( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema_validation = await response.parse() - assert_matches_type(Settings, schema_validation, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.api_gateway.schema_validation.with_raw_response.edit( - zone_id="", - )