59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from enum import Enum
|
|
from typing import Any, Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
def utc_now_iso() -> str:
|
|
return datetime.now(timezone.utc).isoformat()
|
|
|
|
|
|
class Platform(str, Enum):
|
|
windows = "windows"
|
|
pwa = "pwa"
|
|
web = "web"
|
|
unknown = "unknown"
|
|
|
|
|
|
class DeviceHello(BaseModel):
|
|
device_id: str = Field(min_length=3, max_length=128)
|
|
platform: Platform = Platform.unknown
|
|
version: str = "0.0.0"
|
|
hostname: str = ""
|
|
capabilities: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class ConnectedDevice(BaseModel):
|
|
device_id: str
|
|
platform: Platform
|
|
version: str
|
|
hostname: str = ""
|
|
capabilities: list[str] = Field(default_factory=list)
|
|
connected_at: str = Field(default_factory=utc_now_iso)
|
|
last_seen_at: str = Field(default_factory=utc_now_iso)
|
|
|
|
|
|
class DispatchRequest(BaseModel):
|
|
action: Literal["notify", "wallpaper_set", "overlay_show", "sync_settings", "ping"]
|
|
data: dict[str, Any] = Field(default_factory=dict)
|
|
target_scope: Literal["all", "windows", "pwa", "web", "device_ids"] = "all"
|
|
device_ids: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class DispatchResult(BaseModel):
|
|
command_id: str
|
|
delivered_to: list[str] = Field(default_factory=list)
|
|
skipped: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class UpdateManifest(BaseModel):
|
|
version: str = "0.0.0"
|
|
download_url: str = ""
|
|
sha256: str = ""
|
|
notes: str = ""
|
|
published_at: str = Field(default_factory=utc_now_iso)
|
|
|