diff --git a/.stats.yml b/.stats.yml index 883b95a3c1a..1ac28185879 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1567 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cbb99272da54989b18eb7fb838f75d228fc482ba11f8178a44529002184ed785.yml +configured_endpoints: 1571 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ce6973d9ffb4160d1590bf265381b7b3cc895123688d710646ee414838002e82.yml diff --git a/api.md b/api.md index fc1a5a520e3..8d2a22ad93b 100644 --- a/api.md +++ b/api.md @@ -1134,6 +1134,32 @@ Types: from cloudflare.types.dns import DNSSetting ``` +### Zone + +Types: + +```python +from cloudflare.types.dns.settings import ZoneEditResponse, ZoneGetResponse +``` + +Methods: + +- client.dns.settings.zone.edit(\*, zone_id, \*\*params) -> Optional[ZoneEditResponse] +- client.dns.settings.zone.get(\*, zone_id) -> Optional[ZoneGetResponse] + +### Account + +Types: + +```python +from cloudflare.types.dns.settings import AccountEditResponse, AccountGetResponse +``` + +Methods: + +- client.dns.settings.account.edit(\*, account_id, \*\*params) -> Optional[AccountEditResponse] +- client.dns.settings.account.get(\*, account_id) -> Optional[AccountGetResponse] + ## Analytics ### Reports diff --git a/src/cloudflare/resources/dns/__init__.py b/src/cloudflare/resources/dns/__init__.py index 41d02da3350..58768dba906 100644 --- a/src/cloudflare/resources/dns/__init__.py +++ b/src/cloudflare/resources/dns/__init__.py @@ -24,6 +24,14 @@ RecordsResourceWithStreamingResponse, AsyncRecordsResourceWithStreamingResponse, ) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from .analytics import ( AnalyticsResource, AsyncAnalyticsResource, @@ -54,6 +62,12 @@ "AsyncRecordsResourceWithRawResponse", "RecordsResourceWithStreamingResponse", "AsyncRecordsResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", "AnalyticsResource", "AsyncAnalyticsResource", "AnalyticsResourceWithRawResponse", diff --git a/src/cloudflare/resources/dns/dns.py b/src/cloudflare/resources/dns/dns.py index 3144141748a..a4c4157a412 100644 --- a/src/cloudflare/resources/dns/dns.py +++ b/src/cloudflare/resources/dns/dns.py @@ -20,6 +20,14 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource +from .settings.settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) from .analytics.analytics import ( AnalyticsResource, AsyncAnalyticsResource, @@ -49,6 +57,10 @@ def dnssec(self) -> DNSSECResource: def records(self) -> RecordsResource: return RecordsResource(self._client) + @cached_property + def settings(self) -> SettingsResource: + return SettingsResource(self._client) + @cached_property def analytics(self) -> AnalyticsResource: return AnalyticsResource(self._client) @@ -86,6 +98,10 @@ def dnssec(self) -> AsyncDNSSECResource: def records(self) -> AsyncRecordsResource: return AsyncRecordsResource(self._client) + @cached_property + def settings(self) -> AsyncSettingsResource: + return AsyncSettingsResource(self._client) + @cached_property def analytics(self) -> AsyncAnalyticsResource: return AsyncAnalyticsResource(self._client) @@ -126,6 +142,10 @@ def dnssec(self) -> DNSSECResourceWithRawResponse: def records(self) -> RecordsResourceWithRawResponse: return RecordsResourceWithRawResponse(self._dns.records) + @cached_property + def settings(self) -> SettingsResourceWithRawResponse: + return SettingsResourceWithRawResponse(self._dns.settings) + @cached_property def analytics(self) -> AnalyticsResourceWithRawResponse: return AnalyticsResourceWithRawResponse(self._dns.analytics) @@ -147,6 +167,10 @@ def dnssec(self) -> AsyncDNSSECResourceWithRawResponse: def records(self) -> AsyncRecordsResourceWithRawResponse: return AsyncRecordsResourceWithRawResponse(self._dns.records) + @cached_property + def settings(self) -> AsyncSettingsResourceWithRawResponse: + return AsyncSettingsResourceWithRawResponse(self._dns.settings) + @cached_property def analytics(self) -> AsyncAnalyticsResourceWithRawResponse: return AsyncAnalyticsResourceWithRawResponse(self._dns.analytics) @@ -168,6 +192,10 @@ def dnssec(self) -> DNSSECResourceWithStreamingResponse: def records(self) -> RecordsResourceWithStreamingResponse: return RecordsResourceWithStreamingResponse(self._dns.records) + @cached_property + def settings(self) -> SettingsResourceWithStreamingResponse: + return SettingsResourceWithStreamingResponse(self._dns.settings) + @cached_property def analytics(self) -> AnalyticsResourceWithStreamingResponse: return AnalyticsResourceWithStreamingResponse(self._dns.analytics) @@ -189,6 +217,10 @@ def dnssec(self) -> AsyncDNSSECResourceWithStreamingResponse: def records(self) -> AsyncRecordsResourceWithStreamingResponse: return AsyncRecordsResourceWithStreamingResponse(self._dns.records) + @cached_property + def settings(self) -> AsyncSettingsResourceWithStreamingResponse: + return AsyncSettingsResourceWithStreamingResponse(self._dns.settings) + @cached_property def analytics(self) -> AsyncAnalyticsResourceWithStreamingResponse: return AsyncAnalyticsResourceWithStreamingResponse(self._dns.analytics) diff --git a/src/cloudflare/resources/dns/settings/__init__.py b/src/cloudflare/resources/dns/settings/__init__.py new file mode 100644 index 00000000000..d9cc83fd9d1 --- /dev/null +++ b/src/cloudflare/resources/dns/settings/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .zone import ( + ZoneResource, + AsyncZoneResource, + ZoneResourceWithRawResponse, + AsyncZoneResourceWithRawResponse, + ZoneResourceWithStreamingResponse, + AsyncZoneResourceWithStreamingResponse, +) +from .account import ( + AccountResource, + AsyncAccountResource, + AccountResourceWithRawResponse, + AsyncAccountResourceWithRawResponse, + AccountResourceWithStreamingResponse, + AsyncAccountResourceWithStreamingResponse, +) +from .settings import ( + SettingsResource, + AsyncSettingsResource, + SettingsResourceWithRawResponse, + AsyncSettingsResourceWithRawResponse, + SettingsResourceWithStreamingResponse, + AsyncSettingsResourceWithStreamingResponse, +) + +__all__ = [ + "ZoneResource", + "AsyncZoneResource", + "ZoneResourceWithRawResponse", + "AsyncZoneResourceWithRawResponse", + "ZoneResourceWithStreamingResponse", + "AsyncZoneResourceWithStreamingResponse", + "AccountResource", + "AsyncAccountResource", + "AccountResourceWithRawResponse", + "AsyncAccountResourceWithRawResponse", + "AccountResourceWithStreamingResponse", + "AsyncAccountResourceWithStreamingResponse", + "SettingsResource", + "AsyncSettingsResource", + "SettingsResourceWithRawResponse", + "AsyncSettingsResourceWithRawResponse", + "SettingsResourceWithStreamingResponse", + "AsyncSettingsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/dns/settings/account.py b/src/cloudflare/resources/dns/settings/account.py new file mode 100644 index 00000000000..51604ef650a --- /dev/null +++ b/src/cloudflare/resources/dns/settings/account.py @@ -0,0 +1,278 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +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 ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.dns.settings import account_edit_params +from ....types.dns.settings.account_get_response import AccountGetResponse +from ....types.dns.settings.account_edit_response import AccountEditResponse + +__all__ = ["AccountResource", "AsyncAccountResource"] + + +class AccountResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AccountResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AccountResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AccountResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AccountResourceWithStreamingResponse(self) + + def edit( + self, + *, + account_id: str, + zone_defaults: account_edit_params.ZoneDefaults | 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, + ) -> Optional[AccountEditResponse]: + """ + Update DNS settings for an account + + Args: + account_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._patch( + f"/accounts/{account_id}/dns_settings", + body=maybe_transform({"zone_defaults": zone_defaults}, account_edit_params.AccountEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccountEditResponse]], ResultWrapper[AccountEditResponse]), + ) + + def get( + self, + *, + account_id: str, + # 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, + ) -> Optional[AccountGetResponse]: + """ + Show DNS settings for an account + + Args: + account_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccountGetResponse]], ResultWrapper[AccountGetResponse]), + ) + + +class AsyncAccountResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAccountResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAccountResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAccountResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAccountResourceWithStreamingResponse(self) + + async def edit( + self, + *, + account_id: str, + zone_defaults: account_edit_params.ZoneDefaults | 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, + ) -> Optional[AccountEditResponse]: + """ + Update DNS settings for an account + + Args: + account_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._patch( + f"/accounts/{account_id}/dns_settings", + body=await async_maybe_transform({"zone_defaults": zone_defaults}, account_edit_params.AccountEditParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccountEditResponse]], ResultWrapper[AccountEditResponse]), + ) + + async def get( + self, + *, + account_id: str, + # 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, + ) -> Optional[AccountGetResponse]: + """ + Show DNS settings for an account + + Args: + account_id: Identifier + + 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 account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[AccountGetResponse]], ResultWrapper[AccountGetResponse]), + ) + + +class AccountResourceWithRawResponse: + def __init__(self, account: AccountResource) -> None: + self._account = account + + self.edit = to_raw_response_wrapper( + account.edit, + ) + self.get = to_raw_response_wrapper( + account.get, + ) + + +class AsyncAccountResourceWithRawResponse: + def __init__(self, account: AsyncAccountResource) -> None: + self._account = account + + self.edit = async_to_raw_response_wrapper( + account.edit, + ) + self.get = async_to_raw_response_wrapper( + account.get, + ) + + +class AccountResourceWithStreamingResponse: + def __init__(self, account: AccountResource) -> None: + self._account = account + + self.edit = to_streamed_response_wrapper( + account.edit, + ) + self.get = to_streamed_response_wrapper( + account.get, + ) + + +class AsyncAccountResourceWithStreamingResponse: + def __init__(self, account: AsyncAccountResource) -> None: + self._account = account + + self.edit = async_to_streamed_response_wrapper( + account.edit, + ) + self.get = async_to_streamed_response_wrapper( + account.get, + ) diff --git a/src/cloudflare/resources/dns/settings/settings.py b/src/cloudflare/resources/dns/settings/settings.py new file mode 100644 index 00000000000..72c08ebed20 --- /dev/null +++ b/src/cloudflare/resources/dns/settings/settings.py @@ -0,0 +1,134 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .zone import ( + ZoneResource, + AsyncZoneResource, + ZoneResourceWithRawResponse, + AsyncZoneResourceWithRawResponse, + ZoneResourceWithStreamingResponse, + AsyncZoneResourceWithStreamingResponse, +) +from .account import ( + AccountResource, + AsyncAccountResource, + AccountResourceWithRawResponse, + AsyncAccountResourceWithRawResponse, + AccountResourceWithStreamingResponse, + AsyncAccountResourceWithStreamingResponse, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["SettingsResource", "AsyncSettingsResource"] + + +class SettingsResource(SyncAPIResource): + @cached_property + def zone(self) -> ZoneResource: + return ZoneResource(self._client) + + @cached_property + def account(self) -> AccountResource: + return AccountResource(self._client) + + @cached_property + def with_raw_response(self) -> SettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return SettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return SettingsResourceWithStreamingResponse(self) + + +class AsyncSettingsResource(AsyncAPIResource): + @cached_property + def zone(self) -> AsyncZoneResource: + return AsyncZoneResource(self._client) + + @cached_property + def account(self) -> AsyncAccountResource: + return AsyncAccountResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSettingsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncSettingsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSettingsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncSettingsResourceWithStreamingResponse(self) + + +class SettingsResourceWithRawResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + @cached_property + def zone(self) -> ZoneResourceWithRawResponse: + return ZoneResourceWithRawResponse(self._settings.zone) + + @cached_property + def account(self) -> AccountResourceWithRawResponse: + return AccountResourceWithRawResponse(self._settings.account) + + +class AsyncSettingsResourceWithRawResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + @cached_property + def zone(self) -> AsyncZoneResourceWithRawResponse: + return AsyncZoneResourceWithRawResponse(self._settings.zone) + + @cached_property + def account(self) -> AsyncAccountResourceWithRawResponse: + return AsyncAccountResourceWithRawResponse(self._settings.account) + + +class SettingsResourceWithStreamingResponse: + def __init__(self, settings: SettingsResource) -> None: + self._settings = settings + + @cached_property + def zone(self) -> ZoneResourceWithStreamingResponse: + return ZoneResourceWithStreamingResponse(self._settings.zone) + + @cached_property + def account(self) -> AccountResourceWithStreamingResponse: + return AccountResourceWithStreamingResponse(self._settings.account) + + +class AsyncSettingsResourceWithStreamingResponse: + def __init__(self, settings: AsyncSettingsResource) -> None: + self._settings = settings + + @cached_property + def zone(self) -> AsyncZoneResourceWithStreamingResponse: + return AsyncZoneResourceWithStreamingResponse(self._settings.zone) + + @cached_property + def account(self) -> AsyncAccountResourceWithStreamingResponse: + return AsyncAccountResourceWithStreamingResponse(self._settings.account) diff --git a/src/cloudflare/resources/dns/settings/zone.py b/src/cloudflare/resources/dns/settings/zone.py new file mode 100644 index 00000000000..4f145caad94 --- /dev/null +++ b/src/cloudflare/resources/dns/settings/zone.py @@ -0,0 +1,365 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +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 ...._wrappers import ResultWrapper +from ...._base_client import make_request_options +from ....types.dns.settings import zone_edit_params +from ....types.dns.settings.zone_get_response import ZoneGetResponse +from ....types.dns.settings.zone_edit_response import ZoneEditResponse + +__all__ = ["ZoneResource", "AsyncZoneResource"] + + +class ZoneResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ZoneResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ZoneResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ZoneResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ZoneResourceWithStreamingResponse(self) + + def edit( + self, + *, + zone_id: str, + flatten_all_cnames: bool | NotGiven = NOT_GIVEN, + foundation_dns: bool | NotGiven = NOT_GIVEN, + internal_dns: zone_edit_params.InternalDNS | NotGiven = NOT_GIVEN, + multi_provider: bool | NotGiven = NOT_GIVEN, + nameservers: zone_edit_params.Nameservers | NotGiven = NOT_GIVEN, + ns_ttl: float | NotGiven = NOT_GIVEN, + secondary_overrides: bool | NotGiven = NOT_GIVEN, + soa: zone_edit_params.SOA | NotGiven = NOT_GIVEN, + zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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, + ) -> Optional[ZoneEditResponse]: + """ + Update DNS settings for a zone + + Args: + zone_id: Identifier + + flatten_all_cnames: Whether to flatten all CNAME records in the zone. Note that, due to DNS + limitations, a CNAME record at the zone apex will always be flattened. + + foundation_dns: Whether to enable Foundation DNS Advanced Nameservers on the zone. + + internal_dns: Settings for this internal zone. + + multi_provider: Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + + nameservers: Settings determining the nameservers through which the zone should be available. + + ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. + + secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + + soa: Components of the zone's SOA record. + + zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. + + 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}/dns_settings", + body=maybe_transform( + { + "flatten_all_cnames": flatten_all_cnames, + "foundation_dns": foundation_dns, + "internal_dns": internal_dns, + "multi_provider": multi_provider, + "nameservers": nameservers, + "ns_ttl": ns_ttl, + "secondary_overrides": secondary_overrides, + "soa": soa, + "zone_mode": zone_mode, + }, + zone_edit_params.ZoneEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZoneEditResponse]], ResultWrapper[ZoneEditResponse]), + ) + + def get( + self, + *, + zone_id: str, + # 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, + ) -> Optional[ZoneGetResponse]: + """ + Show DNS settings for a zone + + Args: + zone_id: Identifier + + 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._get( + f"/zones/{zone_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZoneGetResponse]], ResultWrapper[ZoneGetResponse]), + ) + + +class AsyncZoneResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncZoneResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncZoneResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncZoneResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncZoneResourceWithStreamingResponse(self) + + async def edit( + self, + *, + zone_id: str, + flatten_all_cnames: bool | NotGiven = NOT_GIVEN, + foundation_dns: bool | NotGiven = NOT_GIVEN, + internal_dns: zone_edit_params.InternalDNS | NotGiven = NOT_GIVEN, + multi_provider: bool | NotGiven = NOT_GIVEN, + nameservers: zone_edit_params.Nameservers | NotGiven = NOT_GIVEN, + ns_ttl: float | NotGiven = NOT_GIVEN, + secondary_overrides: bool | NotGiven = NOT_GIVEN, + soa: zone_edit_params.SOA | NotGiven = NOT_GIVEN, + zone_mode: Literal["standard", "cdn_only", "dns_only"] | 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, + ) -> Optional[ZoneEditResponse]: + """ + Update DNS settings for a zone + + Args: + zone_id: Identifier + + flatten_all_cnames: Whether to flatten all CNAME records in the zone. Note that, due to DNS + limitations, a CNAME record at the zone apex will always be flattened. + + foundation_dns: Whether to enable Foundation DNS Advanced Nameservers on the zone. + + internal_dns: Settings for this internal zone. + + multi_provider: Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + + nameservers: Settings determining the nameservers through which the zone should be available. + + ns_ttl: The time to live (TTL) of the zone's nameserver (NS) records. + + secondary_overrides: Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + + soa: Components of the zone's SOA record. + + zone_mode: Whether the zone mode is a regular or CDN/DNS only zone. + + 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}/dns_settings", + body=await async_maybe_transform( + { + "flatten_all_cnames": flatten_all_cnames, + "foundation_dns": foundation_dns, + "internal_dns": internal_dns, + "multi_provider": multi_provider, + "nameservers": nameservers, + "ns_ttl": ns_ttl, + "secondary_overrides": secondary_overrides, + "soa": soa, + "zone_mode": zone_mode, + }, + zone_edit_params.ZoneEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZoneEditResponse]], ResultWrapper[ZoneEditResponse]), + ) + + async def get( + self, + *, + zone_id: str, + # 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, + ) -> Optional[ZoneGetResponse]: + """ + Show DNS settings for a zone + + Args: + zone_id: Identifier + + 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._get( + f"/zones/{zone_id}/dns_settings", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ZoneGetResponse]], ResultWrapper[ZoneGetResponse]), + ) + + +class ZoneResourceWithRawResponse: + def __init__(self, zone: ZoneResource) -> None: + self._zone = zone + + self.edit = to_raw_response_wrapper( + zone.edit, + ) + self.get = to_raw_response_wrapper( + zone.get, + ) + + +class AsyncZoneResourceWithRawResponse: + def __init__(self, zone: AsyncZoneResource) -> None: + self._zone = zone + + self.edit = async_to_raw_response_wrapper( + zone.edit, + ) + self.get = async_to_raw_response_wrapper( + zone.get, + ) + + +class ZoneResourceWithStreamingResponse: + def __init__(self, zone: ZoneResource) -> None: + self._zone = zone + + self.edit = to_streamed_response_wrapper( + zone.edit, + ) + self.get = to_streamed_response_wrapper( + zone.get, + ) + + +class AsyncZoneResourceWithStreamingResponse: + def __init__(self, zone: AsyncZoneResource) -> None: + self._zone = zone + + self.edit = async_to_streamed_response_wrapper( + zone.edit, + ) + self.get = async_to_streamed_response_wrapper( + zone.get, + ) diff --git a/src/cloudflare/types/dns/settings/__init__.py b/src/cloudflare/types/dns/settings/__init__.py index f8ee8b14b1c..1c775ded108 100644 --- a/src/cloudflare/types/dns/settings/__init__.py +++ b/src/cloudflare/types/dns/settings/__init__.py @@ -1,3 +1,10 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .zone_edit_params import ZoneEditParams as ZoneEditParams +from .zone_get_response import ZoneGetResponse as ZoneGetResponse +from .zone_edit_response import ZoneEditResponse as ZoneEditResponse +from .account_edit_params import AccountEditParams as AccountEditParams +from .account_get_response import AccountGetResponse as AccountGetResponse +from .account_edit_response import AccountEditResponse as AccountEditResponse diff --git a/src/cloudflare/types/dns/settings/account_edit_params.py b/src/cloudflare/types/dns/settings/account_edit_params.py new file mode 100644 index 00000000000..0c5b2de17d0 --- /dev/null +++ b/src/cloudflare/types/dns/settings/account_edit_params.py @@ -0,0 +1,101 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["AccountEditParams", "ZoneDefaults", "ZoneDefaultsInternalDNS", "ZoneDefaultsNameservers", "ZoneDefaultsSOA"] + + +class AccountEditParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + zone_defaults: ZoneDefaults + + +class ZoneDefaultsInternalDNS(TypedDict, total=False): + reference_zone_id: str + """The ID of the zone to fallback to.""" + + +class ZoneDefaultsNameservers(TypedDict, total=False): + type: Required[Literal["cloudflare.standard", "cloudflare.standard.random", "custom.account", "custom.tenant"]] + """Nameserver type""" + + +class ZoneDefaultsSOA(TypedDict, total=False): + expire: Required[float] + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: Required[float] + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: Required[str] + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: Required[float] + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: Required[float] + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: Required[str] + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: Required[float] + """The time to live (TTL) of the SOA record itself.""" + + +class ZoneDefaults(TypedDict, total=False): + flatten_all_cnames: bool + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: bool + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: ZoneDefaultsInternalDNS + """Settings for this internal zone.""" + + multi_provider: bool + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: ZoneDefaultsNameservers + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: float + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: bool + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: ZoneDefaultsSOA + """Components of the zone's SOA record.""" + + zone_mode: Literal["standard", "cdn_only", "dns_only"] + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/dns/settings/account_edit_response.py b/src/cloudflare/types/dns/settings/account_edit_response.py new file mode 100644 index 00000000000..01c81450284 --- /dev/null +++ b/src/cloudflare/types/dns/settings/account_edit_response.py @@ -0,0 +1,105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = [ + "AccountEditResponse", + "ZoneDefaults", + "ZoneDefaultsInternalDNS", + "ZoneDefaultsNameservers", + "ZoneDefaultsSOA", +] + + +class ZoneDefaultsInternalDNS(BaseModel): + reference_zone_id: Optional[str] = None + """The ID of the zone to fallback to.""" + + +class ZoneDefaultsNameservers(BaseModel): + type: Literal["cloudflare.standard", "cloudflare.standard.random", "custom.account", "custom.tenant"] + """Nameserver type""" + + +class ZoneDefaultsSOA(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" + + +class ZoneDefaults(BaseModel): + flatten_all_cnames: Optional[bool] = None + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: Optional[bool] = None + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: Optional[ZoneDefaultsInternalDNS] = None + """Settings for this internal zone.""" + + multi_provider: Optional[bool] = None + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Optional[ZoneDefaultsNameservers] = None + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: Optional[bool] = None + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: Optional[ZoneDefaultsSOA] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" + + +class AccountEditResponse(BaseModel): + zone_defaults: Optional[ZoneDefaults] = None diff --git a/src/cloudflare/types/dns/settings/account_get_response.py b/src/cloudflare/types/dns/settings/account_get_response.py new file mode 100644 index 00000000000..cd44220e207 --- /dev/null +++ b/src/cloudflare/types/dns/settings/account_get_response.py @@ -0,0 +1,105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = [ + "AccountGetResponse", + "ZoneDefaults", + "ZoneDefaultsInternalDNS", + "ZoneDefaultsNameservers", + "ZoneDefaultsSOA", +] + + +class ZoneDefaultsInternalDNS(BaseModel): + reference_zone_id: Optional[str] = None + """The ID of the zone to fallback to.""" + + +class ZoneDefaultsNameservers(BaseModel): + type: Literal["cloudflare.standard", "cloudflare.standard.random", "custom.account", "custom.tenant"] + """Nameserver type""" + + +class ZoneDefaultsSOA(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" + + +class ZoneDefaults(BaseModel): + flatten_all_cnames: Optional[bool] = None + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: Optional[bool] = None + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: Optional[ZoneDefaultsInternalDNS] = None + """Settings for this internal zone.""" + + multi_provider: Optional[bool] = None + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Optional[ZoneDefaultsNameservers] = None + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: Optional[bool] = None + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: Optional[ZoneDefaultsSOA] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" + + +class AccountGetResponse(BaseModel): + zone_defaults: Optional[ZoneDefaults] = None diff --git a/src/cloudflare/types/dns/settings/zone_edit_params.py b/src/cloudflare/types/dns/settings/zone_edit_params.py new file mode 100644 index 00000000000..1537935e299 --- /dev/null +++ b/src/cloudflare/types/dns/settings/zone_edit_params.py @@ -0,0 +1,100 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ZoneEditParams", "InternalDNS", "Nameservers", "SOA"] + + +class ZoneEditParams(TypedDict, total=False): + zone_id: Required[str] + """Identifier""" + + flatten_all_cnames: bool + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: bool + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: InternalDNS + """Settings for this internal zone.""" + + multi_provider: bool + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Nameservers + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: float + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: bool + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: SOA + """Components of the zone's SOA record.""" + + zone_mode: Literal["standard", "cdn_only", "dns_only"] + """Whether the zone mode is a regular or CDN/DNS only zone.""" + + +class InternalDNS(TypedDict, total=False): + reference_zone_id: str + """The ID of the zone to fallback to.""" + + +class Nameservers(TypedDict, total=False): + type: Required[Literal["cloudflare.standard", "custom.account", "custom.tenant", "custom.zone"]] + """Nameserver type""" + + ns_set: int + """Configured nameserver set to be used for this zone""" + + +class SOA(TypedDict, total=False): + expire: Required[float] + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: Required[float] + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: Required[str] + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: Required[float] + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: Required[float] + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: Required[str] + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: Required[float] + """The time to live (TTL) of the SOA record itself.""" diff --git a/src/cloudflare/types/dns/settings/zone_edit_response.py b/src/cloudflare/types/dns/settings/zone_edit_response.py new file mode 100644 index 00000000000..dd87558815a --- /dev/null +++ b/src/cloudflare/types/dns/settings/zone_edit_response.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ZoneEditResponse", "InternalDNS", "Nameservers", "SOA"] + + +class InternalDNS(BaseModel): + reference_zone_id: Optional[str] = None + """The ID of the zone to fallback to.""" + + +class Nameservers(BaseModel): + type: Literal["cloudflare.standard", "custom.account", "custom.tenant", "custom.zone"] + """Nameserver type""" + + ns_set: Optional[int] = None + """Configured nameserver set to be used for this zone""" + + +class SOA(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" + + +class ZoneEditResponse(BaseModel): + flatten_all_cnames: Optional[bool] = None + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: Optional[bool] = None + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: Optional[InternalDNS] = None + """Settings for this internal zone.""" + + multi_provider: Optional[bool] = None + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Optional[Nameservers] = None + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: Optional[bool] = None + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: Optional[SOA] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/src/cloudflare/types/dns/settings/zone_get_response.py b/src/cloudflare/types/dns/settings/zone_get_response.py new file mode 100644 index 00000000000..076a9147434 --- /dev/null +++ b/src/cloudflare/types/dns/settings/zone_get_response.py @@ -0,0 +1,98 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["ZoneGetResponse", "InternalDNS", "Nameservers", "SOA"] + + +class InternalDNS(BaseModel): + reference_zone_id: Optional[str] = None + """The ID of the zone to fallback to.""" + + +class Nameservers(BaseModel): + type: Literal["cloudflare.standard", "custom.account", "custom.tenant", "custom.zone"] + """Nameserver type""" + + ns_set: Optional[int] = None + """Configured nameserver set to be used for this zone""" + + +class SOA(BaseModel): + expire: float + """ + Time in seconds of being unable to query the primary server after which + secondary servers should stop serving the zone. + """ + + min_ttl: float + """The time to live (TTL) for negative caching of records within the zone.""" + + mname: str + """The primary nameserver, which may be used for outbound zone transfers.""" + + refresh: float + """ + Time in seconds after which secondary servers should re-check the SOA record to + see if the zone has been updated. + """ + + retry: float + """ + Time in seconds after which secondary servers should retry queries after the + primary server was unresponsive. + """ + + rname: str + """ + The email address of the zone administrator, with the first label representing + the local part of the email address. + """ + + ttl: float + """The time to live (TTL) of the SOA record itself.""" + + +class ZoneGetResponse(BaseModel): + flatten_all_cnames: Optional[bool] = None + """Whether to flatten all CNAME records in the zone. + + Note that, due to DNS limitations, a CNAME record at the zone apex will always + be flattened. + """ + + foundation_dns: Optional[bool] = None + """Whether to enable Foundation DNS Advanced Nameservers on the zone.""" + + internal_dns: Optional[InternalDNS] = None + """Settings for this internal zone.""" + + multi_provider: Optional[bool] = None + """ + Whether to enable multi-provider DNS, which causes Cloudflare to activate the + zone even when non-Cloudflare NS records exist, and to respect NS records at the + zone apex during outbound zone transfers. + """ + + nameservers: Optional[Nameservers] = None + """ + Settings determining the nameservers through which the zone should be available. + """ + + ns_ttl: Optional[float] = None + """The time to live (TTL) of the zone's nameserver (NS) records.""" + + secondary_overrides: Optional[bool] = None + """ + Allows a Secondary DNS zone to use (proxied) override records and CNAME + flattening at the zone apex. + """ + + soa: Optional[SOA] = None + """Components of the zone's SOA record.""" + + zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]] = None + """Whether the zone mode is a regular or CDN/DNS only zone.""" diff --git a/tests/api_resources/dns/settings/__init__.py b/tests/api_resources/dns/settings/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/dns/settings/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/dns/settings/test_account.py b/tests/api_resources/dns/settings/test_account.py new file mode 100644 index 00000000000..df18160c388 --- /dev/null +++ b/tests/api_resources/dns/settings/test_account.py @@ -0,0 +1,244 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.dns.settings import AccountGetResponse, AccountEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAccount: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + account = client.dns.settings.account.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + account = client.dns.settings.account.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + zone_defaults={ + "flatten_all_cnames": False, + "foundation_dns": False, + "internal_dns": {"reference_zone_id": "reference_zone_id"}, + "multi_provider": False, + "nameservers": {"type": "cloudflare.standard"}, + "ns_ttl": 86400, + "secondary_overrides": False, + "soa": { + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + "zone_mode": "standard", + }, + ) + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.dns.settings.account.with_raw_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account = response.parse() + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.dns.settings.account.with_streaming_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account = response.parse() + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.dns.settings.account.with_raw_response.edit( + account_id="", + ) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + account = client.dns.settings.account.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.settings.account.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account = response.parse() + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.settings.account.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account = response.parse() + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.dns.settings.account.with_raw_response.get( + account_id="", + ) + + +class TestAsyncAccount: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + account = await async_client.dns.settings.account.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + account = await async_client.dns.settings.account.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + zone_defaults={ + "flatten_all_cnames": False, + "foundation_dns": False, + "internal_dns": {"reference_zone_id": "reference_zone_id"}, + "multi_provider": False, + "nameservers": {"type": "cloudflare.standard"}, + "ns_ttl": 86400, + "secondary_overrides": False, + "soa": { + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + "zone_mode": "standard", + }, + ) + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.account.with_raw_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account = await response.parse() + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.account.with_streaming_response.edit( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account = await response.parse() + assert_matches_type(Optional[AccountEditResponse], account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.dns.settings.account.with_raw_response.edit( + account_id="", + ) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + account = await async_client.dns.settings.account.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.account.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account = await response.parse() + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.account.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account = await response.parse() + assert_matches_type(Optional[AccountGetResponse], account, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.dns.settings.account.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/dns/settings/test_zone.py b/tests/api_resources/dns/settings/test_zone.py new file mode 100644 index 00000000000..2834dcebfb3 --- /dev/null +++ b/tests/api_resources/dns/settings/test_zone.py @@ -0,0 +1,246 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.dns.settings import ZoneGetResponse, ZoneEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestZone: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + zone = client.dns.settings.zone.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + zone = client.dns.settings.zone.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + flatten_all_cnames=False, + foundation_dns=False, + internal_dns={"reference_zone_id": "reference_zone_id"}, + multi_provider=False, + nameservers={ + "type": "cloudflare.standard", + "ns_set": 1, + }, + ns_ttl=86400, + secondary_overrides=False, + soa={ + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + zone_mode="standard", + ) + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.dns.settings.zone.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone = response.parse() + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.dns.settings.zone.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone = response.parse() + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @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.dns.settings.zone.with_raw_response.edit( + zone_id="", + ) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + zone = client.dns.settings.zone.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.dns.settings.zone.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone = response.parse() + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.dns.settings.zone.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone = response.parse() + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.dns.settings.zone.with_raw_response.get( + zone_id="", + ) + + +class TestAsyncZone: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + zone = await async_client.dns.settings.zone.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + zone = await async_client.dns.settings.zone.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + flatten_all_cnames=False, + foundation_dns=False, + internal_dns={"reference_zone_id": "reference_zone_id"}, + multi_provider=False, + nameservers={ + "type": "cloudflare.standard", + "ns_set": 1, + }, + ns_ttl=86400, + secondary_overrides=False, + soa={ + "expire": 604800, + "min_ttl": 1800, + "mname": "kristina.ns.cloudflare.com", + "refresh": 10000, + "retry": 2400, + "rname": "admin.example.com", + "ttl": 3600, + }, + zone_mode="standard", + ) + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.zone.with_raw_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone = await response.parse() + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.zone.with_streaming_response.edit( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone = await response.parse() + assert_matches_type(Optional[ZoneEditResponse], zone, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @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.dns.settings.zone.with_raw_response.edit( + zone_id="", + ) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + zone = await async_client.dns.settings.zone.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.dns.settings.zone.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone = await response.parse() + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.dns.settings.zone.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone = await response.parse() + assert_matches_type(Optional[ZoneGetResponse], zone, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="HTTP 422 from prism") + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.dns.settings.zone.with_raw_response.get( + zone_id="", + )