-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
38 lines (29 loc) · 1.14 KB
/
__init__.py
File metadata and controls
38 lines (29 loc) · 1.14 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
34
35
36
37
38
import logging
import json
from urllib.parse import urlencode
log = logging.getLogger("socketdev")
class AlertTypes:
def __init__(self, api):
self.api = api
def get(self, alert_types: list = None, language: str = "en-US", **kwargs) -> dict:
"""
Get alert types metadata.
Args:
alert_types: List of alert type strings to get metadata for
language: Language for alert metadata (default: en-US)
**kwargs: Additional query parameters
Returns:
dict: API response containing alert types metadata
"""
path = "alert-types"
query_params = {"language": language}
query_params.update(kwargs)
if query_params:
path += "?" + urlencode(query_params)
payload = json.dumps(alert_types or [])
response = self.api.do_request(path=path, method="POST", payload=payload)
if response.status_code == 200:
return response.json()
log.error(f"Error getting alert types: {response.status_code}")
log.error(response.text)
return {}