def post_kinesis()

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


def post_kinesis():
    try:
        body = app.current_event.json_body
        if 'id' not in body:
            body['id'] = str(uuid.uuid4())

        kinesis.put_record(
            StreamName=os.environ['KINESIS_STREAM_NAME'],
            Data=json.dumps(body),
            PartitionKey=body['id']
        )

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