from cdnmon.model.cdn import BGPViewCIDR
from cdnmon.model.cdn import CNAMEPattern
from cdnmon.model.cdn import CommonCDN
from cdnmon.model.cdn import DomainOwnershipVerficationStatus
from cdnmon.model.cdn import DomainOwnershipVerification
from cdnmon.model.cdn import HTTPOwnershipVerification
from cdnmon.model.cdn import OwnershipVerification

CDN = CommonCDN(
    name="upyun",
    asn_patterns=["youpai", "upyun"],
    cname_suffixes=[
        CNAMEPattern(suffix=".b0.aicdn.com", pattern=r"[0-9a-f]{12}.b0.aicdn.com", is_root=True),
        CNAMEPattern(suffix="nm.aicdn.com", pattern=r"nm.aicdn.com", is_leaf=True),
    ],
    cidr=BGPViewCIDR(query_term_list=["youpai", "upyun"]),
    frontend_ownership_verification=OwnershipVerification(
        txt=DomainOwnershipVerification(
            status=DomainOwnershipVerficationStatus.REQUIRED,
            prefix="upyun-verify",
            pattern=r"[0-9a-f]{32}",
        ),
    ),
    backend_ownership_verification=OwnershipVerification(
        txt=DomainOwnershipVerification(status=DomainOwnershipVerficationStatus.NOT_REQUIRED),
        http=HTTPOwnershipVerification(status=DomainOwnershipVerficationStatus.NOT_REQUIRED),
    ),
)
