from datetime import datetime

from sqlalchemy import Boolean, Column, DateTime, Integer, String
from sqlalchemy.orm import relationship

from src.core.models.base import Base


class CDN(Base):
    """
    Database model for Content Delivery Network (CDN).
    """

    __tablename__ = "cdns"

    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    label = Column(String(255), nullable=False)  # Label or name of the CDN
    host = Column(String(255), nullable=False)  # Host address of the CDN
    root_path = Column(String(255), nullable=False)  # Root path of the CDN
    is_active = Column(Boolean, default=True)  # Whether the CDN is active or not
    created_at = Column(DateTime, nullable=False, default=datetime.utcnow)  # Timestamp of CDN creation

    def __repr__(self):
        return f"<CDN(label={self.label}, host={self.host}, is_active={self.is_active})>"
