def check_bot_status()

in functions/source/lex_custom_resource/lex_custom_resource.py [0:0]


def check_bot_status(bot_name):
    """
    Checks status of Lex Bot.
    Raises an exception if Lex Bot is in an unexpected state.
    :param bot_name: Lex Bot Name
    :return: True if index is Ready, False otherwise
    """
    bot = lex_client.get_bot(
        name=bot_name,
        versionOrAlias='$LATEST'
    )
    status = bot['status']
    if status == 'FAILED':
        raise Exception("Lex Bot is in FAILED state with failure reason: " + bot['failureReason'])
    if status == 'BUILDING':
        return False
    if status == 'READY':
        return True
    raise Exception("Lex Bot is in " + status + " state")