-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncthing.py
34 lines (30 loc) · 1.02 KB
/
syncthing.py
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
import time
import requests
import json
class Syncthing:
def __init__(self, settings):
self.settings = settings
self.token = settings.syncthing_key
def get_status(self):
settings = self.settings
headers = {
'Authorization': f'Bearer {self.token}',
'Content-Type': 'application/json'
}
response = requests.get(f"{settings.syncthing_api_url}/system/status", headers=headers)
return response.json()
def get_health(self):
settings = self.settings
headers = {
'Content-Type': 'application/json'
}
response = requests.get(f"{settings.syncthing_api_url}/noauth/health", headers=headers)
return response.json()
def get_completion(self,folder_id):
settings = self.settings
headers = {
'Authorization': f'Bearer {self.token}',
'Content-Type': 'application/json'
}
response = requests.get(f"{settings.syncthing_api_url}/db/completion?folder={folder_id}", headers=headers)
return response.json()