From b0fa819bc0e5a89a18dca07d5ba154126cf9def2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:24:48 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#312) --- api.md | 4 +-- .../resources/zones/dns_settings.py | 18 +++++------ src/cloudflare/types/zones/nameserver.py | 2 +- .../types/zones/nameserver_param.py | 2 +- .../api_resources/zones/test_dns_settings.py | 30 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api.md b/api.md index a01312f9553..a320fa98030 100644 --- a/api.md +++ b/api.md @@ -298,8 +298,8 @@ from cloudflare.types.zones import DNSSetting, Nameserver Methods: -- client.zones.dns_settings.edit(\*, zone_id, \*\*params) -> DNSSetting -- client.zones.dns_settings.get(\*, zone_id) -> DNSSetting +- client.zones.dns_settings.edit(\*, zone_id, \*\*params) -> Optional +- client.zones.dns_settings.get(\*, zone_id) -> Optional ## Settings diff --git a/src/cloudflare/resources/zones/dns_settings.py b/src/cloudflare/resources/zones/dns_settings.py index 671421c9820..1f9101a95f1 100644 --- a/src/cloudflare/resources/zones/dns_settings.py +++ b/src/cloudflare/resources/zones/dns_settings.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -51,7 +51,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSetting: + ) -> Optional[DNSSetting]: """ Update DNS settings for a zone @@ -97,7 +97,7 @@ def edit( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[DNSSetting], ResultWrapper[DNSSetting]), + cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), ) def get( @@ -110,7 +110,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSetting: + ) -> Optional[DNSSetting]: """ Show DNS settings for a zone @@ -136,7 +136,7 @@ def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[DNSSetting], ResultWrapper[DNSSetting]), + cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), ) @@ -163,7 +163,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSetting: + ) -> Optional[DNSSetting]: """ Update DNS settings for a zone @@ -209,7 +209,7 @@ async def edit( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[DNSSetting], ResultWrapper[DNSSetting]), + cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), ) async def get( @@ -222,7 +222,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> DNSSetting: + ) -> Optional[DNSSetting]: """ Show DNS settings for a zone @@ -248,7 +248,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper._unwrapper, ), - cast_to=cast(Type[DNSSetting], ResultWrapper[DNSSetting]), + cast_to=cast(Type[Optional[DNSSetting]], ResultWrapper[DNSSetting]), ) diff --git a/src/cloudflare/types/zones/nameserver.py b/src/cloudflare/types/zones/nameserver.py index b63db9d5ec0..3076da16fbd 100644 --- a/src/cloudflare/types/zones/nameserver.py +++ b/src/cloudflare/types/zones/nameserver.py @@ -8,5 +8,5 @@ class Nameserver(BaseModel): - type: Literal["cloudflare.standard", "cloudflare.foundation_dns"] + type: Literal["cloudflare.standard"] """Nameserver type""" diff --git a/src/cloudflare/types/zones/nameserver_param.py b/src/cloudflare/types/zones/nameserver_param.py index 688e5116eae..6d73075a2ae 100644 --- a/src/cloudflare/types/zones/nameserver_param.py +++ b/src/cloudflare/types/zones/nameserver_param.py @@ -8,5 +8,5 @@ class NameserverParam(TypedDict, total=False): - type: Required[Literal["cloudflare.standard", "cloudflare.foundation_dns"]] + type: Required[Literal["cloudflare.standard"]] """Nameserver type""" diff --git a/tests/api_resources/zones/test_dns_settings.py b/tests/api_resources/zones/test_dns_settings.py index 99cce7c0c8f..8072f04cc44 100644 --- a/tests/api_resources/zones/test_dns_settings.py +++ b/tests/api_resources/zones/test_dns_settings.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -23,7 +23,7 @@ def test_method_edit(self, client: Cloudflare) -> None: dns_setting = client.zones.dns_settings.edit( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -35,7 +35,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: nameservers={"type": "cloudflare.standard"}, secondary_overrides=False, ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -47,7 +47,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" dns_setting = response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -59,7 +59,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dns_setting = response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) assert cast(Any, response.is_closed) is True @@ -77,7 +77,7 @@ def test_method_get(self, client: Cloudflare) -> None: dns_setting = client.zones.dns_settings.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -89,7 +89,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" dns_setting = response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -101,7 +101,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" dns_setting = response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) assert cast(Any, response.is_closed) is True @@ -123,7 +123,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: dns_setting = await async_client.zones.dns_settings.edit( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -135,7 +135,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) nameservers={"type": "cloudflare.standard"}, secondary_overrides=False, ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -147,7 +147,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" dns_setting = await response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -159,7 +159,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" dns_setting = await response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) assert cast(Any, response.is_closed) is True @@ -177,7 +177,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: dns_setting = await async_client.zones.dns_settings.get( zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -189,7 +189,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" dns_setting = await response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) @pytest.mark.skip() @parametrize @@ -201,7 +201,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" dns_setting = await response.parse() - assert_matches_type(DNSSetting, dns_setting, path=["response"]) + assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"]) assert cast(Any, response.is_closed) is True