Skip to content

Commit 1cf23ad

Browse files
Merge pull request #90 from appwrite/1.6.x
1.6.x
2 parents 4c9856c + 0504509 commit 1cf23ad

File tree

271 files changed

+596
-469
lines changed

Some content is hidden

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

271 files changed

+596
-469
lines changed

README.md

+2-2
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.5.6-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.6.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.5.x. 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.6.x. 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

appwrite/client.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def __init__(self):
1313
self._endpoint = 'https://cloud.appwrite.io/v1'
1414
self._global_headers = {
1515
'content-type': '',
16-
'user-agent' : 'AppwritePythonSDK/5.0.3 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
16+
'user-agent' : 'AppwritePythonSDK/6.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
1717
'x-sdk-name': 'Python',
1818
'x-sdk-platform': 'server',
1919
'x-sdk-language': 'python',
20-
'x-sdk-version': '5.0.3',
21-
'X-Appwrite-Response-Format' : '1.5.0',
20+
'x-sdk-version': '6.0.0',
21+
'X-Appwrite-Response-Format' : '1.6.0',
2222
}
2323

2424
def set_self_signed(self, status=True):
@@ -113,6 +113,11 @@ def call(self, method, path='', headers=None, params=None, response_type='json')
113113

114114
response.raise_for_status()
115115

116+
warnings = response.headers.get('x-appwrite-warning')
117+
if warnings:
118+
for warning in warnings.split(';'):
119+
print(f'Warning: {warning}')
120+
116121
content_type = response.headers['Content-Type']
117122

118123
if response_type == 'location':

appwrite/enums/name.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Name(Enum):
88
V1_FUNCTIONS = "v1-functions"
99
V1_USAGE = "v1-usage"
1010
V1_USAGE_DUMP = "v1-usage-dump"
11-
WEBHOOKSV1 = "webhooksv1"
11+
V1_WEBHOOKS = "v1-webhooks"
1212
V1_CERTIFICATES = "v1-certificates"
1313
V1_BUILDS = "v1-builds"
1414
V1_MESSAGING = "v1-messaging"

appwrite/enums/runtime.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ class Runtime(Enum):
4646
CPP_17 = "cpp-17"
4747
CPP_20 = "cpp-20"
4848
BUN_1_0 = "bun-1.0"
49+
GO_1_23 = "go-1.23"

appwrite/services/account.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def create_jwt(self):
9595
"""Create JWT"""
9696

9797

98-
api_path = '/account/jwt'
98+
api_path = '/account/jwts'
9999
api_params = {}
100100

101101
return self.client.call('post', api_path, {
@@ -132,7 +132,7 @@ def update_mfa(self, mfa):
132132
}, api_params)
133133

134134
def create_mfa_authenticator(self, type):
135-
"""Add Authenticator"""
135+
"""Create Authenticator"""
136136

137137

138138
api_path = '/account/mfa/authenticators/{type}'
@@ -167,7 +167,7 @@ def update_mfa_authenticator(self, type, otp):
167167
'content-type': 'application/json',
168168
}, api_params)
169169

170-
def delete_mfa_authenticator(self, type, otp):
170+
def delete_mfa_authenticator(self, type):
171171
"""Delete Authenticator"""
172172

173173

@@ -176,19 +176,15 @@ def delete_mfa_authenticator(self, type, otp):
176176
if type is None:
177177
raise AppwriteException('Missing required parameter: "type"')
178178

179-
if otp is None:
180-
raise AppwriteException('Missing required parameter: "otp"')
181-
182179
api_path = api_path.replace('{type}', type)
183180

184-
api_params['otp'] = otp
185181

186182
return self.client.call('delete', api_path, {
187183
'content-type': 'application/json',
188184
}, api_params)
189185

190186
def create_mfa_challenge(self, factor):
191-
"""Create 2FA Challenge"""
187+
"""Create MFA Challenge"""
192188

193189

194190
api_path = '/account/mfa/challenge'
@@ -693,7 +689,7 @@ def create_phone_verification(self):
693689
}, api_params)
694690

695691
def update_phone_verification(self, user_id, secret):
696-
"""Create phone verification (confirmation)"""
692+
"""Update phone verification (confirmation)"""
697693

698694

699695
api_path = '/account/verification/phone'

appwrite/services/functions.py

+67-14
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
}, api_params)
2222

23-
def create(self, function_id, name, runtime, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, template_repository = None, template_owner = None, template_root_directory = None, template_branch = None):
23+
def create(self, function_id, name, runtime, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, scopes = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, template_repository = None, template_owner = None, template_root_directory = None, template_version = None, specification = None):
2424
"""Create function"""
2525

