def lambda_handler(event, context): # fetch all todos from the database result = todoDAO.TodoDAO().list_item() return { "statusCode": 200, "body": json.dumps(result, cls=decimal_encoder.DecimalEncoder) }
def lambda_handler(event, context): # delete todo todoDAO.TodoDAO().delete_item(event['pathParameters']['id']) # create a response response = { "statusCode": 200 } return response
def lambda_handler(event, context): result = todoDAO.TodoDAO().get_item(event['pathParameters']['id']) if result == {}: item = {'error': "Todo not found", 'id': event['pathParameters']['id']} return { "statusCode": 404, "body": json.dumps(item, cls=decimal_encoder.DecimalEncoder) } else: return { "statusCode": 200, "body": json.dumps(result, cls=decimal_encoder.DecimalEncoder) }
def lambda_handler(event, context): data = json.loads(event['body']) if 'text' not in data: logging.error("Validation Failed") raise Exception("Couldn't create the todo item.") item = todoDAO.TodoDAO().put_item(data['text'], data['id'] if ('id' in data) else None) # create a response response = { "statusCode": 200, "body": json.dumps(item, cls=decimal_encoder.DecimalEncoder) } return response
def lambda_handler(event, context): data = json.loads(event['body']) if 'text' not in data or 'checked' not in data: logging.error("Validation Failed") raise Exception("Couldn't update the todo item.") item = todoDAO.TodoDAO().update_item(event['pathParameters']['id'], data['text'], data['checked']) # create a response response = { "statusCode": 200, "body": json.dumps(item, cls=decimal_encoder.DecimalEncoder) } return response
def lambda_handler(event, context): # Obtengo el idioma a traducir de la peticion HTTP language = event['pathParameters']['language'] # fetch todo from the database result = todoDAO.TodoDAO().get_item(event['pathParameters']['id']) # Traduzco el texto al lenguage solicitado translatedText = translateText(result['text'], language) # Grabo el texto traducido en el campo text del Item result['text'] = translatedText # create a response response = { "statusCode": 200, "body": json.dumps(result, cls=decimal_encoder.DecimalEncoder) } return response