'GET /api/roles
Displays a collection (list) of roles.'

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

    rval = []
    for role in trans.sa_session.query(trans.app.model.Role).filter((trans.app.model.Role.table.c.deleted == false())):
        if (trans.user_is_admin() or trans.app.security_agent.ok_to_display(trans.user, role)):
            item = role.to_dict(value_mapper={'id': trans.security.encode_id})
            encoded_id = trans.security.encode_id(role.id)
            item['url'] = url_for('role', id=encoded_id)
            rval.append(item)
    return rval
