def post_events()

in lambda/api/app.py [0:0]


def post_events():
    try:
        event = app.current_event.json_body

        if 'id' not in event:
            event['id'] = str(uuid.uuid4())

        events.put_events(Entries=[{
            'Source': 'events-api',
            'DetailType': 'NewItem',
            'Detail': json.dumps(event),
            'EventBusName': os.environ['EVENT_BUS_NAME']
        }])

        return {"result": event['id']}
    except Exception as e:
        logger.error(e)
        metrics.add_metric(name='API_Error_Events',
                           unit=MetricUnit.Count, value=1)
        raise ServiceError(502, "Something went wrong! Please try again.")