-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path__init__.py
More file actions
33 lines (27 loc) · 1.09 KB
/
__init__.py
File metadata and controls
33 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
init.py file for api/ folder. Includes abstract class ReportingApi
"""
from aikido_zen.background_process.requests.make_request import Response
from aikido_zen.helpers.logging import logger
class ReportingApi:
"""This is the super class for the reporting API's"""
@staticmethod
def to_api_response(res: Response):
"""Converts results into an Api response obj"""
status = res.status_code
if status == 429:
return {"success": False, "error": "rate_limited"}
elif status == 401:
return {"success": False, "error": "invalid_token"}
elif status == 200:
try:
return res.json()
except Exception as e:
logger.debug(
"Trying to load json, failed: %s (body=%s)", str(e), res.text
)
return {"success": False, "error": "unknown_error"}
def report(self, token, event, timeout_in_sec):
"""Report event to aikido server"""
def fetch_firewall_lists(self, token):
"""Fetches the different lists from aikido's servers"""