add get_items

This commit is contained in:
2025-04-08 13:44:06 -03:00
parent 68ff6f282b
commit 6450e5fa7c
18 changed files with 393 additions and 195 deletions

View File

@@ -1,12 +1,23 @@
import json
from aws_lambda_powertools.event_handler.api_gateway import Router
from aws_lambda_powertools.event_handler.exceptions import (
BadRequestError,
)
from elasticsearch import Elasticsearch
from layercake.dynamodb import (
DynamoDBCollection,
DynamoDBPersistenceLayer,
KeyPair,
)
import elastic
from boto3clients import dynamodb_client
from settings import ELASTIC_CONN, ORDER_TABLE
router = Router()
order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
order_collect = DynamoDBCollection(order_layer, exception_cls=BadRequestError)
elastic_client = Elasticsearch(**ELASTIC_CONN)
@@ -22,3 +33,13 @@ def get_orders():
query=json.loads(query),
elastic_client=elastic_client,
)
@router.get(
'/<id>',
compress=True,
tags=['Order'],
summary='Get order',
)
def get_order(id: str):
return order_collect.get_item(KeyPair(id, '0'))