From 0249a365c4a914087164bb6163066a3f51965ead Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:24:08 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#351) --- api.md | 6 ++--- src/cloudflare/resources/dnssec.py | 38 +++++++++++++-------------- tests/api_resources/test_dnssec.py | 42 +++++++++++++++--------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/api.md b/api.md index 4a802219a7b..d7e50a129f5 100644 --- a/api.md +++ b/api.md @@ -1713,9 +1713,9 @@ from cloudflare.types.dnssec import DNSSEC, DNSSECDeleteResponse Methods: -- client.dnssec.delete(\*, zone_id, \*\*params) -> DNSSECDeleteResponse -- client.dnssec.edit(\*, zone_id, \*\*params) -> DNSSEC -- client.dnssec.get(\*, zone_id) -> DNSSEC +- client.dnssec.delete(\*, zone_id, \*\*params) -> Optional +- client.dnssec.edit(\*, zone_id, \*\*params) -> Optional +- client.dnssec.get(\*, zone_id) -> Optional # EmailRouting diff --git a/src/cloudflare/resources/dnssec.py b/src/cloudflare/resources/dnssec.py index dfd162ae0c3..4f85f2f6f3a 100644 --- a/src/cloudflare/resources/dnssec.py +++ b/src/cloudflare/resources/dnssec.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, cast +from typing import Any, Type, Optional, cast from typing_extensions import Literal import httpx @@ -49,7 +49,7 @@ def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSECDeleteResponse: + ) -> Optional[DNSSECDeleteResponse]: """ Delete DNSSEC. @@ -67,7 +67,7 @@ def delete( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - DNSSECDeleteResponse, + Optional[DNSSECDeleteResponse], self._delete( f"/zones/{zone_id}/dnssec", body=maybe_transform(body, dnssec_delete_params.DNSSECDeleteParams), @@ -76,7 +76,7 @@ def delete( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSECDeleteResponse]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, ), cast_to=cast( Any, ResultWrapper[DNSSECDeleteResponse] @@ -97,7 +97,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSEC: + ) -> Optional[DNSSEC]: """ Enable or disable DNSSEC. @@ -148,9 +148,9 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSEC]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSEC]]._unwrapper, ), - cast_to=cast(Type[DNSSEC], ResultWrapper[DNSSEC]), + cast_to=cast(Type[Optional[DNSSEC]], ResultWrapper[DNSSEC]), ) def get( @@ -163,7 +163,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSEC: + ) -> Optional[DNSSEC]: """ Details about DNSSEC status and configuration. @@ -187,9 +187,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSEC]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSEC]]._unwrapper, ), - cast_to=cast(Type[DNSSEC], ResultWrapper[DNSSEC]), + cast_to=cast(Type[Optional[DNSSEC]], ResultWrapper[DNSSEC]), ) @@ -213,7 +213,7 @@ async def delete( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSECDeleteResponse: + ) -> Optional[DNSSECDeleteResponse]: """ Delete DNSSEC. @@ -231,7 +231,7 @@ async def delete( if not zone_id: raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") return cast( - DNSSECDeleteResponse, + Optional[DNSSECDeleteResponse], await self._delete( f"/zones/{zone_id}/dnssec", body=await async_maybe_transform(body, dnssec_delete_params.DNSSECDeleteParams), @@ -240,7 +240,7 @@ async def delete( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSECDeleteResponse]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSECDeleteResponse]]._unwrapper, ), cast_to=cast( Any, ResultWrapper[DNSSECDeleteResponse] @@ -261,7 +261,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSEC: + ) -> Optional[DNSSEC]: """ Enable or disable DNSSEC. @@ -312,9 +312,9 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSEC]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSEC]]._unwrapper, ), - cast_to=cast(Type[DNSSEC], ResultWrapper[DNSSEC]), + cast_to=cast(Type[Optional[DNSSEC]], ResultWrapper[DNSSEC]), ) async def get( @@ -327,7 +327,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSEC: + ) -> Optional[DNSSEC]: """ Details about DNSSEC status and configuration. @@ -351,9 +351,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[DNSSEC]._unwrapper, + post_parser=ResultWrapper[Optional[DNSSEC]]._unwrapper, ), - cast_to=cast(Type[DNSSEC], ResultWrapper[DNSSEC]), + cast_to=cast(Type[Optional[DNSSEC]], ResultWrapper[DNSSEC]), ) diff --git a/tests/api_resources/test_dnssec.py b/tests/api_resources/test_dnssec.py index 69a5f52ccc1..dbccb299de5 100644 --- a/tests/api_resources/test_dnssec.py +++ b/tests/api_resources/test_dnssec.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -24,7 +24,7 @@ def test_method_delete(self, client: Cloudflare) -> None: zone_id="023e105f4ecef8ad9ca31a8372d0c353", body={}, ) - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -37,7 +37,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -50,7 +50,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -69,7 +69,7 @@ def test_method_edit(self, client: Cloudflare) -> None: dnssec = client.dnssec.edit( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -80,7 +80,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: dnssec_presigned=True, status="active", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -92,7 +92,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -104,7 +104,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -122,7 +122,7 @@ def test_method_get(self, client: Cloudflare) -> None: dnssec = client.dnssec.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -134,7 +134,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" dnssec = response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -146,7 +146,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -169,7 +169,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: zone_id="023e105f4ecef8ad9ca31a8372d0c353", body={}, ) - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -182,7 +182,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -195,7 +195,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(DNSSECDeleteResponse, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSECDeleteResponse], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -214,7 +214,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: dnssec = await async_client.dnssec.edit( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -225,7 +225,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) dnssec_presigned=True, status="active", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -237,7 +237,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -249,7 +249,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True @@ -267,7 +267,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: dnssec = await async_client.dnssec.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -279,7 +279,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" dnssec = await response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) @pytest.mark.skip() @parametrize @@ -291,7 +291,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" dnssec = await response.parse() - assert_matches_type(DNSSEC, dnssec, path=["response"]) + assert_matches_type(Optional[DNSSEC], dnssec, path=["response"]) assert cast(Any, response.is_closed) is True