from typing import Optional

from pydantic import BaseModel, Field


class PermissionRuleOctBaseDTO(BaseModel):
    permission: str = Field(..., description="Permission identifier", max_length=20)
    start_date: Optional[int] = Field(None, description="Start date")
    end_date: Optional[int] = Field(None, description="End date")
    sector: Optional[str] = Field(None, max_length=8, description="Sector")
    system: Optional[str] = Field(None, max_length=5, description="System")


class PermissionRuleOctCreateDTO(PermissionRuleOctBaseDTO):
    """Schema for creating a permission rule OCT"""
    pass


class PermissionRuleOctUpdateDTO(PermissionRuleOctBaseDTO):
    """Schema for updating a permission rule OCT"""
    permission: Optional[str] = Field(None, description="Permission identifier", max_length=20)


class PermissionRuleOctResponseDTO(PermissionRuleOctBaseDTO):
    """Schema for permission rule OCT response"""
    id: int
    company_id: int
    tenant_id: int

    class Config:
        from_attributes = True
