Files
saladeaula.digital/http-api/app/routes/users/logs.py
2025-08-15 00:06:05 -03:00

31 lines
898 B
Python

from aws_lambda_powertools.event_handler.api_gateway import Router
from aws_lambda_powertools.event_handler.exceptions import (
BadRequestError as PowertoolsBadRequestError,
)
from layercake.dynamodb import (
ComposeKey,
DynamoDBPersistenceLayer,
MissingError,
PartitionKey,
)
from boto3clients import dynamodb_client
from config import USER_TABLE
class BadRequestError(MissingError, PowertoolsBadRequestError): ...
router = Router()
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
@router.get('/<id>/logs', compress=True, tags=['User'])
def get_logs(id: str):
return user_layer.collection.query(
# Post-migration: uncomment the following line
# PartitionKey(ComposeKey(id, 'LOGS')),
PartitionKey(ComposeKey(id, 'log', delimiter=':')),
start_key=router.current_event.get_query_string_value('start_key', None),
)