diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 795268d6..5ad7aad6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -13,8 +13,16 @@ Change Log Unreleased ---------- +[9.7.0] - 2024-04-04 +-------------------- Added -~~~~~ +~~~~~~~ +* Added new ``SUBSIDY_REDEEMED`` and ``SUBSIDY_REDEMPTION_REVERSED`` events in enterprise. + +[9.6.0] - 2024-04-01 +-------------------- +Added +~~~~~~~ * Added new ``CONTENT_OBJECT_TAGGED`` events in content_authoring. [9.5.2] - 2024-02-13 diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index 33f541c4..9d5edda1 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "9.6.0" +__version__ = "9.7.0" diff --git a/openedx_events/enterprise/__init__.py b/openedx_events/enterprise/__init__.py new file mode 100644 index 00000000..f12207ec --- /dev/null +++ b/openedx_events/enterprise/__init__.py @@ -0,0 +1,6 @@ +""" +Package where events related to the enterprise subdomain are implemented. + +The enterprise subdomain corresponds to {Architecture Subdomain} defined in +the OEP-41. +""" diff --git a/openedx_events/enterprise/data.py b/openedx_events/enterprise/data.py new file mode 100644 index 00000000..23c3dd01 --- /dev/null +++ b/openedx_events/enterprise/data.py @@ -0,0 +1,24 @@ +""" +Data attributes for events within the architecture subdomain ``enterprise``. + +These attributes follow the form of attr objects specified in OEP-49 data +pattern. +""" + +import attr + + +@attr.s(frozen=True) +class SubsidyRedemption: + """ + Attributes for a Subsidy Redemption object. + + Arguments: + subsidy_identifier (str): unique identifier to fetch the applied subsidy + content_key (str): content id where subsidy is utilized + lms_user_id (str): lms user id of subsidy beneficiary + """ + + subsidy_identifier = attr.ib(type=str) + content_key = attr.ib(type=str) + lms_user_id = attr.ib(type=int) diff --git a/openedx_events/enterprise/signals.py b/openedx_events/enterprise/signals.py new file mode 100644 index 00000000..287a3849 --- /dev/null +++ b/openedx_events/enterprise/signals.py @@ -0,0 +1,34 @@ +""" +Standardized signals definitions for events within the architecture subdomain ``enterprise``. + +All signals defined in this module must follow the name and versioning +conventions specified in OEP-41. + +They also must comply with the payload definition specified in +docs/decisions/0003-events-payload.rst +""" + +from openedx_events.enterprise.data import SubsidyRedemption +from openedx_events.tooling import OpenEdxPublicSignal + +# .. event_type: org.openedx.enterprise.subsidy.redeemed.v1 +# .. event_name: SUBSIDY_REDEEMED +# .. event_description: emitted when an enterprise subsidy is utilized. +# .. event_data: SubsidyRedemption +SUBSIDY_REDEEMED = OpenEdxPublicSignal( + event_type="org.openedx.enterprise.subsidy.redeemed.v1", + data={ + "redemption": SubsidyRedemption, + } +) + +# .. event_type: org.openedx.enterprise.subsidy.redemption-reversed.v1 +# .. event_name: SUBSIDY_REDEMPTION_REVERSED +# .. event_description: emitted when an enterprise subsidy is reversed. +# .. event_data: SubsidyRedemption +SUBSIDY_REDEMPTION_REVERSED = OpenEdxPublicSignal( + event_type="org.openedx.enterprise.subsidy.redemption-reversed.v1", + data={ + "redemption": SubsidyRedemption, + } +) diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redeemed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redeemed+v1_schema.avsc new file mode 100644 index 00000000..0f6f6763 --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redeemed+v1_schema.avsc @@ -0,0 +1,29 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "redemption", + "type": { + "name": "SubsidyRedemption", + "type": "record", + "fields": [ + { + "name": "subsidy_identifier", + "type": "string" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "lms_user_id", + "type": "long" + } + ] + } + } + ], + "namespace": "org.openedx.enterprise.subsidy.redeemed.v1" +} \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redemption-reversed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redemption-reversed+v1_schema.avsc new file mode 100644 index 00000000..b6dbe9fb --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy+redemption-reversed+v1_schema.avsc @@ -0,0 +1,29 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "redemption", + "type": { + "name": "SubsidyRedemption", + "type": "record", + "fields": [ + { + "name": "subsidy_identifier", + "type": "string" + }, + { + "name": "content_key", + "type": "string" + }, + { + "name": "lms_user_id", + "type": "long" + } + ] + } + } + ], + "namespace": "org.openedx.enterprise.subsidy.redemption-reversed.v1" +} \ No newline at end of file