-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Expected Behavior
Users often interact with objects in json format.
Would it make sense to update this SDK so that users can easily transform json strings into objects whose types match those defined in the CDEvent spec?
We currently have some code that looks like this
some_json_str = '...' # this could be consumed from kafka or some http service
typed_msg = CDEventMsgFactory.from_json(some_json_str)
if isinstance(typed_msg, Taskrunstarted):
# do something...
elif isinstance(typed_msg, Taskrunfinished):
# do something...
etc...
Along with verifying that the json is valid, we can also do some additional checks, like checking enum values, as specified in the schema.
We can then also go back to json with something like
new_json_str = CDEventMsgFactory.to_json(typed_msg)
Actual Behavior
We wrote our own internal libraries, but we think it would be good to share this code, for others to re-use.
Steps to Reproduce the Problem
n/a
Specifications
- Platform: Any
- Python Version: Any
Metadata
Metadata
Assignees
Labels
No labels