mirror of https://github.com/MISP/PyMISP
commit
2c3c6d39ff
|
@ -1295,17 +1295,16 @@ class PyMISP(object):
|
||||||
return self._check_response(response)
|
return self._check_response(response)
|
||||||
|
|
||||||
def set_sightings(self, sightings):
|
def set_sightings(self, sightings):
|
||||||
"""Push a sighting (python dictionary)"""
|
"""Push a sighting (python dictionary or MISPSighting) or a list of sightings"""
|
||||||
to_post = []
|
|
||||||
if not isinstance(sightings, list):
|
if not isinstance(sightings, list):
|
||||||
sightings = [sightings]
|
sightings = [sightings]
|
||||||
for sighting in sightings:
|
for sighting in sightings:
|
||||||
if isinstance(sighting, MISPSighting):
|
if isinstance(sighting, MISPSighting):
|
||||||
to_post.append(sighting.to_json())
|
to_post = sighting.to_json()
|
||||||
elif isinstance(sighting, dict):
|
elif isinstance(sighting, dict):
|
||||||
to_post.append(json.dumps(sightings))
|
to_post = json.dumps(sighting)
|
||||||
url = urljoin(self.root_url, 'sightings/add/')
|
url = urljoin(self.root_url, 'sightings/add/')
|
||||||
response = self.__prepare_request('POST', url, json.dumps(to_post))
|
response = self.__prepare_request('POST', url, to_post)
|
||||||
return self._check_response(response)
|
return self._check_response(response)
|
||||||
|
|
||||||
def sighting_per_json(self, json_file):
|
def sighting_per_json(self, json_file):
|
||||||
|
|
Loading…
Reference in New Issue