From 13fd321e55277be7ea6e87fbf83484a58e948727 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Thu, 6 Jun 2024 16:35:52 -0400 Subject: [PATCH] feat: re-generate avro schemas for renamed events --- openedx_events/enterprise/data.py | 32 ++++++++++--------- ...dger_transaction+committed+v1_schema.avsc} | 2 +- ...ledger_transaction+created+v1_schema.avsc} | 2 +- ..._ledger_transaction+failed+v1_schema.avsc} | 2 +- ...edger_transaction+reversed+v1_schema.avsc} | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) rename openedx_events/event_bus/avro/tests/schemas/{org+openedx+enterprise_subsidies+ledger_transaction+created+v1_schema.avsc => org+openedx+enterprise+subsidy_ledger_transaction+committed+v1_schema.avsc} (96%) rename openedx_events/event_bus/avro/tests/schemas/{org+openedx+enterprise_subsidies+ledger_transaction+failed+v1_schema.avsc => org+openedx+enterprise+subsidy_ledger_transaction+created+v1_schema.avsc} (97%) rename openedx_events/event_bus/avro/tests/schemas/{org+openedx+enterprise_subsidies+ledger_transaction+reversed+v1_schema.avsc => org+openedx+enterprise+subsidy_ledger_transaction+failed+v1_schema.avsc} (96%) rename openedx_events/event_bus/avro/tests/schemas/{org+openedx+enterprise_subsidies+ledger_transaction+committed+v1_schema.avsc => org+openedx+enterprise+subsidy_ledger_transaction+reversed+v1_schema.avsc} (96%) diff --git a/openedx_events/enterprise/data.py b/openedx_events/enterprise/data.py index 0e4d71af..fb7ca113 100644 --- a/openedx_events/enterprise/data.py +++ b/openedx_events/enterprise/data.py @@ -28,9 +28,23 @@ class SubsidyRedemption: @attr.s(frozen=True) -class LedgerTransactionReversal: +class BaseLedgerTransaction: + """ + Defines the common attributes of the transaction classes below. + """ + uuid = attr.ib(type=UUID) + created = attr.ib(type=datetime) + modified = attr.ib(type=datetime) + idempotency_key = attr.ib(type=str) + quantity = attr.ib(type=int) + state = attr.ib(type=str) + + +@attr.s(frozen=True) +class LedgerTransactionReversal(BaseLedgerTransaction): """ Attributes of an ``openedx_ledger.Reversal`` record. + A ``Reversal`` is a model that represents the "undo-ing" of a ``Transaction`` (see below). It's primarily used within the domain of edX Enterprise for recording unenrollments and refunds of subsidized enterprise enrollments. @@ -45,18 +59,12 @@ class LedgerTransactionReversal: state (str): Current lifecyle state of the record, one of (created, pending, committed, failed). """ - uuid = attr.ib(type=UUID) - created = attr.ib(type=datetime) - modified = attr.ib(type=datetime) - idempotency_key = attr.ib(type=str) - quantity = attr.ib(type=int) - state = attr.ib(type=str) - @attr.s(frozen=True) -class LedgerTransaction: +class LedgerTransaction(BaseLedgerTransaction): """ Attributes of an ``openedx_ledger.Transaction`` record. + A ``Transaction`` is a model that represents value moving in or out of a ``Ledger``. It's primarily used within the domain of edX Enterprise for recording the redemption of subsidized enrollments. https://github.com/openedx/openedx-ledger/blob/master/openedx_ledger/models.py @@ -78,12 +86,6 @@ class LedgerTransaction: reversal (LedgerTransactionReversal): Any reversal associated with this transaction. """ - uuid = attr.ib(type=UUID) - created = attr.ib(type=datetime) - modified = attr.ib(type=datetime) - idempotency_key = attr.ib(type=str) - quantity = attr.ib(type=int) - state = attr.ib(type=str) ledger_uuid = attr.ib(type=UUID) subsidy_access_policy_uuid = attr.ib(type=UUID) lms_user_id = attr.ib(type=int) diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+created+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+committed+v1_schema.avsc similarity index 96% rename from openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+created+v1_schema.avsc rename to openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+committed+v1_schema.avsc index 54c1bd01..9eb1146e 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+created+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+committed+v1_schema.avsc @@ -106,5 +106,5 @@ } } ], - "namespace": "org.openedx.enterprise_subsidies.ledger_transaction.created.v1" + "namespace": "org.openedx.enterprise.subsidy_ledger_transaction.committed.v1" } \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+failed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+created+v1_schema.avsc similarity index 97% rename from openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+failed+v1_schema.avsc rename to openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+created+v1_schema.avsc index 450822f1..f32785e6 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+failed+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+created+v1_schema.avsc @@ -106,5 +106,5 @@ } } ], - "namespace": "org.openedx.enterprise_subsidies.ledger_transaction.failed.v1" + "namespace": "org.openedx.enterprise.subsidy_ledger_transaction.created.v1" } \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+reversed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+failed+v1_schema.avsc similarity index 96% rename from openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+reversed+v1_schema.avsc rename to openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+failed+v1_schema.avsc index 54f5ce36..f37d08b6 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+reversed+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+failed+v1_schema.avsc @@ -106,5 +106,5 @@ } } ], - "namespace": "org.openedx.enterprise_subsidies.ledger_transaction.reversed.v1" + "namespace": "org.openedx.enterprise.subsidy_ledger_transaction.failed.v1" } \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+committed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+reversed+v1_schema.avsc similarity index 96% rename from openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+committed+v1_schema.avsc rename to openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+reversed+v1_schema.avsc index 22d16e47..fe0d5df1 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise_subsidies+ledger_transaction+committed+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+enterprise+subsidy_ledger_transaction+reversed+v1_schema.avsc @@ -106,5 +106,5 @@ } } ], - "namespace": "org.openedx.enterprise_subsidies.ledger_transaction.committed.v1" + "namespace": "org.openedx.enterprise.subsidy_ledger_transaction.reversed.v1" } \ No newline at end of file