Skip to content

Commit

Permalink
#250 - Implement list comment methods for alerts and cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamforka committed Aug 2, 2022
1 parent cc64ac2 commit 06b036a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions thehive4py/endpoints/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
OutputAlert,
)
from thehive4py.types.case import OutputCase
from thehive4py.types.comment import OutputComment
from thehive4py.types.observable import InputObservable, OutputObservable


Expand Down Expand Up @@ -141,3 +142,22 @@ def find_observables(
params={"name": "alert-observables"},
json={"query": query},
)

def find_comments(
self,
alert_id: str,
filters: Optional[FilterExpr] = None,
sortby: Optional[SortExpr] = None,
paginate: Optional[Paginate] = None,
) -> List[OutputComment]:
query: QueryExpr = [
{"_name": "getAlert", "idOrName": alert_id},
{"_name": "comments"},
*self._build_subquery(filters=filters, sortby=sortby, paginate=paginate),
]
return self._session.make_request(
"POST",
path="/api/v1/query",
params={"name": "alert-comments"},
json={"query": query},
)
20 changes: 20 additions & 0 deletions thehive4py/endpoints/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
InputUpdateCase,
OutputCase,
)
from thehive4py.types.comment import OutputComment
from thehive4py.types.observable import InputObservable, OutputObservable
from thehive4py.types.share import InputShare, OutputShare
from thehive4py.types.task import InputTask, OutputTask
Expand Down Expand Up @@ -256,6 +257,25 @@ def find_attachments(
json={"query": query},
)

def find_comments(
self,
case_id: CaseId,
filters: Optional[FilterExpr] = None,
sortby: Optional[SortExpr] = None,
paginate: Optional[Paginate] = None,
) -> List[OutputComment]:
query: QueryExpr = [
{"_name": "getCase", "idOrName": case_id},
{"_name": "comments"},
*self._build_subquery(filters=filters, sortby=sortby, paginate=paginate),
]
return self._session.make_request(
"POST",
path="/api/v1/query",
params={"name": "case-comments"},
json={"query": query},
)

def close(
self,
case_id: CaseId,
Expand Down

0 comments on commit 06b036a

Please sign in to comment.