diff --git a/CHANGELOG.md b/CHANGELOG.md index d98302c..fcd422a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 15.3.0 + +* Added get_console_pausing health endpoint +* Added ttl parameter to list_documents and list_rows for cached responses +* Added optional activate parameter to Sites.create_deployment +* Updated docs and examples to reflect TTL usage and activation +* Updated query filtering docs in Messaging service + ## 15.2.0 * 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). diff --git a/appwrite/client.py b/appwrite/client.py index 629e335..57a7bd0 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,11 +15,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/15.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/15.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '15.2.0', + 'x-sdk-version': '15.3.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 76dd142..376d723 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -718,7 +718,7 @@ def create_boolean_attribute(self, database_id: str, collection_id: str, key: st database_id : str Database ID. collection_id : str - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). key : str Attribute Key. required : bool @@ -2236,6 +2236,61 @@ def create_relationship_attribute(self, database_id: str, collection_id: str, re 'content-type': 'application/json', }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.") + 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]: + """ + Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + key : str + Attribute Key. + on_delete : Optional[RelationMutate] + Constraints option + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + if on_delete is not None: + api_params['onDelete'] = on_delete + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_string_column` instead.") 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]: """ @@ -2831,62 +2886,8 @@ def delete_attribute(self, database_id: str, collection_id: str, key: str) -> Di 'content-type': 'application/json', }, api_params) - @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead.") - 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]: - """ - Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - - - .. deprecated::1.8.0 - This API has been deprecated since 1.8.0. Please use `tablesDB.update_relationship_column` instead. - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - key : str - Attribute Key. - on_delete : Optional[RelationMutate] - Constraints option - new_key : Optional[str] - New Attribute Key. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - if collection_id is None: - raise AppwriteException('Missing required parameter: "collection_id"') - - if key is None: - raise AppwriteException('Missing required parameter: "key"') - - api_path = api_path.replace('{databaseId}', database_id) - api_path = api_path.replace('{collectionId}', collection_id) - api_path = api_path.replace('{key}', key) - - api_params['onDelete'] = on_delete - api_params['newKey'] = new_key - - return self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.list_rows` instead.") - 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]: + 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]: """ Get a list of all the user's documents in a given collection. You can use the query params to filter your results. @@ -2904,6 +2905,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional Transaction ID to read uncommitted changes within the transaction. total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. + ttl : Optional[float] + TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). Returns ------- @@ -2933,6 +2936,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional api_params['transactionId'] = transaction_id if total is not None: api_params['total'] = total + if ttl is not None: + api_params['ttl'] = ttl return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/health.py b/appwrite/services/health.py index fd01701..b0ba18b 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -101,6 +101,40 @@ def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) + def get_console_pausing(self, threshold: Optional[float] = None, inactivity_days: Optional[float] = None) -> Dict[str, Any]: + """ + Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. + + + Parameters + ---------- + threshold : Optional[float] + Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10. + inactivity_days : Optional[float] + Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/console-pausing' + api_params = {} + + if threshold is not None: + api_params['threshold'] = threshold + if inactivity_days is not None: + api_params['inactivityDays'] = inactivity_days + + return self.client.call('get', api_path, { + }, api_params) + def get_db(self) -> Dict[str, Any]: """ Check the Appwrite database servers are up and connection is successful. diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index 4a5564b..b412775 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -2307,7 +2307,7 @@ def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, s topic_id : str Topic ID. The topic ID subscribed to. queries : Optional[List[str]] - 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 + 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 search : Optional[str] Search term to filter your list results. Max length: 256 chars. total : Optional[bool] diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 292e696..8567479 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -448,7 +448,7 @@ def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, se return self.client.call('get', api_path, { }, api_params) - 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]: + 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]: """ 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. @@ -458,14 +458,14 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta Site ID. code : InputFile 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. - activate : bool - Automatically activate the deployment when it is finished building. install_command : Optional[str] Install Commands. build_command : Optional[str] Build Commands. output_directory : Optional[str] Output Directory. + activate : Optional[bool] + Automatically activate the deployment when it is finished building. on_progress : callable, optional Optional callback for upload progress @@ -488,9 +488,6 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta if code is None: raise AppwriteException('Missing required parameter: "code"') - if activate is None: - raise AppwriteException('Missing required parameter: "activate"') - api_path = api_path.replace('{siteId}', site_id) if install_command is not None: @@ -500,7 +497,8 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta if output_directory is not None: api_params['outputDirectory'] = output_directory api_params['code'] = code - api_params['activate'] = str(activate).lower() if type(activate) is bool else activate + if activate is not None: + api_params['activate'] = str(activate).lower() if type(activate) is bool else activate param_name = 'code' diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index ee73241..08dc69b 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -2970,7 +2970,7 @@ def delete_index(self, database_id: str, table_id: str, key: str) -> Dict[str, A 'content-type': 'application/json', }, api_params) - 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]: + 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]: """ Get a list of all the user's rows in a given table. You can use the query params to filter your results. @@ -2986,6 +2986,8 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str] Transaction ID to read uncommitted changes within the transaction. total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. + ttl : Optional[float] + TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). Returns ------- @@ -3015,6 +3017,8 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str] api_params['transactionId'] = transaction_id if total is not None: api_params['total'] = total + if ttl is not None: + api_params['ttl'] = ttl return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 1e15296..767dab9 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -247,7 +247,7 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str] team_id : str Team ID. roles : List[str] - 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. + 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. email : Optional[str] Email of the new team member. user_id : Optional[str] @@ -345,7 +345,7 @@ def update_membership(self, team_id: str, membership_id: str, roles: List[str]) membership_id : str Membership ID. roles : List[str] - 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. + 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. Returns ------- diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 11ce444..ea3fe1a 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -14,6 +14,7 @@ result = databases.list_documents( collection_id = '', queries = [], # optional transaction_id = '', # optional - total = False # optional + total = False, # optional + ttl = 0 # optional ) ``` diff --git a/docs/examples/health/get-console-pausing.md b/docs/examples/health/get-console-pausing.md new file mode 100644 index 0000000..884a445 --- /dev/null +++ b/docs/examples/health/get-console-pausing.md @@ -0,0 +1,16 @@ +```python +from appwrite.client import Client +from appwrite.services.health import Health + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +health = Health(client) + +result = health.get_console_pausing( + threshold = None, # optional + inactivity_days = None # optional +) +``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index dc411f0..7d7c25b 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -13,9 +13,9 @@ sites = Sites(client) result = sites.create_deployment( site_id = '', code = InputFile.from_path('file.png'), - activate = False, install_command = '', # optional build_command = '', # optional - output_directory = '' # optional + output_directory = '', # optional + activate = False # optional ) ``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 150ff6d..b616d1a 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -14,6 +14,7 @@ result = tables_db.list_rows( table_id = '', queries = [], # optional transaction_id = '', # optional - total = False # optional + total = False, # optional + ttl = 0 # optional ) ``` diff --git a/setup.py b/setup.py index ba6249b..8446427 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '15.2.0', + version = '15.3.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -18,7 +18,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/15.2.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/15.3.0.tar.gz', install_requires=[ 'requests', ],