import enum
from typing import Dict, Optional

import pydantic


class DatabaseEntityType(enum.Enum):
    schemas = "Schemas"
    schema = "Schema"
    tables = "Tables"
    views = "Views"
    table = "Table"
    view = "View"
    column = "Column"
    row = "Row"


class DatabaseEntity(pydantic.BaseModel):
    name: str = pydantic.Field(description="Name or value of the item.")
    type: DatabaseEntityType = pydantic.Field(description="Type of the item.")
    dbschema: Optional[str] = pydantic.Field(
        default=None, description="Schema of the item."
    )

    datatype: Optional[str] = pydantic.Field(
        default=None, description="Data type of the column (only for columns)."
    )
    nullable: Optional[bool] = pydantic.Field(
        default=None,
        description="Whether the column is nullable (only for columns).",
    )

    data: Optional[Dict] = pydantic.Field(
        default=None, description="Data of the row (only for rows)."
    )
