def validate_api_key(api_key):
    """
    Validate the provided API key.

    :param api_key: API key provided.
    :type api_key: ``str``

    :return: TokenDB object on success.
    :rtype: :class:`.ApiKeyDB`
    """
    api_key_db = ApiKey.get(api_key)

    if not api_key_db.enabled:
        raise exceptions.ApiKeyDisabledError("API key is disabled.")

    LOG.audit('API key with id "%s" is validated.' % (api_key_db.id))

    return api_key_db

    Validate the provided API key.

    :param api_key: API key provided.
    :type api_key: ``str``

    :return: TokenDB object on success.
    :rtype: :class:`.ApiKeyDB`
    
st2common/st2common/util/auth.py