44 lines
887 B
Python
44 lines
887 B
Python
|
|
"""Schemas for bot API keys and project reports."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from typing import Any
|
||
|
|
from uuid import UUID
|
||
|
|
|
||
|
|
from sqlmodel import Field, SQLModel
|
||
|
|
|
||
|
|
|
||
|
|
class BotApiKeyCreate(SQLModel):
|
||
|
|
name: str
|
||
|
|
|
||
|
|
|
||
|
|
class BotApiKeyRead(SQLModel):
|
||
|
|
id: UUID
|
||
|
|
name: str
|
||
|
|
key_last_four: str
|
||
|
|
created_at: datetime
|
||
|
|
last_used_at: datetime | None
|
||
|
|
|
||
|
|
|
||
|
|
class BotApiKeyCreated(BotApiKeyRead):
|
||
|
|
"""Returned once on creation — includes the plaintext key, never stored."""
|
||
|
|
key: str
|
||
|
|
|
||
|
|
|
||
|
|
class BotReportCreate(SQLModel):
|
||
|
|
project: str | None = None
|
||
|
|
task: str | None = None
|
||
|
|
status: str | None = "busy"
|
||
|
|
detail: dict[str, Any] | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class BotReportRead(SQLModel):
|
||
|
|
id: UUID
|
||
|
|
key_id: UUID
|
||
|
|
project: str | None
|
||
|
|
task: str | None
|
||
|
|
status: str | None
|
||
|
|
detail: dict[str, Any] | None
|
||
|
|
reported_at: datetime
|