Skip to content

Commit

Permalink
Merge pull request #70 from appwrite/dev
Browse files Browse the repository at this point in the history
fix: patch updates for appwrite 1.4.1
  • Loading branch information
abnegate authored Sep 1, 2023
2 parents 4746e2d + b63c20f commit e2ff759
Show file tree
Hide file tree
Showing 13 changed files with 919 additions and 838 deletions.
8 changes: 4 additions & 4 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def __init__(self):
self._endpoint = 'https://HOSTNAME/v1'
self._global_headers = {
'content-type': '',
'user-agent' : 'AppwritePythonSDK/3.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'user-agent' : 'AppwritePythonSDK/3.0.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': '3.0.0',
'x-sdk-version': '3.0.1',
'X-Appwrite-Response-Format' : '1.4.0',
}

Expand Down Expand Up @@ -170,7 +170,7 @@ def chunked_upload(
input_file.data = input[offset:end]

params[param_name] = input_file
headers["content-range"] = f'bytes {offset}-{min((offset + self._chunk_size) - 1, size)}/{size}'
headers["content-range"] = f'bytes {offset}-{min((offset + self._chunk_size) - 1, size - 1)}/{size}'

result = self.call(
'post',
Expand All @@ -185,7 +185,7 @@ def chunked_upload(
headers["x-appwrite-id"] = result["$id"]

if on_progress is not None:
end = min((((counter * self._chunk_size) + self._chunk_size) - 1), size)
end = min((((counter * self._chunk_size) + self._chunk_size) - 1), size - 1)
on_progress({
"$id": result["$id"],
"progress": min(offset, size)/size * 100,
Expand Down
83 changes: 82 additions & 1 deletion appwrite/role.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,111 @@
class Role:
"""Helper class to generate role strings for `Permission`."""
@staticmethod
def any():
"""Grants access to anyone.
This includes authenticated and unauthenticated users.
"""
return 'any'

@staticmethod
def user(id, status = ""):
"""Grants access to a specific user by user ID.
You can optionally pass verified or unverified for
`status` to target specific types of users.
Parameters
----------
id : str
status : str, optional
Returns
-------
str
"""
if status:
return f'user:{id}/{status}'
return f'user:{id}'

@staticmethod
def users(status = ""):
"""Grants access to any authenticated or anonymous user.
You can optionally pass verified or unverified for
`status` to target specific types of users.
Parameters
----------
status : str, optional
Returns
-------
str
"""
if status:
return f'users/{status}'
return 'users'

@staticmethod
def guests():
"""Grants access to any guest user without a session.
Authenticated users don't have access to this role.
Returns
-------
str
"""
return 'guests'

@staticmethod
def team(id, role = ""):
"""Grants access to a team by team ID.
You can optionally pass a role for `role` to target
team members with the specified role.
Parameters
----------
id : str
role : str, optional
Returns
-------
str
"""
if role:
return f'team:{id}/{role}'
return f'team:{id}'

@staticmethod
def member(id):
return f'member:{id}'
"""Grants access to a specific member of a team.
When the member is removed from the team, they will
no longer have access.
Parameters
----------
id : str
Returns
-------
str
"""
return f'member:{id}'

@staticmethod
def label(name):
"""Grants access to a user with the specified label.
Parameters
----------
name : str
Returns
-------
str
"""
return f'label:{name}'
Loading

0 comments on commit e2ff759

Please sign in to comment.