set_sightings

Maybe I didn't use it correctly but the method set_sightings didn't work for me. It's working now but I'm not sure whether sending a request for every sighting in the list is the best solution.
pull/162/head
AninaAntonie 2017-12-28 10:17:57 +01:00 committed by GitHub
parent 0ff2120511
commit 72597c1b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -1295,17 +1295,16 @@ class PyMISP(object):
return self._check_response(response)
def set_sightings(self, sightings):
"""Push a sighting (python dictionary)"""
to_post = []
"""Push a sighting (python dictionary or MISPSighting) or a list of sightings"""
if not isinstance(sightings, list):
sightings = [sightings]
for sighting in sightings:
if isinstance(sighting, MISPSighting):
to_post.append(sighting.to_json())
to_post = sighting.to_json()
elif isinstance(sighting, dict):
to_post.append(json.dumps(sightings))
to_post = json.dumps(sighting)
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)
def sighting_per_json(self, json_file):