import/export devices
build-and-push / build (push) Failing after 17s

This commit is contained in:
2026-08-01 01:47:42 +05:00
parent 6fe7c69adb
commit a6d4fa1f6d
7 changed files with 501 additions and 9 deletions
+34
View File
@@ -209,6 +209,40 @@ class DeviceEdit(BaseModel):
return self
# ---------- device CSV import ----------
class DeviceImportRow(BaseModel):
"""A single CSV row — lenient so one bad row never 422s the whole batch.
Each row is re-validated with ``DeviceCreate`` inside the router so failures
are collected per-row instead of rejecting the entire request.
"""
mac_address: str | None = None
group: str | None = None
name: str | None = None
phone: str | None = None
alias: str | None = None
class DeviceImportRequest(BaseModel):
devices: list[DeviceImportRow]
dry_run: bool = Field(default=False, description="Validate only; commit nothing")
class DeviceImportError(BaseModel):
row: int # 1-based index within the submitted rows
mac: str | None = None
detail: str
class DeviceImportResult(BaseModel):
total: int # rows submitted
valid: int # rows that passed validation
created: int # rows actually inserted (0 on dry_run)
dry_run: bool
errors: list[DeviceImportError]
# ---------- radusergroup ----------
class UserGroupBase(BaseModel):
username: str = Field(max_length=64)