Added in searchable indexes, only brings back index and count etc, not results within the index

pull/9/head
Thomas King 2016-03-18 08:38:04 +00:00
parent bc655cedbf
commit c73becee36
1 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import datetime
import os
import base64
import re
import urllib
try:
from urllib.parse import urljoin
@ -170,6 +171,8 @@ class PyMISP(object):
raise PyMISPError('Unknown error: {}'.format(response.text))
errors = []
if type(to_return) is list:
to_return = {'response':to_return}
if to_return.get('error'):
if not isinstance(to_return['error'], list):
errors.append(to_return['error'])
@ -677,6 +680,13 @@ class PyMISP(object):
response = session.post(url, data=json.dumps(query))
return self._check_response(response)
def search_index(self, value):
value = urllib.quote(value)
session = self.__prepare_session('json')
url = urljoin(self.root_url, 'events/index/searchall:%s' % value)
response = session.get(url)
return self._check_response(response)
def search_all(self, value):
query = {'value': value, 'searchall': 1}
session = self.__prepare_session('json')