add deduplication window
This commit is contained in:
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