@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user