Skip to content

Commit 4b687e3

Browse files
committed
Update for 1.0.0
1 parent e8d6be4 commit 4b687e3

22 files changed

+212
-33
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Appwrite Python SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.0.0-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).**
9+
**This SDK is compatible with Appwrite server version 1.0.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).**
1010

1111
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. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

@@ -53,6 +53,7 @@ result = users.create('[USER_ID]', '[email protected]', 'password')
5353
```python
5454
from appwrite.client import Client
5555
from appwrite.services.users import Users
56+
from appwrite.id import ID
5657

5758
client = Client()
5859

@@ -65,7 +66,7 @@ client = Client()
6566

6667
users = Users(client)
6768

68-
result = users.create('[USER_ID]', '[email protected]', 'password')
69+
result = users.create(ID.unique(), '[email protected]', 'password')
6970
```
7071

7172
### Error Handling
@@ -74,7 +75,7 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code`
7475
```python
7576
users = Users(client)
7677
try:
77-
result = users.create('[USER_ID]', '[email protected]', 'password')
78+
result = users.create(ID.unique(), '[email protected]', 'password')
7879
except AppwriteException as e:
7980
print(e.message)
8081
```

appwrite/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def __init__(self):
1414
'x-sdk-name': 'Python',
1515
'x-sdk-platform': 'server',
1616
'x-sdk-language': 'python',
17-
'x-sdk-version': '1.0.0-RC1',
18-
'X-Appwrite-Response-Format' : '1.0.0-RC1',
17+
'x-sdk-version': '1.0.0',
18+
'X-Appwrite-Response-Format' : '1.0.0',
1919
}
2020

2121
def set_self_signed(self, status=True):

appwrite/query.py

+2
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,7 @@ def addQuery(attribute, method, value):
6262
def parseValues(value):
6363
if type(value) == str:
6464
return f'"{value}"'
65+
elif type(value) == bool:
66+
return str(value).lower()
6567
else:
6668
return str(value)

appwrite/role.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ def any():
44
return 'any'
55

66
@staticmethod
7-
def user(id):
7+
def user(id, status = ""):
8+
if status:
9+
return f'user:{id}/{status}'
810
return f'user:{id}'
911

1012
@staticmethod
11-
def users():
13+
def users(status = ""):
14+
if status:
15+
return f'users/{status}'
1216
return 'users'
1317

1418
@staticmethod
@@ -21,6 +25,10 @@ def team(id, role = ""):
2125
return f'team:{id}/{role}'
2226
return f'team:{id}'
2327

28+
@staticmethod
29+
def member(id):
30+
return f'member:{id}'
31+
2432
@staticmethod
2533
def status(status):
2634
return f'status:{status}'

appwrite/services/account.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def update_email(self, email, password):
3737
'content-type': 'application/json',
3838
}, params)
3939

40-
def get_logs(self, queries = None):
41-
"""Get Account Logs"""
40+
def list_logs(self, queries = None):
41+
"""List Account Logs"""
4242

4343

4444
path = '/account/logs'
@@ -178,8 +178,8 @@ def update_recovery(self, user_id, secret, password, password_again):
178178
'content-type': 'application/json',
179179
}, params)
180180

181-
def get_sessions(self):
182-
"""Get Account Sessions"""
181+
def list_sessions(self):
182+
"""List Account Sessions"""
183183

184184

185185
path = '/account/sessions'

appwrite/services/functions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def list(self, queries = None, search = None):
2020
'content-type': 'application/json',
2121
}, params)
2222

23-
def create(self, function_id, name, execute, runtime, events = None, schedule = None, timeout = None):
23+
def create(self, function_id, name, execute, runtime, events = None, schedule = None, timeout = None, enabled = None):
2424
"""Create Function"""
2525

2626

@@ -46,6 +46,7 @@ def create(self, function_id, name, execute, runtime, events = None, schedule =
4646
params['events'] = events
4747
params['schedule'] = schedule
4848
params['timeout'] = timeout
49+
params['enabled'] = enabled
4950

5051
return self.client.call('post', path, {
5152
'content-type': 'application/json',
@@ -78,7 +79,7 @@ def get(self, function_id):
7879
'content-type': 'application/json',
7980
}, params)
8081

81-
def update(self, function_id, name, execute, events = None, schedule = None, timeout = None):
82+
def update(self, function_id, name, execute, events = None, schedule = None, timeout = None, enabled = None):
8283
"""Update Function"""
8384

8485

@@ -100,6 +101,7 @@ def update(self, function_id, name, execute, events = None, schedule = None, tim
100101
params['events'] = events
101102
params['schedule'] = schedule
102103
params['timeout'] = timeout
104+
params['enabled'] = enabled
103105

104106
return self.client.call('put', path, {
105107
'content-type': 'application/json',
@@ -312,7 +314,7 @@ def get_execution(self, function_id, execution_id):
312314
'content-type': 'application/json',
313315
}, params)
314316

315-
def list_variables(self, function_id, queries = None, search = None):
317+
def list_variables(self, function_id):
316318
"""List Variables"""
317319

318320

@@ -323,8 +325,6 @@ def list_variables(self, function_id, queries = None, search = None):
323325

324326
path = path.replace('{functionId}', function_id)
325327

326-
params['queries'] = queries
327-
params['search'] = search
328328

329329
return self.client.call('get', path, {
330330
'content-type': 'application/json',

appwrite/services/locale.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get(self):
1717
'content-type': 'application/json',
1818
}, params)
1919

20-
def get_continents(self):
20+
def list_continents(self):
2121
"""List Continents"""
2222

2323

@@ -28,7 +28,7 @@ def get_continents(self):
2828
'content-type': 'application/json',
2929
}, params)
3030

31-
def get_countries(self):
31+
def list_countries(self):
3232
"""List Countries"""
3333

3434

@@ -39,7 +39,7 @@ def get_countries(self):
3939
'content-type': 'application/json',
4040
}, params)
4141

42-
def get_countries_eu(self):
42+
def list_countries_eu(self):
4343
"""List EU Countries"""
4444

4545

@@ -50,7 +50,7 @@ def get_countries_eu(self):
5050
'content-type': 'application/json',
5151
}, params)
5252

53-
def get_countries_phones(self):
53+
def list_countries_phones(self):
5454
"""List Countries Phone Codes"""
5555

5656

@@ -61,7 +61,7 @@ def get_countries_phones(self):
6161
'content-type': 'application/json',
6262
}, params)
6363

64-
def get_currencies(self):
64+
def list_currencies(self):
6565
"""List Currencies"""
6666

6767

@@ -72,7 +72,7 @@ def get_currencies(self):
7272
'content-type': 'application/json',
7373
}, params)
7474

75-
def get_languages(self):
75+
def list_languages(self):
7676
"""List Languages"""
7777

7878

appwrite/services/teams.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def delete(self, team_id):
9393
'content-type': 'application/json',
9494
}, params)
9595

96-
def get_memberships(self, team_id, queries = None, search = None):
97-
"""Get Team Memberships"""
96+
def list_memberships(self, team_id, queries = None, search = None):
97+
"""List Team Memberships"""
9898

9999

100100
path = '/teams/{teamId}/memberships'

appwrite/services/users.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ def update_email(self, user_id, email):
300300
'content-type': 'application/json',
301301
}, params)
302302

303-
def get_logs(self, user_id, queries = None):
304-
"""Get User Logs"""
303+
def list_logs(self, user_id, queries = None):
304+
"""List User Logs"""
305305

306306

307307
path = '/users/{userId}/logs'
@@ -317,8 +317,8 @@ def get_logs(self, user_id, queries = None):
317317
'content-type': 'application/json',
318318
}, params)
319319

320-
def get_memberships(self, user_id):
321-
"""Get User Memberships"""
320+
def list_memberships(self, user_id):
321+
"""List User Memberships"""
322322

323323

324324
path = '/users/{userId}/memberships'
@@ -429,8 +429,8 @@ def update_prefs(self, user_id, prefs):
429429
'content-type': 'application/json',
430430
}, params)
431431

432-
def get_sessions(self, user_id):
433-
"""Get User Sessions"""
432+
def list_sessions(self, user_id):
433+
"""List User Sessions"""
434434

435435

436436
path = '/users/{userId}/sessions'

docs/examples/account/list-logs.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.account import Account
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
10+
)
11+
12+
account = Account(client)
13+
14+
result = account.list_logs()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.account import Account
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token
10+
)
11+
12+
account = Account(client)
13+
14+
result = account.list_sessions()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_continents()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_countries_eu()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_countries_phones()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_countries()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_currencies()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.locale import Locale
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
locale = Locale(client)
13+
14+
result = locale.list_languages()
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from appwrite.client import Client
2+
from appwrite.services.teams import Teams
3+
4+
client = Client()
5+
6+
(client
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
8+
.set_project('5df5acd0d48c2') # Your project ID
9+
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
10+
)
11+
12+
teams = Teams(client)
13+
14+
result = teams.list_memberships('[TEAM_ID]')

0 commit comments

Comments
 (0)