def get_object_by_name_or_id(cb, cls, name_field="name", id=None, name=None):
    """
    Locate an object in the API by either ID or name.

    Args:
        cb (CBCloudAPI): Reference to the CBCloudAPI.
        cls (class): Class of object to be found.
        name_field (str): Name field to search on.
        id (int): ID of object to search for. May be None to do name searching.
        name (str): Object name to search on.
        force_init (bool): True to force a new object found by ID to be initialized.

    Returns:
        list: List of objects that match the search criteria.
    """
    clsname = cls.__name__
    attempted_to_find = ''
    try:
        if not (id or name) or (id and name):
            raise Exception("Either id or name should be provided.")
        if id:
            attempted_to_find = "ID of {0:d}".format(id)
            objs = [cb.select(cls, id)]
        else:
            attempted_to_find = "name {0:s}".format(name)
            objs = cb.select(cls).where("{0}:{1}".format(name_field, name))[::]
            if not len(objs):
                raise Exception("No {0}s match".format(clsname))
    except Exception as e:
        raise Exception("Could not find {0} with {1:s}: {2:s}".format(clsname, attempted_to_find, str(e)))
    else:
        return objs