otupy.transfers.mqtt.message.Message
- class Message(headers: Headers = None, body: Body = None)
Bases:
RecordMQTT Message representation
This class implements the HTTP-specific representation of the OpenC2 Message metadata. The OpenC2 Message metadata are described in Table 3.1 of the Language Specification as message elements, but they are not framed in a concrete structure. The HTTP Specification defines such structure in Sec. 3.3.2, and this class is its implementation. The MQTT specification mandates the usage of the Message type defined in Table 3-1 of the Specification, but does not provide serialization requirements.
The methods of this class are meant to translate back and for the otupy Message class.
Methods
Builds instance from dictionary
Create an otupy Message from MQTT Message
Create MQTT Message from otupy Message
Converts to dictionary
Attributes
Contains the Content
Contains the Message metadata
- classmethod fromdict(dic, e)
Builds instance from dictionary
It is used during deserialization to create an otupy instance from the text message. It takes an
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides standard methods to create instances of base objects like strings, integers, boolean).- Parameters:
dic – The intermediary dictionary representation from which the object is built.
e – The
Encoderthat is being used.
- Returns:
An instance of this class initialized from the dictionary values.
- get()
Create an otupy Message from MQTT Message
- Parameters:
msg – An otupy Message.
- Returns:
An HTTP Message
- set(msg: Message)
Create MQTT Message from otupy Message
- Parameters:
msg – An otupy Message.
- Returns:
An MQTT Message
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.