-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
64 lines (51 loc) · 2.17 KB
/
__init__.py
File metadata and controls
64 lines (51 loc) · 2.17 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
54
55
56
57
58
59
60
61
62
63
64
import logging
from urllib.parse import urlencode
log = logging.getLogger("socketdev")
class Analytics:
def __init__(self, api):
self.api = api
def get_org(self, filter: str, **kwargs) -> list:
"""
Get organization analytics (deprecated).
**DEPRECATED**: Use the Historical module methods instead:
- sdk.historical.alerts_trend() for alerts analytics
- sdk.historical.dependencies_trend() for dependencies analytics
Args:
filter: Analytics filter type
**kwargs: Additional query parameters
Returns:
list: API response containing analytics data
"""
log.warning("Analytics.get_org() is deprecated. Use Historical module methods instead.")
path = f"analytics/org/{filter}"
if kwargs:
path += "?" + urlencode(kwargs)
response = self.api.do_request(path=path)
if response.status_code == 200:
return response.json()
log.error(f"Error getting org analytics: {response.status_code}")
log.error(response.text)
return []
def get_repo(self, name: str, filter: str, **kwargs) -> list:
"""
Get repository analytics (deprecated).
**DEPRECATED**: Use the Historical module methods instead:
- sdk.historical.alerts_trend() for alerts analytics
- sdk.historical.dependencies_trend() for dependencies analytics
Args:
name: Repository name
filter: Analytics filter type
**kwargs: Additional query parameters
Returns:
list: API response containing analytics data
"""
log.warning("Analytics.get_repo() is deprecated. Use Historical module methods instead.")
path = f"analytics/repo/{name}/{filter}"
if kwargs:
path += "?" + urlencode(kwargs)
response = self.api.do_request(path=path)
if response.status_code == 200:
return response.json()
log.error(f"Error getting repo analytics: {response.status_code}")
log.error(response.text)
return []