Skip to content

Commit 9ca7284

Browse files
committed
chore: update Python SDK to 18.0.0
1 parent aade353 commit 9ca7284

4 files changed

Lines changed: 127 additions & 1 deletion

File tree

appwrite/services/project.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
from ..models.key_list import KeyList;
66
from ..enums.scopes import Scopes;
77
from ..models.key import Key;
8+
from ..models.project import Project as ProjectModel;
89
from ..models.platform_list import PlatformList;
910
from ..models.platform_android import PlatformAndroid;
1011
from ..models.platform_apple import PlatformApple;
1112
from ..models.platform_linux import PlatformLinux;
1213
from ..models.platform_web import PlatformWeb;
1314
from ..models.platform_windows import PlatformWindows;
1415
from ..enums.protocol_id import ProtocolId;
15-
from ..models.project import Project as ProjectModel;
1616
from ..enums.service_id import ServiceId;
1717
from ..models.variable_list import VariableList;
1818
from ..models.variable import Variable;
@@ -249,6 +249,44 @@ def delete_key(
249249
return response
250250

251251

252+
def update_labels(
253+
self,
254+
labels: List[str]
255+
) -> ProjectModel:
256+
"""
257+
Update the project labels. Labels can be used to easily filter projects in an organization.
258+
259+
Parameters
260+
----------
261+
labels : List[str]
262+
Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long.
263+
264+
Returns
265+
-------
266+
ProjectModel
267+
API response as a typed Pydantic model
268+
269+
Raises
270+
------
271+
AppwriteException
272+
If API request fails
273+
"""
274+
275+
api_path = '/project/labels'
276+
api_params = {}
277+
if labels is None:
278+
raise AppwriteException('Missing required parameter: "labels"')
279+
280+
281+
api_params['labels'] = self._normalize_value(labels)
282+
283+
response = self.client.call('put', api_path, {
284+
'content-type': 'application/json',
285+
}, api_params)
286+
287+
return self._parse_response(response, model=ProjectModel)
288+
289+
252290
def list_platforms(
253291
self,
254292
queries: Optional[List[str]] = None,

appwrite/services/users.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,57 @@ def create_jwt(
933933
return self._parse_response(response, model=Jwt)
934934

935935

936+
def update_labels(
937+
self,
938+
user_id: str,
939+
labels: List[str],
940+
model_type: Type[T] = dict
941+
) -> User[T]:
942+
"""
943+
Update the user labels by its unique ID.
944+
945+
Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info.
946+
947+
Parameters
948+
----------
949+
user_id : str
950+
User ID.
951+
labels : List[str]
952+
Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long.
953+
954+
model_type : Type[T], optional
955+
Pydantic model class for the user-defined data. Defaults to dict for backward compatibility.
956+
957+
Returns
958+
-------
959+
User[T]
960+
API response as a typed Pydantic model
961+
962+
Raises
963+
------
964+
AppwriteException
965+
If API request fails
966+
"""
967+
968+
api_path = '/users/{userId}/labels'
969+
api_params = {}
970+
if user_id is None:
971+
raise AppwriteException('Missing required parameter: "user_id"')
972+
973+
if labels is None:
974+
raise AppwriteException('Missing required parameter: "labels"')
975+
976+
api_path = api_path.replace('{userId}', str(self._normalize_value(user_id)))
977+
978+
api_params['labels'] = self._normalize_value(labels)
979+
980+
response = self.client.call('put', api_path, {
981+
'content-type': 'application/json',
982+
}, api_params)
983+
984+
return User.with_data(response, model_type)
985+
986+
936987
def list_logs(
937988
self,
938989
user_id: str,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```python
2+
from appwrite.client import Client
3+
from appwrite.services.project import Project
4+
from appwrite.models import Project as ProjectModel
5+
6+
client = Client()
7+
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
8+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
9+
client.set_key('<YOUR_API_KEY>') # Your secret API key
10+
11+
project = Project(client)
12+
13+
result: ProjectModel = project.update_labels(
14+
labels = []
15+
)
16+
17+
print(result.model_dump())
18+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```python
2+
from appwrite.client import Client
3+
from appwrite.services.users import Users
4+
from appwrite.models import User
5+
6+
client = Client()
7+
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
8+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
9+
client.set_key('<YOUR_API_KEY>') # Your secret API key
10+
11+
users = Users(client)
12+
13+
result: User = users.update_labels(
14+
user_id = '<USER_ID>',
15+
labels = []
16+
)
17+
18+
print(result.model_dump())
19+
```

0 commit comments

Comments
 (0)