Add support for PP user
This commit is contained in:
parent
5365b942ce
commit
1752a9151d
@ -92,6 +92,37 @@ class OMMClient2:
|
|||||||
# 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):
|
||||||
|
"""
|
||||||
|
Get PP user
|
||||||
|
|
||||||
|
:param uid: User id
|
||||||
|
"""
|
||||||
|
r = self.connection.request(messages.GetPPUser(uid))
|
||||||
|
r.raise_on_error()
|
||||||
|
if r.user is None:
|
||||||
|
return None
|
||||||
|
return r.user[0]
|
||||||
|
|
||||||
|
def get_users(self):
|
||||||
|
"""
|
||||||
|
Get all PP users
|
||||||
|
"""
|
||||||
|
next_uid = 0
|
||||||
|
while True:
|
||||||
|
r = self.connection.request(messages.GetPPUser(next_uid, maxRecords=20))
|
||||||
|
try:
|
||||||
|
r.raise_on_error()
|
||||||
|
except exceptions.ENoEnt:
|
||||||
|
# No more devices to fetch
|
||||||
|
break
|
||||||
|
|
||||||
|
# Output all found devices
|
||||||
|
for user in r.user:
|
||||||
|
yield user
|
||||||
|
|
||||||
|
# Determine next possible ppn
|
||||||
|
next_uid = int(user["uid"]) + 1
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
"""
|
"""
|
||||||
|
@ -84,6 +84,7 @@ class Response:
|
|||||||
|
|
||||||
from .getaccount import GetAccount, GetAccountResp
|
from .getaccount import GetAccount, GetAccountResp
|
||||||
from .getppdev import GetPPDev, GetPPDevResp
|
from .getppdev import GetPPDev, GetPPDevResp
|
||||||
|
from .getppuser import GetPPUser, GetPPUserResp
|
||||||
from .open import Open, OpenResp
|
from .open import Open, OpenResp
|
||||||
from .ping import Ping, PingResp
|
from .ping import Ping, PingResp
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ def _response_type_by_name(name):
|
|||||||
response_types = [
|
response_types = [
|
||||||
GetAccountResp,
|
GetAccountResp,
|
||||||
GetPPDevResp,
|
GetPPDevResp,
|
||||||
|
GetPPUserResp,
|
||||||
PingResp,
|
PingResp,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
27
mitel_ommclient2/messages/getppuser.py
Normal file
27
mitel_ommclient2/messages/getppuser.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from . import Request, Response
|
||||||
|
|
||||||
|
|
||||||
|
class GetPPUser(Request):
|
||||||
|
def __init__(self, uid, maxRecords=None, **kwargs):
|
||||||
|
super().__init__("GetPPUser", **kwargs)
|
||||||
|
|
||||||
|
self.attrs["uid"] = uid
|
||||||
|
|
||||||
|
if maxRecords is not None:
|
||||||
|
self.attrs["maxRecords"] = maxRecords
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ppn(self):
|
||||||
|
return self.attrs.get("ppn")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def maxRecords(self):
|
||||||
|
return self.attrs.get("maxRecords")
|
||||||
|
|
||||||
|
|
||||||
|
class GetPPUserResp(Response):
|
||||||
|
@property
|
||||||
|
def user(self):
|
||||||
|
return self.childs.get("user")
|
Loading…
Reference in New Issue
Block a user