Skip to content

Commit 5b93ea7

Browse files
authored
Merge pull request #135 from appwrite/dev
feat: Python SDK update for version 15.3.0
2 parents 61ca333 + 78f1773 commit 5b93ea7

File tree

13 files changed

+142
-75
lines changed

13 files changed

+142
-75
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 15.3.0
4+
5+
* Added get_console_pausing health endpoint
6+
* Added ttl parameter to list_documents and list_rows for cached responses
7+
* Added optional activate parameter to Sites.create_deployment
8+
* Updated docs and examples to reflect TTL usage and activation
9+
* Updated query filtering docs in Messaging service
10+
311
## 15.2.0
412

513
* Extended BuildRuntime and Runtime enums with new runtime versions (e.g., node-23/24/25, php-8.4, ruby-3.4/4.0, python-3.13/3.14, python-ml-3.13, deno-2.5/2.6, dotnet-10, java-25, swift-6.2, kotlin-2.3, bun-1.2/1.3, go-1.24/1.25/1.26).

appwrite/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def __init__(self):
1515
self._endpoint = 'https://cloud.appwrite.io/v1'
1616
self._global_headers = {
1717
'content-type': '',
18-
'user-agent' : f'AppwritePythonSDK/15.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
18+
'user-agent' : f'AppwritePythonSDK/15.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
1919
'x-sdk-name': 'Python',
2020
'x-sdk-platform': 'server',
2121
'x-sdk-language': 'python',
22-
'x-sdk-version': '15.2.0',
22+
'x-sdk-version': '15.3.0',
2323
'X-Appwrite-Response-Format' : '1.8.0',
2424
}
2525

appwrite/services/databases.py

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def create_boolean_attribute(self, database_id: str, collection_id: str, key: st
718718
database_id : str
719719
Database ID.
720720
collection_id : str
721-
Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
721+
Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
722722
key : str
723723
Attribute Key.
724724
required : bool
@@ -2236,6 +2236,61 @@ def create_relationship_attribute(self, database_id: str, collection_id: str, re
22362236
'content-type': 'application/json',
22372237
}, api_params)
22382238

