add deduplication window
This commit is contained in:
@@ -14,10 +14,11 @@ from config import ENROLLMENT_TABLE, MEILISEARCH_API_KEY, MEILISEARCH_HOST, USER
|
||||
from middlewares import Tenant, TenantMiddleware
|
||||
|
||||
from .cancel import router as cancel
|
||||
from .deduplication_window import router as deduplication_window
|
||||
from .enroll import router as enroll
|
||||
from .slots import router as slots
|
||||
|
||||
__all__ = ['slots', 'cancel', 'enroll']
|
||||
__all__ = ['slots', 'cancel', 'enroll', 'deduplication_window']
|
||||
|
||||
|
||||
router = Router()
|
||||
@@ -76,7 +77,7 @@ def get_enrollment(id: str):
|
||||
+ SortKey('archived_date')
|
||||
+ SortKey('cancel_policy')
|
||||
+ SortKey('parent_vacancy', path_spec='vacancy')
|
||||
+ SortKey('lock', path_spec='hash')
|
||||
+ SortKey('lock')
|
||||
+ SortKey('author')
|
||||
+ SortKey('tenant')
|
||||
+ SortKey('cert')
|
||||
|
||||
@@ -18,7 +18,7 @@ user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
|
||||
class Cancel(BaseModel):
|
||||
id: UUID4 | str
|
||||
lock_hash: str
|
||||
lock_hash: str | None = None
|
||||
course: dict = {}
|
||||
vacancy: dict = {}
|
||||
|
||||
|
||||
29
http-api/app/routes/enrollments/deduplication_window.py
Normal file
29
http-api/app/routes/enrollments/deduplication_window.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import ENROLLMENT_TABLE
|
||||
|
||||
router = Router()
|
||||
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
|
||||
|
||||
class DeduplicationWindow(BaseModel):
|
||||
lock_hash: str
|
||||
|
||||
|
||||
@router.patch(
|
||||
'/<id>/deduplicationwindow',
|
||||
compress=True,
|
||||
tags=['Enrollment'],
|
||||
)
|
||||
def deduplication_window(id: str, payload: DeduplicationWindow):
|
||||
with enrollment_layer.transact_writer() as transact:
|
||||
transact.delete(key=KeyPair(id, 'lock'))
|
||||
transact.delete(key=KeyPair('lock', payload.lock_hash))
|
||||
|
||||
return payload
|
||||
Reference in New Issue
Block a user