# Generated by tosca.yaml2python from ../../../../../../unfurl/unfurl/configurators/templates/dns.py at 2023-10-24T18:50:07 overwrite not modified (change to "ok" to allow)

import unfurl
from typing import List, Dict, Any, Tuple, Union, Sequence
from typing_extensions import Annotated
from tosca import (
    ArtifactType,
    Attribute,
    B,
    BPS,
    Bitrate,
    Capability,
    CapabilityType,
    D,
    DataType,
    Eval,
    Frequency,
    GB,
    GBPS,
    GHZ,
    GHz,
    GIB,
    GIBPS,
    Gbps,
    GiB,
    Gibps,
    GroupType,
    H,
    HZ,
    Hz,
    InterfaceType,
    KB,
    KBPS,
    KHZ,
    KIB,
    KIBPS,
    Kbps,
    KiB,
    Kibps,
    M,
    MB,
    MBPS,
    MHZ,
    MHz,
    MIB,
    MIBPS,
    MS,
    Mbps,
    MiB,
    Mibps,
    NS,
    Namespace,
    NodeType,
    PolicyType,
    Property,
    REQUIRED,
    MISSING,
    RelationshipType,
    Requirement,
    S,
    Size,
    T,
    TB,
    TBPS,
    TIB,
    TIBPS,
    Tbps,
    TiB,
    Tibps,
    Time,
    ToscaDataType,
    ToscaInputs,
    ToscaOutputs,
    US,
    b,
    bps,
    d,
    equal,
    field,
    gb,
    gbps,
    ghz,
    gib,
    gibps,
    greater_or_equal,
    greater_than,
    h,
    hz,
    in_range,
    kB,
    kHz,
    kb,
    kbps,
    khz,
    kib,
    kibps,
    length,
    less_or_equal,
    less_than,
    loader,
    m,
    max_length,
    mb,
    mbps,
    metadata_to_yaml,
    mhz,
    mib,
    mibps,
    min_length,
    ms,
    ns,
    operation,
    pattern,
    s,
    tb,
    tbps,
    tib,
    tibps,
    tosca_timestamp,
    tosca_version,
    us,
    valid_values,
)
import tosca
import unfurl.configurators.dns


class unfurl_datatypes_DNSRecord(DataType):
    _type_name = "unfurl.datatypes.DNSRecord"
    _type_metadata = {"additionalProperties": True}
    type: str
    value: Union[str, None] = None
    values: Union[List[Any], None] = None


class unfurl_capabilities_DNSZone(tosca.capabilities.Root):
    _type_name = "unfurl.capabilities.DNSZone"


class unfurl_relationships_DNSRecords(tosca.relationships.Root):
    _type_name = "unfurl.relationships.DNSRecords"
    records: Dict[str, "unfurl_datatypes_DNSRecord"]

    _valid_target_types = ["unfurl_capabilities_DNSZone"]


class unfurl_nodes_DNSZone(tosca.nodes.Root):
    _type_name = "unfurl.nodes.DNSZone"
    _type_metadata = {"title": "DNS Zone"}
    name: str = Property(title="Domain Name")
    """Top level part of the DNS name (e.g. example.com)"""

    provider: Dict[str, Any] = Property(metadata={"sensitive": True})
    """OctoDNS provider configuration"""

    records: Dict[str, "unfurl_datatypes_DNSRecord"] = Property(
        metadata={"computed": True}, factory=lambda: ({})
    )
    """DNS records to add to the zone"""

    exclusive: bool = False
    """Zone exclusively managed by this instance (removes unrecognized records)"""

    default_ttl: int = Property(title="Default TTL", default=300)
    testing: bool = Property(title="Testing", default=False)
    """Is this DNS zone being used for testing? (If set, Let's Encrypt staging will be used.)"""

    zone: Dict[str, Any] = Attribute(metadata={"internal": True})
    """The records found in the zone"""

    managed_records: Dict[str, Any] = Attribute(title="Managed Records")
    """The records in the zone that are managed by this instance"""

    resolve: "unfurl_capabilities_DNSZone" = Capability(
        factory=unfurl_capabilities_DNSZone
    )

    parent_zone: Union["unfurl_capabilities_DNSZone", None] = Requirement(
        default=None, metadata={"visibility": "hidden"}
    )

    @operation(
        apply_to=[
            "Install.check",
            "Install.connect",
            "Standard.delete",
            "Standard.configure",
        ]
    )
    def default(self, **kw):
        return unfurl.configurators.dns.DNSConfigurator()

