mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
pluggin - adds pending appointments to towers
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class TowerInfo:
|
class TowerInfo:
|
||||||
def __init__(self, netaddr, available_slots, status="active", appointments=None):
|
def __init__(self, netaddr, available_slots, status="active", appointments=None, pending_appointments=None):
|
||||||
self.netaddr = netaddr
|
self.netaddr = netaddr
|
||||||
self.available_slots = available_slots
|
self.available_slots = available_slots
|
||||||
self.status = status
|
self.status = status
|
||||||
@@ -9,20 +9,31 @@ class TowerInfo:
|
|||||||
else:
|
else:
|
||||||
self.appointments = appointments
|
self.appointments = appointments
|
||||||
|
|
||||||
|
if not pending_appointments:
|
||||||
|
self.pending_appointments = []
|
||||||
|
else:
|
||||||
|
self.pending_appointments = pending_appointments
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, tower_data):
|
def from_dict(cls, tower_data):
|
||||||
netaddr = tower_data.get("netaddr")
|
netaddr = tower_data.get("netaddr")
|
||||||
available_slots = tower_data.get("available_slots")
|
available_slots = tower_data.get("available_slots")
|
||||||
status = tower_data.get("status")
|
status = tower_data.get("status")
|
||||||
appointments = tower_data.get("appointments")
|
appointments = tower_data.get("appointments")
|
||||||
|
pending_appointments = tower_data.get("pending_appointments")
|
||||||
|
|
||||||
if any(v is None for v in [netaddr, available_slots, status, appointments]):
|
if any(v is None for v in [netaddr, available_slots, status, appointments, pending_appointments]):
|
||||||
raise ValueError("Wrong appointment data, some fields are missing")
|
raise ValueError("Wrong appointment data, some fields are missing")
|
||||||
|
|
||||||
return cls(netaddr, available_slots, status, appointments)
|
return cls(netaddr, available_slots, status, appointments, pending_appointments)
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return self.__dict__
|
return self.__dict__
|
||||||
|
|
||||||
def get_summary(self):
|
def get_summary(self):
|
||||||
return {"netaddr": self.netaddr, "status": self.status, "available_slots": self.available_slots}
|
return {
|
||||||
|
"netaddr": self.netaddr,
|
||||||
|
"status": self.status,
|
||||||
|
"available_slots": self.available_slots,
|
||||||
|
"pending_appointments": self.pending_appointments,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user