diff --git a/README.md b/README.md index efa806d..eb42d99 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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.7-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.0-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) diff --git a/appwrite/client.py b/appwrite/client.py index 723e00e..85c47bd 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -13,12 +13,12 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : 'AppwritePythonSDK/5.0.3 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', + 'user-agent' : 'AppwritePythonSDK/6.0.0-rc.1 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '5.0.3', - 'X-Appwrite-Response-Format' : '1.5.0', + 'x-sdk-version': '6.0.0-rc.1', + 'X-Appwrite-Response-Format' : '1.6.0', } def set_self_signed(self, status=True): diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 1d08938..7e38e08 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -132,7 +132,7 @@ def update_mfa(self, mfa): }, api_params) def create_mfa_authenticator(self, type): - """Add Authenticator""" + """Create Authenticator""" api_path = '/account/mfa/authenticators/{type}' @@ -167,7 +167,7 @@ def update_mfa_authenticator(self, type, otp): 'content-type': 'application/json', }, api_params) - def delete_mfa_authenticator(self, type, otp): + def delete_mfa_authenticator(self, type): """Delete Authenticator""" @@ -176,19 +176,15 @@ def delete_mfa_authenticator(self, type, otp): if type is None: raise AppwriteException('Missing required parameter: "type"') - if otp is None: - raise AppwriteException('Missing required parameter: "otp"') - api_path = api_path.replace('{type}', type) - api_params['otp'] = otp return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) def create_mfa_challenge(self, factor): - """Create 2FA Challenge""" + """Create MFA Challenge""" api_path = '/account/mfa/challenge' @@ -693,7 +689,7 @@ def create_phone_verification(self): }, api_params) def update_phone_verification(self, user_id, secret): - """Create phone verification (confirmation)""" + """Update phone verification (confirmation)""" api_path = '/account/verification/phone' diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 2bbaa98..704aa8f 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -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, 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): + 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): """Create function""" @@ -56,7 +56,7 @@ def create(self, function_id, name, runtime, execute = None, events = None, sche api_params['templateRepository'] = template_repository api_params['templateOwner'] = template_owner api_params['templateRootDirectory'] = template_root_directory - api_params['templateBranch'] = template_branch + api_params['templateVersion'] = template_version return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -69,6 +69,38 @@ def list_runtimes(self): api_path = '/functions/runtimes' api_params = {} + return self.client.call('get', api_path, { + 'content-type': 'application/json', + }, api_params) + + def list_templates(self, runtimes = None, use_cases = None, limit = None, offset = None): + """List function templates""" + + + api_path = '/functions/templates' + api_params = {} + + api_params['runtimes'] = runtimes + api_params['useCases'] = use_cases + api_params['limit'] = limit + api_params['offset'] = offset + + return self.client.call('get', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_template(self, template_id): + """Get function template""" + + + api_path = '/functions/templates/{templateId}' + api_params = {} + if template_id is None: + raise AppwriteException('Missing required parameter: "template_id"') + + api_path = api_path.replace('{templateId}', template_id) + + return self.client.call('get', api_path, { 'content-type': 'application/json', }, api_params) @@ -210,7 +242,7 @@ def get_deployment(self, function_id, deployment_id): }, api_params) def update_deployment(self, function_id, deployment_id): - """Update function deployment""" + """Update deployment""" api_path = '/functions/{functionId}/deployments/{deploymentId}' @@ -290,8 +322,8 @@ def update_deployment_build(self, function_id, deployment_id): 'content-type': 'application/json', }, api_params) - def download_deployment(self, function_id, deployment_id): - """Download Deployment""" + def get_deployment_download(self, function_id, deployment_id): + """Download deployment""" api_path = '/functions/{functionId}/deployments/{deploymentId}/download' @@ -328,7 +360,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, scheduled_at = None): + def create_execution(self, function_id, body = None, xasync = None, path = None, method = None, headers = None, scheduled_at = None, on_progress = None): """Create execution""" @@ -340,15 +372,18 @@ def create_execution(self, function_id, body = None, xasync = None, path = None, api_path = api_path.replace('{functionId}', function_id) api_params['body'] = body - api_params['async'] = xasync + api_params['async'] = str(xasync).lower() if type(xasync) is bool else xasync api_params['path'] = path api_params['method'] = method - api_params['headers'] = headers + api_params['headers'] = str(headers).lower() if type(headers) is bool else headers api_params['scheduledAt'] = scheduled_at - return self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) + + upload_id = '' + + return self.client.chunked_upload(api_path, { + 'content-type': 'multipart/form-data', + }, api_params, param_name, on_progress, upload_id) def get_execution(self, function_id, execution_id): """Get execution""" diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 86955a3..138e36d 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -9,6 +9,5 @@ client.set_session('') # The user session to authenticate with account = Account(client) result = account.delete_mfa_authenticator( - type = AuthenticatorType.TOTP, - otp = '' + type = AuthenticatorType.TOTP ) diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 6bc91c1..9ea00ea 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -29,5 +29,5 @@ result = functions.create( template_repository = '', # optional template_owner = '', # optional template_root_directory = '', # optional - template_branch = '' # optional + template_version = '' # optional ) diff --git a/docs/examples/functions/download-deployment.md b/docs/examples/functions/get-deployment-download.md similarity index 73% rename from docs/examples/functions/download-deployment.md rename to docs/examples/functions/get-deployment-download.md index 2d0289b..f6725a2 100644 --- a/docs/examples/functions/download-deployment.md +++ b/docs/examples/functions/get-deployment-download.md @@ -3,11 +3,11 @@ from appwrite.client import Client client = Client() client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint client.set_project('<YOUR_PROJECT_ID>') # Your project ID -client.set_key('<YOUR_API_KEY>') # Your secret API key +client.set_session('') # The user session to authenticate with functions = Functions(client) -result = functions.download_deployment( +result = functions.get_deployment_download( function_id = '', deployment_id = '' ) diff --git a/docs/examples/functions/get-template.md b/docs/examples/functions/get-template.md new file mode 100644 index 0000000..dfb7735 --- /dev/null +++ b/docs/examples/functions/get-template.md @@ -0,0 +1,11 @@ +from appwrite.client import Client + +client = Client() +client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID + +functions = Functions(client) + +result = functions.get_template( + template_id = '' +) diff --git a/docs/examples/functions/list-templates.md b/docs/examples/functions/list-templates.md new file mode 100644 index 0000000..2de2b90 --- /dev/null +++ b/docs/examples/functions/list-templates.md @@ -0,0 +1,14 @@ +from appwrite.client import Client + +client = Client() +client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID + +functions = Functions(client) + +result = functions.list_templates( + runtimes = [], # optional + use_cases = [], # optional + limit = 1, # optional + offset = 0 # optional +) diff --git a/setup.py b/setup.py index df39af5..bd374b9 100644 --- a/setup.py +++ b/setup.py @@ -13,17 +13,17 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '5.0.3', + version = '6.0.0-rc.1', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, long_description_content_type = 'text/markdown', author = 'Appwrite Team', - author_email = 'team@appwrite.io', + author_email = 'team@localhost.test', maintainer = 'Appwrite Team', - maintainer_email = 'team@appwrite.io', + maintainer_email = 'team@localhost.test', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/5.0.3.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/6.0.0-rc.1.tar.gz', install_requires=[ 'requests', ],