-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeers.py
More file actions
48 lines (40 loc) · 1.16 KB
/
peers.py
File metadata and controls
48 lines (40 loc) · 1.16 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
import requests
import constants
from helpers import requests_error, response_to_dict
@requests_error
def peers_list(**kwargs):
PARAMS = [
'state',
'os',
'version',
'limit',
'offset',
'orderBy'
]
payload = {}
for name in kwargs:
if name not in PARAMS:
raise ValueError("%s is not a valid parameter." % name)
payload[name] = kwargs[name]
response = requests.get(constants.PEERS_LIST,
params=payload,
timeout=constants.TIMEOUT
)
return response_to_dict(response)
@requests_error
def peers_get(ip, port):
payload = {
'ip': ip,
'port': port
}
response = requests.get(constants.PEERS_GET,
params=payload,
timeout=constants.TIMEOUT
)
return response_to_dict(response)
@requests_error
def peers_get_version():
response = requests.get(constants.PEERS_GET_VERSION,
timeout=constants.TIMEOUT
)
return response_to_dict(response)