def render(args):
    """
    Helper to parse REST Api requests

    :param args:
    :return:
    """
    query = database.session_query(ApiKey)
    user_id = args.pop("user_id", None)
    aid = args.pop("id", None)
    has_permission = args.pop("has_permission", False)
    requesting_user_id = args.pop("requesting_user_id")

    if user_id:
        query = query.filter(ApiKey.user_id == user_id)

    if aid:
        query = query.filter(ApiKey.id == aid)

    if not has_permission:
        query = query.filter(ApiKey.user_id == requesting_user_id)

    return database.sort_and_page(query, ApiKey, args)

    Helper to parse REST Api requests

    :param args:
    :return:
    
lemur/api_keys/service.py