2239+
@deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.")
2240+
def update_relationship_attribute(self, database_id: str, collection_id: str, key: str, on_delete: Optional[RelationMutate] = None, new_key: Optional[str] = None) -> Dict[str, Any]:
2241+
"""
2242+
Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
2243+
2244+
2245+
.. deprecated::1.8.0
2246+
This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.
2247+
Parameters
2248+
----------
2249+
database_id : str
2250+
Database ID.
2251+
collection_id : str
2252+
Collection ID.
2253+
key : str
2254+
Attribute Key.
2255+
on_delete : Optional[RelationMutate]
2256+
Constraints option
2257+
new_key : Optional[str]
2258+
New Attribute Key.
2259+
2260+
Returns
2261+
-------
2262+
Dict[str, Any]
2263+
API response as a dictionary
2264+
2265+
Raises
2266+
------
2267+
AppwriteException
2268+
If API request fails
2269+
"""
2270+
2271+
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'
2272+
api_params = {}
2273+
if database_id is None:
2274+
raise AppwriteException('Missing required parameter: "database_id"')
2275+
2276+
if collection_id is None:
2277+
raise AppwriteException('Missing required parameter: "collection_id"')
2278+
2279+
if key is None:
2280+
raise AppwriteException('Missing required parameter: "key"')
2281+
2282+
api_path = api_path.replace('{databaseId}', database_id)
2283+
api_path = api_path.replace('{collectionId}', collection_id)
2284+
api_path = api_path.replace('{key}', key)
2285+
2286+
if on_delete is not None:
2287+
api_params['onDelete'] = on_delete
2288+
api_params['newKey'] = new_key
2289+
2290+
return self.client.call('patch', api_path, {
2291+
'content-type': 'application/json',
2292+
}, api_params)
2293+
22392294
@deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_string_column` instead.")
22402295
def create_string_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]:
22412296
"""
@@ -2831,62 +2886,8 @@ def delete_attribute(self, database_id: str, collection_id: str, key: str) -> Di
28312886
'content-type': 'application/json',
28322887
}, api_params)
28332888

2834-
@deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.")
2835-
def update_relationship_attribute(self, database_id: str, collection_id: str, key: str, on_delete: Optional[RelationMutate] = None, new_key: Optional[str] = None) -> Dict[str, Any]:
2836-
"""
2837-
Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes).
2838-
2839-
2840-
.. deprecated::1.8.0
2841-
This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.
2842-
Parameters
2843-
----------
2844-
database_id : str
2845-
Database ID.
2846-
collection_id : str
2847-
Collection ID.
2848-
key : str
2849-
Attribute Key.
2850-
on_delete : Optional[RelationMutate]
2851-
Constraints option
2852-
new_key : Optional[str]
2853-
New Attribute Key.
2854-
2855-
Returns
2856-
-------
2857-
Dict[str, Any]
2858-
API response as a dictionary
2859-
2860-
Raises
2861-
------
2862-
AppwriteException
2863-
If API request fails
2864-
"""
2865-
2866-
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'
2867-
api_params = {}
2868-
if database_id is None:
2869-
raise AppwriteException('Missing required parameter: "database_id"')
2870-
2871-
if collection_id is None:
2872-
raise AppwriteException('Missing required parameter: "collection_id"')
2873-
2874-
if key is None:
2875-
raise AppwriteException('Missing required parameter: "key"')
2876-
2877-
api_path = api_path.replace('{databaseId}', database_id)
2878-
api_path = api_path.replace('{collectionId}', collection_id)
2879-
api_path = api_path.replace('{key}', key)
2880-
2881-
api_params['onDelete'] = on_delete
2882-
api_params['newKey'] = new_key
2883-
2884-
return self.client.call('patch', api_path, {
2885-
'content-type': 'application/json',
2886-
}, api_params)
2887-
28882889
@deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_rows` instead.")
2889-
def list_documents(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]:
2890+
def list_documents(self, database_id: str, collection_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None) -> Dict[str, Any]:
28902891
"""
28912892
Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
28922893
@@ -2904,6 +2905,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional
29042905
Transaction ID to read uncommitted changes within the transaction.
29052906
total : Optional[bool]
29062907
When set to false, the total count returned will be 0 and will not be calculated.
2908+
ttl : Optional[float]
2909+
TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
29072910
29082911
Returns
29092912
-------
@@ -2933,6 +2936,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional
29332936
api_params['transactionId'] = transaction_id
29342937
if total is not None:
29352938
api_params['total'] = total
2939+
if ttl is not None:
2940+
api_params['ttl'] = ttl
29362941

29372942
return self.client.call('get', api_path, {
29382943
}, api_params)

appwrite/services/health.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,40 @@ def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]:
101101
return self.client.call('get', api_path, {
102102
}, api_params)
103103

104+
def get_console_pausing(self, threshold: Optional[float] = None, inactivity_days: Optional[float] = None) -> Dict[str, Any]:
105+
"""
106+
Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking.
107+
108+
109+
Parameters
110+
----------
111+
threshold : Optional[float]
112+
Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10.
113+
inactivity_days : Optional[float]
114+
Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7.
115+
116+
Returns
117+
-------
118+
Dict[str, Any]
119+
API response as a dictionary
120+
121+
Raises
122+
------
123+
AppwriteException
124+
If API request fails
125+
"""
126+
127+
api_path = '/health/console-pausing'
128+
api_params = {}
129+
130+
if threshold is not None:
131+
api_params['threshold'] = threshold
132+
if inactivity_days is not None:
133+
api_params['inactivityDays'] = inactivity_days
134+
135+
return self.client.call('get', api_path, {
136+
}, api_params)
137+
104138
def get_db(self) -> Dict[str, Any]:
105139
"""
106140
Check the Appwrite database servers are up and connection is successful.

appwrite/services/messaging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, s
23072307
topic_id : str
23082308
Topic ID. The topic ID subscribed to.
23092309
queries : Optional[List[str]]
2310-
Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled
2310+
Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: targetId, topicId, userId, providerType
23112311
search : Optional[str]
23122312
Search term to filter your list results. Max length: 256 chars.
23132313
total : Optional[bool]

appwrite/services/sites.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, se
448448
return self.client.call('get', api_path, {
449449
}, api_params)
450450

