Add GetPPDev message

This commit is contained in:
clerie 2022-01-16 13:52:08 +01:00
parent 1b0a5caa1b
commit f1c340fb3d
3 changed files with 41 additions and 0 deletions

View File

@ -50,6 +50,18 @@ class OMMClient2:
return None
return r.account[0]
def get_pp_dev(self, ppn):
"""
Get PP device
:param id: Device id
"""
r = self.session.request(messages.GetPPDev(ppn))
r.raise_on_error()
if r.pp is None:
return None
return r.pp[0]
def ping(self):
"""
Is OMM still there?

View File

@ -98,6 +98,7 @@ class Response:
return self.attrs.get("maxLen")
from .getaccount import GetAccount, GetAccountResp
from .getppdev import GetPPDev, GetPPDevResp
from .open import Open, OpenResp
from .ping import Ping, PingResp
@ -124,6 +125,7 @@ def construct(request):
def _response_type_by_name(name):
response_types = [
GetAccountResp,
GetPPDevResp,
PingResp,
]

View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
from . import Request, Response
class GetPPDev(Request):
def __init__(self, ppn, maxRecords=None, **kwargs):
super().__init__("GetPPDev", **kwargs)
self.attrs["ppn"] = ppn
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 GetPPDevResp(Response):
@property
def pp(self):
return self.childs.get("pp")