2626

@@ -47,6 +47,7 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche
4747
api_params['logging'] = logging
4848
api_params['entrypoint'] = entrypoint
4949
api_params['commands'] = commands
50+
api_params['scopes'] = scopes
5051
api_params['installationId'] = installation_id
5152
api_params['providerRepositoryId'] = provider_repository_id
5253
api_params['providerBranch'] = provider_branch
@@ -55,7 +56,8 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche
5556
api_params['templateRepository'] = template_repository
5657
api_params['templateOwner'] = template_owner
5758
api_params['templateRootDirectory'] = template_root_directory
58-
api_params['templateBranch'] = template_branch
59+
api_params['templateVersion'] = template_version
60+
api_params['specification'] = specification
5961

6062
return self.client.call('post', api_path, {
6163
'content-type': 'application/json',
@@ -72,6 +74,17 @@ def list_runtimes(self):
7274
'content-type': 'application/json',
7375
}, api_params)
7476

77+
def list_specifications(self):
78+
"""List available function runtime specifications"""
79+
80+
81+
api_path = '/functions/specifications'
82+
api_params = {}
83+
84+
return self.client.call('get', api_path, {
85+
'content-type': 'application/json',
86+
}, api_params)
87+
7588
def get(self, function_id):
7689
"""Get function"""
7790

@@ -88,7 +101,7 @@ def get(self, function_id):
88101
'content-type': 'application/json',
89102
}, api_params)
90103

91-
def update(self, function_id, name, runtime = None, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None):
104+
def update(self, function_id, name, runtime = None, execute = None, events = None, schedule = None, timeout = None, enabled = None, logging = None, entrypoint = None, commands = None, scopes = None, installation_id = None, provider_repository_id = None, provider_branch = None, provider_silent_mode = None, provider_root_directory = None, specification = None):
92105
"""Update function"""
93106

94107

@@ -112,11 +125,13 @@ def update(self, function_id, name, runtime = None, execute = None, events = Non
112125
api_params['logging'] = logging
113126
api_params['entrypoint'] = entrypoint
114127
api_params['commands'] = commands
128+
api_params['scopes'] = scopes
115129
api_params['installationId'] = installation_id
116130
api_params['providerRepositoryId'] = provider_repository_id
117131
api_params['providerBranch'] = provider_branch
118132
api_params['providerSilentMode'] = provider_silent_mode
119133
api_params['providerRootDirectory'] = provider_root_directory
134+
api_params['specification'] = specification
120135

121136
return self.client.call('put', api_path, {
122137
'content-type': 'application/json',
@@ -208,7 +223,7 @@ def get_deployment(self, function_id, deployment_id):
208223
}, api_params)
209224

210225
def update_deployment(self, function_id, deployment_id):
211-
"""Update function deployment"""
226+
"""Update deployment"""
212227

213228

214229
api_path = '/functions/{functionId}/deployments/{deploymentId}'
@@ -247,32 +262,49 @@ def delete_deployment(self, function_id, deployment_id):
247262
'content-type': 'application/json',
248263
}, api_params)
249264

250-
def create_build(self, function_id, deployment_id, build_id):
251-
"""Create build"""
265+
def create_build(self, function_id, deployment_id, build_id = None):
266+
"""Rebuild deployment"""
252267

253268

254-
api_path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'
269+
api_path = '/functions/{functionId}/deployments/{deploymentId}/build'
255270
api_params = {}
256271
if function_id is None:
257272
raise AppwriteException('Missing required parameter: "function_id"')
258273

259274
if deployment_id is None:
260275
raise AppwriteException('Missing required parameter: "deployment_id"')
261276

262-
if build_id is None:
263-
raise AppwriteException('Missing required parameter: "build_id"')
264-
265277
api_path = api_path.replace('{functionId}', function_id)
266278
api_path = api_path.replace('{deploymentId}', deployment_id)
267-
api_path = api_path.replace('{buildId}', build_id)
268279

280+
api_params['buildId'] = build_id
269281

270282
return self.client.call('post', api_path, {
271283
'content-type': 'application/json',
272284
}, api_params)
273285