451-
def create_deployment(self, site_id: str, code: InputFile, activate: bool, install_command: Optional[str] = None, build_command: Optional[str] = None, output_directory: Optional[str] = None, on_progress = None) -> Dict[str, Any]:
451+
def create_deployment(self, site_id: str, code: InputFile, install_command: Optional[str] = None, build_command: Optional[str] = None, output_directory: Optional[str] = None, activate: Optional[bool] = None, on_progress = None) -> Dict[str, Any]:
452452
"""
453453
Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID.
454454
@@ -458,14 +458,14 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta
458458
Site ID.
459459
code : InputFile
460460
Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
461-
activate : bool
462-
Automatically activate the deployment when it is finished building.
463461
install_command : Optional[str]
464462
Install Commands.
465463
build_command : Optional[str]
466464
Build Commands.
467465
output_directory : Optional[str]
468466
Output Directory.
467+
activate : Optional[bool]
468+
Automatically activate the deployment when it is finished building.
469469
on_progress : callable, optional
470470
Optional callback for upload progress
471471
@@ -488,9 +488,6 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta
488488
if code is None:
489489
raise AppwriteException('Missing required parameter: "code"')
490490

491-
if activate is None:
492-
raise AppwriteException('Missing required parameter: "activate"')
493-
494491
api_path = api_path.replace('{siteId}', site_id)
495492

496493
if install_command is not None:
@@ -500,7 +497,8 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta
500497
if output_directory is not None:
501498
api_params['outputDirectory'] = output_directory
502499
api_params['code'] = code
503-
api_params['activate'] = str(activate).lower() if type(activate) is bool else activate
500+
if activate is not None:
501+
api_params['activate'] = str(activate).lower() if type(activate) is bool else activate
504502

505503
param_name = 'code'
506504

appwrite/services/tables_db.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ def delete_index(self, database_id: str, table_id: str, key: str) -> Dict[str, A
29702970
'content-type': 'application/json',
29712971
}, api_params)
29722972

2973-
def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None) -> Dict[str, Any]:
2973+
def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str]] = None, transaction_id: Optional[str] = None, total: Optional[bool] = None, ttl: Optional[float] = None) -> Dict[str, Any]:
29742974
"""
29752975
Get a list of all the user's rows in a given table. You can use the query params to filter your results.
29762976
@@ -2986,6 +2986,8 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str]
29862986
Transaction ID to read uncommitted changes within the transaction.
29872987
total : Optional[bool]
29882988
When set to false, the total count returned will be 0 and will not be calculated.
2989+
ttl : Optional[float]
2990+
TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours).
29892991
29902992
Returns
29912993
-------
@@ -3015,6 +3017,8 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str]
30153017
api_params['transactionId'] = transaction_id
30163018
if total is not None:
30173019
api_params['total'] = total
3020+
if ttl is not None:
3021+
api_params['ttl'] = ttl
30183022

30193023
return self.client.call('get', api_path, {
30203024
}, api_params)

appwrite/services/teams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str]
247247
team_id : str
248248
Team ID.
249249
roles : List[str]
250-
Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
250+
Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.
251251
email : Optional[str]
252252
Email of the new team member.
253253
user_id : Optional[str]
@@ -345,7 +345,7 @@ def update_membership(self, team_id: str, membership_id: str, roles: List[str])
345345
membership_id : str
346346
Membership ID.
347347
roles : List[str]
348-
An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
348+
An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long.
349349
350350
Returns
351351
-------

docs/examples/databases/list-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ result = databases.list_documents(
1414
collection_id = '<COLLECTION_ID>',
1515
queries = [], # optional
1616
transaction_id = '<TRANSACTION_ID>', # optional
17-
total = False # optional
17+
total = False, # optional
18+
ttl = 0 # optional
1819
)
1920
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```python
2+
from appwrite.client import Client
3+
from appwrite.services.health import Health
4+
5+
client = Client()
6+
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
7+
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
8+
client.set_key('<YOUR_API_KEY>') # Your secret API key
9+
10+
health = Health(client)
11+
12+
result = health.get_console_pausing(
13+
threshold = None, # optional
14+
inactivity_days = None # optional
15+
)
16+
```

0 commit comments

Comments
 (0)