def paginate(page_func, items_key, next_token_key, options, *args):
    """
    Paginates over a list of items

    Args:
        page_func (Callable): the function which retrieves items
        items_key (str): the name of the key to find the items returned from a page_func call
        next_token_key (str): the name of the key to find the next token value
        options (dict): dictionary containing options such as "limit"
        *args: the arguments to pass to the page_func
    """
    resp = page_func(*args, options=options)
    yield resp.get(items_key, [])
    while resp.get(next_token_key, None) is not None:
        options[next_token_key] = resp[next_token_key]
        resp = page_func(*args, options=options)
        yield resp[items_key]
