fix
This commit is contained in:
41
http-api/app/routes/users/logs.py
Normal file
41
http-api/app/routes/users/logs.py
Normal file
@@ -0,0 +1,41 @@
|
||||
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,
|
||||
DynamoDBCollection,
|
||||
DynamoDBPersistenceLayer,
|
||||
MissingError,
|
||||
PartitionKey,
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import USER_TABLE
|
||||
|
||||
from .orgs import router as orgs
|
||||
|
||||
__all__ = ['orgs']
|
||||
|
||||
|
||||
class BadRequestError(MissingError, PowertoolsBadRequestError): ...
|
||||
|
||||
|
||||
router = Router()
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
user_collect = DynamoDBCollection(user_layer, exception_cls=BadRequestError)
|
||||
|
||||
|
||||
@router.get(
|
||||
'/<id>/logs',
|
||||
compress=True,
|
||||
tags=['User'],
|
||||
summary='Get user logs',
|
||||
)
|
||||
def get_logs(id: str):
|
||||
return user_collect.query(
|
||||
# Post-migration: uncomment to enable PartitionKey with a composite key (id with `logs` prefix).
|
||||
# PartitionKey(ComposeKey(id, 'logs')),
|
||||
PartitionKey(ComposeKey(id, 'log', delimiter=':')),
|
||||
start_key=router.current_event.get_query_string_value('start_key', None),
|
||||
)
|
||||
Reference in New Issue
Block a user