from schemas.base_imports import (
    CrudCollection,
    UUID,
    String,
    mapped_column,
    Mapped,
    Index,
)


class EndpointRestriction(CrudCollection):
    """
    Initialize Endpoint Restriction with default values
    """

    __tablename__ = "endpoint_restriction"
    __exclude__fields__ = []

    operation_uu_id: Mapped[UUID] = mapped_column(
        String, comment="UUID of the operation", nullable=False, unique=True
    )
    endpoint_function: Mapped[str] = mapped_column(
        String, comment="Function name of the API endpoint"
    )
    endpoint_name: Mapped[str] = mapped_column(
        String, comment="Name of the API endpoint"
    )
    endpoint_method: Mapped[str] = mapped_column(
        String, comment="HTTP method used by the endpoint"
    )
    endpoint_desc: Mapped[str] = mapped_column(
        String, server_default="", comment="Description of the endpoint"
    )

    __table_args__ = (
        Index("idx_endpoint_restriction_operation_uu_id", operation_uu_id, endpoint_method, endpoint_name, unique=True),
    )    
