Skip to content

Commit

Permalink
feat: Adding LicenseLifecycle data event (#36)
Browse files Browse the repository at this point in the history
Related to https://openedx.atlassian.net/browse/ARCHBOM-2005 ticket

Archbom is implementing an event bus kafka producer in license-manager. The types implemented in this PR are necessary for that work.
  • Loading branch information
jinder1s authored Jan 13, 2022
1 parent 1a65c11 commit 807afff
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 11 deletions.
22 changes: 14 additions & 8 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ Change Log
Unreleased
~~~~~~~~~~

Added
-----
* Added data definition for enterprise/LicenseLifecycle
* Added LicenseCreated signal definition


[0.7.0] - 2022-01-06
____________________
~~~~~~~~~~~~~~~~~~~~

Added
-----
* Added AvroAttrsBridge class to convert between avro standard and attrs classes

[0.6.0] - 2021-09-15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Added
_____
* Add custom formatting class for events responses.
Expand All @@ -34,39 +40,39 @@ _______
* Default is send_robust instead of send unless specified otherwise.

[0.5.1] - 2021-08-26
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Changed
_______
* Remove TestCase inheritance from OpenEdxTestMixin.

[0.5.0] - 2021-08-24
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Added
_____
* Utilities to use while testing in other platforms.

[0.4.1] - 2021-08-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Changed
_______
* Remove raise_exception assignment in events metadata.

[0.4.0] - 2021-08-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Added
_____
* Preliminary Open edX events definitions.

[0.3.0] - 2021-08-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Added
_____
* Add tooling needed to create and trigger events in Open edX platform.
* Add Data Attribute classes used as arguments by Open edX Events.


[0.2.0] - 2021-07-28
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~
Changed
_______

Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "0.7.0"
__version__ = "0.7.1"
2 changes: 1 addition & 1 deletion openedx_events/avro_attrs_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def dict_to_attrs(self, data: dict, attrs_cls):
return attrs_cls(**data)


class KafkaWrapper(AvroAttrsBridge):
class AvroAttrsBridgeKafkaWrapper(AvroAttrsBridge):
"""
Wrapper class to help AvroAttrsBridge to work with kafka.
"""
Expand Down
8 changes: 8 additions & 0 deletions openedx_events/enterprise/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3

"""
Package where events related to the enterprise subdomain are implemented.
The enterprise subdomain corresponds to {Architecture Subdomain} defined in
the OEP-41.
"""
54 changes: 54 additions & 0 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
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 LicenseLifecycle:
"""
Event to track changes to subscriptsion.License records.
Arguments:
license_uuid (str): The UUID linked to this license and storing in the License Manager DB.
This value is always present.
license_activation_key (str):
previous_license_uuid (str): The UUID linked to the previous license that this license is
a renewal for. Non-empty only on after the
edx.server.license-manager.license-lifecycle.renewed event has occurred.
assigned_date (str): Formatted ISO-8601 Date String representing the date
this license was most recently assigned to the assigned_email.
May be empty.
activation_date (str): Formatted ISO-8601 Date String this license was most recently activated
for the assigned_email.
May be empty.
assigned_lms_user_id (str): The LMS User id of the user that this license 'belongs to'.
May be empty if this license is not activated yet.
assigned_email (str): The email assigned to this license.
Will be empty if this license is not assigned to a learner yet.
expiration_processed (bool): Boolean value of License 'expiration_processed' field, may be True or False.
True means a license is expired.
auto_applied (bool):
enterprise_customer_uuid (str): UUID used to internally represent an enterprise
enterprise_customer_slug (str): Short name of an enterprise used in the URLs and other places
for display purposes.
enterprise_customer_name (str): Long Name of an enterprise customer. Used for display and reporting
customer_agreement_uuid (str): The active Customer Agreement UUID that this license is linked to.
"""

license_uuid = attr.ib(type=str)
license_activation_key = attr.ib(type=str)
previous_license_uuid = attr.ib(type=str)
assigned_date = attr.ib(type=str)
activation_date = attr.ib(type=str)
assigned_email = attr.ib(type=str)
expiration_processed = attr.ib(type=bool)
assigned_lms_user_id = attr.ib(type=int, default=None)
auto_applied = attr.ib(type=bool, default=False)
enterprise_customer_uuid = attr.ib(type=str, default=None)
enterprise_customer_slug = attr.ib(type=str, default=None)
enterprise_customer_name = attr.ib(type=str, default=None)
customer_agreement_uuid = attr.ib(type=str, default=None)
23 changes: 23 additions & 0 deletions openedx_events/enterprise/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Custom signals definitions that representing the Open edX platform events.
All signals defined in this module must follow the name and versioning
conventions specified in docs/decisions/0002-events-naming-and-versioning.rst
They also must comply with the payload definition specified in
docs/decisions/0003-events-payload.rst
"""

from openedx_events.enterprise.data import LicenseLifecycle
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.enterprise.subscription.license.modified.v1
# .. event_name: LICENSE_CREATED
# .. event_description: emitted with Subscription.License is created.
# .. event_data: LicenseLifecycle
LICENSE_CREATED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.subscription.license.created.v1",
data={
"lifecycle": LicenseLifecycle,
}
)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.0
current_version = 0.7.1
commit = True
tag = True

Expand Down

0 comments on commit 807afff

Please sign in to comment.