-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from intezer/feat/add-search-alerts-history
add alerts history with filters TKT-3002
- Loading branch information
Showing
10 changed files
with
371 additions
and
59 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
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,21 @@ | ||
import datetime | ||
import sys | ||
from pprint import pprint | ||
|
||
from intezer_sdk.alerts import query_alerts_history | ||
from intezer_sdk import api | ||
|
||
|
||
def alerts_history_example(start_date: datetime.datetime, end_date: datetime.datetime): | ||
results = query_alerts_history(start_time=start_date, end_time=end_date) | ||
for result in results: | ||
pprint(result) | ||
|
||
|
||
def main(args): | ||
api.set_global_api('<api_key>') | ||
alerts_history_example(**args) | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) |
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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '1.19.18' | ||
__version__ = '1.20' |
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,30 @@ | ||
from typing import List | ||
from typing import Dict | ||
from typing import Tuple | ||
|
||
from intezer_sdk.api import IntezerApiClient | ||
from intezer_sdk.api import raise_for_status | ||
from intezer_sdk.history_results import HistoryResult | ||
|
||
|
||
class AlertsHistoryResult(HistoryResult): | ||
|
||
def __init__(self, request_url_path: str, api: IntezerApiClient, filters: Dict): | ||
""" | ||
Fetch all alerts history results from server. | ||
""" | ||
super().__init__(request_url_path, api, filters) | ||
|
||
def _fetch_history(self, url_path: str, data: Dict) -> Tuple[int, List]: | ||
""" | ||
Request from server filtered alerts history. | ||
:param url_path: Url to request new data from. | ||
:param data: filtered data. | ||
:return: Count of all results exits in filtered request and amount | ||
alerts as requested. | ||
""" | ||
response = self._api.request_with_refresh_expired_access_token( | ||
path=url_path, method='POST', data=data) | ||
raise_for_status(response) | ||
data_response = response.json()['result'] | ||
return data_response['alerts_count'], data_response['alerts'] |
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.