-
Notifications
You must be signed in to change notification settings - Fork 0
/
discloudapi.py
152 lines (120 loc) · 5.52 KB
/
discloudapi.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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import requests
url = "https://api.discloud.app/v2"
def formatReturn(result):
result_json = result.json()
result_json["rateLimit"] = result.headers["ratelimit-limit"]
result_json["rateLimitRemaining"] = result.headers["ratelimit-remaining"]
result_json["rateLimitReset"] = result.headers["ratelimit-reset"]
return result_json
class Client:
def __init__(self, api_token: str):
self.api_token = api_token
self.headers={"api-token":self.api_token}
# USER AREA
def user(self):
result = requests.get(url+"/user", headers=self.headers)
result_json = formatReturn(result)
return result_json
def locale(self, locale: str):
result = requests.put(url+f"/locale/{locale}", headers=self.headers)
result_json = formatReturn(result)
return result_json
def upload(self):
result = requests.post(url+f"/upload", headers=self.headers)
result_json = formatReturn(result)
return result_json
# APP AREA
def app(self, app_id: str):
result = requests.get(url+f"/app/{app_id}", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appStatus(self, app_id: str):
result = requests.get(url+f"/app/{app_id}/status", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appLogs(self, app_id: str):
result = requests.get(url+f"/app/{app_id}/logs", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appStart(self, app_id: str):
result = requests.put(url+f"/app/{app_id}/start", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appRestart(self, app_id: str):
result = requests.put(url+f"/app/{app_id}/restart", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appStop(self, app_id: str):
result = requests.put(url+f"/app/{app_id}/stop", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appCommit(self, app_id: str):
result = requests.put(url+f"/app/{app_id}/commit", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appDelete(self, app_id: str):
result = requests.delete(url+f"/app/{app_id}/delete", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appBackup(self, app_id: str):
result = requests.get(url+f"/app/{app_id}/backup", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appRamUpdate(self, app_id: str, ramMB: int):
result = requests.put(url+f"/app/{app_id}/ram", headers=self.headers, json={"ramMB": ramMB})
result_json = formatReturn(result)
return result_json
# TEAM AREA
def team(self):
result = requests.get(url+f"/team", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamStatus(self, app_id: str):
result = requests.get(url+f"/team/{app_id}/status", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamLogs(self, app_id: str):
result = requests.get(url+f"/team/{app_id}/logs", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamStart(self, app_id: str):
result = requests.put(url+f"/team/{app_id}/start", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamRestart(self, app_id: str):
result = requests.put(url+f"/team/{app_id}/restart", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamStop(self, app_id: str):
result = requests.put(url+f"/team/{app_id}/stop", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamCommit(self, app_id: str):
result = requests.put(url+f"/team/{app_id}/commit", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamBackup(self, app_id: str):
result = requests.get(url+f"/team/{app_id}/backup", headers=self.headers)
result_json = formatReturn(result)
return result_json
def appTeamRamUpdate(self, app_id: str, ramMB: int):
result = requests.put(url+f"/team/{app_id}/ram", headers=self.headers, json={"ramMB": ramMB})
result_json = formatReturn(result)
return result_json
# MOD AREA
def mod(self, app_id: str):
result = requests.get(url+f"/app/{app_id}/team", headers=self.headers)
result_json = formatReturn(result)
return result_json
def addMod(self, app_id: str, mod_id: int, permissions: list):
result = requests.post(url+f"/app/{app_id}/team", headers=self.headers, json={"modID": mod_id, "perms":permissions})
result_json = formatReturn(result)
return result_json
def editMod(self, app_id: str, mod_id: int, permissions: list):
result = requests.put(url+f"/app/{app_id}/team", headers=self.headers, json={"modID": mod_id, "perms":permissions})
result_json = formatReturn(result)
return result_json
def deleteMod(self, app_id: str, mod_id: int):
result = requests.delete(url+f"/app/{app_id}/team/{mod_id}", headers=self.headers)
result_json = formatReturn(result)
return result_json