72 lines
1.7 KiB
Python
72 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any, Literal
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class RuntimeModel(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
|
|
class RegistryRegistration(RuntimeModel):
|
|
descriptor: dict[str, Any]
|
|
manifest: dict[str, Any]
|
|
|
|
|
|
class MessageCommand(RuntimeModel):
|
|
schema_version: str
|
|
correlation_id: UUID
|
|
conversation_id: UUID | None = None
|
|
from_address: str = Field(min_length=1)
|
|
to_addresses: list[str] = Field(min_length=1)
|
|
body: str = Field(min_length=1)
|
|
subject_refs: dict[str, str] = Field(default_factory=dict)
|
|
|
|
|
|
class EventCommand(RuntimeModel):
|
|
schema_version: str
|
|
correlation_id: UUID
|
|
event_type: str = Field(pattern=r"^[a-z][a-z0-9]*(?:[.-][a-z0-9][a-z0-9-]*)+$")
|
|
occurred_at: datetime
|
|
subject_refs: dict[str, str] = Field(default_factory=dict)
|
|
payload: dict[str, Any]
|
|
|
|
|
|
class Provenance(RuntimeModel):
|
|
source_system: str
|
|
source_ref: str
|
|
schema_version: str
|
|
content_hash: str | None = None
|
|
indexed_at: datetime
|
|
|
|
|
|
class PortRecord(RuntimeModel):
|
|
id: str
|
|
data: dict[str, Any]
|
|
provenance: Provenance
|
|
|
|
|
|
class PortCollection(RuntimeModel):
|
|
items: list[PortRecord]
|
|
next_cursor: str | None = None
|
|
|
|
|
|
class PortAccepted(RuntimeModel):
|
|
id: str
|
|
status: Literal["accepted", "duplicate"]
|
|
correlation_id: UUID
|
|
|
|
|
|
class HealthResponse(RuntimeModel):
|
|
service: str = "hub-core"
|
|
status: Literal["ok"] = "ok"
|
|
version: str
|
|
|
|
|
|
class ReadinessResponse(RuntimeModel):
|
|
service: str = "hub-core"
|
|
status: Literal["ok", "degraded"]
|
|
checks: dict[str, str]
|