Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jun 5, 2024
1 parent 0592df8 commit d3c3d58
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1335
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1a0beb27a59a3abb36f2931ebc3fc1bcbf0f91a8da100fc87d2254a85549879b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-13157b0171e236329a3811eedbce4e5b71b517be66de1126b5dcb6ac4b964ee6.yml
25 changes: 25 additions & 0 deletions src/cloudflare/resources/zones/dns_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from typing import Type, Optional, cast
from typing_extensions import Literal

import httpx

Expand Down Expand Up @@ -46,7 +47,10 @@ def edit(
foundation_dns: bool | NotGiven = NOT_GIVEN,
multi_provider: bool | NotGiven = NOT_GIVEN,
nameservers: NameserverParam | NotGiven = NOT_GIVEN,
ns_ttl: float | NotGiven = NOT_GIVEN,
secondary_overrides: bool | NotGiven = NOT_GIVEN,
soa: dns_setting_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,
Expand All @@ -68,9 +72,15 @@ def edit(
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
Expand All @@ -88,7 +98,10 @@ def edit(
"foundation_dns": foundation_dns,
"multi_provider": multi_provider,
"nameservers": nameservers,
"ns_ttl": ns_ttl,
"secondary_overrides": secondary_overrides,
"soa": soa,
"zone_mode": zone_mode,
},
dns_setting_edit_params.DNSSettingEditParams,
),
Expand Down Expand Up @@ -158,7 +171,10 @@ async def edit(
foundation_dns: bool | NotGiven = NOT_GIVEN,
multi_provider: bool | NotGiven = NOT_GIVEN,
nameservers: NameserverParam | NotGiven = NOT_GIVEN,
ns_ttl: float | NotGiven = NOT_GIVEN,
secondary_overrides: bool | NotGiven = NOT_GIVEN,
soa: dns_setting_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,
Expand All @@ -180,9 +196,15 @@ async def edit(
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
Expand All @@ -200,7 +222,10 @@ async def edit(
"foundation_dns": foundation_dns,
"multi_provider": multi_provider,
"nameservers": nameservers,
"ns_ttl": ns_ttl,
"secondary_overrides": secondary_overrides,
"soa": soa,
"zone_mode": zone_mode,
},
dns_setting_edit_params.DNSSettingEditParams,
),
Expand Down
47 changes: 46 additions & 1 deletion src/cloudflare/types/zones/dns_setting.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
# 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
from .nameserver import Nameserver

__all__ = ["DNSSetting"]
__all__ = ["DNSSetting", "Soa"]


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 DNSSetting(BaseModel):
Expand All @@ -24,8 +60,17 @@ class DNSSetting(BaseModel):
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."""
48 changes: 46 additions & 2 deletions src/cloudflare/types/zones/dns_setting_edit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from __future__ import annotations

from typing_extensions import Required, TypedDict
from typing_extensions import Literal, Required, TypedDict

from .nameserver_param import NameserverParam

__all__ = ["DNSSettingEditParams"]
__all__ = ["DNSSettingEditParams", "Soa"]


class DNSSettingEditParams(TypedDict, total=False):
Expand All @@ -28,8 +28,52 @@ class DNSSettingEditParams(TypedDict, total=False):
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 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."""
22 changes: 22 additions & 0 deletions tests/api_resources/zones/test_dns_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
foundation_dns=False,
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="dns_only",
)
assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"])

Expand Down Expand Up @@ -122,7 +133,18 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare)
foundation_dns=False,
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="dns_only",
)
assert_matches_type(Optional[DNSSetting], dns_setting, path=["response"])

Expand Down

0 comments on commit d3c3d58

Please sign in to comment.