Skip to content

Commit 263145e

Browse files
authored
Added serialization of data
1 parent 2945f4f commit 263145e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

caso/record.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,21 @@ def ssm_message(self):
4848
"""Render record as the expected SSM message."""
4949
raise NotImplementedError("Method not implemented")
5050

51-
51+
def serialization_message(self):
52+
"""Render record as the expected logstash message."""
53+
opts = {
54+
"by_alias": True,
55+
"exclude_none": True,
56+
}
57+
# NOTE(acostatnini): part related to the definition of the logstash message to be
58+
# serialized before to send data
59+
# NOTE(aloga): do not iter over the dictionary returned by record.dict() as this
60+
# is just a dictionary representation of the object, where no serialization is
61+
# done. In order to get objects correctly serialized we need to convert to JSON,
62+
# then reload the model
63+
serialized_record = json.loads(self.json(**opts))
64+
return serialized_record
65+
5266
class _ValidCloudStatus(str, enum.Enum):
5367
started = "started"
5468
completed = "completed"

0 commit comments

Comments
 (0)