feat(fleet): edit apparatus name independently of onboard availability
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user