diff --git a/mitel_ommclient2/__init__.py b/mitel_ommclient2/__init__.py new file mode 100644 index 0000000..463a3ec --- /dev/null +++ b/mitel_ommclient2/__init__.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +from . import client +from . import connection +from . import messages +from . import session + +from .client import OMMClient2 diff --git a/mitel_ommclient2/client.py b/mitel_ommclient2/client.py new file mode 100644 index 0000000..b598336 --- /dev/null +++ b/mitel_ommclient2/client.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 + +from .session import Session +from . import messages + +class OMMClient2: + """ + High level wrapper for the OM Application XML Interface + + This class tries to provide functions for often used methods without the + need of using the underlying messaging protocol + + :param host: Hostname or IP address of the OMM + :param username: Username + :param password: Password + :param session: A :class:`mitel_ommclient2.session.Session` object + + Usage:: + + >>> c = OMMClient2("omm.local", "admin", "admin") + >>> c.ping() + + Use session for not implemented features:: + + >>> r = s.session.request(mitel_ommclient2.messages.Ping()) + + To get more contol over the connection handling, initialize + :class:`mitel_ommclient2.session.Session` manually:: + + >>> s = mitel_ommclient2.session.Session("omm.local", "admin", "admin", port=12345) + >>> c = OMMClient2(session=s) + """ + + def __init__(self, host=None, username=None, password=None, session=None): + if session is None: + self.session = Session(host, username, password) + else: + self.session = session + + def ping(self): + """ + Is OMM still there? + + Returns `True` when response is received. + """ + + r = self.session.request(messages.Ping()) + if r.errCode is None: + return True + return False