'index( trans, state=None, tool_id=None, history_id=None, date_range_min=None, date_range_max=None, user_details=False )
* GET /api/jobs:
return jobs for current user
!! if user is admin and user_details is True, then
return jobs for all galaxy users based on filtering - this is an extended service
:type   state: string or list
:param  state: limit listing of jobs to those that match one of the included states. If none, all are returned.
Valid Galaxy job states include:
\'new\', \'upload\', \'waiting\', \'queued\', \'running\', \'ok\', \'error\', \'paused\', \'deleted\', \'deleted_new\'
:type   tool_id: string or list
:param  tool_id: limit listing of jobs to those that match one of the included tool_ids. If none, all are returned.
:type   user_details: boolean
:param  user_details: if true, and requestor is an admin, will return external job id and user email.
:type   date_range_min: string \'2014-01-01\'
:param  date_range_min: limit the listing of jobs to those updated on or after requested date
:type   date_range_max: string \'2014-12-31\'
:param  date_range_max: limit the listing of jobs to those updated on or before requested date
:type   history_id: string
:param  history_id: limit listing of jobs to those that match the history_id. If none, all are returned.
:rtype:     list
:returns:   list of dictionaries containing summary job information'

@expose_api
def index(self, trans, **kwd):

    state = kwd.get('state', None)
    is_admin = trans.user_is_admin()
    user_details = kwd.get('user_details', False)
    if is_admin:
        query = trans.sa_session.query(trans.app.model.Job)
    else:
        query = trans.sa_session.query(trans.app.model.Job).filter((trans.app.model.Job.user == trans.user))
    def build_and_apply_filters(query, objects, filter_func):
        if (objects is not None):
            if isinstance(objects, string_types):
                query = query.filter(filter_func(objects))
            elif isinstance(objects, list):
                t = []
                for obj in objects:
                    t.append(filter_func(obj))
                query = query.filter(or_(*t))
        return query
    query = build_and_apply_filters(query, state, (lambda s: (trans.app.model.Job.state == s)))
    query = build_and_apply_filters(query, kwd.get('tool_id', None), (lambda t: (trans.app.model.Job.tool_id == t)))
    query = build_and_apply_filters(query, kwd.get('tool_id_like', None), (lambda t: trans.app.model.Job.tool_id.like(t)))
    query = build_and_apply_filters(query, kwd.get('date_range_min', None), (lambda dmin: (trans.app.model.Job.table.c.update_time >= dmin)))
    query = build_and_apply_filters(query, kwd.get('date_range_max', None), (lambda dmax: (trans.app.model.Job.table.c.update_time <= dmax)))
    history_id = kwd.get('history_id', None)
    if (history_id is not None):
        try:
            decoded_history_id = self.decode_id(history_id)
            query = query.filter((trans.app.model.Job.history_id == decoded_history_id))
        except:
            raise exceptions.ObjectAttributeInvalidException()
    out = []
    if (kwd.get('order_by') == 'create_time'):
        order_by = trans.app.model.Job.create_time.desc()
    else:
        order_by = trans.app.model.Job.update_time.desc()
    for job in query.order_by(order_by).all():
        job_dict = job.to_dict('collection', system_details=is_admin)
        j = self.encode_all_ids(trans, job_dict, True)
        if user_details:
            j['user_email'] = job.user.email
        out.append(j)
    return out
