from sqlalchemy import Boolean, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.types import JSON

from app.models.base import BaseModel


class ProvisionInterface(BaseModel):
    """A reusable provision plugin account/configuration."""

    __tablename__ = "provision_interfaces"

    name: Mapped[str] = mapped_column(String(120), nullable=False)
    plugin_id: Mapped[str] = mapped_column(String(80), nullable=False, index=True)
    config: Mapped[dict | None] = mapped_column(JSON, nullable=True)
    enabled: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False, index=True)
    sort_order: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
    remark: Mapped[str | None] = mapped_column(Text, nullable=True)
    last_test_ok: Mapped[bool | None] = mapped_column(Boolean, nullable=True)
    last_test_message: Mapped[str | None] = mapped_column(String(255), nullable=True)
