Main handler.

def lambda_handler(event, context):
    """Main handler."""
    users = boto3.resource("dynamodb").Table(os.environ['people'])
    auth = check_auth(event, role=["admin"])
    if not auth['success']:
        return auth
    user_email = event.get('user_email', None)
    if not user_email:
        msg = "Missing user_email parameter in your request."
        return {'success': False, 'message': msg}
    user_role = event.get('user_role', None)
    if not user_role:
        msg = "Missing user role: `admin`, `analyst`"
        return {'success': False, 'message': msg}
    user_name = event.get('user_name', '')
    seed = random.randint(100000000, 999999999)
    hash_key = "{}{}".format(user_email, seed)
    api_key = hashlib.sha256(hash_key).hexdigest()
    if auth.get('init', False):
        user_role = 'admin'
    else:
        user_role = user_role
    obj = {'email': user_email, 'name': user_name, 'api_key': api_key,
           'role': user_role}
    response = users.put_item(Item=obj)
    return obj