Skip to content

Commit a4b32bd

Browse files
committed
Upgraded to support Appwrite 0.7.0
1 parent cd6c8f8 commit a4b32bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+508
-107
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# 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.6.2-blue.svg?v=1)
4+
![Version](https://img.shields.io/badge/api%20version-0.7.0-blue.svg?v=1)
55

6-
**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.**
6+
**This SDK is compatible with Appwrite server version 0.7.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/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.
1010
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1111

12-
13-
1412
![Appwrite](https://appwrite.io/images/github.png)
1513

1614
## Installation

appwrite/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(self):
77
self._endpoint = 'https://appwrite.io/v1'
88
self._global_headers = {
99
'content-type': '',
10-
'x-sdk-version': 'appwrite:python:0.0.6',
10+
'x-sdk-version': 'appwrite:python:0.1.0',
1111
}
1212

1313
def set_self_signed(self, status=True):

appwrite/services/avatars.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,22 @@ def get_image(self, url, width=400, height=400):
7272
'content-type': 'application/json',
7373
}, params)
7474

75-
def get_q_r(self, text, size=400, margin=1, download=0):
75+
def get_initials(self, name='', width=500, height=500, color='', background=''):
76+
"""Get User Initials"""
77+
78+
params = {}
79+
path = '/avatars/initials'
80+
params['name'] = name
81+
params['width'] = width
82+
params['height'] = height
83+
params['color'] = color
84+
params['background'] = background
85+
86+
return self.client.call('get', path, {
87+
'content-type': 'application/json',
88+
}, params)
89+
90+
def get_q_r(self, text, size=400, margin=1, download=False):
7691
"""Get QR Code"""
7792

7893
params = {}

appwrite/services/database.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,19 @@ def delete_collection(self, collection_id):
7171
'content-type': 'application/json',
7272
}, params)
7373

74-
def list_documents(self, collection_id, filters=[], offset=0, limit=50, order_field='$id', order_type='ASC', order_cast='string', search='', first=0, last=0):
74+
def list_documents(self, collection_id, filters=[], limit=25, offset=0, order_field='', order_type='ASC', order_cast='string', search=''):
7575
"""List Documents"""
7676

7777
params = {}
7878
path = '/database/collections/{collectionId}/documents'
7979
path = path.replace('{collectionId}', collection_id)
8080
params['filters'] = filters
81-
params['offset'] = offset
8281
params['limit'] = limit
82+
params['offset'] = offset
8383
params['orderField'] = order_field
8484
params['orderType'] = order_type
8585
params['orderCast'] = order_cast
8686
params['search'] = search
87-
params['first'] = first
88-
params['last'] = last
8987

