Skip to content

Commit

Permalink
Update for 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Sep 14, 2022
1 parent e8d6be4 commit 4b687e3
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 33 deletions.
9 changes: 5 additions & 4 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.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)

Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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)
```
Expand Down
4 changes: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions appwrite/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 10 additions & 2 deletions appwrite/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}'
8 changes: 4 additions & 4 deletions appwrite/services/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
10 changes: 5 additions & 5 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',
}, 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"""


Expand All @@ -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',
Expand Down Expand Up @@ -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"""


Expand All @@ -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',
Expand Down Expand Up @@ -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"""


Expand All @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions appwrite/services/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get(self):
'content-type': 'application/json',
}, params)

def get_continents(self):
def list_continents(self):
"""List Continents"""


Expand All @@ -28,7 +28,7 @@ def get_continents(self):
'content-type': 'application/json',
}, params)

def get_countries(self):
def list_countries(self):
"""List Countries"""


Expand All @@ -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"""


Expand All @@ -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"""


Expand All @@ -61,7 +61,7 @@ def get_countries_phones(self):
'content-type': 'application/json',
}, params)

def get_currencies(self):
def list_currencies(self):
"""List Currencies"""


Expand All @@ -72,7 +72,7 @@ def get_currencies(self):
'content-type': 'application/json',
}, params)

def get_languages(self):
def list_languages(self):
"""List Languages"""


Expand Down
4 changes: 2 additions & 2 deletions appwrite/services/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
12 changes: 6 additions & 6 deletions appwrite/services/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
14 changes: 14 additions & 0 deletions docs/examples/account/list-logs.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/account/list-sessions.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-continents.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-countries-e-u.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-countries-phones.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-countries.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-currencies.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/locale/list-languages.md
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions docs/examples/teams/list-memberships.md
Original file line number Diff line number Diff line change
@@ -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]')
Loading

0 comments on commit 4b687e3

Please sign in to comment.