"""Pydantic models for provenance graph edges connecting nodes."""
from typing import ClassVar
from uuid import UUID
from pydantic import BaseModel, ConfigDict, Field
[docs]
class EdgeBase(BaseModel):
"""Model for a graph edge connecting two nodes."""
[docs]
from_id: UUID = Field(..., description="Node the edge is coming from")
[docs]
to_id: UUID = Field(..., description="Node the edge is going to")
[docs]
class EdgeCreate(EdgeBase):
"""Fields used to create an Edge."""
[docs]
execution_id: UUID | None = Field(default=None, description="Execution this edge belongs to")
[docs]
class Edge(EdgeBase):
"""Edge response model."""
[docs]
model_config = ConfigDict(from_attributes=True)
[docs]
col_names_for_table: ClassVar[list[str]] = ["id_", "from_id", "to_id", "execution_id"]
[docs]
id_: int = Field(..., gt=0)
[docs]
execution_id: UUID | None = None