2026-03-20 20:44:00 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from typing import Optional
|
2026-03-21 09:19:50 +02:00
|
|
|
from pydantic import BaseModel, EmailStr, Field
|
2026-03-20 20:44:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class RegisterRequest(BaseModel):
|
2026-03-21 07:36:36 +02:00
|
|
|
uuid: str = Field(..., pattern=r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
|
2026-03-20 20:44:00 +02:00
|
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RegisterResponse(BaseModel):
|
|
|
|
|
user_id: int
|
|
|
|
|
uuid: str
|
2026-03-21 08:12:01 +02:00
|
|
|
api_key: str
|
2026-03-20 20:44:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeoData(BaseModel):
|
|
|
|
|
lat: float = Field(..., ge=-90.0, le=90.0)
|
|
|
|
|
lon: float = Field(..., ge=-180.0, le=180.0)
|
|
|
|
|
accuracy: float = Field(..., gt=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SignalRequest(BaseModel):
|
2026-03-21 07:36:36 +02:00
|
|
|
user_id: str = Field(..., pattern=r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
|
2026-03-20 20:44:00 +02:00
|
|
|
timestamp: int = Field(..., gt=0)
|
|
|
|
|
geo: Optional[GeoData] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SignalResponse(BaseModel):
|
|
|
|
|
status: str
|
|
|
|
|
signal_id: int
|
2026-03-20 23:39:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AdminCreateUserRequest(BaseModel):
|
|
|
|
|
uuid: str = Field(..., min_length=1)
|
|
|
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
|
|
|
password: Optional[str] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AdminSetPasswordRequest(BaseModel):
|
|
|
|
|
password: str = Field(..., min_length=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AdminBlockRequest(BaseModel):
|
|
|
|
|
is_blocked: bool
|
2026-03-21 09:19:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class PushSubscriptionKeys(BaseModel):
|
|
|
|
|
p256dh: str
|
|
|
|
|
auth: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PushSubscription(BaseModel):
|
|
|
|
|
endpoint: str
|
|
|
|
|
keys: PushSubscriptionKeys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AuthRegisterRequest(BaseModel):
|
|
|
|
|
email: EmailStr
|
|
|
|
|
login: str = Field(..., min_length=3, max_length=30, pattern=r'^[a-zA-Z0-9_-]+$')
|
|
|
|
|
password: str = Field(..., min_length=8, max_length=128)
|
|
|
|
|
push_subscription: Optional[PushSubscription] = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AuthRegisterResponse(BaseModel):
|
|
|
|
|
status: str
|
|
|
|
|
message: str
|