-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
37 lines (29 loc) · 1.09 KB
/
__init__.py
File metadata and controls
37 lines (29 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
34
35
36
37
import logging
from urllib.parse import urlencode
log = logging.getLogger("socketdev")
class ThreatFeed:
def __init__(self, api):
self.api = api
def get(self, org_slug: str = None, **kwargs) -> dict:
"""
Get threat feed items.
Args:
org_slug: Organization slug (required for the new endpoint)
**kwargs: Query parameters like per_page, page_cursor, sort, etc.
Returns:
dict: API response containing threat feed items
"""
if org_slug:
# Use the new org-scoped endpoint
path = f"orgs/{org_slug}/threat-feed"
else:
# Use the deprecated global endpoint
path = "threat-feed"
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 threat feed: {response.status_code}")
log.error(response.text)
return {"results": [], "nextPage": None}