9088
return self.client.call('get', path, {
9189
'content-type': 'application/json',
@@ -146,14 +144,3 @@ def delete_document(self, collection_id, document_id):
146144
return self.client.call('delete', path, {
147145
'content-type': 'application/json',
148146
}, 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/functions.py

+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
from ..service import Service
2+
3+
4+
class Functions(Service):
5+
6+
def __init__(self, client):
7+
super(Functions, self).__init__(client)
8+
9+
def list(self, search='', limit=25, offset=0, order_type='ASC'):
10+
"""List Functions"""
11+
12+
params = {}
13+
path = '/functions'
14+
params['search'] = search
15+
params['limit'] = limit
16+
params['offset'] = offset
17+
params['orderType'] = order_type
18+
19+
return self.client.call('get', path, {
20+
'content-type': 'application/json',
21+
}, params)
22+
23+
def create(self, name, execute, env, vars={}, events=[], schedule='', timeout=15):
24+
"""Create Function"""
25+
26+
params = {}
27+
path = '/functions'
28+
params['name'] = name
29+
params['execute'] = execute
30+
params['env'] = env
31+
params['vars'] = vars
32+
params['events'] = events
33+
params['schedule'] = schedule
34+
params['timeout'] = timeout
35+
36+
return self.client.call('post', path, {
37+
'content-type': 'application/json',
38+
}, params)
39+
40+
def get(self, function_id):
41+
"""Get Function"""
42+
43+
params = {}
44+
path = '/functions/{functionId}'
45+
path = path.replace('{functionId}', function_id)
46+
47+
return self.client.call('get', path, {
48+
'content-type': 'application/json',
49+
}, params)
50+
51+
def update(self, function_id, name, execute, vars={}, events=[], schedule='', timeout=15):
52+
"""Update Function"""
53+
54+
params = {}
55+
path = '/functions/{functionId}'
56+
path = path.replace('{functionId}', function_id)
57+
params['name'] = name
58+
params['execute'] = execute
59+
params['vars'] = vars
60+
params['events'] = events
61+
params['schedule'] = schedule
62+
params['timeout'] = timeout
63+
64+
return self.client.call('put', path, {
65+
'content-type': 'application/json',
66+
}, params)
67+
68+
def delete(self, function_id):
69+
"""Delete Function"""
70+
71+
params = {}
72+
path = '/functions/{functionId}'
73+
path = path.replace('{functionId}', function_id)
74+
75+
return self.client.call('delete', path, {
76+
'content-type': 'application/json',
77+
}, params)
78+
79+
def list_executions(self, function_id, search='', limit=25, offset=0, order_type='ASC'):
80+
"""List Executions"""
81+
82+
params = {}
83+
path = '/functions/{functionId}/executions'
84+
path = path.replace('{functionId}', function_id)
85+
params['search'] = search
86+
params['limit'] = limit
87+
params['offset'] = offset
88+
params['orderType'] = order_type
89+
90+
return self.client.call('get', path, {
91+
'content-type': 'application/json',
92+
}, params)
93+
94+
def create_execution(self, function_id):
95+
"""Create Execution"""
96+
97+
params = {}
98+
path = '/functions/{functionId}/executions'
99+
path = path.replace('{functionId}', function_id)
100+
101+
return self.client.call('post', path, {
102+
'content-type': 'application/json',
103+
}, params)
104+
105+
def get_execution(self, function_id, execution_id):
106+
"""Get Execution"""
107+
108+
params = {}
109+
path = '/functions/{functionId}/executions/{executionId}'
110+
path = path.replace('{functionId}', function_id)
111+
path = path.replace('{executionId}', execution_id)
112+
113+
return self.client.call('get', path, {
114+
'content-type': 'application/json',
115+
}, params)
116+
117+
def update_tag(self, function_id, tag):
118+
"""Update Function Tag"""
119+
120+
params = {}
121+
path = '/functions/{functionId}/tag'
122+
path = path.replace('{functionId}', function_id)
123+
params['tag'] = tag
124+
125+
return self.client.call('patch', path, {
126+
'content-type': 'application/json',
127+
}, params)
128+
129+
def list_tags(self, function_id, search='', limit=25, offset=0, order_type='ASC'):
130+
"""List Tags"""
131+
132+
params = {}
133+
path = '/functions/{functionId}/tags'
134+
path = path.replace('{functionId}', function_id)
135+
params['search'] = search
136+
params['limit'] = limit
137+
params['offset'] = offset
138+
params['orderType'] = order_type
139+
140+
return self.client.call('get', path, {
141+
'content-type': 'application/json',
142+
}, params)
143+
144+
def create_tag(self, function_id, command, code):
145+
"""Create Tag"""
146+
147+
params = {}
148+
path = '/functions/{functionId}/tags'
149+
path = path.replace('{functionId}', function_id)
150+
params['command'] = command
151+
params['code'] = code
152+
153+
return self.client.call('post', path, {
154+
'content-type': 'multipart/form-data',
155+
}, params)
156+
157+
def get_tag(self, function_id, tag_id):
158+
"""Get Tag"""
159+
160+
params = {}
161+
path = '/functions/{functionId}/tags/{tagId}'
162+
path = path.replace('{functionId}', function_id)
163+
path = path.replace('{tagId}', tag_id)
164+
165+
return self.client.call('get', path, {
166+
'content-type': 'application/json',
167+
}, params)
168+
169+
def delete_tag(self, function_id, tag_id):
170+
"""Delete Tag"""
171+
172+
params = {}
173+
path = '/functions/{functionId}/tags/{tagId}'
174+
path = path.replace('{functionId}', function_id)
175+
path = path.replace('{tagId}', tag_id)
176+
177+
return self.client.call('delete', path, {
178+
'content-type': 'application/json',
179+
}, params)

appwrite/services/locale.py

+10
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ def get_currencies(self):
6565
return self.client.call('get', path, {
6666
'content-type': 'application/json',
6767
}, params)
68+
69+
def get_languages(self):
70+
"""List Languages"""
71+
72+
params = {}
73+
path = '/locale/languages'
74+
75+
return self.client.call('get', path, {
76+
'content-type': 'application/json',
77+
}, params)

appwrite/services/storage.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ def get_file_preview(self, file_id, width=0, height=0, quality=100, background='
9595
'content-type': 'application/json',
9696
}, params)
9797

98-
def get_file_view(self, file_id, xas=''):
98+
def get_file_view(self, file_id):
9999
"""Get File for View"""
100100

101101
params = {}
102102
path = '/storage/files/{fileId}/view'
103103
path = path.replace('{fileId}', file_id)
104-
params['as'] = xas
105104

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

appwrite/services/teams.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def list(self, search='', limit=25, offset=0, order_type='ASC'):
2020
'content-type': 'application/json',
2121
}, params)
2222

