from datetime import datetime

from pydantic import BaseModel

from src.db.models.admin import Permission


class PermissionResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    name: str


def to_response(permission: Permission) -> PermissionResponse:
    response: PermissionResponse = PermissionResponse(
        id=permission.id,
        created_date=permission.created_date,
        last_modified_date=permission.last_modified_date,
        version=permission.version,
        name=permission.name
    )
    return response
