"""
Policy Model
"""
from enum import Enum
from sqlalchemy import Column, Integer, String, Text, Enum as SQLEnum
from sqlalchemy.orm import relationship
from app.models.base import Base, TimestampMixin

class PolicyStatus(str, Enum):
    ACTIVE = "active"
    WARNING = "warning"
    DISABLED = "disabled"

class Policy(Base, TimestampMixin):
    """
    Sicherheits-Policy für Compliance-Checks
    """
    __tablename__ = "policies"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(255), nullable=False)
    description = Column(Text, nullable=True)
    category = Column(String(100), nullable=False)
    status = Column(SQLEnum(PolicyStatus), default=PolicyStatus.ACTIVE)
    
    # SLA-Definitionen (in Tagen, 0 = deaktiviert/sofort)
    critical_sla_days = Column(Integer, default=2)
    high_sla_days = Column(Integer, default=7)
    medium_sla_days = Column(Integer, default=30)
    low_sla_days = Column(Integer, default=90)

    # Relationship
    assets = relationship("Asset", back_populates="policy")

    def __repr__(self):
        return f"<Policy(name='{self.name}')>"
