mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
plugin - endpoint -> netaddr in TowerInfo and adds get_summary
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class TowerInfo:
|
||||
def __init__(self, endpoint, available_slots, appointments=None):
|
||||
self.endpoint = endpoint
|
||||
def __init__(self, netaddr, available_slots, appointments=None):
|
||||
self.netaddr = netaddr
|
||||
self.available_slots = available_slots
|
||||
|
||||
if not appointments:
|
||||
@@ -10,14 +10,17 @@ class TowerInfo:
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, tower_data):
|
||||
endpoint = tower_data.get("endpoint")
|
||||
netaddr = tower_data.get("netaddr")
|
||||
available_slots = tower_data.get("available_slots")
|
||||
appointments = tower_data.get("appointments")
|
||||
|
||||
if any(v is None for v in [endpoint, available_slots, appointments]):
|
||||
if any(v is None for v in [netaddr, available_slots, appointments]):
|
||||
raise ValueError("Wrong appointment data, some fields are missing")
|
||||
|
||||
return cls(endpoint, available_slots, appointments)
|
||||
return cls(netaddr, available_slots, appointments)
|
||||
|
||||
def to_dict(self):
|
||||
return self.__dict__
|
||||
|
||||
def get_summary(self):
|
||||
return {"netaddr": self.netaddr, "available_slots": self.available_slots}
|
||||
|
||||
Reference in New Issue
Block a user