Skip to content
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

fix: patch updates for appwrite 1.4.1 #70

Merged
merged 1 commit into from
Sep 1, 2023
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
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