Skip to content

Commit e2ff759

Browse files
authored
Merge pull request #70 from appwrite/dev
fix: patch updates for appwrite 1.4.1
2 parents 4746e2d + b63c20f commit e2ff759

File tree

13 files changed

+919
-838
lines changed

13 files changed

+919
-838
lines changed

appwrite/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def __init__(self):
1111
self._endpoint = 'https://HOSTNAME/v1'
1212
self._global_headers = {
1313
'content-type': '',
14-
'user-agent' : 'AppwritePythonSDK/3.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
14+
'user-agent' : 'AppwritePythonSDK/3.0.1 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
1515
'x-sdk-name': 'Python',
1616
'x-sdk-platform': 'server',
1717
'x-sdk-language': 'python',
18-
'x-sdk-version': '3.0.0',
18+
'x-sdk-version': '3.0.1',
1919
'X-Appwrite-Response-Format' : '1.4.0',
2020
}
2121

@@ -170,7 +170,7 @@ def chunked_upload(
170170
input_file.data = input[offset:end]
171171

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

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

187187
if on_progress is not None:
188-
end = min((((counter * self._chunk_size) + self._chunk_size) - 1), size)
188+
end = min((((counter * self._chunk_size) + self._chunk_size) - 1), size - 1)
189189
on_progress({
190190
"$id": result["$id"],
191191
"progress": min(offset, size)/size * 100,

appwrite/role.py

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,111 @@
11
class Role:
2+
"""Helper class to generate role strings for `Permission`."""
23
@staticmethod
34
def any():
5+
"""Grants access to anyone.
6+
7+
This includes authenticated and unauthenticated users.
8+
"""
49
return 'any'
510

611
@staticmethod
712
def user(id, status = ""):
13+
"""Grants access to a specific user by user ID.
14+
15+
You can optionally pass verified or unverified for
16+
`status` to target specific types of users.
17+
18+
Parameters
19+
----------
20+
id : str
21+
status : str, optional
22+
23+
Returns
24+
-------
25+
str
26+
"""
827
if status:
928
return f'user:{id}/{status}'
1029
return f'user:{id}'
1130

1231
@staticmethod
1332
def users(status = ""):
33+
"""Grants access to any authenticated or anonymous user.
34+
35+
You can optionally pass verified or unverified for
36+
`status` to target specific types of users.
37+
38+
Parameters
39+
----------
40+
status : str, optional
41+
42+
Returns
43+
-------
44+
str
45+
"""
1446
if status:
1547
return f'users/{status}'
1648
return 'users'
1749

1850
@staticmethod
1951
def guests():
52+
"""Grants access to any guest user without a session.
53+
54+
Authenticated users don't have access to this role.
55+
56+
Returns
57+
-------
58+
str
59+
"""
2060
return 'guests'
2161

2262
@staticmethod
2363
def team(id, role = ""):
64+
"""Grants access to a team by team ID.
65+
66+
You can optionally pass a role for `role` to target
67+
team members with the specified role.
68+
69+
Parameters
70+
----------
71+
id : str
72+
role : str, optional
73+
74+
Returns
75+
-------
76+
str
77+
"""
2478
if role:
2579
return f'team:{id}/{role}'
2680
return f'team:{id}'
2781

2882
@staticmethod
2983
def member(id):
30-
return f'member:{id}'
84+
"""Grants access to a specific member of a team.
85+
86+
When the member is removed from the team, they will
87+
no longer have access.
88+
89+
Parameters
90+
----------
91+
id : str
92+
93+
Returns
94+
-------
95+
str
96+
"""
97+
return f'member:{id}'
98+
99+
@staticmethod
100+
def label(name):
101+
"""Grants access to a user with the specified label.
102+
103+
Parameters
104+
----------
105+
name : str
106+
107+
Returns
108+
-------
109+
str
110+
"""
111+
return f'label:{name}'

0 commit comments

Comments
 (0)