Spaces:
Paused
Paused
Download src/models/webhook_log.py from arimatch1/crewhub-api-2: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/models/webhook_log.py
- Command line
-
hf download hf://spaces/arimatch1/crewhub-api-2/src/models/webhook_log.py
-
curl -L -o webhook_log.py https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/models/webhook_log.py
1.84 kB
| # Copyright (c) 2026 CrewHub. All rights reserved. | |
| # Proprietary and confidential. See LICENSE for details. | |
| """Webhook log model for tracking A2A communication.""" | |
| import uuid | |
| from datetime import datetime | |
| from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, JSON, String, Text, Uuid, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from src.database import Base | |
| class WebhookLog(Base): | |
| __tablename__ = "webhook_logs" | |
| id: Mapped[uuid.UUID] = mapped_column( | |
| Uuid, primary_key=True, default=uuid.uuid4 | |
| ) | |
| agent_id: Mapped[uuid.UUID] = mapped_column( | |
| Uuid, ForeignKey("agents.id", ondelete="CASCADE"), nullable=False, index=True | |
| ) | |
| task_id: Mapped[uuid.UUID | None] = mapped_column( | |
| Uuid, ForeignKey("tasks.id", ondelete="SET NULL"), nullable=True, index=True | |
| ) | |
| direction: Mapped[str] = mapped_column( | |
| String(10), nullable=False, index=True | |
| ) # "outbound" (marketplace→agent) or "inbound" (agent→marketplace) | |
| method: Mapped[str] = mapped_column( | |
| String(50), nullable=False | |
| ) # e.g. "tasks/send", "tasks/statusUpdate" | |
| request_body: Mapped[dict | None] = mapped_column(JSON, nullable=True) | |
| response_body: Mapped[dict | None] = mapped_column(JSON, nullable=True) | |
| status_code: Mapped[int | None] = mapped_column(Integer, nullable=True) | |
| success: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) | |
| error_message: Mapped[str | None] = mapped_column(Text, nullable=True) | |
| latency_ms: Mapped[int | None] = mapped_column(Integer, nullable=True) | |
| created_at: Mapped[datetime] = mapped_column( | |
| DateTime(timezone=True), server_default=func.now(), nullable=False | |
| ) | |
| def __repr__(self) -> str: | |
| return f"<WebhookLog(id={self.id}, direction={self.direction}, method={self.method})>" | |