from sqlalchemy import Integer, String, Text from sqlalchemy.orm import Mapped, mapped_column from core_db import AuditMixin, Base, TenantMixin, VersionMixin class GatewayRequestAudit(TenantMixin, AuditMixin, VersionMixin, Base): __tablename__ = "gateway_request_audit" request_id: Mapped[str] = mapped_column(String(64), index=True) method: Mapped[str] = mapped_column(String(16)) path: Mapped[str] = mapped_column(String(512), index=True) query_string: Mapped[str | None] = mapped_column(Text, nullable=True) target_service: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True) target_url: Mapped[str | None] = mapped_column(String(1024), nullable=True) status_code: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True) duration_ms: Mapped[int] = mapped_column(Integer) client_host: Mapped[str | None] = mapped_column(String(128), nullable=True) user_agent: Mapped[str | None] = mapped_column(String(512), nullable=True) error_message: Mapped[str | None] = mapped_column(Text, nullable=True)