Description
Hi,
I am using the event grid client SDK in python to generate custom events. I have come across an issue I can't seem to solve without going away from the event grid SDK.
The problem is that the event grid model serializer does not give me the correct output for when including types that are not the basic types. A simple reproducible example:
from azure.eventgrid.models import EventGridEvent
import datetime
import uuid
event=EventGridEvent(
topic="test",
id=uuid.uuid4(),
subject="testUpdated",
data={"time":datetime.datetime.now().replace(tzinfo=datetime.timezone.utc)},
event_type="test.test",
event_time=datetime.datetime.now().replace(tzinfo=datetime.timezone.utc),
data_version=2.0,
)
print(event.serialize())
This would return
{'id': '3e02a22c-f327-4f62-af25-b71e0865888b', 'topic': 'product', 'subject': 'ProductUpdated', 'data': {'time': '2020-09-07 10:37:08.348679+00:00'}, 'eventType': 'supplychain.product', 'eventTime': '2020-09-07T10:37:08.348679Z', 'dataVersion': '2.0'}
the serialize is not called by me in the code I actually use, but it looks like that is what is called behind the scenes when I send off the event. I want the datetime (the key "time" in the above example) to be serialized just as the parent-level "event_time". My problem is not only with datetime as in the current example, but also with decimals.
I guess this fits in this repo and not in the EventGrid SDK repo, but feel free to redirect me there.