diff --git a/README.md b/README.md index 8d2994e..703c1e3 100644 --- a/README.md +++ b/README.md @@ -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.0.0-RC1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.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) -**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).** +**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).** 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) @@ -53,6 +53,7 @@ result = users.create('[USER_ID]', 'email@example.com', 'password') ```python from appwrite.client import Client from appwrite.services.users import Users +from appwrite.id import ID client = Client() @@ -65,7 +66,7 @@ client = Client() users = Users(client) -result = users.create('[USER_ID]', 'email@example.com', 'password') +result = users.create(ID.unique(), 'email@example.com', 'password') ``` ### Error Handling @@ -74,7 +75,7 @@ The Appwrite Python SDK raises `AppwriteException` object with `message`, `code` ```python users = Users(client) try: - result = users.create('[USER_ID]', 'email@example.com', 'password') + result = users.create(ID.unique(), 'email@example.com', 'password') except AppwriteException as e: print(e.message) ``` diff --git a/appwrite/client.py b/appwrite/client.py index 457af18..8bec1a5 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -14,8 +14,8 @@ def __init__(self): 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '1.0.0-RC1', - 'X-Appwrite-Response-Format' : '1.0.0-RC1', + 'x-sdk-version': '1.0.0', + 'X-Appwrite-Response-Format' : '1.0.0', } def set_self_signed(self, status=True): diff --git a/appwrite/query.py b/appwrite/query.py index 7df3c1f..7896958 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -62,5 +62,7 @@ def addQuery(attribute, method, value): def parseValues(value): if type(value) == str: return f'"{value}"' + elif type(value) == bool: + return str(value).lower() else: return str(value) \ No newline at end of file diff --git a/appwrite/role.py b/appwrite/role.py index 3d02b69..73780b2 100644 --- a/appwrite/role.py +++ b/appwrite/role.py @@ -4,11 +4,15 @@ def any(): return 'any' @staticmethod - def user(id): + def user(id, status = ""): + if status: + return f'user:{id}/{status}' return f'user:{id}' @staticmethod - def users(): + def users(status = ""): + if status: + return f'users/{status}' return 'users' @staticmethod @@ -21,6 +25,10 @@ def team(id, role = ""): return f'team:{id}/{role}' return f'team:{id}' + @staticmethod + def member(id): + return f'member:{id}' + @staticmethod def status(status): return f'status:{status}' \ No newline at end of file diff --git a/appwrite/services/account.py b/appwrite/services/account.py index a58ec1f..f3a946a 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -37,8 +37,8 @@ def update_email(self, email, password): 'content-type': 'application/json', }, params) - def get_logs(self, queries = None): - """Get Account Logs""" + def list_logs(self, queries = None): + """List Account Logs""" path = '/account/logs' @@ -178,8 +178,8 @@ def update_recovery(self, user_id, secret, password, password_again): 'content-type': 'application/json', }, params) - def get_sessions(self): - """Get Account Sessions""" + def list_sessions(self): + """List Account Sessions""" path = '/account/sessions' diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index d8a16b7..f8dffd5 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', }, params) - def create(self, function_id, name, execute, runtime, events = None, schedule = None, timeout = None): + def create(self, function_id, name, execute, runtime, events = None, schedule = None, timeout = None, enabled = None): """Create Function""" @@ -46,6 +46,7 @@ def create(self, function_id, name, execute, runtime, events = None, schedule = params['events'] = events params['schedule'] = schedule params['timeout'] = timeout + params['enabled'] = enabled return self.client.call('post', path, { 'content-type': 'application/json', @@ -78,7 +79,7 @@ def get(self, function_id): 'content-type': 'application/json', }, params) - def update(self, function_id, name, execute, events = None, schedule = None, timeout = None): + def update(self, function_id, name, execute, events = None, schedule = None, timeout = None, enabled = None): """Update Function""" @@ -100,6 +101,7 @@ def update(self, function_id, name, execute, events = None, schedule = None, tim params['events'] = events params['schedule'] = schedule params['timeout'] = timeout + params['enabled'] = enabled return self.client.call('put', path, { 'content-type': 'application/json', @@ -312,7 +314,7 @@ def get_execution(self, function_id, execution_id): 'content-type': 'application/json', }, params) - def list_variables(self, function_id, queries = None, search = None): + def list_variables(self, function_id): """List Variables""" @@ -323,8 +325,6 @@ def list_variables(self, function_id, queries = None, search = None): path = path.replace('{functionId}', function_id) - params['queries'] = queries - params['search'] = search return self.client.call('get', path, { 'content-type': 'application/json', diff --git a/appwrite/services/locale.py b/appwrite/services/locale.py index 7a11012..4dc02ac 100644 --- a/appwrite/services/locale.py +++ b/appwrite/services/locale.py @@ -17,7 +17,7 @@ def get(self): 'content-type': 'application/json', }, params) - def get_continents(self): + def list_continents(self): """List Continents""" @@ -28,7 +28,7 @@ def get_continents(self): 'content-type': 'application/json', }, params) - def get_countries(self): + def list_countries(self): """List Countries""" @@ -39,7 +39,7 @@ def get_countries(self): 'content-type': 'application/json', }, params) - def get_countries_eu(self): + def list_countries_eu(self): """List EU Countries""" @@ -50,7 +50,7 @@ def get_countries_eu(self): 'content-type': 'application/json', }, params) - def get_countries_phones(self): + def list_countries_phones(self): """List Countries Phone Codes""" @@ -61,7 +61,7 @@ def get_countries_phones(self): 'content-type': 'application/json', }, params) - def get_currencies(self): + def list_currencies(self): """List Currencies""" @@ -72,7 +72,7 @@ def get_currencies(self): 'content-type': 'application/json', }, params) - def get_languages(self): + def list_languages(self): """List Languages""" diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 08407c3..7616aa2 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -93,8 +93,8 @@ def delete(self, team_id): 'content-type': 'application/json', }, params) - def get_memberships(self, team_id, queries = None, search = None): - """Get Team Memberships""" + def list_memberships(self, team_id, queries = None, search = None): + """List Team Memberships""" path = '/teams/{teamId}/memberships' diff --git a/appwrite/services/users.py b/appwrite/services/users.py index dfcb011..1587955 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -300,8 +300,8 @@ def update_email(self, user_id, email): 'content-type': 'application/json', }, params) - def get_logs(self, user_id, queries = None): - """Get User Logs""" + def list_logs(self, user_id, queries = None): + """List User Logs""" path = '/users/{userId}/logs' @@ -317,8 +317,8 @@ def get_logs(self, user_id, queries = None): 'content-type': 'application/json', }, params) - def get_memberships(self, user_id): - """Get User Memberships""" + def list_memberships(self, user_id): + """List User Memberships""" path = '/users/{userId}/memberships' @@ -429,8 +429,8 @@ def update_prefs(self, user_id, prefs): 'content-type': 'application/json', }, params) - def get_sessions(self, user_id): - """Get User Sessions""" + def list_sessions(self, user_id): + """List User Sessions""" path = '/users/{userId}/sessions' diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md new file mode 100644 index 0000000..53747b0 --- /dev/null +++ b/docs/examples/account/list-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token +) + +account = Account(client) + +result = account.list_logs() diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md new file mode 100644 index 0000000..1ac9d99 --- /dev/null +++ b/docs/examples/account/list-sessions.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_jwt('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') # Your secret JSON Web Token +) + +account = Account(client) + +result = account.list_sessions() diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md new file mode 100644 index 0000000..20dd8e0 --- /dev/null +++ b/docs/examples/locale/list-continents.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_continents() diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md new file mode 100644 index 0000000..b31725a --- /dev/null +++ b/docs/examples/locale/list-countries-e-u.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_countries_eu() diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md new file mode 100644 index 0000000..a44d8ad --- /dev/null +++ b/docs/examples/locale/list-countries-phones.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_countries_phones() diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md new file mode 100644 index 0000000..932fa1c --- /dev/null +++ b/docs/examples/locale/list-countries.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_countries() diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md new file mode 100644 index 0000000..1895162 --- /dev/null +++ b/docs/examples/locale/list-currencies.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_currencies() diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md new file mode 100644 index 0000000..f7a66cb --- /dev/null +++ b/docs/examples/locale/list-languages.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.locale import Locale + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +locale = Locale(client) + +result = locale.list_languages() diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md new file mode 100644 index 0000000..4535e57 --- /dev/null +++ b/docs/examples/teams/list-memberships.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.teams import Teams + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +teams = Teams(client) + +result = teams.list_memberships('[TEAM_ID]') diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md new file mode 100644 index 0000000..53560b4 --- /dev/null +++ b/docs/examples/users/list-logs.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.list_logs('[USER_ID]') diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md new file mode 100644 index 0000000..2f729cc --- /dev/null +++ b/docs/examples/users/list-memberships.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.list_memberships('[USER_ID]') diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md new file mode 100644 index 0000000..4fada3d --- /dev/null +++ b/docs/examples/users/list-sessions.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.users import Users + +client = Client() + +(client + .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint + .set_project('5df5acd0d48c2') # Your project ID + .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key +) + +users = Users(client) + +result = users.list_sessions('[USER_ID]') diff --git a/setup.py b/setup.py index 2097276..0189a21 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setuptools.setup( name = 'appwrite', packages = ['appwrite', 'appwrite/services'], - version = '1.0.0-RC1', + version = '1.0.0', 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', author = 'Appwrite Team', @@ -11,7 +11,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/1.0.0-RC1.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/1.0.0.tar.gz', # keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'], install_requires=[ 'requests',