Skip to content

Commit

Permalink
feat: 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jul 3, 2024
1 parent ad531fe commit 0379959
Show file tree
Hide file tree
Showing 269 changed files with 554 additions and 447 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Appwrite Python SDK

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

**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).**
**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).**

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)

Expand Down
5 changes: 5 additions & 0 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def call(self, method, path='', headers=None, params=None, response_type='json')

response.raise_for_status()

warnings = response.headers.get('x-appwrite-warning')
if warnings:
for warning in warnings.split(';'):
print(f'Warning: {warning}')

content_type = response.headers['Content-Type']

if response_type == 'location':
Expand Down
2 changes: 1 addition & 1 deletion appwrite/enums/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Name(Enum):
V1_FUNCTIONS = "v1-functions"
V1_USAGE = "v1-usage"
V1_USAGE_DUMP = "v1-usage-dump"
WEBHOOKSV1 = "webhooksv1"
V1_WEBHOOKS = "v1-webhooks"
V1_CERTIFICATES = "v1-certificates"
V1_BUILDS = "v1-builds"
V1_MESSAGING = "v1-messaging"
Expand Down
1 change: 1 addition & 0 deletions appwrite/enums/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ class Runtime(Enum):
CPP_17 = "cpp-17"
CPP_20 = "cpp-20"
BUN_1_0 = "bun-1.0"
GO_1_22 = "go-1.22"
2 changes: 1 addition & 1 deletion appwrite/services/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create_jwt(self):
"""Create JWT"""


api_path = '/account/jwt'
api_path = '/account/jwts'
api_params = {}

return self.client.call('post', api_path, {
Expand Down
60 changes: 50 additions & 10 deletions appwrite/services/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def list(self, queries = None, search = None):
'content-type': 'application/json',
}, api_params)

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):
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_branch = None):
"""Create function"""


Expand All @@ -47,6 +47,7 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche
api_params['logging'] = logging
api_params['entrypoint'] = entrypoint
api_params['commands'] = commands
api_params['scopes'] = scopes
api_params['installationId'] = installation_id
api_params['providerRepositoryId'] = provider_repository_id
api_params['providerBranch'] = provider_branch
Expand Down Expand Up @@ -88,7 +89,7 @@ def get(self, function_id):
'content-type': 'application/json',
}, api_params)

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):
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):
"""Update function"""


Expand All @@ -112,6 +113,7 @@ def update(self, function_id, name, runtime = None, execute = None, events = Non
api_params['logging'] = logging
api_params['entrypoint'] = entrypoint
api_params['commands'] = commands
api_params['scopes'] = scopes
api_params['installationId'] = installation_id
api_params['providerRepositoryId'] = provider_repository_id
api_params['providerBranch'] = provider_branch
Expand Down Expand Up @@ -247,30 +249,47 @@ def delete_deployment(self, function_id, deployment_id):
'content-type': 'application/json',
}, api_params)

def create_build(self, function_id, deployment_id, build_id):
"""Create build"""
def create_build(self, function_id, deployment_id, build_id = None):
"""Rebuild deployment"""


api_path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'
api_path = '/functions/{functionId}/deployments/{deploymentId}/build'
api_params = {}
if function_id is None:
raise AppwriteException('Missing required parameter: "function_id"')

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

if build_id is None:
raise AppwriteException('Missing required parameter: "build_id"')

api_path = api_path.replace('{functionId}', function_id)
api_path = api_path.replace('{deploymentId}', deployment_id)
api_path = api_path.replace('{buildId}', build_id)

api_params['buildId'] = build_id

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

def update_deployment_build(self, function_id, deployment_id):
"""Cancel deployment"""


api_path = '/functions/{functionId}/deployments/{deploymentId}/build'
api_params = {}
if function_id is None:
raise AppwriteException('Missing required parameter: "function_id"')

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

api_path = api_path.replace('{functionId}', function_id)
api_path = api_path.replace('{deploymentId}', deployment_id)


return self.client.call('patch', api_path, {
'content-type': 'application/json',
}, api_params)

def download_deployment(self, function_id, deployment_id):
"""Download Deployment"""

Expand Down Expand Up @@ -309,7 +328,7 @@ def list_executions(self, function_id, queries = None, search = None):
'content-type': 'application/json',
}, api_params)

def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None):
def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None):
"""Create execution"""


Expand All @@ -325,6 +344,7 @@ def create_execution(self, function_id, body = None, xasync = None, path = None,
api_params['path'] = path
api_params['method'] = method
api_params['headers'] = headers
api_params['scheduledAt'] = scheduled_at

return self.client.call('post', api_path, {
'content-type': 'application/json',
Expand All @@ -350,6 +370,26 @@ def get_execution(self, function_id, execution_id):
'content-type': 'application/json',
}, api_params)

def delete_execution(self, function_id, execution_id):
"""Delete execution"""


api_path = '/functions/{functionId}/executions/{executionId}'
api_params = {}
if function_id is None:
raise AppwriteException('Missing required parameter: "function_id"')

if execution_id is None:
raise AppwriteException('Missing required parameter: "execution_id"')

api_path = api_path.replace('{functionId}', function_id)
api_path = api_path.replace('{executionId}', execution_id)


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

def list_variables(self, function_id):
"""List variables"""

Expand Down
18 changes: 18 additions & 0 deletions appwrite/services/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,24 @@ def update_email(self, user_id, email):
'content-type': 'application/json',
}, api_params)

def create_jwt(self, user_id, session_id = None, duration = None):
"""Create user JWT"""


api_path = '/users/{userId}/jwts'
api_params = {}
if user_id is None:
raise AppwriteException('Missing required parameter: "user_id"')

api_path = api_path.replace('{userId}', user_id)

api_params['sessionId'] = session_id
api_params['duration'] = duration

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

def update_labels(self, user_id, labels):
"""Update user labels"""

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-anonymous-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-email-password-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-email-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-j-w-t.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-magic-u-r-l-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-authenticator.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from appwrite.enums import AuthenticatorType

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from appwrite.enums import AuthenticationFactor

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-mfa-recovery-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-o-auth2token.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from appwrite.enums import OAuthProvider

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-phone-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-phone-verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete-mfa-authenticator.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from appwrite.enums import AuthenticatorType

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get-mfa-recovery-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from appwrite.client import Client

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

account = Account(client)
Expand Down
Loading

0 comments on commit 0379959

Please sign in to comment.