-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
53 lines (38 loc) · 1.41 KB
/
__init__.py
File metadata and controls
53 lines (38 loc) · 1.41 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import logging
import json
log = logging.getLogger("socketdev")
class Telemetry:
def __init__(self, api):
self.api = api
def get_config(self, org_slug: str) -> dict:
"""
Get telemetry configuration.
Args:
org_slug: Organization slug
Returns:
dict containing telemetry configuration
"""
path = f"orgs/{org_slug}/telemetry/config"
response = self.api.do_request(path=path)
if response.status_code == 200:
return response.json()
log.error(f"Error getting telemetry config: {response.status_code}")
log.error(response.text)
return {}
def update_config(self, org_slug: str, **kwargs) -> dict:
"""
Update telemetry configuration.
Args:
org_slug: Organization slug
**kwargs: Configuration parameters to update
Returns:
dict containing the updated telemetry configuration
"""
path = f"orgs/{org_slug}/telemetry/config"
payload = json.dumps(kwargs) if kwargs else "{}"
response = self.api.do_request(path=path, method="PUT", payload=payload)
if response.status_code == 200:
return response.json()
log.error(f"Error updating telemetry config: {response.status_code}")
log.error(response.text)
return {}