Introduce ability to attach users to devices
This commit is contained in:
parent
ac9ae74a0b
commit
8849b8488c
@ -53,6 +53,32 @@ class OMMClient2:
|
|||||||
r = self.connection.request(m)
|
r = self.connection.request(m)
|
||||||
r.raise_on_error()
|
r.raise_on_error()
|
||||||
|
|
||||||
|
def attach_user_device(self, uid, ppn):
|
||||||
|
"""
|
||||||
|
Attach user to device
|
||||||
|
|
||||||
|
:param uid: User id
|
||||||
|
:param ppn: Device id
|
||||||
|
|
||||||
|
Requires ommsync=True
|
||||||
|
"""
|
||||||
|
t_u = types.PPUserType()
|
||||||
|
t_u.uid = uid
|
||||||
|
t_u.ppn = ppn
|
||||||
|
t_u.relType = types.PPRelTypeType("Dynamic")
|
||||||
|
t_d = types.PPDevType()
|
||||||
|
t_d.ppn = ppn
|
||||||
|
t_d.uid = uid
|
||||||
|
t_d.relType = types.PPRelTypeType("Dynamic")
|
||||||
|
m = messages.SetPP()
|
||||||
|
m.childs.user = [t_u]
|
||||||
|
m.childs.pp = [t_d]
|
||||||
|
r = self.connection.request(m)
|
||||||
|
r.raise_on_error()
|
||||||
|
if r.childs.user is None:
|
||||||
|
return None
|
||||||
|
return r.childs.user[0], r.childs.pp[0]
|
||||||
|
|
||||||
def create_user(self, num):
|
def create_user(self, num):
|
||||||
"""
|
"""
|
||||||
Create PP user
|
Create PP user
|
||||||
|
@ -141,6 +141,7 @@ from .getppuser import GetPPUser, GetPPUserResp
|
|||||||
from .getpublickey import GetPublicKey, GetPublicKeyResp
|
from .getpublickey import GetPublicKey, GetPublicKeyResp
|
||||||
from .open import Open, OpenResp
|
from .open import Open, OpenResp
|
||||||
from .ping import Ping, PingResp
|
from .ping import Ping, PingResp
|
||||||
|
from .setpp import SetPP, SetPPResp
|
||||||
from .setppuser import SetPPUser, SetPPUserResp
|
from .setppuser import SetPPUser, SetPPUserResp
|
||||||
|
|
||||||
def construct(request):
|
def construct(request):
|
||||||
|
20
mitel_ommclient2/messages/setpp.py
Normal file
20
mitel_ommclient2/messages/setpp.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from . import Request, Response, request_type, response_type
|
||||||
|
from ..types import PPDevType, PPUserType
|
||||||
|
|
||||||
|
|
||||||
|
@request_type
|
||||||
|
class SetPP(Request):
|
||||||
|
CHILDS = {
|
||||||
|
"pp": PPDevType,
|
||||||
|
"user": PPUserType,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@response_type
|
||||||
|
class SetPPResp(Response):
|
||||||
|
CHILDS = {
|
||||||
|
"pp": PPDevType,
|
||||||
|
"user": PPUserType,
|
||||||
|
}
|
@ -96,7 +96,11 @@ class MonitoringStateType(EnumType):
|
|||||||
|
|
||||||
|
|
||||||
class PPRelTypeType(EnumType):
|
class PPRelTypeType(EnumType):
|
||||||
VALUES = None
|
VALUES = [
|
||||||
|
"Fixed",
|
||||||
|
"Dynamic",
|
||||||
|
"Unbound",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class AccountType(ChildType):
|
class AccountType(ChildType):
|
||||||
@ -134,6 +138,18 @@ class PPDevType(ChildType):
|
|||||||
"ppDefaultProfileLoaded": bool,
|
"ppDefaultProfileLoaded": bool,
|
||||||
"subscribeToPARIOnly": bool,
|
"subscribeToPARIOnly": bool,
|
||||||
# undocumented
|
# undocumented
|
||||||
|
"ommId": str,
|
||||||
|
"ommIdAck": str,
|
||||||
|
"timeStampAdmin": int,
|
||||||
|
"timeStampRelation": int,
|
||||||
|
"timeStampRoaming": int,
|
||||||
|
"timeStampSubscription": int,
|
||||||
|
"autoCreate": bool,
|
||||||
|
"roaming": None, # value: 'RoamingComplete'
|
||||||
|
"modicType": str, # value: '01'
|
||||||
|
"locationData": str, # value: '000001000000'
|
||||||
|
"dectIeFixedId": str,
|
||||||
|
"subscriptionId": str,
|
||||||
"ppnSec": int,
|
"ppnSec": int,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,4 +229,7 @@ class PPUserType(ChildType):
|
|||||||
"keyLockEnable": None,
|
"keyLockEnable": None,
|
||||||
"keyLockPin": None,
|
"keyLockPin": None,
|
||||||
"keyLockTime": None,
|
"keyLockTime": None,
|
||||||
|
"ppnOld": int,
|
||||||
|
"timeStampAdmin": int,
|
||||||
|
"timeStampRelation": int,
|
||||||
}
|
}
|
||||||
|
5
ommcli
5
ommcli
@ -70,6 +70,11 @@ if __name__ == "__main__":
|
|||||||
parser_exit = subparsers.add_parser("exit")
|
parser_exit = subparsers.add_parser("exit")
|
||||||
parser_exit.set_defaults(func=exit)
|
parser_exit.set_defaults(func=exit)
|
||||||
|
|
||||||
|
parser_get_account = subparsers.add_parser("attach_user_device")
|
||||||
|
parser_get_account.add_argument("uid", type=int)
|
||||||
|
parser_get_account.add_argument("ppn", type=int)
|
||||||
|
parser_get_account.set_defaults(func=c.attach_user_device, format=format_list)
|
||||||
|
|
||||||
parser_get_account = subparsers.add_parser("create_user")
|
parser_get_account = subparsers.add_parser("create_user")
|
||||||
parser_get_account.add_argument("num")
|
parser_get_account.add_argument("num")
|
||||||
parser_get_account.set_defaults(func=c.create_user, format=format_child_type)
|
parser_get_account.set_defaults(func=c.create_user, format=format_child_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user