feat(fleet): edit apparatus name independently of onboard availability

This commit is contained in:
DCCONSTRUCTIONS
2026-09-25 22:28:22 +03:00
parent ee7576b7b4
commit aecae4a986
8 changed files with 147 additions and 6 deletions
+15
View File
@@ -273,6 +273,21 @@ class FleetRegistry:
"core_endpoint": row["binding"]["endpoint"],
}
def rename(self, identifier: str, name: str, expected_revision: int) -> dict:
"""Update operator metadata without contacting or re-enrolling the board."""
if (not name.strip() or len(name.strip()) > 80
or any(ord(c) < 32 or 127 <= ord(c) < 160 for c in name)):
raise PairingError("Введите название аппарата от 1 до 80 символов без управляющих знаков.")
with self.lock:
row = self.find(identifier)
if row["name"] == name.strip():
return self.public(row) # Safe retry after a lost response.
if row["revision"] != expected_revision:
raise PairingError("Аппарат изменился. Отмените правку и повторите её по свежим данным.")
row.update(name=name.strip(), revision=row["revision"] + 1)
self.save(row)
return self.public(row)
def listing(self):
with self.lock:
return {