def index(): sources_ids = match_ids('sources', authz.sources(authz.READ)) q = Document.all().filter(Document.source_id.in_(sources_ids)) hashes = request.args.getlist('content_hash') if len(hashes): q = q.filter(Document.content_hash.in_(hashes)) return jsonify(Pager(q))
def status(): return jsonify({ 'logged_in': authz.logged_in(), 'api_key': request.auth_role.api_key if authz.logged_in() else None, 'role': request.auth_role, 'roles': list(request.auth_roles), 'permissions': { 'watchlists': { 'read': authz.watchlists(authz.READ), 'write': authz.watchlists(authz.WRITE) }, 'sources': { 'read': authz.sources(authz.READ), 'write': authz.sources(authz.WRITE) } }, 'logout': url_for('.logout') })
def status(): enable_cache(vary_user=True) return jsonify({ 'logged_in': authz.logged_in(), 'api_key': request.auth_role.api_key if authz.logged_in() else None, 'role': request.auth_role, 'roles': list(request.auth_roles), 'permissions': { 'collections': { 'read': authz.collections(authz.READ), 'write': authz.collections(authz.WRITE) }, 'sources': { 'read': authz.sources(authz.READ), 'write': authz.sources(authz.WRITE) } }, 'logout': url_for('.logout') })
def query(): creds = authz.collections(authz.READ), authz.sources(authz.READ) enable_cache(vary_user=True, vary=creds) query = documents_query(request.args) query['size'] = get_limit(default=100) query['from'] = get_offset() result = execute_documents_query(request.args, query) result['alert'] = None if authz.logged_in(): result['alert'] = Alert.exists(request.args, request.auth_role) params = next_params(request.args, result) if params is not None: result['next'] = url_for('search_api.query', **params) return jsonify(result)
def _query(escape=False): ''' everything here should be applicable both to the internal and to the public api ''' creds = authz.collections(authz.READ), authz.sources(authz.READ) enable_cache(vary_user=True, vary=creds) query = documents_query(request.args, escape=escape) query['size'] = get_limit(default=100) query['from'] = get_offset() result = execute_documents_query(request.args, query) params = next_params(request.args, result) if params is not None: result['next'] = url_for('search_api.query', **params) return result
def index(): q = Source.all_by_ids(ids=authz.sources(authz.READ)) return jsonify(Pager(q))
def authz_filter(q): return add_filter(q, { "terms": {"source_id": list(authz.sources(authz.READ))} })
def authz_sources_filter(q): return add_filter(q, { "terms": {"source_id": list(authz.sources(authz.READ))} })
def index(): pager = Pager(Source.all(ids=authz.sources(authz.READ))) return jsonify(pager)