Compare commits

..

2 Commits

Author SHA1 Message Date
f1c340fb3d Add GetPPDev message 2022-01-16 13:52:08 +01:00
1b0a5caa1b Pass childs to childs attribute 2022-01-16 13:47:06 +01:00
3 changed files with 42 additions and 1 deletions

View File

@ -50,6 +50,18 @@ class OMMClient2:
return None return None
return r.account[0] 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): def ping(self):
""" """
Is OMM still there? Is OMM still there?

View File

@ -44,7 +44,7 @@ class DictRequest(Request):
def __init__(self, name, attrs={}, childs={}): def __init__(self, name, attrs={}, childs={}):
self.name = name self.name = name
self.attrs = attrs self.attrs = attrs
self.childs = attrs self.childs = childs
class Response: class Response:
@ -98,6 +98,7 @@ class Response:
return self.attrs.get("maxLen") return self.attrs.get("maxLen")
from .getaccount import GetAccount, GetAccountResp from .getaccount import GetAccount, GetAccountResp
from .getppdev import GetPPDev, GetPPDevResp
from .open import Open, OpenResp from .open import Open, OpenResp
from .ping import Ping, PingResp from .ping import Ping, PingResp
@ -124,6 +125,7 @@ def construct(request):
def _response_type_by_name(name): def _response_type_by_name(name):
response_types = [ response_types = [
GetAccountResp, GetAccountResp,
GetPPDevResp,
PingResp, 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")