From 865f337dde2427c629ed1567608e606632b872d7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Oct 2025 04:27:32 +0000 Subject: [PATCH 1/2] testing --- appwrite/client.py | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appwrite/client.py b/appwrite/client.py index 8240727..bc054e6 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/13.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/13.3.1 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '13.3.0', + 'x-sdk-version': '13.3.1', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/setup.py b/setup.py index 6eef569..8cd303b 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '13.3.0', + version = '13.3.1', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/13.3.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.3.1.tar.gz', install_requires=[ 'requests', ], From a09cbbaa0d92092cf6161601efa3fbc213f58e72 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 9 Oct 2025 20:22:59 +1300 Subject: [PATCH 2/2] Add transactions --- CHANGELOG.md | 4 + appwrite/client.py | 4 +- appwrite/services/databases.py | 255 +++++++++++++++++- appwrite/services/tables_db.py | 253 ++++++++++++++++- docs/examples/databases/create-document.md | 3 +- docs/examples/databases/create-documents.md | 3 +- docs/examples/databases/create-operations.md | 24 ++ docs/examples/databases/create-transaction.md | 13 + .../databases/decrement-document-attribute.md | 3 +- docs/examples/databases/delete-document.md | 3 +- docs/examples/databases/delete-documents.md | 3 +- docs/examples/databases/delete-transaction.md | 13 + docs/examples/databases/get-document.md | 3 +- docs/examples/databases/get-transaction.md | 13 + .../databases/increment-document-attribute.md | 3 +- docs/examples/databases/list-documents.md | 3 +- docs/examples/databases/list-transactions.md | 13 + docs/examples/databases/update-document.md | 3 +- docs/examples/databases/update-documents.md | 3 +- docs/examples/databases/update-transaction.md | 15 ++ docs/examples/databases/upsert-document.md | 3 +- docs/examples/databases/upsert-documents.md | 3 +- docs/examples/messaging/create-push.md | 2 +- docs/examples/messaging/update-push.md | 2 +- docs/examples/tablesdb/create-operations.md | 24 ++ docs/examples/tablesdb/create-row.md | 3 +- docs/examples/tablesdb/create-rows.md | 3 +- docs/examples/tablesdb/create-transaction.md | 13 + .../examples/tablesdb/decrement-row-column.md | 3 +- docs/examples/tablesdb/delete-row.md | 3 +- docs/examples/tablesdb/delete-rows.md | 3 +- docs/examples/tablesdb/delete-transaction.md | 13 + docs/examples/tablesdb/get-row.md | 3 +- docs/examples/tablesdb/get-transaction.md | 13 + .../examples/tablesdb/increment-row-column.md | 3 +- docs/examples/tablesdb/list-rows.md | 3 +- docs/examples/tablesdb/list-transactions.md | 13 + docs/examples/tablesdb/update-row.md | 3 +- docs/examples/tablesdb/update-rows.md | 3 +- docs/examples/tablesdb/update-transaction.md | 15 ++ docs/examples/tablesdb/upsert-row.md | 3 +- docs/examples/tablesdb/upsert-rows.md | 3 +- setup.py | 4 +- 43 files changed, 723 insertions(+), 55 deletions(-) create mode 100644 docs/examples/databases/create-operations.md create mode 100644 docs/examples/databases/create-transaction.md create mode 100644 docs/examples/databases/delete-transaction.md create mode 100644 docs/examples/databases/get-transaction.md create mode 100644 docs/examples/databases/list-transactions.md create mode 100644 docs/examples/databases/update-transaction.md create mode 100644 docs/examples/tablesdb/create-operations.md create mode 100644 docs/examples/tablesdb/create-transaction.md create mode 100644 docs/examples/tablesdb/delete-transaction.md create mode 100644 docs/examples/tablesdb/get-transaction.md create mode 100644 docs/examples/tablesdb/list-transactions.md create mode 100644 docs/examples/tablesdb/update-transaction.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 584aa5c..1c24624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 13.4.0 + +* Add transaction support for Databases and TablesDB + ## 13.3.0 * Deprecate `createVerification` method in `Account` service diff --git a/appwrite/client.py b/appwrite/client.py index bc054e6..5213678 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/13.3.1 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/13.4.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': '13.3.1', + 'x-sdk-version': '13.4.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 708cbe6..0af913f 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -87,6 +87,199 @@ def create(self, database_id: str, name: str, enabled: bool = None) -> Dict[str, 'content-type': 'application/json', }, api_params) + def list_transactions(self, queries: List[str] = None) -> Dict[str, Any]: + """ + List transactions across all databases. + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions' + api_params = {} + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_transaction(self, ttl: float = None) -> Dict[str, Any]: + """ + Create a new transaction. + + Parameters + ---------- + ttl : float + Seconds before the transaction expires. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions' + api_params = {} + + api_params['ttl'] = ttl + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_transaction(self, transaction_id: str) -> Dict[str, Any]: + """ + Get a transaction by its unique ID. + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_transaction(self, transaction_id: str, commit: bool = None, rollback: bool = None) -> Dict[str, Any]: + """ + Update a transaction, to either commit or roll back its operations. + + Parameters + ---------- + transaction_id : str + Transaction ID. + commit : bool + Commit transaction? + rollback : bool + Rollback transaction? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + api_params['commit'] = commit + api_params['rollback'] = rollback + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: + """ + Delete a transaction by its unique ID. + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_operations(self, transaction_id: str, operations: List[dict] = None) -> Dict[str, Any]: + """ + Create multiple operations in a single transaction. + + Parameters + ---------- + transaction_id : str + Transaction ID. + operations : List[dict] + Array of staged operations. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/transactions/{transactionId}/operations' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + api_params['operations'] = operations + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + def get(self, database_id: str) -> Dict[str, Any]: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -2122,7 +2315,7 @@ def update_relationship_attribute(self, database_id: str, collection_id: str, ke 'content-type': 'application/json', }, api_params) - def list_documents(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + def list_documents(self, database_id: str, collection_id: str, queries: List[str] = None, transaction_id: str = 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. @@ -2136,6 +2329,8 @@ def list_documents(self, database_id: str, collection_id: str, queries: List[str Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). queries : 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. + transaction_id : str + Transaction ID to read uncommitted changes within the transaction. Returns ------- @@ -2160,11 +2355,12 @@ def list_documents(self, database_id: str, collection_id: str, queries: List[str api_path = api_path.replace('{collectionId}', collection_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) - def create_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: + def create_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2182,6 +2378,8 @@ def create_document(self, database_id: str, collection_id: str, document_id: str Document data as JSON object. permissions : List[str] An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2214,12 +2412,13 @@ def create_document(self, database_id: str, collection_id: str, document_id: str api_params['documentId'] = document_id api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]: + def create_documents(self, database_id: str, collection_id: str, documents: List[dict], transaction_id: str = None) -> Dict[str, Any]: """ Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2233,6 +2432,8 @@ def create_documents(self, database_id: str, collection_id: str, documents: List Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. documents : List[dict] Array of documents data as JSON objects. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2260,12 +2461,13 @@ def create_documents(self, database_id: str, collection_id: str, documents: List api_path = api_path.replace('{collectionId}', collection_id) api_params['documents'] = documents + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict]) -> Dict[str, Any]: + def upsert_documents(self, database_id: str, collection_id: str, documents: List[dict], transaction_id: str = None) -> Dict[str, Any]: """ Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2280,6 +2482,8 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List Collection ID. documents : List[dict] Array of document data as JSON objects. May contain partial documents. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2307,12 +2511,13 @@ def upsert_documents(self, database_id: str, collection_id: str, documents: List api_path = api_path.replace('{collectionId}', collection_id) api_params['documents'] = documents + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_documents(self, database_id: str, collection_id: str, data: dict = None, queries: List[str] = None) -> Dict[str, Any]: + def update_documents(self, database_id: str, collection_id: str, data: dict = None, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. @@ -2328,6 +2533,8 @@ def update_documents(self, database_id: str, collection_id: str, data: dict = No Document data as JSON object. Include only attribute and value pairs to be updated. queries : 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. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2353,12 +2560,13 @@ def update_documents(self, database_id: str, collection_id: str, data: dict = No api_params['data'] = data api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_documents(self, database_id: str, collection_id: str, queries: List[str] = None) -> Dict[str, Any]: + def delete_documents(self, database_id: str, collection_id: str, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Bulk delete documents using queries, if no queries are passed then all documents are deleted. @@ -2372,6 +2580,8 @@ def delete_documents(self, database_id: str, collection_id: str, queries: List[s Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). queries : 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. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2396,12 +2606,13 @@ def delete_documents(self, database_id: str, collection_id: str, queries: List[s api_path = api_path.replace('{collectionId}', collection_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_document(self, database_id: str, collection_id: str, document_id: str, queries: List[str] = None) -> Dict[str, Any]: + def get_document(self, database_id: str, collection_id: str, document_id: str, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Get a document by its unique ID. This endpoint response returns a JSON object with the document data. @@ -2417,6 +2628,8 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q Document ID. queries : 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. + transaction_id : str + Transaction ID to read uncommitted changes within the transaction. Returns ------- @@ -2445,11 +2658,12 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q api_path = api_path.replace('{documentId}', document_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) - def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: + def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2467,6 +2681,8 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str Document data as JSON object. Include all required attributes of the document to be created or updated. permissions : List[str] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2499,12 +2715,13 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_document(self, database_id: str, collection_id: str, document_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]: + def update_document(self, database_id: str, collection_id: str, document_id: str, data: dict = None, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -2522,6 +2739,8 @@ def update_document(self, database_id: str, collection_id: str, document_id: str Document data as JSON object. Include only attribute and value pairs to be updated. permissions : List[str] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2551,12 +2770,13 @@ def update_document(self, database_id: str, collection_id: str, document_id: str api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_document(self, database_id: str, collection_id: str, document_id: str) -> Dict[str, Any]: + def delete_document(self, database_id: str, collection_id: str, document_id: str, transaction_id: str = None) -> Dict[str, Any]: """ Delete a document by its unique ID. @@ -2570,6 +2790,8 @@ def delete_document(self, database_id: str, collection_id: str, document_id: str Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). document_id : str Document ID. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2597,12 +2819,13 @@ def delete_document(self, database_id: str, collection_id: str, document_id: str api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{documentId}', document_id) + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def decrement_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, min: float = None) -> Dict[str, Any]: + def decrement_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, min: float = None, transaction_id: str = None) -> Dict[str, Any]: """ Decrement a specific attribute of a document by a given value. @@ -2622,6 +2845,8 @@ def decrement_document_attribute(self, database_id: str, collection_id: str, doc Value to increment the attribute by. The value must be a number. min : float Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2655,12 +2880,13 @@ def decrement_document_attribute(self, database_id: str, collection_id: str, doc api_params['value'] = value api_params['min'] = min + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def increment_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, max: float = None) -> Dict[str, Any]: + def increment_document_attribute(self, database_id: str, collection_id: str, document_id: str, attribute: str, value: float = None, max: float = None, transaction_id: str = None) -> Dict[str, Any]: """ Increment a specific attribute of a document by a given value. @@ -2680,6 +2906,8 @@ def increment_document_attribute(self, database_id: str, collection_id: str, doc Value to increment the attribute by. The value must be a number. max : float Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2713,6 +2941,7 @@ def increment_document_attribute(self, database_id: str, collection_id: str, doc api_params['value'] = value api_params['max'] = max + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2827,7 +3056,7 @@ def create_index(self, database_id: str, collection_id: str, key: str, type: Ind def get_index(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: """ - Get index by ID. + Get an index by its unique ID. .. deprecated::1.8.0 This API has been deprecated since 1.8.0. Please use `tablesDB.get_index` instead. diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index ec65274..03852dc 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -83,6 +83,199 @@ def create(self, database_id: str, name: str, enabled: bool = None) -> Dict[str, 'content-type': 'application/json', }, api_params) + def list_transactions(self, queries: List[str] = None) -> Dict[str, Any]: + """ + List transactions across all databases. + + Parameters + ---------- + queries : List[str] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions' + api_params = {} + + api_params['queries'] = queries + + return self.client.call('get', api_path, { + }, api_params) + + def create_transaction(self, ttl: float = None) -> Dict[str, Any]: + """ + Create a new transaction. + + Parameters + ---------- + ttl : float + Seconds before the transaction expires. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions' + api_params = {} + + api_params['ttl'] = ttl + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def get_transaction(self, transaction_id: str) -> Dict[str, Any]: + """ + Get a transaction by its unique ID. + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + + return self.client.call('get', api_path, { + }, api_params) + + def update_transaction(self, transaction_id: str, commit: bool = None, rollback: bool = None) -> Dict[str, Any]: + """ + Update a transaction, to either commit or roll back its operations. + + Parameters + ---------- + transaction_id : str + Transaction ID. + commit : bool + Commit transaction? + rollback : bool + Rollback transaction? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + api_params['commit'] = commit + api_params['rollback'] = rollback + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def delete_transaction(self, transaction_id: str) -> Dict[str, Any]: + """ + Delete a transaction by its unique ID. + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + + return self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_operations(self, transaction_id: str, operations: List[dict] = None) -> Dict[str, Any]: + """ + Create multiple operations in a single transaction. + + Parameters + ---------- + transaction_id : str + Transaction ID. + operations : List[dict] + Array of staged operations. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/transactions/{transactionId}/operations' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', transaction_id) + + api_params['operations'] = operations + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + def get(self, database_id: str) -> Dict[str, Any]: """ Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. @@ -2233,7 +2426,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: List[str] = None) -> Dict[str, Any]: + def list_rows(self, database_id: str, table_id: str, queries: List[str] = None, transaction_id: str = 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. @@ -2245,6 +2438,8 @@ def list_rows(self, database_id: str, table_id: str, queries: List[str] = None) Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). queries : 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. + transaction_id : str + Transaction ID to read uncommitted changes within the transaction. Returns ------- @@ -2269,11 +2464,12 @@ def list_rows(self, database_id: str, table_id: str, queries: List[str] = None) api_path = api_path.replace('{tableId}', table_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) - def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: + def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -2289,6 +2485,8 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p Row data as JSON object. permissions : List[str] An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2321,12 +2519,13 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p api_params['rowId'] = row_id api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def create_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict[str, Any]: + def create_rows(self, database_id: str, table_id: str, rows: List[dict], transaction_id: str = None) -> Dict[str, Any]: """ Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -2338,6 +2537,8 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. rows : List[dict] Array of rows data as JSON objects. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2365,12 +2566,13 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict api_path = api_path.replace('{tableId}', table_id) api_params['rows'] = rows + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) - def upsert_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict[str, Any]: + def upsert_rows(self, database_id: str, table_id: str, rows: List[dict], transaction_id: str = None) -> Dict[str, Any]: """ Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -2383,6 +2585,8 @@ def upsert_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict Table ID. rows : List[dict] Array of row data as JSON objects. May contain partial rows. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2410,12 +2614,13 @@ def upsert_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict api_path = api_path.replace('{tableId}', table_id) api_params['rows'] = rows + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_rows(self, database_id: str, table_id: str, data: dict = None, queries: List[str] = None) -> Dict[str, Any]: + def update_rows(self, database_id: str, table_id: str, data: dict = None, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. @@ -2429,6 +2634,8 @@ def update_rows(self, database_id: str, table_id: str, data: dict = None, querie Row data as JSON object. Include only column and value pairs to be updated. queries : 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. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2454,12 +2661,13 @@ def update_rows(self, database_id: str, table_id: str, data: dict = None, querie api_params['data'] = data api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_rows(self, database_id: str, table_id: str, queries: List[str] = None) -> Dict[str, Any]: + def delete_rows(self, database_id: str, table_id: str, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Bulk delete rows using queries, if no queries are passed then all rows are deleted. @@ -2471,6 +2679,8 @@ def delete_rows(self, database_id: str, table_id: str, queries: List[str] = None Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). queries : 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. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2495,12 +2705,13 @@ def delete_rows(self, database_id: str, table_id: str, queries: List[str] = None api_path = api_path.replace('{tableId}', table_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[str] = None) -> Dict[str, Any]: + def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Get a row by its unique ID. This endpoint response returns a JSON object with the row data. @@ -2514,6 +2725,8 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[st Row ID. queries : 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. + transaction_id : str + Transaction ID to read uncommitted changes within the transaction. Returns ------- @@ -2542,11 +2755,12 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[st api_path = api_path.replace('{rowId}', row_id) api_params['queries'] = queries + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) - def upsert_row(self, database_id: str, table_id: str, row_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]: + def upsert_row(self, database_id: str, table_id: str, row_id: str, data: dict = None, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -2562,6 +2776,8 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: dict = Row data as JSON object. Include all required columns of the row to be created or updated. permissions : List[str] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2591,12 +2807,13 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: dict = api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', }, api_params) - def update_row(self, database_id: str, table_id: str, row_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]: + def update_row(self, database_id: str, table_id: str, row_id: str, data: dict = None, permissions: List[str] = None, transaction_id: str = None) -> Dict[str, Any]: """ Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -2612,6 +2829,8 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: dict = Row data as JSON object. Include only columns and value pairs to be updated. permissions : List[str] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2641,12 +2860,13 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: dict = api_params['data'] = data api_params['permissions'] = permissions + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def delete_row(self, database_id: str, table_id: str, row_id: str) -> Dict[str, Any]: + def delete_row(self, database_id: str, table_id: str, row_id: str, transaction_id: str = None) -> Dict[str, Any]: """ Delete a row by its unique ID. @@ -2658,6 +2878,8 @@ def delete_row(self, database_id: str, table_id: str, row_id: str) -> Dict[str, Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). row_id : str Row ID. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2685,12 +2907,13 @@ def delete_row(self, database_id: str, table_id: str, row_id: str) -> Dict[str, api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{rowId}', row_id) + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', }, api_params) - def decrement_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: float = None, min: float = None) -> Dict[str, Any]: + def decrement_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: float = None, min: float = None, transaction_id: str = None) -> Dict[str, Any]: """ Decrement a specific column of a row by a given value. @@ -2708,6 +2931,8 @@ def decrement_row_column(self, database_id: str, table_id: str, row_id: str, col Value to increment the column by. The value must be a number. min : float Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2741,12 +2966,13 @@ def decrement_row_column(self, database_id: str, table_id: str, row_id: str, col api_params['value'] = value api_params['min'] = min + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', }, api_params) - def increment_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: float = None, max: float = None) -> Dict[str, Any]: + def increment_row_column(self, database_id: str, table_id: str, row_id: str, column: str, value: float = None, max: float = None, transaction_id: str = None) -> Dict[str, Any]: """ Increment a specific column of a row by a given value. @@ -2764,6 +2990,8 @@ def increment_row_column(self, database_id: str, table_id: str, row_id: str, col Value to increment the column by. The value must be a number. max : float Maximum value for the column. If the current value is greater than this value, an error will be thrown. + transaction_id : str + Transaction ID for staging the operation. Returns ------- @@ -2797,6 +3025,7 @@ def increment_row_column(self, database_id: str, table_id: str, row_id: str, col api_params['value'] = value api_params['max'] = max + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 3d7dee1..f42a3d8 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -19,5 +19,6 @@ result = databases.create_document( "age": 30, "isAdmin": False }, - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 1b94e51..97fa4c6 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -11,5 +11,6 @@ databases = Databases(client) result = databases.create_documents( database_id = '', collection_id = '', - documents = [] + documents = [], + transaction_id = '' # optional ) diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md new file mode 100644 index 0000000..d8fc1fa --- /dev/null +++ b/docs/examples/databases/create-operations.md @@ -0,0 +1,24 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_operations( + transaction_id = '', + operations = [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] # optional +) diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md new file mode 100644 index 0000000..a733b65 --- /dev/null +++ b/docs/examples/databases/create-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_transaction( + ttl = 60 # optional +) diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md index 3efedf7..09ed9fc 100644 --- a/docs/examples/databases/decrement-document-attribute.md +++ b/docs/examples/databases/decrement-document-attribute.md @@ -14,5 +14,6 @@ result = databases.decrement_document_attribute( document_id = '', attribute = '', value = None, # optional - min = None # optional + min = None, # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 57f8b3b..89d8585 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -11,5 +11,6 @@ databases = Databases(client) result = databases.delete_document( database_id = '', collection_id = '', - document_id = '' + document_id = '', + transaction_id = '' # optional ) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index a315f0c..63130fb 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -11,5 +11,6 @@ databases = Databases(client) result = databases.delete_documents( database_id = '', collection_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md new file mode 100644 index 0000000..fab1f2a --- /dev/null +++ b/docs/examples/databases/delete-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.delete_transaction( + transaction_id = '' +) diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index aff5008..6cd0bc2 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -12,5 +12,6 @@ result = databases.get_document( database_id = '', collection_id = '', document_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md new file mode 100644 index 0000000..2a89f3d --- /dev/null +++ b/docs/examples/databases/get-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.get_transaction( + transaction_id = '' +) diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md index 9ae1ced..3e85656 100644 --- a/docs/examples/databases/increment-document-attribute.md +++ b/docs/examples/databases/increment-document-attribute.md @@ -14,5 +14,6 @@ result = databases.increment_document_attribute( document_id = '', attribute = '', value = None, # optional - max = None # optional + max = None, # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 8b450cd..cecac30 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -11,5 +11,6 @@ databases = Databases(client) result = databases.list_documents( database_id = '', collection_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md new file mode 100644 index 0000000..a410c96 --- /dev/null +++ b/docs/examples/databases/list-transactions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.list_transactions( + queries = [] # optional +) diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 9ef6527..c9ef02f 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -13,5 +13,6 @@ result = databases.update_document( collection_id = '', document_id = '', data = {}, # optional - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 5a50d1a..2aab8c6 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -12,5 +12,6 @@ result = databases.update_documents( database_id = '', collection_id = '', data = {}, # optional - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md new file mode 100644 index 0000000..571f98c --- /dev/null +++ b/docs/examples/databases/update-transaction.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional +) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index c491ea4..e1a2f44 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -13,5 +13,6 @@ result = databases.upsert_document( collection_id = '', document_id = '', data = {}, - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 5136d5f..f0720e3 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -11,5 +11,6 @@ databases = Databases(client) result = databases.upsert_documents( database_id = '', collection_id = '', - documents = [] + documents = [], + transaction_id = '' # optional ) diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 8671b56..b706234 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -17,7 +17,7 @@ result = messaging.create_push( targets = [], # optional data = {}, # optional action = '', # optional - image = '[ID1:ID2]', # optional + image = '', # optional icon = '', # optional sound = '', # optional color = '', # optional diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index e3bb02e..ce5d394 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -17,7 +17,7 @@ result = messaging.update_push( body = '', # optional data = {}, # optional action = '', # optional - image = '[ID1:ID2]', # optional + image = '', # optional icon = '', # optional sound = '', # optional color = '', # optional diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md new file mode 100644 index 0000000..a4881a9 --- /dev/null +++ b/docs/examples/tablesdb/create-operations.md @@ -0,0 +1,24 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_operations( + transaction_id = '', + operations = [ + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] # optional +) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index d4c1cda..d2de586 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -19,5 +19,6 @@ result = tables_db.create_row( "age": 30, "isAdmin": False }, - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 656a47a..1527e0b 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -11,5 +11,6 @@ tables_db = TablesDB(client) result = tables_db.create_rows( database_id = '', table_id = '', - rows = [] + rows = [], + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md new file mode 100644 index 0000000..05cc80e --- /dev/null +++ b/docs/examples/tablesdb/create-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_transaction( + ttl = 60 # optional +) diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md index 096bc4d..d207bb1 100644 --- a/docs/examples/tablesdb/decrement-row-column.md +++ b/docs/examples/tablesdb/decrement-row-column.md @@ -14,5 +14,6 @@ result = tables_db.decrement_row_column( row_id = '', column = '', value = None, # optional - min = None # optional + min = None, # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md index 569b607..3943ab2 100644 --- a/docs/examples/tablesdb/delete-row.md +++ b/docs/examples/tablesdb/delete-row.md @@ -11,5 +11,6 @@ tables_db = TablesDB(client) result = tables_db.delete_row( database_id = '', table_id = '', - row_id = '' + row_id = '', + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index c3e836e..290d6d3 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -11,5 +11,6 @@ tables_db = TablesDB(client) result = tables_db.delete_rows( database_id = '', table_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md new file mode 100644 index 0000000..6d2957f --- /dev/null +++ b/docs/examples/tablesdb/delete-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.delete_transaction( + transaction_id = '' +) diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md index c806214..4398c9a 100644 --- a/docs/examples/tablesdb/get-row.md +++ b/docs/examples/tablesdb/get-row.md @@ -12,5 +12,6 @@ result = tables_db.get_row( database_id = '', table_id = '', row_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md new file mode 100644 index 0000000..e50c63a --- /dev/null +++ b/docs/examples/tablesdb/get-transaction.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.get_transaction( + transaction_id = '' +) diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md index bcb88f7..8e121f6 100644 --- a/docs/examples/tablesdb/increment-row-column.md +++ b/docs/examples/tablesdb/increment-row-column.md @@ -14,5 +14,6 @@ result = tables_db.increment_row_column( row_id = '', column = '', value = None, # optional - max = None # optional + max = None, # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 9ae7549..eb0a4ed 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -11,5 +11,6 @@ tables_db = TablesDB(client) result = tables_db.list_rows( database_id = '', table_id = '', - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md new file mode 100644 index 0000000..e597c2d --- /dev/null +++ b/docs/examples/tablesdb/list-transactions.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.list_transactions( + queries = [] # optional +) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 86d0cf2..89dbfb0 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -13,5 +13,6 @@ result = tables_db.update_row( table_id = '', row_id = '', data = {}, # optional - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 386ddf8..4717581 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -12,5 +12,6 @@ result = tables_db.update_rows( database_id = '', table_id = '', data = {}, # optional - queries = [] # optional + queries = [], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md new file mode 100644 index 0000000..97b518d --- /dev/null +++ b/docs/examples/tablesdb/update-transaction.md @@ -0,0 +1,15 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional +) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 068fded..8539e12 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -13,5 +13,6 @@ result = tables_db.upsert_row( table_id = '', row_id = '', data = {}, # optional - permissions = ["read("any")"] # optional + permissions = ["read("any")"], # optional + transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 06436c0..d42e259 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -11,5 +11,6 @@ tables_db = TablesDB(client) result = tables_db.upsert_rows( database_id = '', table_id = '', - rows = [] + rows = [], + transaction_id = '' # optional ) diff --git a/setup.py b/setup.py index 8cd303b..dd1346f 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '13.3.1', + version = '13.4.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/13.3.1.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.4.0.tar.gz', install_requires=[ 'requests', ],