Skip to content
Snippets Groups Projects

Greg 86 notification format changes

Merged Jonas Braathen requested to merge GREG-86-notification-format-changes into master
4 files
+ 91
45
Compare changes
  • Side-by-side
  • Inline
Files
4
  • 6ef7aab0
    - The field 'source' is now formatted like 'greg:instance_name:environment'
    - The field 'type' is now formatted like 'object_type.operation'
    - The field 'data' now contains the identifiers of all objects related to the change
@@ -26,7 +26,7 @@ def generate_event_type(n: Notification) -> str:
routing key is removed results in minor changes to the code.
"""
object_type = camel_to_snake(n.object_type)
return f"{settings.INTERNAL_RK_PREFIX}.{object_type}.{n.operation}"
return f"{object_type}.{n.operation}"
def create_cloud_event_payload(n: Notification) -> str:
@@ -52,14 +52,12 @@ def create_cloud_event_payload(n: Notification) -> str:
object_type = camel_to_snake(n.object_type)
content: dict[str, Union[str, dict[str, str]]] = {
"id": str(n.id),
"source": f"urn:greg:{settings.INSTANCE_NAME}:{object_type}:{n.identifier}",
"source": f"greg:{settings.INSTANCE_NAME}:{settings.ENVIRONMENT}",
"specversion": "1.0",
"type": generate_event_type(n),
}
if n.object_type in ("Role", "Consent", "Identity"):
content["data"] = {
"person_id": n.meta.get("person_id"),
}
if n.meta:
content["data"] = n.meta
return json.dumps(content)
Loading