mirror of https://github.com/MISP/PyMISP
Merge pull request #59 from tomking2/master
Fixed double status code check on helpers and other functionspull/25/head
commit
d5c004e320
|
@ -352,30 +352,30 @@ class PyMISP(object):
|
||||||
# ########## Helpers ##########
|
# ########## Helpers ##########
|
||||||
|
|
||||||
def get(self, eid):
|
def get(self, eid):
|
||||||
response = self.get_event(int(eid), 'json')
|
response = self.get_event(int(eid))
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def get_stix(self, **kwargs):
|
def get_stix(self, **kwargs):
|
||||||
response = self.get_stix_event(**kwargs)
|
response = self.get_stix_event(**kwargs)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def update(self, event):
|
def update(self, event):
|
||||||
eid = event['Event']['id']
|
eid = event['Event']['id']
|
||||||
response = self.update_event(eid, event, 'json')
|
response = self.update_event(eid, event)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def new_event(self, distribution=None, threat_level_id=None, analysis=None, info=None, date=None, published=False):
|
def new_event(self, distribution=None, threat_level_id=None, analysis=None, info=None, date=None, published=False):
|
||||||
data = self._prepare_full_event(distribution, threat_level_id, analysis, info, date, published)
|
data = self._prepare_full_event(distribution, threat_level_id, analysis, info, date, published)
|
||||||
response = self.add_event(data, 'json')
|
response = self.add_event(data)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def publish(self, event):
|
def publish(self, event):
|
||||||
if event['Event']['published']:
|
if event['Event']['published']:
|
||||||
return {'error': 'Already published'}
|
return {'error': 'Already published'}
|
||||||
event = self._prepare_update(event)
|
event = self._prepare_update(event)
|
||||||
event['Event']['published'] = True
|
event['Event']['published'] = True
|
||||||
response = self.update_event(event['Event']['id'], event, 'json')
|
response = self.update_event(event['Event']['id'], event)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def add_tag(self, event, tag):
|
def add_tag(self, event, tag):
|
||||||
session = self.__prepare_session()
|
session = self.__prepare_session()
|
||||||
|
@ -393,7 +393,7 @@ class PyMISP(object):
|
||||||
event['Event']['threat_level_id'] = threat_level_id
|
event['Event']['threat_level_id'] = threat_level_id
|
||||||
self._prepare_update(event)
|
self._prepare_update(event)
|
||||||
response = self.update_event(event['Event']['id'], event)
|
response = self.update_event(event['Event']['id'], event)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
# ##### File attributes #####
|
# ##### File attributes #####
|
||||||
|
|
||||||
|
@ -406,8 +406,8 @@ class PyMISP(object):
|
||||||
if a.get('distribution') is None:
|
if a.get('distribution') is None:
|
||||||
a['distribution'] = 5
|
a['distribution'] = 5
|
||||||
event['Event']['Attribute'] = attributes
|
event['Event']['Attribute'] = attributes
|
||||||
response = self.update_event(event['Event']['id'], event, 'json')
|
response = self.update_event(event['Event']['id'], event)
|
||||||
return self._check_response(response)
|
return response
|
||||||
|
|
||||||
def add_named_attribute(self, event, category, type_value, value, to_ids=False, comment=None, distribution=None, proposal=False):
|
def add_named_attribute(self, event, category, type_value, value, to_ids=False, comment=None, distribution=None, proposal=False):
|
||||||
attributes = []
|
attributes = []
|
||||||
|
|
Loading…
Reference in New Issue