Compare commits

..

No commits in common. "0a442e4ab56d72bd8dc19dfc3038347cea1f3dd7" and "80eec844bfed771a784a881ced6a26201e524cca" have entirely different histories.

4 changed files with 21 additions and 111 deletions

View File

@ -102,7 +102,7 @@ class OMMClient2:
yield pp yield pp
# Determine next possible ppn # Determine next possible ppn
next_ppn = int(pp.ppn) + 1 next_ppn = int(pp["ppn"]) + 1
def get_user(self, uid): def get_user(self, uid):
""" """

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from . import Request, Response, request_type, response_type from . import Request, Response, request_type, response_type
from ..types import AccountType
@request_type @request_type
@ -15,5 +14,5 @@ class GetAccount(Request):
@response_type @response_type
class GetAccountResp(Response): class GetAccountResp(Response):
CHILDS = { CHILDS = {
"account": AccountType, "account": None,
} }

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from . import Request, Response, request_type, response_type from . import Request, Response, request_type, response_type
from ..types import PPDevType
@request_type @request_type
@ -15,5 +14,5 @@ class GetPPDev(Request):
@response_type @response_type
class GetPPDevResp(Response): class GetPPDevResp(Response):
CHILDS = { CHILDS = {
"pp": PPDevType, "pp": None,
} }

View File

@ -11,15 +11,12 @@ class ChildType:
FIELDS = {} FIELDS = {}
def __init__(self, attrs={}): def __init__(self, attrs={}):
self._attrs = {} self._attrs = {}
if self.FIELDS is not None:
for k, v in attrs.items(): for k, v in attrs.items():
setattr(self, k, v) setattr(self, k, v)
else:
# don't check attrs for types we do have any information
self._attrs = attrs
def __getattr__(self, name): def __getattr__(self, name):
if name in self.FIELDS.keys(): if name in self.FIELDS.keys():
@ -48,97 +45,11 @@ def cast_dict_to_childtype(t, d):
return t(d) return t(d)
class EnumType:
VALUES = [] # Allowed values
def __init__(self, s):
if self.VALUES is not None:
if s in self.VALUES:
self.value = s
else:
raise ValueError()
else:
self.value = s
def __str__(self):
return str(self.value)
def __repr__(self):
return "{}({})".format(self.__class__.__name__, repr(self.value))
class CallForwardStateType(EnumType):
VALUES = [
"Off",
"Busy",
"NoAnswer",
"BusyNoAnswer",
"All",
]
class DECTSubscriptionStateType(EnumType):
VALUES = None
class LanguageType(EnumType):
VALUES = None
class MonitoringStateType(EnumType):
VALUES = None
class PPRelTypeType(EnumType):
VALUES = None
class AccountType(ChildType):
FIELDS = {
"id": int,
"username": str,
"password": str,
"oldPassword": str,
"permission": None,
"active": bool,
"aging": None,
"expire": int,
"state": str,
}
class PPDevType(ChildType):
FIELDS = {
"ppn": int,
"timeStamp": int,
"relType": PPRelTypeType,
"uid": int,
"ipei": str,
"ac": str,
"s": DECTSubscriptionStateType,
"uak": str,
"encrypt": bool,
"capMessaging": bool,
"capMessagingForInternalUse": bool,
"capEnhLocating": bool,
"capBluetooth": bool,
"ethAddr": str,
"hwType": str,
"ppProfileCapability": bool,
"ppDefaultProfileLoaded": bool,
"subscribeToPARIOnly": bool,
# undocumented
"ppnSec": int,
}
class PPUserType(ChildType): class PPUserType(ChildType):
FIELDS = { FIELDS = {
"uid": int, "uid": int,
"timeStamp": int, "timeStamp": int,
"relType": PPRelTypeType, "relType": None, #PPRelTypeType,
"ppn": int, "ppn": int,
"name": str, "name": str,
"num": str, "num": str,
@ -151,10 +62,10 @@ class PPUserType(ChildType):
"sosNum": str, "sosNum": str,
"voiceboxNum": str, "voiceboxNum": str,
"manDownNum": str, "manDownNum": str,
"forwardState": CallForwardStateType, "forwardStateCall": None, #ForwardStateType,
"forwardTime": int, "forwardTime": int,
"forwardDest": str, "forwardDest": str,
"langPP": LanguageType, "langPP": None, #LanguageType,
"holdRingBackTime": int, "holdRingBackTime": int,
"autoAnswer": str, "autoAnswer": str,
"microphoneMute": str, "microphoneMute": str,
@ -177,17 +88,17 @@ class PPUserType(ChildType):
"conferenceServerType": str, "conferenceServerType": str,
"conferenceServerURI": str, "conferenceServerURI": str,
"monitoringMode": str, "monitoringMode": str,
"CUS": MonitoringStateType, "CUS": None, #MonitoringStateType,
"HAS": MonitoringStateType, "HAS": None, #MonitoringStateType,
"HSS": MonitoringStateType, "HSS": None, #MonitoringStateType,
"HRS": MonitoringStateType, "HRS": None, #MonitoringStateType,
"HCS": MonitoringStateType, "HCS": None, #MonitoringStateType,
"SRS": MonitoringStateType, "SRS": None, #MonitoringStateType,
"SCS": MonitoringStateType, "SCS": None, #MonitoringStateType,
"CDS": MonitoringStateType, "CDS": None, #MonitoringStateType,
"HBS": MonitoringStateType, "HBS": None, #MonitoringStateType,
"BTS": MonitoringStateType, "BTS": None, #MonitoringStateType,
"SWS": MonitoringStateType, "SWS": None, #MonitoringStateType,
"credentialPw": str, "credentialPw": str,
"configurationDataLoaded": bool, "configurationDataLoaded": bool,
"ppData": str, "ppData": str,
@ -198,6 +109,7 @@ class PPUserType(ChildType):
"uidSec": int, "uidSec": int,
"permanent": bool, "permanent": bool,
"lang": None, "lang": None,
"forwardState": None,
"autoLogoutOnCharge": bool, "autoLogoutOnCharge": bool,
"hotDeskingSupport": bool, "hotDeskingSupport": bool,
"authenticateLogout": bool, "authenticateLogout": bool,