Adding the possibility to delete elements/IOCs from watchers

This commit is contained in:
Félix Aime
2021-02-16 16:51:36 +01:00
parent af499f3cda
commit 53620b6a0a
3 changed files with 56 additions and 4 deletions

View File

@ -70,7 +70,7 @@ class IOCs(object):
@staticmethod
def delete(ioc_id):
"""
Delete an IOC by its id to the database.
Delete an IOC by its id in the database.
:return: status of the operation in JSON
"""
if db.session.query(exists().where(Ioc.id == ioc_id)).scalar():
@ -82,6 +82,21 @@ class IOCs(object):
return {"status": False,
"message": "IOC not found"}
@staticmethod
def delete_by_value(ioc_value):
"""
Delete an IOC by its value in the database.
:return: status of the operation in JSON
"""
if db.session.query(exists().where(Ioc.value == ioc_value)).scalar():
db.session.query(Ioc).filter_by(value=ioc_value).delete()
db.session.commit()
return {"status": True,
"message": "IOC deleted"}
else:
return {"status": False,
"message": "IOC not found"}
@staticmethod
def search(term):
"""