# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Optional
from typing_extensions import Required, TypedDict

from ..._types import SequenceNotStr
from .upstream_ips import UpstreamIPs
from .attack_mitigation_param import AttackMitigationParam

__all__ = ["DNSFirewallCreateParams"]


class DNSFirewallCreateParams(TypedDict, total=False):
    account_id: Required[str]
    """Identifier."""

    name: Required[str]
    """DNS Firewall cluster name"""

    upstream_ips: Required[SequenceNotStr[UpstreamIPs]]

    attack_mitigation: Optional[AttackMitigationParam]
    """Attack mitigation settings"""

    deprecate_any_requests: bool
    """Whether to refuse to answer queries for the ANY type"""

    dns_firewall_ip_count: int
    """Number of IPv4 addresses to assign to the DNS Firewall cluster.

    Only used during cluster creation and cannot be changed later.
    """

    ecs_fallback: bool
    """Whether to forward client IP (resolver) subnet if no EDNS Client Subnet is sent"""

    maximum_cache_ttl: float
    """
    By default, Cloudflare attempts to cache responses for as long as indicated by
    the TTL received from upstream nameservers. This setting sets an upper bound on
    this duration. For caching purposes, higher TTLs will be decreased to the
    maximum value defined by this setting.

    This setting does not affect the TTL value in the DNS response Cloudflare
    returns to clients. Cloudflare will always forward the TTL value received from
    upstream nameservers.
    """

    minimum_cache_ttl: float
    """
    By default, Cloudflare attempts to cache responses for as long as indicated by
    the TTL received from upstream nameservers. This setting sets a lower bound on
    this duration. For caching purposes, lower TTLs will be increased to the minimum
    value defined by this setting.

    This setting does not affect the TTL value in the DNS response Cloudflare
    returns to clients. Cloudflare will always forward the TTL value received from
    upstream nameservers.

    Note that, even with this setting, there is no guarantee that a response will be
    cached for at least the specified duration. Cached responses may be removed
    earlier for capacity or other operational reasons.
    """

    negative_cache_ttl: Optional[float]
    """
    This setting controls how long DNS Firewall should cache negative responses
    (e.g., NXDOMAIN) from the upstream servers.

    This setting does not affect the TTL value in the DNS response Cloudflare
    returns to clients. Cloudflare will always forward the TTL value received from
    upstream nameservers.
    """

    ratelimit: Optional[float]
    """
    Maximum number of DNS queries per second that will be forwarded to your upstream
    nameservers. The limit is enforced per server, where each server receives a
    fraction of the configured value. The actual aggregate rate for a data center
    may vary depending on how many servers are present. Responses served from cache
    do not count toward this limit. Set to null to disable rate limiting.
    """

    retries: float
    """
    Number of retries for fetching DNS responses from upstream nameservers (not
    counting the initial attempt)
    """