274-
def download_deployment(self, function_id, deployment_id):
275-
"""Download Deployment"""
286+
def update_deployment_build(self, function_id, deployment_id):
287+
"""Cancel deployment"""
288+
289+
290+
api_path = '/functions/{functionId}/deployments/{deploymentId}/build'
291+
api_params = {}
292+
if function_id is None:
293+
raise AppwriteException('Missing required parameter: "function_id"')
294+
295+
if deployment_id is None:
296+
raise AppwriteException('Missing required parameter: "deployment_id"')
297+
298+
api_path = api_path.replace('{functionId}', function_id)
299+
api_path = api_path.replace('{deploymentId}', deployment_id)
300+
301+
302+
return self.client.call('patch', api_path, {
303+
'content-type': 'application/json',
304+
}, api_params)
305+
306+
def get_deployment_download(self, function_id, deployment_id):
307+
"""Download deployment"""
276308

277309

278310
api_path = '/functions/{functionId}/deployments/{deploymentId}/download'
@@ -309,7 +341,7 @@ def list_executions(self, function_id, queries = None, search = None):
309341
'content-type': 'application/json',
310342
}, api_params)
311343

312-
def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None):
344+
def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None):
313345
"""Create execution"""
314346

315347

@@ -325,6 +357,7 @@ def create_execution(self, function_id, body = None, xasync = None, path = None,
325357
api_params['path'] = path
326358
api_params['method'] = method
327359
api_params['headers'] = headers
360+
api_params['scheduledAt'] = scheduled_at
328361

329362
return self.client.call('post', api_path, {
330363
'content-type': 'application/json',
@@ -350,6 +383,26 @@ def get_execution(self, function_id, execution_id):
350383
'content-type': 'application/json',
351384
}, api_params)
352385

386+
def delete_execution(self, function_id, execution_id):
387+
"""Delete execution"""
388+
389+
390+
api_path = '/functions/{functionId}/executions/{executionId}'
391+
api_params = {}
392+
if function_id is None:
393+
raise AppwriteException('Missing required parameter: "function_id"')
394+
395+
if execution_id is None:
396+
raise AppwriteException('Missing required parameter: "execution_id"')
397+
398+
api_path = api_path.replace('{functionId}', function_id)
399+
api_path = api_path.replace('{executionId}', execution_id)
400+
401+
402+
return self.client.call('delete', api_path, {
403+
'content-type': 'application/json',
404+
}, api_params)
405+
353406
def list_variables(self, function_id):
354407
"""List variables"""
355408

appwrite/services/users.py

+18
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,24 @@ def update_email(self, user_id, email):
330330
'content-type': 'application/json',
331331
}, api_params)
332332

333+
def create_jwt(self, user_id, session_id = None, duration = None):
334+
"""Create user JWT"""
335+
336+
337+
api_path = '/users/{userId}/jwts'
338+
api_params = {}
339+
if user_id is None:
340+
raise AppwriteException('Missing required parameter: "user_id"')
341+
342+
api_path = api_path.replace('{userId}', user_id)
343+
344+
api_params['sessionId'] = session_id
345+
api_params['duration'] = duration
346+
347+
return self.client.call('post', api_path, {
348+
'content-type': 'application/json',
349+
}, api_params)
350+
333351
def update_labels(self, user_id, labels):
334352
"""Update user labels"""
335353

docs/examples/account/create-anonymous-session.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66

77
account = Account(client)
88

docs/examples/account/create-email-password-session.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66

77
account = Account(client)
88

docs/examples/account/create-email-token.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66

77
account = Account(client)
88

docs/examples/account/create-j-w-t.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66

77
account = Account(client)
88

docs/examples/account/create-magic-u-r-l-token.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66

77
account = Account(client)
88

docs/examples/account/create-mfa-authenticator.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from appwrite.enums import AuthenticatorType
33

44
client = Client()
55
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
6-
client.set_project('5df5acd0d48c2') # Your project ID
6+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
77
client.set_session('') # The user session to authenticate with
88

99
account = Account(client)

docs/examples/account/create-mfa-challenge.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from appwrite.enums import AuthenticationFactor
33

44
client = Client()
55
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
6-
client.set_project('5df5acd0d48c2') # Your project ID
6+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
77

88
account = Account(client)
99

docs/examples/account/create-mfa-recovery-codes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from appwrite.client import Client
22

33
client = Client()
44
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
5-
client.set_project('5df5acd0d48c2') # Your project ID
5+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
66
client.set_session('') # The user session to authenticate with
77

88
account = Account(client)

docs/examples/account/create-o-auth2token.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from appwrite.enums import OAuthProvider
33

44
client = Client()
55
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
6-
client.set_project('5df5acd0d48c2') # Your project ID
6+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
77

88
account = Account(client)
99

0 commit comments

Comments
 (0)