Skip to content

Commit a7b43b6

Browse files
committed
Upgraded to support Appwrite 0.6
1 parent edba392 commit a7b43b6

21 files changed

+332
-18
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Appwrite SDK for Python
1+
# Appwrite Python SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1)
4-
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
4+
![Version](https://img.shields.io/badge/api%20version-0.6.0-blue.svg?v=1)
55

6-
**This SDK is compatible with Appwrite server version 0.5.3. For older versions, please check previous releases.**
6+
**This SDK is compatible with Appwrite server version 0.6.0. For older versions, please check previous releases.**
77

88
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way.
99
Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.

appwrite/client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ def set_locale(self, value):
3838
self._global_headers['x-appwrite-locale'] = value.lower()
3939
return self
4040

41-
def set_mode(self, value):
42-
self._global_headers['x-appwrite-mode'] = value.lower()
43-
return self
44-
4541
def call(self, method, path='', headers=None, params=None):
4642
if headers is None:
4743
headers = {}

appwrite/services/database.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def list_documents(self, collection_id, filters=[], offset=0, limit=50, order_fi
8080
params['filters'] = filters
8181
params['offset'] = offset
8282
params['limit'] = limit
83-
params['order-field'] = order_field
84-
params['order-type'] = order_type
85-
params['order-cast'] = order_cast
83+
params['orderField'] = order_field
84+
params['orderType'] = order_type
85+
params['orderCast'] = order_cast
8686
params['search'] = search
8787
params['first'] = first
8888
params['last'] = last
@@ -146,3 +146,14 @@ def delete_document(self, collection_id, document_id):
146146
return self.client.call('delete', path, {
147147
'content-type': 'application/json',
148148
}, params)
149+
150+
def get_collection_logs(self, collection_id):
151+
"""Get Collection Logs"""
152+
153+
params = {}
154+
path = '/database/collections/{collectionId}/logs'
155+
path = path.replace('{collectionId}', collection_id)
156+
157+
return self.client.call('get', path, {
158+
'content-type': 'application/json',
159+
}, params)

appwrite/services/health.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
from ..service import Service
2+
3+
4+
class Health(Service):
5+
6+
def __init__(self, client):
7+
super(Health, self).__init__(client)
8+
9+
def get(self):
10+
"""Get HTTP"""
11+
12+
params = {}
13+
path = '/health'
14+
15+
return self.client.call('get', path, {
16+
'content-type': 'application/json',
17+
}, params)
18+
19+
def get_anti_virus(self):
20+
"""Get Anti virus"""
21+
22+
params = {}
23+
path = '/health/anti-virus'
24+
25+
return self.client.call('get', path, {
26+
'content-type': 'application/json',
27+
}, params)
28+
29+
def get_cache(self):
30+
"""Get Cache"""
31+
32+
params = {}
33+
path = '/health/cache'
34+
35+
return self.client.call('get', path, {
36+
'content-type': 'application/json',
37+
}, params)
38+
39+
def get_d_b(self):
40+
"""Get DB"""
41+
42+
params = {}
43+
path = '/health/db'
44+
45+
return self.client.call('get', path, {
46+
'content-type': 'application/json',
47+
}, params)
48+
49+
def get_queue_certificates(self):
50+
"""Get Certificate Queue"""
51+
52+
params = {}
53+
path = '/health/queue/certificates'
54+
55+
return self.client.call('get', path, {
56+
'content-type': 'application/json',
57+
}, params)
58+
59+
def get_queue_functions(self):
60+
"""Get Functions Queue"""
61+
62+
params = {}
63+
path = '/health/queue/functions'
64+
65+
return self.client.call('get', path, {
66+
'content-type': 'application/json',
67+
}, params)
68+
69+
def get_queue_logs(self):
70+
"""Get Logs Queue"""
71+
72+
params = {}
73+
path = '/health/queue/logs'
74+
75+
return self.client.call('get', path, {
76+
'content-type': 'application/json',
77+
}, params)
78+
79+
def get_queue_tasks(self):
80+
"""Get Tasks Queue"""
81+
82+
params = {}
83+
path = '/health/queue/tasks'
84+
85+
return self.client.call('get', path, {
86+
'content-type': 'application/json',
87+
}, params)
88+
89+
def get_queue_usage(self):
90+
"""Get Usage Queue"""
91+
92+
params = {}
93+
path = '/health/queue/usage'
94+
95+
return self.client.call('get', path, {
96+
'content-type': 'application/json',
97+
}, params)
98+
99+
def get_queue_webhooks(self):
100+
"""Get Webhooks Queue"""
101+
102+
params = {}
103+
path = '/health/queue/webhooks'
104+
105+
return self.client.call('get', path, {
106+
'content-type': 'application/json',
107+
}, params)
108+
109+
def get_storage_local(self):
110+
"""Get Local Storage"""
111+
112+
params = {}
113+
path = '/health/storage/local'
114+
115+
return self.client.call('get', path, {
116+
'content-type': 'application/json',
117+
}, params)
118+
119+
def get_time(self):
120+
"""Get Time"""
121+
122+
params = {}
123+
path = '/health/time'
124+
125+
return self.client.call('get', path, {
126+
'content-type': 'application/json',
127+
}, params)

appwrite/services/locale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get(self):
1717
}, params)
1818

1919
def get_continents(self):
20-
"""List Countries"""
20+
"""List Continents"""
2121

2222
params = {}
2323
path = '/locale/continents'

appwrite/services/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def delete_session(self, user_id, session_id):
104104
"""Delete User Session"""
105105

106106
params = {}
107-
path = '/users/{userId}/sessions/:session'
107+
path = '/users/{userId}/sessions/{sessionId}'
108108
path = path.replace('{userId}', user_id)
109-
params['sessionId'] = session_id
109+
path = path.replace('{sessionId}', session_id)
110110

111111
return self.client.call('delete', path, {
112112
'content-type': 'application/json',
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from appwrite.client import Client
2+
from appwrite.services.database import Database
3+
4+
client = Client()
5+
6+
(client
7+
.set_project('5df5acd0d48c2') # Your project ID
8+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
9+
)
10+
11+
database = Database(client)
12+
13+
result = database.get_collection_logs('[COLLECTION_ID]')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from appwrite.client import Client
2+
from appwrite.services.health import Health
3+
4+
client = Client()
5+
6+
(client
7+
.set_project('5df5acd0d48c2') # Your project ID
8+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
9+
)
10+
11+
health = Health(client)
12+
13+
result = health.get_anti_virus()

docs/examples/health/get-cache.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from appwrite.client import Client
2+
from appwrite.services.health import Health
3+
4+
client = Client()
5+
6+
(client
7+
.set_project('5df5acd0d48c2') # Your project ID
8+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
9+
)
10+
11+
health = Health(client)
12+
13+
result = health.get_cache()

docs/examples/health/get-d-b.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from appwrite.client import Client
2+
from appwrite.services.health import Health
3+
4+
client = Client()
5+
6+
(client
7+
.set_project('5df5acd0d48c2') # Your project ID
8+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
9+
)
10+
11+
health = Health(client)
12+
13+
result = health.get_d_b()

0 commit comments

Comments
 (0)