Skip to content

updated to support 1.0.0-RC1 #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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-0.15.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-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 0.15.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.0.0-RC1. 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
7 changes: 5 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ def __init__(self):
self._endpoint = 'https://HOSTNAME/v1'
self._global_headers = {
'content-type': '',
'x-sdk-version': 'appwrite:python:0.10.0',
'X-Appwrite-Response-Format' : '0.15.0',
'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',
}

def set_self_signed(self, status=True):
Expand Down
8 changes: 8 additions & 0 deletions appwrite/id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ID:
@staticmethod
def custom(id):
return id

@staticmethod
def unique():
return 'unique()'
21 changes: 21 additions & 0 deletions appwrite/permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Permission:

@staticmethod
def read(role):
return f'read("{role}")'

@staticmethod
def write(role):
return f'write("{role}")'

@staticmethod
def create(role):
return f'create("{role}")'

@staticmethod
def update(role):
return f'update("{role}")'

@staticmethod
def delete(role):
return f'delete("{role}")'
50 changes: 37 additions & 13 deletions appwrite/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,59 @@ def notEqual(attribute, value):
return Query.addQuery(attribute, "notEqual", value)

@staticmethod
def lesser(attribute, value):
return Query.addQuery(attribute, "lesser", value)
def lessThan(attribute, value):
return Query.addQuery(attribute, "lessThan", value)

@staticmethod
def lesserEqual(attribute, value):
return Query.addQuery(attribute, "lesserEqual", value)
def lessThanEqual(attribute, value):
return Query.addQuery(attribute, "lessThanEqual", value)

@staticmethod
def greater(attribute, value):
return Query.addQuery(attribute, "greater", value)
def greaterThan(attribute, value):
return Query.addQuery(attribute, "greaterThan", value)

@staticmethod
def greaterEqual(attribute, value):
return Query.addQuery(attribute, "greaterEqual", value)
def greaterThanEqual(attribute, value):
return Query.addQuery(attribute, "greaterThanEqual", value)

@staticmethod
def search(attribute, value):
return Query.addQuery(attribute, "search", value)

@staticmethod
def addQuery(attribute, oper, value):
def orderAsc(attribute):
return f'orderAsc("{attribute}")'

@staticmethod
def orderDesc(attribute):
return f'orderDesc("{attribute}")'

@staticmethod
def cursorBefore(id):
return f'cursorBefore("{id}")'

@staticmethod
def cursorAfter(id):
return f'cursorAfter("{id}")'

@staticmethod
def limit(limit):
return f'limit({limit})'

@staticmethod
def offset(offset):
return f'offset({offset})'

@staticmethod
def addQuery(attribute, method, value):
if type(value) == list:
return '{}.{}({})'.format(attribute,oper, ','.join(map(Query.parseValues, value)))
return f'{method}("{attribute}", [{",".join(map(Query.parseValues, value))}])'
else:
return '{}.{}({})'.format(attribute,oper, Query.parseValues(value))
return f'{method}("{attribute}", [{Query.parseValues(value)}])'

@staticmethod
def parseValues(value):
if type(value) == str:
return '"{}"'.format(value)
return f'"{value}"'
else:
return value
return str(value)
26 changes: 26 additions & 0 deletions appwrite/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Role:
@staticmethod
def any():
return 'any'

@staticmethod
def user(id):
return f'user:{id}'

@staticmethod
def users():
return 'users'

@staticmethod
def guests():
return 'guests'

@staticmethod
def team(id, role = ""):
if role:
return f'team:{id}/{role}'
return f'team:{id}'

@staticmethod
def status(status):
return f'status:{status}'
Loading