mitel_ommclient2/docs/manual/messages.rst

46 lines
1.3 KiB
ReStructuredText
Raw Normal View History

2022-01-17 13:52:56 +01:00
Message Usage Manual
====================
The API consists of three main message types: request, response and event. They
are represented by :class:`mitel_ommclient2.messages.Request`, :class:`mitel_ommclient2.messages.Response`
and events aren't supported yet.
There are several subclasses for each messages type, which provide a conveinient
interface to message content using attributes.
2022-01-17 13:52:56 +01:00
For each message you can access each field directly as class attributes.
There are two special attributes:
* name: returns the message name
* childs: allowes you to access childs by the child name as class attributes
2022-01-17 13:52:56 +01:00
Using messages
--------------
Just choose one of several message classes of :module:`mitel_ommclient2.messages`
and hand it over to :func:`mitel_ommclient2.client.OMMClient2.request` or
:func:`mitel_ommclient2.connection.Connection.request`.
.. code-block:: python
import time
my_time = int(time.time())
m = mitel_ommclient2.messages.Ping()
m.timeStamp = my_time
r = c.request(m)
2022-01-17 13:52:56 +01:00
ping = r.timeStamp - my_time
A more complex example
----------------------
2022-01-17 13:52:56 +01:00
This demonstrates how to access message childs.
2022-01-17 13:52:56 +01:00
.. code-block:: python
m = messages.GetAccount()
m.id = id
r = self.connection.request(m)
return r.childs.account[0]