-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Alan Grgic <alan.grgic@code42.com>
- Loading branch information
1 parent
9ca9d9a
commit 585dae6
Showing
17 changed files
with
369 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
- master | ||
tags: | ||
- v* | ||
pull_request: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from py42.clients import BaseClient | ||
from py42.sdk.queries.fileevents.file_event_query import FileEventQuery | ||
|
||
|
||
class SavedSearchClient(BaseClient): | ||
"""A client to interact with saved search APIs.""" | ||
|
||
_version = u"v1" | ||
_resource = u"/forensic-search/queryservice/api/{}/saved".format(_version) | ||
|
||
def __init__(self, session, file_event_client): | ||
super(SavedSearchClient, self).__init__(session) | ||
self._file_event_client = file_event_client | ||
|
||
def get(self): | ||
"""Fetch details of existing saved searches. | ||
Returns: | ||
:class:`py42.response.Py42Response` | ||
""" | ||
uri = u"{}".format(self._resource) | ||
return self._session.get(uri) | ||
|
||
def get_by_id(self, search_id): | ||
"""Fetch the details of a saved search by its given search Id. | ||
Args: | ||
search_id (str): Unique search Id of the saved search. | ||
Returns: | ||
:class:`py42.response.Py42Response` | ||
""" | ||
uri = u"{}/{}".format(self._resource, search_id) | ||
return self._session.get(uri) | ||
|
||
def execute(self, search_id, pg_num=1, pg_size=10000): | ||
""" | ||
Execute a saved search for given search Id and return its results. | ||
Args: | ||
search_id (str): Unique search Id of the saved search. | ||
pg_num (int, optional): The consecutive group of results of size pg_size in the result set to return. Defaults to 1. | ||
pg_size (int, optional): The maximum number of results to be returned. Defaults to 10,000. | ||
Returns: | ||
:class:`py42.response.Py42Response` | ||
""" | ||
response = self.get_by_id(search_id) | ||
search = response[u"searches"][0] | ||
query = FileEventQuery.from_dict(search) | ||
return self._file_event_client.search(query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.