23-
def create(self, name, roles=[]):
23+
def create(self, name, roles=["owner"]):
2424
"""Create Team"""
2525

2626
params = {}
@@ -66,12 +66,16 @@ def delete(self, team_id):
6666
'content-type': 'application/json',
6767
}, params)
6868

69-
def get_memberships(self, team_id):
69+
def get_memberships(self, team_id, search='', limit=25, offset=0, order_type='ASC'):
7070
"""Get Team Memberships"""
7171

7272
params = {}
7373
path = '/teams/{teamId}/memberships'
7474
path = path.replace('{teamId}', team_id)
75+
params['search'] = search
76+
params['limit'] = limit
77+
params['offset'] = offset
78+
params['orderType'] = order_type
7579

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

appwrite/services/users.py

+11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ def get(self, user_id):
4444
'content-type': 'application/json',
4545
}, params)
4646

47+
def delete_user(self, user_id):
48+
"""Delete User"""
49+
50+
params = {}
51+
path = '/users/{userId}'
52+
path = path.replace('{userId}', user_id)
53+
54+
return self.client.call('delete', path, {
55+
'content-type': 'application/json',
56+
}, params)
57+
4758
def get_logs(self, user_id):
4859
"""Get User Logs"""
4960

docs/examples/avatars/get-browser.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from appwrite.services.avatars import Avatars
44
client = Client()
55

66
(client
7-
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
88
.set_project('5df5acd0d48c2') # Your project ID
99
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
1010
)

docs/examples/avatars/get-credit-card.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from appwrite.services.avatars import Avatars
44
client = Client()
55

66
(client
7-
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
88
.set_project('5df5acd0d48c2') # Your project ID
99
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
1010
)

docs/examples/avatars/get-favicon.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from appwrite.services.avatars import Avatars
44
client = Client()
55

66
(client
7-
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
88
.set_project('5df5acd0d48c2') # Your project ID
99
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
1010
)

docs/examples/avatars/get-flag.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from appwrite.services.avatars import Avatars
44
client = Client()
55

66
(client
7-
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
88
.set_project('5df5acd0d48c2') # Your project ID
99
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
1010
)

docs/examples/avatars/get-image.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from appwrite.services.avatars import Avatars
44
client = Client()
55

66
(client
7-
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
7+
.set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint
88
.set_project('5df5acd0d48c2') # Your project ID
99
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
1010
)

0 commit comments

Comments
 (0)