From f119a57a3d8b034c1cb34005c02c5b29f4f2a8be Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 Nov 2025 11:43:56 +0000 Subject: [PATCH] fix none issue --- CHANGELOG.md | 4 + appwrite/client.py | 4 +- appwrite/services/account.py | 36 +- appwrite/services/avatars.py | 54 ++- appwrite/services/databases.py | 291 +++++++++----- appwrite/services/functions.py | 161 +++++--- appwrite/services/health.py | 45 ++- appwrite/services/messaging.py | 666 ++++++++++++++++++++++----------- appwrite/services/sites.py | 140 ++++--- appwrite/services/storage.py | 119 ++++-- appwrite/services/tables_db.py | 294 ++++++++++----- appwrite/services/teams.py | 36 +- appwrite/services/tokens.py | 6 +- appwrite/services/users.py | 105 ++++-- setup.py | 4 +- 15 files changed, 1309 insertions(+), 656 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0c81a..31396fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 13.6.1 + +* Fix passing of `None` to nullable parameters + ## 13.6.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/appwrite/client.py b/appwrite/client.py index a4b7310..67fef99 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.6.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/13.6.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.6.0', + 'x-sdk-version': '13.6.1', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/services/account.py b/appwrite/services/account.py index c1c3d49..242dd34 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -73,7 +73,8 @@ def create(self, user_id: str, email: str, password: str, name: Optional[str] = api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -144,8 +145,10 @@ def list_identities(self, queries: Optional[List[str]] = None, total: Optional[b api_path = '/account/identities' api_params = {} - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -229,8 +232,10 @@ def list_logs(self, queries: Optional[List[str]] = None, total: Optional[bool] = api_path = '/account/logs' api_params = {} - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -586,7 +591,8 @@ def update_password(self, password: str, old_password: Optional[str] = None) -> api_params['password'] = password - api_params['oldPassword'] = old_password + if old_password is not None: + api_params['oldPassword'] = old_password return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1147,7 +1153,8 @@ def create_email_token(self, user_id: str, email: str, phrase: Optional[bool] = api_params['userId'] = user_id api_params['email'] = email - api_params['phrase'] = phrase + if phrase is not None: + api_params['phrase'] = phrase return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1193,8 +1200,10 @@ def create_magic_url_token(self, user_id: str, email: str, url: Optional[str] = api_params['userId'] = user_id api_params['email'] = email - api_params['url'] = url - api_params['phrase'] = phrase + if url is not None: + api_params['url'] = url + if phrase is not None: + api_params['phrase'] = phrase return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1237,9 +1246,12 @@ def create_o_auth2_token(self, provider: OAuthProvider, success: Optional[str] = api_path = api_path.replace('{provider}', provider) - api_params['success'] = success - api_params['failure'] = failure - api_params['scopes'] = scopes + if success is not None: + api_params['success'] = success + if failure is not None: + api_params['failure'] = failure + if scopes is not None: + api_params['scopes'] = scopes return self.client.call('get', api_path, { }, api_params, response_type='location') diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 3923da6..bb19c28 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -46,9 +46,12 @@ def get_browser(self, code: Browser, width: Optional[float] = None, height: Opti api_path = api_path.replace('{code}', code) - api_params['width'] = width - api_params['height'] = height - api_params['quality'] = quality + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height + if quality is not None: + api_params['quality'] = quality return self.client.call('get', api_path, { }, api_params) @@ -89,9 +92,12 @@ def get_credit_card(self, code: CreditCard, width: Optional[float] = None, heigh api_path = api_path.replace('{code}', code) - api_params['width'] = width - api_params['height'] = height - api_params['quality'] = quality + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height + if quality is not None: + api_params['quality'] = quality return self.client.call('get', api_path, { }, api_params) @@ -165,9 +171,12 @@ def get_flag(self, code: Flag, width: Optional[float] = None, height: Optional[f api_path = api_path.replace('{code}', code) - api_params['width'] = width - api_params['height'] = height - api_params['quality'] = quality + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height + if quality is not None: + api_params['quality'] = quality return self.client.call('get', api_path, { }, api_params) @@ -207,8 +216,10 @@ def get_image(self, url: str, width: Optional[float] = None, height: Optional[fl api_params['url'] = url - api_params['width'] = width - api_params['height'] = height + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height return self.client.call('get', api_path, { }, api_params) @@ -247,10 +258,14 @@ def get_initials(self, name: Optional[str] = None, width: Optional[float] = None api_path = '/avatars/initials' api_params = {} - api_params['name'] = name - api_params['width'] = width - api_params['height'] = height - api_params['background'] = background + if name is not None: + api_params['name'] = name + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height + if background is not None: + api_params['background'] = background return self.client.call('get', api_path, { }, api_params) @@ -289,9 +304,12 @@ def get_qr(self, text: str, size: Optional[float] = None, margin: Optional[float api_params['text'] = text - api_params['size'] = size - api_params['margin'] = margin - api_params['download'] = download + if size is not None: + api_params['size'] = size + if margin is not None: + api_params['margin'] = margin + if download is not None: + api_params['download'] = download return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 2e0853a..ff54cfa 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -41,9 +41,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/databases' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -87,7 +90,8 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> api_params['databaseId'] = database_id api_params['name'] = name - api_params['enabled'] = enabled + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -116,7 +120,8 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An api_path = '/databases/transactions' api_params = {} - api_params['queries'] = queries + if queries is not None: + api_params['queries'] = queries return self.client.call('get', api_path, { }, api_params) @@ -144,7 +149,8 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: api_path = '/databases/transactions' api_params = {} - api_params['ttl'] = ttl + if ttl is not None: + api_params['ttl'] = ttl return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -212,8 +218,10 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, api_path = api_path.replace('{transactionId}', transaction_id) - api_params['commit'] = commit - api_params['rollback'] = rollback + if commit is not None: + api_params['commit'] = commit + if rollback is not None: + api_params['rollback'] = rollback return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -280,7 +288,8 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] api_path = api_path.replace('{transactionId}', transaction_id) - api_params['operations'] = operations + if operations is not None: + api_params['operations'] = operations return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -358,7 +367,8 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> api_path = api_path.replace('{databaseId}', database_id) api_params['name'] = name - api_params['enabled'] = enabled + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -435,9 +445,12 @@ def list_collections(self, database_id: str, queries: Optional[List[str]] = None api_path = api_path.replace('{databaseId}', database_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -490,9 +503,12 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per api_params['collectionId'] = collection_id api_params['name'] = name - api_params['permissions'] = permissions - api_params['documentSecurity'] = document_security - api_params['enabled'] = enabled + if permissions is not None: + api_params['permissions'] = permissions + if document_security is not None: + api_params['documentSecurity'] = document_security + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -586,9 +602,12 @@ def update_collection(self, database_id: str, collection_id: str, name: str, per api_path = api_path.replace('{collectionId}', collection_id) api_params['name'] = name - api_params['permissions'] = permissions - api_params['documentSecurity'] = document_security - api_params['enabled'] = enabled + if permissions is not None: + api_params['permissions'] = permissions + if document_security is not None: + api_params['documentSecurity'] = document_security + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -675,8 +694,10 @@ def list_attributes(self, database_id: str, collection_id: str, queries: Optiona api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -734,8 +755,10 @@ def create_boolean_attribute(self, database_id: str, collection_id: str, key: st api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -794,7 +817,8 @@ def update_boolean_attribute(self, database_id: str, collection_id: str, key: st api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -852,8 +876,10 @@ def create_datetime_attribute(self, database_id: str, collection_id: str, key: s api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -912,7 +938,8 @@ def update_datetime_attribute(self, database_id: str, collection_id: str, key: s api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -971,8 +998,10 @@ def create_email_attribute(self, database_id: str, collection_id: str, key: str, api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1032,7 +1061,8 @@ def update_email_attribute(self, database_id: str, collection_id: str, key: str, api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1097,8 +1127,10 @@ def create_enum_attribute(self, database_id: str, collection_id: str, key: str, api_params['key'] = key api_params['elements'] = elements api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1164,7 +1196,8 @@ def update_enum_attribute(self, database_id: str, collection_id: str, key: str, api_params['elements'] = elements api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1227,10 +1260,14 @@ def create_float_attribute(self, database_id: str, collection_id: str, key: str, api_params['key'] = key api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['array'] = array + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1293,10 +1330,13 @@ def update_float_attribute(self, database_id: str, collection_id: str, key: str, api_path = api_path.replace('{key}', key) api_params['required'] = required - api_params['min'] = min - api_params['max'] = max + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1359,10 +1399,14 @@ def create_integer_attribute(self, database_id: str, collection_id: str, key: st api_params['key'] = key api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['array'] = array + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1425,10 +1469,13 @@ def update_integer_attribute(self, database_id: str, collection_id: str, key: st api_path = api_path.replace('{key}', key) api_params['required'] = required - api_params['min'] = min - api_params['max'] = max + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1487,8 +1534,10 @@ def create_ip_attribute(self, database_id: str, collection_id: str, key: str, re api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1548,7 +1597,8 @@ def update_ip_attribute(self, database_id: str, collection_id: str, key: str, re api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1663,7 +1713,8 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1778,7 +1829,8 @@ def update_point_attribute(self, database_id: str, collection_id: str, key: str, api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1893,7 +1945,8 @@ def update_polygon_attribute(self, database_id: str, collection_id: str, key: st api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1956,10 +2009,14 @@ def create_relationship_attribute(self, database_id: str, collection_id: str, re api_params['relatedCollectionId'] = related_collection_id api_params['type'] = type - api_params['twoWay'] = two_way - api_params['key'] = key - api_params['twoWayKey'] = two_way_key - api_params['onDelete'] = on_delete + if two_way is not None: + api_params['twoWay'] = two_way + if key is not None: + api_params['key'] = key + if two_way_key is not None: + api_params['twoWayKey'] = two_way_key + if on_delete is not None: + api_params['onDelete'] = on_delete return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2026,9 +2083,12 @@ def create_string_attribute(self, database_id: str, collection_id: str, key: str api_params['key'] = key api_params['size'] = size api_params['required'] = required - api_params['default'] = default - api_params['array'] = array - api_params['encrypt'] = encrypt + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array + if encrypt is not None: + api_params['encrypt'] = encrypt return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2090,8 +2150,10 @@ def update_string_attribute(self, database_id: str, collection_id: str, key: str api_params['required'] = required api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + if size is not None: + api_params['size'] = size + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2150,8 +2212,10 @@ def create_url_attribute(self, database_id: str, collection_id: str, key: str, r api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2211,7 +2275,8 @@ def update_url_attribute(self, database_id: str, collection_id: str, key: str, r api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2357,8 +2422,10 @@ def update_relationship_attribute(self, database_id: str, collection_id: str, ke 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 + if on_delete is not None: + api_params['onDelete'] = on_delete + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2406,9 +2473,12 @@ def list_documents(self, database_id: str, collection_id: str, queries: Optional api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -2465,8 +2535,10 @@ 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 + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2516,7 +2588,8 @@ 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 + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2567,7 +2640,8 @@ 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 + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -2615,9 +2689,12 @@ def update_documents(self, database_id: str, collection_id: str, data: Optional[ api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['data'] = data - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if data is not None: + api_params['data'] = data + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2663,8 +2740,10 @@ def delete_documents(self, database_id: str, collection_id: str, queries: Option api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', @@ -2716,8 +2795,10 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{documentId}', document_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) @@ -2774,8 +2855,10 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str api_path = api_path.replace('{documentId}', document_id) api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -2829,9 +2912,12 @@ def update_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['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + if data is not None: + api_params['data'] = data + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2881,7 +2967,8 @@ 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 + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', @@ -2941,9 +3028,12 @@ def decrement_document_attribute(self, database_id: str, collection_id: str, doc api_path = api_path.replace('{documentId}', document_id) api_path = api_path.replace('{attribute}', attribute) - api_params['value'] = value - api_params['min'] = min - api_params['transactionId'] = transaction_id + if value is not None: + api_params['value'] = value + if min is not None: + api_params['min'] = min + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -3003,9 +3093,12 @@ def increment_document_attribute(self, database_id: str, collection_id: str, doc api_path = api_path.replace('{documentId}', document_id) api_path = api_path.replace('{attribute}', attribute) - api_params['value'] = value - api_params['max'] = max - api_params['transactionId'] = transaction_id + if value is not None: + api_params['value'] = value + if max is not None: + api_params['max'] = max + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -3051,8 +3144,10 @@ def list_indexes(self, database_id: str, collection_id: str, queries: Optional[L api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -3116,8 +3211,10 @@ def create_index(self, database_id: str, collection_id: str, key: str, type: Ind api_params['key'] = key api_params['type'] = type api_params['attributes'] = attributes - api_params['orders'] = orders - api_params['lengths'] = lengths + if orders is not None: + api_params['orders'] = orders + if lengths is not None: + api_params['lengths'] = lengths return self.client.call('post', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index e6621a7..c190ae6 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -40,9 +40,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/functions' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -116,21 +119,36 @@ def create(self, function_id: str, name: str, runtime: Runtime, execute: Optiona api_params['functionId'] = function_id api_params['name'] = name api_params['runtime'] = runtime - api_params['execute'] = execute - api_params['events'] = events - api_params['schedule'] = schedule - api_params['timeout'] = timeout - api_params['enabled'] = enabled - api_params['logging'] = logging - api_params['entrypoint'] = entrypoint - api_params['commands'] = commands - api_params['scopes'] = scopes - api_params['installationId'] = installation_id - api_params['providerRepositoryId'] = provider_repository_id - api_params['providerBranch'] = provider_branch - api_params['providerSilentMode'] = provider_silent_mode - api_params['providerRootDirectory'] = provider_root_directory - api_params['specification'] = specification + if execute is not None: + api_params['execute'] = execute + if events is not None: + api_params['events'] = events + if schedule is not None: + api_params['schedule'] = schedule + if timeout is not None: + api_params['timeout'] = timeout + if enabled is not None: + api_params['enabled'] = enabled + if logging is not None: + api_params['logging'] = logging + if entrypoint is not None: + api_params['entrypoint'] = entrypoint + if commands is not None: + api_params['commands'] = commands + if scopes is not None: + api_params['scopes'] = scopes + if installation_id is not None: + api_params['installationId'] = installation_id + if provider_repository_id is not None: + api_params['providerRepositoryId'] = provider_repository_id + if provider_branch is not None: + api_params['providerBranch'] = provider_branch + if provider_silent_mode is not None: + api_params['providerSilentMode'] = provider_silent_mode + if provider_root_directory is not None: + api_params['providerRootDirectory'] = provider_root_directory + if specification is not None: + api_params['specification'] = specification return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -274,22 +292,37 @@ def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, api_path = api_path.replace('{functionId}', function_id) api_params['name'] = name - api_params['runtime'] = runtime - api_params['execute'] = execute - api_params['events'] = events - api_params['schedule'] = schedule - api_params['timeout'] = timeout - api_params['enabled'] = enabled - api_params['logging'] = logging - api_params['entrypoint'] = entrypoint - api_params['commands'] = commands - api_params['scopes'] = scopes - api_params['installationId'] = installation_id + if runtime is not None: + api_params['runtime'] = runtime + if execute is not None: + api_params['execute'] = execute + if events is not None: + api_params['events'] = events + if schedule is not None: + api_params['schedule'] = schedule + if timeout is not None: + api_params['timeout'] = timeout + if enabled is not None: + api_params['enabled'] = enabled + if logging is not None: + api_params['logging'] = logging + if entrypoint is not None: + api_params['entrypoint'] = entrypoint + if commands is not None: + api_params['commands'] = commands + if scopes is not None: + api_params['scopes'] = scopes + if installation_id is not None: + api_params['installationId'] = installation_id api_params['providerRepositoryId'] = provider_repository_id - api_params['providerBranch'] = provider_branch - api_params['providerSilentMode'] = provider_silent_mode - api_params['providerRootDirectory'] = provider_root_directory - api_params['specification'] = specification + if provider_branch is not None: + api_params['providerBranch'] = provider_branch + if provider_silent_mode is not None: + api_params['providerSilentMode'] = provider_silent_mode + if provider_root_directory is not None: + api_params['providerRootDirectory'] = provider_root_directory + if specification is not None: + api_params['specification'] = specification return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -398,9 +431,12 @@ def list_deployments(self, function_id: str, queries: Optional[List[str]] = None api_path = api_path.replace('{functionId}', function_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -452,9 +488,11 @@ def create_deployment(self, function_id: str, code: InputFile, activate: bool, e api_path = api_path.replace('{functionId}', function_id) - api_params['entrypoint'] = entrypoint - api_params['commands'] = commands - api_params['code'] = str(code).lower() if type(code) is bool else code + if entrypoint is not None: + api_params['entrypoint'] = entrypoint + if commands is not None: + api_params['commands'] = commands + api_params['code'] = code api_params['activate'] = str(activate).lower() if type(activate) is bool else activate param_name = 'code' @@ -501,7 +539,8 @@ def create_duplicate_deployment(self, function_id: str, deployment_id: str, buil api_path = api_path.replace('{functionId}', function_id) api_params['deploymentId'] = deployment_id - api_params['buildId'] = build_id + if build_id is not None: + api_params['buildId'] = build_id return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -562,7 +601,8 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s api_params['owner'] = owner api_params['rootDirectory'] = root_directory api_params['version'] = version - api_params['activate'] = activate + if activate is not None: + api_params['activate'] = activate return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -611,7 +651,8 @@ def create_vcs_deployment(self, function_id: str, type: VCSDeploymentType, refer api_params['type'] = type api_params['reference'] = reference - api_params['activate'] = activate + if activate is not None: + api_params['activate'] = activate return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -727,7 +768,8 @@ def get_deployment_download(self, function_id: str, deployment_id: str, type: Op api_path = api_path.replace('{functionId}', function_id) api_path = api_path.replace('{deploymentId}', deployment_id) - api_params['type'] = type + if type is not None: + api_params['type'] = type return self.client.call('get', api_path, { }, api_params) @@ -801,8 +843,10 @@ def list_executions(self, function_id: str, queries: Optional[List[str]] = None, api_path = api_path.replace('{functionId}', function_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -846,12 +890,18 @@ def create_execution(self, function_id: str, body: Optional[str] = None, xasync: api_path = api_path.replace('{functionId}', function_id) - api_params['body'] = body - api_params['async'] = xasync - api_params['path'] = path - api_params['method'] = method - api_params['headers'] = headers - api_params['scheduledAt'] = scheduled_at + if body is not None: + api_params['body'] = body + if xasync is not None: + api_params['async'] = xasync + if path is not None: + api_params['path'] = path + if method is not None: + api_params['method'] = method + if headers is not None: + api_params['headers'] = headers + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1004,7 +1054,8 @@ def create_variable(self, function_id: str, key: str, value: str, secret: Option api_params['key'] = key api_params['value'] = value - api_params['secret'] = secret + if secret is not None: + api_params['secret'] = secret return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1090,8 +1141,10 @@ def update_variable(self, function_id: str, variable_id: str, key: str, value: O api_path = api_path.replace('{variableId}', variable_id) api_params['key'] = key - api_params['value'] = value - api_params['secret'] = secret + if value is not None: + api_params['value'] = value + if secret is not None: + api_params['secret'] = secret return self.client.call('put', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 6a50c6c..c6250a1 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -95,7 +95,8 @@ def get_certificate(self, domain: Optional[str] = None) -> Dict[str, Any]: api_path = '/health/certificate' api_params = {} - api_params['domain'] = domain + if domain is not None: + api_params['domain'] = domain return self.client.call('get', api_path, { }, api_params) @@ -165,7 +166,8 @@ def get_queue_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_path = '/health/queue/builds' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -193,7 +195,8 @@ def get_queue_certificates(self, threshold: Optional[float] = None) -> Dict[str, api_path = '/health/queue/certificates' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -223,8 +226,10 @@ def get_queue_databases(self, name: Optional[str] = None, threshold: Optional[fl api_path = '/health/queue/databases' api_params = {} - api_params['name'] = name - api_params['threshold'] = threshold + if name is not None: + api_params['name'] = name + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -252,7 +257,8 @@ def get_queue_deletes(self, threshold: Optional[float] = None) -> Dict[str, Any] api_path = '/health/queue/deletes' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -287,7 +293,8 @@ def get_failed_jobs(self, name: Name, threshold: Optional[float] = None) -> Dict api_path = api_path.replace('{name}', name) - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -315,7 +322,8 @@ def get_queue_functions(self, threshold: Optional[float] = None) -> Dict[str, An api_path = '/health/queue/functions' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -343,7 +351,8 @@ def get_queue_logs(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_path = '/health/queue/logs' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -371,7 +380,8 @@ def get_queue_mails(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_path = '/health/queue/mails' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -399,7 +409,8 @@ def get_queue_messaging(self, threshold: Optional[float] = None) -> Dict[str, An api_path = '/health/queue/messaging' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -427,7 +438,8 @@ def get_queue_migrations(self, threshold: Optional[float] = None) -> Dict[str, A api_path = '/health/queue/migrations' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -455,7 +467,8 @@ def get_queue_stats_resources(self, threshold: Optional[float] = None) -> Dict[s api_path = '/health/queue/stats-resources' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -483,7 +496,8 @@ def get_queue_usage(self, threshold: Optional[float] = None) -> Dict[str, Any]: api_path = '/health/queue/stats-usage' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) @@ -511,7 +525,8 @@ def get_queue_webhooks(self, threshold: Optional[float] = None) -> Dict[str, Any api_path = '/health/queue/webhooks' api_params = {} - api_params['threshold'] = threshold + if threshold is not None: + api_params['threshold'] = threshold return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/messaging.py b/appwrite/services/messaging.py index 2480c2c..4ef91ba 100644 --- a/appwrite/services/messaging.py +++ b/appwrite/services/messaging.py @@ -37,9 +37,12 @@ def list_messages(self, queries: Optional[List[str]] = None, search: Optional[st api_path = '/messaging/messages' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -101,15 +104,24 @@ def create_email(self, message_id: str, subject: str, content: str, topics: Opti api_params['messageId'] = message_id api_params['subject'] = subject api_params['content'] = content - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['cc'] = cc - api_params['bcc'] = bcc - api_params['attachments'] = attachments - api_params['draft'] = draft - api_params['html'] = html - api_params['scheduledAt'] = scheduled_at + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if cc is not None: + api_params['cc'] = cc + if bcc is not None: + api_params['bcc'] = bcc + if attachments is not None: + api_params['attachments'] = attachments + if draft is not None: + api_params['draft'] = draft + if html is not None: + api_params['html'] = html + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -165,17 +177,28 @@ def update_email(self, message_id: str, topics: Optional[List[str]] = None, user api_path = api_path.replace('{messageId}', message_id) - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['subject'] = subject - api_params['content'] = content - api_params['draft'] = draft - api_params['html'] = html - api_params['cc'] = cc - api_params['bcc'] = bcc - api_params['scheduledAt'] = scheduled_at - api_params['attachments'] = attachments + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if subject is not None: + api_params['subject'] = subject + if content is not None: + api_params['content'] = content + if draft is not None: + api_params['draft'] = draft + if html is not None: + api_params['html'] = html + if cc is not None: + api_params['cc'] = cc + if bcc is not None: + api_params['bcc'] = bcc + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at + if attachments is not None: + api_params['attachments'] = attachments return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -244,24 +267,42 @@ def create_push(self, message_id: str, title: Optional[str] = None, body: Option api_params['messageId'] = message_id - api_params['title'] = title - api_params['body'] = body - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['data'] = data - api_params['action'] = action - api_params['image'] = image - api_params['icon'] = icon - api_params['sound'] = sound - api_params['color'] = color - api_params['tag'] = tag - api_params['badge'] = badge - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at - api_params['contentAvailable'] = content_available - api_params['critical'] = critical - api_params['priority'] = priority + if title is not None: + api_params['title'] = title + if body is not None: + api_params['body'] = body + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if data is not None: + api_params['data'] = data + if action is not None: + api_params['action'] = action + if image is not None: + api_params['image'] = image + if icon is not None: + api_params['icon'] = icon + if sound is not None: + api_params['sound'] = sound + if color is not None: + api_params['color'] = color + if tag is not None: + api_params['tag'] = tag + if badge is not None: + api_params['badge'] = badge + if draft is not None: + api_params['draft'] = draft + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at + if content_available is not None: + api_params['contentAvailable'] = content_available + if critical is not None: + api_params['critical'] = critical + if priority is not None: + api_params['priority'] = priority return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -331,24 +372,42 @@ def update_push(self, message_id: str, topics: Optional[List[str]] = None, users api_path = api_path.replace('{messageId}', message_id) - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['title'] = title - api_params['body'] = body - api_params['data'] = data - api_params['action'] = action - api_params['image'] = image - api_params['icon'] = icon - api_params['sound'] = sound - api_params['color'] = color - api_params['tag'] = tag - api_params['badge'] = badge - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at - api_params['contentAvailable'] = content_available - api_params['critical'] = critical - api_params['priority'] = priority + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if title is not None: + api_params['title'] = title + if body is not None: + api_params['body'] = body + if data is not None: + api_params['data'] = data + if action is not None: + api_params['action'] = action + if image is not None: + api_params['image'] = image + if icon is not None: + api_params['icon'] = icon + if sound is not None: + api_params['sound'] = sound + if color is not None: + api_params['color'] = color + if tag is not None: + api_params['tag'] = tag + if badge is not None: + api_params['badge'] = badge + if draft is not None: + api_params['draft'] = draft + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at + if content_available is not None: + api_params['contentAvailable'] = content_available + if critical is not None: + api_params['critical'] = critical + if priority is not None: + api_params['priority'] = priority return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -397,11 +456,16 @@ def create_sms(self, message_id: str, content: str, topics: Optional[List[str]] api_params['messageId'] = message_id api_params['content'] = content - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if draft is not None: + api_params['draft'] = draft + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -447,12 +511,18 @@ def update_sms(self, message_id: str, topics: Optional[List[str]] = None, users: api_path = api_path.replace('{messageId}', message_id) - api_params['topics'] = topics - api_params['users'] = users - api_params['targets'] = targets - api_params['content'] = content - api_params['draft'] = draft - api_params['scheduledAt'] = scheduled_at + if topics is not None: + api_params['topics'] = topics + if users is not None: + api_params['users'] = users + if targets is not None: + api_params['targets'] = targets + if content is not None: + api_params['content'] = content + if draft is not None: + api_params['draft'] = draft + if scheduled_at is not None: + api_params['scheduledAt'] = scheduled_at return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -553,8 +623,10 @@ def list_message_logs(self, message_id: str, queries: Optional[List[str]] = None api_path = api_path.replace('{messageId}', message_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -590,8 +662,10 @@ def list_targets(self, message_id: str, queries: Optional[List[str]] = None, tot api_path = api_path.replace('{messageId}', message_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -623,9 +697,12 @@ def list_providers(self, queries: Optional[List[str]] = None, search: Optional[s api_path = '/messaging/providers' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -675,12 +752,18 @@ def create_apns_provider(self, provider_id: str, name: str, auth_key: Optional[s api_params['providerId'] = provider_id api_params['name'] = name - api_params['authKey'] = auth_key - api_params['authKeyId'] = auth_key_id - api_params['teamId'] = team_id - api_params['bundleId'] = bundle_id - api_params['sandbox'] = sandbox - api_params['enabled'] = enabled + if auth_key is not None: + api_params['authKey'] = auth_key + if auth_key_id is not None: + api_params['authKeyId'] = auth_key_id + if team_id is not None: + api_params['teamId'] = team_id + if bundle_id is not None: + api_params['bundleId'] = bundle_id + if sandbox is not None: + api_params['sandbox'] = sandbox + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -727,13 +810,20 @@ def update_apns_provider(self, provider_id: str, name: Optional[str] = None, ena api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['authKey'] = auth_key - api_params['authKeyId'] = auth_key_id - api_params['teamId'] = team_id - api_params['bundleId'] = bundle_id - api_params['sandbox'] = sandbox + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if auth_key is not None: + api_params['authKey'] = auth_key + if auth_key_id is not None: + api_params['authKeyId'] = auth_key_id + if team_id is not None: + api_params['teamId'] = team_id + if bundle_id is not None: + api_params['bundleId'] = bundle_id + if sandbox is not None: + api_params['sandbox'] = sandbox return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -776,8 +866,10 @@ def create_fcm_provider(self, provider_id: str, name: str, service_account_json: api_params['providerId'] = provider_id api_params['name'] = name - api_params['serviceAccountJSON'] = service_account_json - api_params['enabled'] = enabled + if service_account_json is not None: + api_params['serviceAccountJSON'] = service_account_json + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -816,9 +908,12 @@ def update_fcm_provider(self, provider_id: str, name: Optional[str] = None, enab api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['serviceAccountJSON'] = service_account_json + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if service_account_json is not None: + api_params['serviceAccountJSON'] = service_account_json return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -873,14 +968,22 @@ def create_mailgun_provider(self, provider_id: str, name: str, api_key: Optional api_params['providerId'] = provider_id api_params['name'] = name - api_params['apiKey'] = api_key - api_params['domain'] = domain - api_params['isEuRegion'] = is_eu_region - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if domain is not None: + api_params['domain'] = domain + if is_eu_region is not None: + api_params['isEuRegion'] = is_eu_region + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -931,15 +1034,24 @@ def update_mailgun_provider(self, provider_id: str, name: Optional[str] = None, api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['apiKey'] = api_key - api_params['domain'] = domain - api_params['isEuRegion'] = is_eu_region - api_params['enabled'] = enabled - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email + if name is not None: + api_params['name'] = name + if api_key is not None: + api_params['apiKey'] = api_key + if domain is not None: + api_params['domain'] = domain + if is_eu_region is not None: + api_params['isEuRegion'] = is_eu_region + if enabled is not None: + api_params['enabled'] = enabled + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -986,10 +1098,14 @@ def create_msg91_provider(self, provider_id: str, name: str, template_id: Option api_params['providerId'] = provider_id api_params['name'] = name - api_params['templateId'] = template_id - api_params['senderId'] = sender_id - api_params['authKey'] = auth_key - api_params['enabled'] = enabled + if template_id is not None: + api_params['templateId'] = template_id + if sender_id is not None: + api_params['senderId'] = sender_id + if auth_key is not None: + api_params['authKey'] = auth_key + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1032,11 +1148,16 @@ def update_msg91_provider(self, provider_id: str, name: Optional[str] = None, en api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['templateId'] = template_id - api_params['senderId'] = sender_id - api_params['authKey'] = auth_key + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if template_id is not None: + api_params['templateId'] = template_id + if sender_id is not None: + api_params['senderId'] = sender_id + if auth_key is not None: + api_params['authKey'] = auth_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1087,12 +1208,18 @@ def create_resend_provider(self, provider_id: str, name: str, api_key: Optional[ api_params['providerId'] = provider_id api_params['name'] = name - api_params['apiKey'] = api_key - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1139,13 +1266,20 @@ def update_resend_provider(self, provider_id: str, name: Optional[str] = None, e api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['apiKey'] = api_key - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1196,12 +1330,18 @@ def create_sendgrid_provider(self, provider_id: str, name: str, api_key: Optiona api_params['providerId'] = provider_id api_params['name'] = name - api_params['apiKey'] = api_key - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1248,13 +1388,20 @@ def update_sendgrid_provider(self, provider_id: str, name: Optional[str] = None, api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['apiKey'] = api_key - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1321,17 +1468,28 @@ def create_smtp_provider(self, provider_id: str, name: str, host: str, port: Opt api_params['providerId'] = provider_id api_params['name'] = name api_params['host'] = host - api_params['port'] = port - api_params['username'] = username - api_params['password'] = password - api_params['encryption'] = encryption - api_params['autoTLS'] = auto_tls - api_params['mailer'] = mailer - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + if port is not None: + api_params['port'] = port + if username is not None: + api_params['username'] = username + if password is not None: + api_params['password'] = password + if encryption is not None: + api_params['encryption'] = encryption + if auto_tls is not None: + api_params['autoTLS'] = auto_tls + if mailer is not None: + api_params['mailer'] = mailer + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1390,19 +1548,32 @@ def update_smtp_provider(self, provider_id: str, name: Optional[str] = None, hos api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['host'] = host - api_params['port'] = port - api_params['username'] = username - api_params['password'] = password - api_params['encryption'] = encryption - api_params['autoTLS'] = auto_tls - api_params['mailer'] = mailer - api_params['fromName'] = from_name - api_params['fromEmail'] = from_email - api_params['replyToName'] = reply_to_name - api_params['replyToEmail'] = reply_to_email - api_params['enabled'] = enabled + if name is not None: + api_params['name'] = name + if host is not None: + api_params['host'] = host + if port is not None: + api_params['port'] = port + if username is not None: + api_params['username'] = username + if password is not None: + api_params['password'] = password + if encryption is not None: + api_params['encryption'] = encryption + if auto_tls is not None: + api_params['autoTLS'] = auto_tls + if mailer is not None: + api_params['mailer'] = mailer + if from_name is not None: + api_params['fromName'] = from_name + if from_email is not None: + api_params['fromEmail'] = from_email + if reply_to_name is not None: + api_params['replyToName'] = reply_to_name + if reply_to_email is not None: + api_params['replyToEmail'] = reply_to_email + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1449,10 +1620,14 @@ def create_telesign_provider(self, provider_id: str, name: str, xfrom: Optional[ api_params['providerId'] = provider_id api_params['name'] = name - api_params['from'] = xfrom - api_params['customerId'] = customer_id - api_params['apiKey'] = api_key - api_params['enabled'] = enabled + if xfrom is not None: + api_params['from'] = xfrom + if customer_id is not None: + api_params['customerId'] = customer_id + if api_key is not None: + api_params['apiKey'] = api_key + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1495,11 +1670,16 @@ def update_telesign_provider(self, provider_id: str, name: Optional[str] = None, api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['customerId'] = customer_id - api_params['apiKey'] = api_key - api_params['from'] = xfrom + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if customer_id is not None: + api_params['customerId'] = customer_id + if api_key is not None: + api_params['apiKey'] = api_key + if xfrom is not None: + api_params['from'] = xfrom return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1546,10 +1726,14 @@ def create_textmagic_provider(self, provider_id: str, name: str, xfrom: Optional api_params['providerId'] = provider_id api_params['name'] = name - api_params['from'] = xfrom - api_params['username'] = username - api_params['apiKey'] = api_key - api_params['enabled'] = enabled + if xfrom is not None: + api_params['from'] = xfrom + if username is not None: + api_params['username'] = username + if api_key is not None: + api_params['apiKey'] = api_key + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1592,11 +1776,16 @@ def update_textmagic_provider(self, provider_id: str, name: Optional[str] = None api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['username'] = username - api_params['apiKey'] = api_key - api_params['from'] = xfrom + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if username is not None: + api_params['username'] = username + if api_key is not None: + api_params['apiKey'] = api_key + if xfrom is not None: + api_params['from'] = xfrom return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1643,10 +1832,14 @@ def create_twilio_provider(self, provider_id: str, name: str, xfrom: Optional[st api_params['providerId'] = provider_id api_params['name'] = name - api_params['from'] = xfrom - api_params['accountSid'] = account_sid - api_params['authToken'] = auth_token - api_params['enabled'] = enabled + if xfrom is not None: + api_params['from'] = xfrom + if account_sid is not None: + api_params['accountSid'] = account_sid + if auth_token is not None: + api_params['authToken'] = auth_token + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1689,11 +1882,16 @@ def update_twilio_provider(self, provider_id: str, name: Optional[str] = None, e api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['accountSid'] = account_sid - api_params['authToken'] = auth_token - api_params['from'] = xfrom + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if account_sid is not None: + api_params['accountSid'] = account_sid + if auth_token is not None: + api_params['authToken'] = auth_token + if xfrom is not None: + api_params['from'] = xfrom return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1740,10 +1938,14 @@ def create_vonage_provider(self, provider_id: str, name: str, xfrom: Optional[st api_params['providerId'] = provider_id api_params['name'] = name - api_params['from'] = xfrom - api_params['apiKey'] = api_key - api_params['apiSecret'] = api_secret - api_params['enabled'] = enabled + if xfrom is not None: + api_params['from'] = xfrom + if api_key is not None: + api_params['apiKey'] = api_key + if api_secret is not None: + api_params['apiSecret'] = api_secret + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1786,11 +1988,16 @@ def update_vonage_provider(self, provider_id: str, name: Optional[str] = None, e api_path = api_path.replace('{providerId}', provider_id) - api_params['name'] = name - api_params['enabled'] = enabled - api_params['apiKey'] = api_key - api_params['apiSecret'] = api_secret - api_params['from'] = xfrom + if name is not None: + api_params['name'] = name + if enabled is not None: + api_params['enabled'] = enabled + if api_key is not None: + api_params['apiKey'] = api_key + if api_secret is not None: + api_params['apiSecret'] = api_secret + if xfrom is not None: + api_params['from'] = xfrom return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1891,8 +2098,10 @@ def list_provider_logs(self, provider_id: str, queries: Optional[List[str]] = No api_path = api_path.replace('{providerId}', provider_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -1928,8 +2137,10 @@ def list_subscriber_logs(self, subscriber_id: str, queries: Optional[List[str]] api_path = api_path.replace('{subscriberId}', subscriber_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -1961,9 +2172,12 @@ def list_topics(self, queries: Optional[List[str]] = None, search: Optional[str] api_path = '/messaging/topics' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -2003,7 +2217,8 @@ def create_topic(self, topic_id: str, name: str, subscribe: Optional[List[str]] api_params['topicId'] = topic_id api_params['name'] = name - api_params['subscribe'] = subscribe + if subscribe is not None: + api_params['subscribe'] = subscribe return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2073,8 +2288,10 @@ def update_topic(self, topic_id: str, name: Optional[str] = None, subscribe: Opt api_path = api_path.replace('{topicId}', topic_id) - api_params['name'] = name - api_params['subscribe'] = subscribe + if name is not None: + api_params['name'] = name + if subscribe is not None: + api_params['subscribe'] = subscribe return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2143,8 +2360,10 @@ def list_topic_logs(self, topic_id: str, queries: Optional[List[str]] = None, to api_path = api_path.replace('{topicId}', topic_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -2182,9 +2401,12 @@ def list_subscribers(self, topic_id: str, queries: Optional[List[str]] = None, s api_path = api_path.replace('{topicId}', topic_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index b8644b7..6980364 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -41,9 +41,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/sites' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -120,21 +123,35 @@ def create(self, site_id: str, name: str, framework: Framework, build_runtime: B api_params['siteId'] = site_id api_params['name'] = name api_params['framework'] = framework - api_params['enabled'] = enabled - api_params['logging'] = logging - api_params['timeout'] = timeout - api_params['installCommand'] = install_command - api_params['buildCommand'] = build_command - api_params['outputDirectory'] = output_directory + if enabled is not None: + api_params['enabled'] = enabled + if logging is not None: + api_params['logging'] = logging + if timeout is not None: + api_params['timeout'] = timeout + if install_command is not None: + api_params['installCommand'] = install_command + if build_command is not None: + api_params['buildCommand'] = build_command + if output_directory is not None: + api_params['outputDirectory'] = output_directory api_params['buildRuntime'] = build_runtime - api_params['adapter'] = adapter - api_params['installationId'] = installation_id - api_params['fallbackFile'] = fallback_file - api_params['providerRepositoryId'] = provider_repository_id - api_params['providerBranch'] = provider_branch - api_params['providerSilentMode'] = provider_silent_mode - api_params['providerRootDirectory'] = provider_root_directory - api_params['specification'] = specification + if adapter is not None: + api_params['adapter'] = adapter + if installation_id is not None: + api_params['installationId'] = installation_id + if fallback_file is not None: + api_params['fallbackFile'] = fallback_file + if provider_repository_id is not None: + api_params['providerRepositoryId'] = provider_repository_id + if provider_branch is not None: + api_params['providerBranch'] = provider_branch + if provider_silent_mode is not None: + api_params['providerSilentMode'] = provider_silent_mode + if provider_root_directory is not None: + api_params['providerRootDirectory'] = provider_root_directory + if specification is not None: + api_params['specification'] = specification return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -282,21 +299,36 @@ def update(self, site_id: str, name: str, framework: Framework, enabled: Optiona api_params['name'] = name api_params['framework'] = framework - api_params['enabled'] = enabled - api_params['logging'] = logging - api_params['timeout'] = timeout - api_params['installCommand'] = install_command - api_params['buildCommand'] = build_command - api_params['outputDirectory'] = output_directory - api_params['buildRuntime'] = build_runtime - api_params['adapter'] = adapter - api_params['fallbackFile'] = fallback_file - api_params['installationId'] = installation_id - api_params['providerRepositoryId'] = provider_repository_id - api_params['providerBranch'] = provider_branch - api_params['providerSilentMode'] = provider_silent_mode - api_params['providerRootDirectory'] = provider_root_directory - api_params['specification'] = specification + if enabled is not None: + api_params['enabled'] = enabled + if logging is not None: + api_params['logging'] = logging + if timeout is not None: + api_params['timeout'] = timeout + if install_command is not None: + api_params['installCommand'] = install_command + if build_command is not None: + api_params['buildCommand'] = build_command + if output_directory is not None: + api_params['outputDirectory'] = output_directory + if build_runtime is not None: + api_params['buildRuntime'] = build_runtime + if adapter is not None: + api_params['adapter'] = adapter + if fallback_file is not None: + api_params['fallbackFile'] = fallback_file + if installation_id is not None: + api_params['installationId'] = installation_id + if provider_repository_id is not None: + api_params['providerRepositoryId'] = provider_repository_id + if provider_branch is not None: + api_params['providerBranch'] = provider_branch + if provider_silent_mode is not None: + api_params['providerSilentMode'] = provider_silent_mode + if provider_root_directory is not None: + api_params['providerRootDirectory'] = provider_root_directory + if specification is not None: + api_params['specification'] = specification return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -405,9 +437,12 @@ def list_deployments(self, site_id: str, queries: Optional[List[str]] = None, se api_path = api_path.replace('{siteId}', site_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -457,10 +492,13 @@ def create_deployment(self, site_id: str, code: InputFile, activate: bool, insta api_path = api_path.replace('{siteId}', site_id) - api_params['installCommand'] = install_command - api_params['buildCommand'] = build_command - api_params['outputDirectory'] = output_directory - api_params['code'] = str(code).lower() if type(code) is bool else code + if install_command is not None: + api_params['installCommand'] = install_command + if build_command is not None: + api_params['buildCommand'] = build_command + 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 param_name = 'code' @@ -565,7 +603,8 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str, api_params['owner'] = owner api_params['rootDirectory'] = root_directory api_params['version'] = version - api_params['activate'] = activate + if activate is not None: + api_params['activate'] = activate return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -614,7 +653,8 @@ def create_vcs_deployment(self, site_id: str, type: VCSDeploymentType, reference api_params['type'] = type api_params['reference'] = reference - api_params['activate'] = activate + if activate is not None: + api_params['activate'] = activate return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -730,7 +770,8 @@ def get_deployment_download(self, site_id: str, deployment_id: str, type: Option api_path = api_path.replace('{siteId}', site_id) api_path = api_path.replace('{deploymentId}', deployment_id) - api_params['type'] = type + if type is not None: + api_params['type'] = type return self.client.call('get', api_path, { }, api_params) @@ -804,8 +845,10 @@ def list_logs(self, site_id: str, queries: Optional[List[str]] = None, total: Op api_path = api_path.replace('{siteId}', site_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -957,7 +1000,8 @@ def create_variable(self, site_id: str, key: str, value: str, secret: Optional[b api_params['key'] = key api_params['value'] = value - api_params['secret'] = secret + if secret is not None: + api_params['secret'] = secret return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1043,8 +1087,10 @@ def update_variable(self, site_id: str, variable_id: str, key: str, value: Optio api_path = api_path.replace('{variableId}', variable_id) api_params['key'] = key - api_params['value'] = value - api_params['secret'] = secret + if value is not None: + api_params['value'] = value + if secret is not None: + api_params['secret'] = secret return self.client.call('put', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index d00b1a0..1c25c46 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -39,9 +39,12 @@ def list_buckets(self, queries: Optional[List[str]] = None, search: Optional[str api_path = '/storage/buckets' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -95,14 +98,22 @@ def create_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st api_params['bucketId'] = bucket_id api_params['name'] = name - api_params['permissions'] = permissions - api_params['fileSecurity'] = file_security - api_params['enabled'] = enabled - api_params['maximumFileSize'] = maximum_file_size - api_params['allowedFileExtensions'] = allowed_file_extensions - api_params['compression'] = compression - api_params['encryption'] = encryption - api_params['antivirus'] = antivirus + if permissions is not None: + api_params['permissions'] = permissions + if file_security is not None: + api_params['fileSecurity'] = file_security + if enabled is not None: + api_params['enabled'] = enabled + if maximum_file_size is not None: + api_params['maximumFileSize'] = maximum_file_size + if allowed_file_extensions is not None: + api_params['allowedFileExtensions'] = allowed_file_extensions + if compression is not None: + api_params['compression'] = compression + if encryption is not None: + api_params['encryption'] = encryption + if antivirus is not None: + api_params['antivirus'] = antivirus return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -188,14 +199,22 @@ def update_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st api_path = api_path.replace('{bucketId}', bucket_id) api_params['name'] = name - api_params['permissions'] = permissions - api_params['fileSecurity'] = file_security - api_params['enabled'] = enabled - api_params['maximumFileSize'] = maximum_file_size - api_params['allowedFileExtensions'] = allowed_file_extensions - api_params['compression'] = compression - api_params['encryption'] = encryption - api_params['antivirus'] = antivirus + if permissions is not None: + api_params['permissions'] = permissions + if file_security is not None: + api_params['fileSecurity'] = file_security + if enabled is not None: + api_params['enabled'] = enabled + if maximum_file_size is not None: + api_params['maximumFileSize'] = maximum_file_size + if allowed_file_extensions is not None: + api_params['allowedFileExtensions'] = allowed_file_extensions + if compression is not None: + api_params['compression'] = compression + if encryption is not None: + api_params['encryption'] = encryption + if antivirus is not None: + api_params['antivirus'] = antivirus return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -266,9 +285,12 @@ def list_files(self, bucket_id: str, queries: Optional[List[str]] = None, search api_path = api_path.replace('{bucketId}', bucket_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -322,8 +344,9 @@ def create_file(self, bucket_id: str, file_id: str, file: InputFile, permissions api_path = api_path.replace('{bucketId}', bucket_id) api_params['fileId'] = file_id - api_params['file'] = str(file).lower() if type(file) is bool else file - api_params['permissions'] = permissions + api_params['file'] = file + if permissions is not None: + api_params['permissions'] = permissions param_name = 'file' @@ -409,8 +432,10 @@ def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['name'] = name - api_params['permissions'] = permissions + if name is not None: + api_params['name'] = name + if permissions is not None: + api_params['permissions'] = permissions return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -489,7 +514,8 @@ def get_file_download(self, bucket_id: str, file_id: str, token: Optional[str] = api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['token'] = token + if token is not None: + api_params['token'] = token return self.client.call('get', api_path, { }, api_params) @@ -551,18 +577,30 @@ def get_file_preview(self, bucket_id: str, file_id: str, width: Optional[float] api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['width'] = width - api_params['height'] = height - api_params['gravity'] = gravity - api_params['quality'] = quality - api_params['borderWidth'] = border_width - api_params['borderColor'] = border_color - api_params['borderRadius'] = border_radius - api_params['opacity'] = opacity - api_params['rotation'] = rotation - api_params['background'] = background - api_params['output'] = output - api_params['token'] = token + if width is not None: + api_params['width'] = width + if height is not None: + api_params['height'] = height + if gravity is not None: + api_params['gravity'] = gravity + if quality is not None: + api_params['quality'] = quality + if border_width is not None: + api_params['borderWidth'] = border_width + if border_color is not None: + api_params['borderColor'] = border_color + if border_radius is not None: + api_params['borderRadius'] = border_radius + if opacity is not None: + api_params['opacity'] = opacity + if rotation is not None: + api_params['rotation'] = rotation + if background is not None: + api_params['background'] = background + if output is not None: + api_params['output'] = output + if token is not None: + api_params['token'] = token return self.client.call('get', api_path, { }, api_params) @@ -602,7 +640,8 @@ def get_file_view(self, bucket_id: str, file_id: str, token: Optional[str] = Non api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['token'] = token + if token is not None: + api_params['token'] = token return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index edd7645..5318ca4 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -38,9 +38,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/tablesdb' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -81,7 +84,8 @@ def create(self, database_id: str, name: str, enabled: Optional[bool] = None) -> api_params['databaseId'] = database_id api_params['name'] = name - api_params['enabled'] = enabled + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -110,7 +114,8 @@ def list_transactions(self, queries: Optional[List[str]] = None) -> Dict[str, An api_path = '/tablesdb/transactions' api_params = {} - api_params['queries'] = queries + if queries is not None: + api_params['queries'] = queries return self.client.call('get', api_path, { }, api_params) @@ -138,7 +143,8 @@ def create_transaction(self, ttl: Optional[float] = None) -> Dict[str, Any]: api_path = '/tablesdb/transactions' api_params = {} - api_params['ttl'] = ttl + if ttl is not None: + api_params['ttl'] = ttl return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -206,8 +212,10 @@ def update_transaction(self, transaction_id: str, commit: Optional[bool] = None, api_path = api_path.replace('{transactionId}', transaction_id) - api_params['commit'] = commit - api_params['rollback'] = rollback + if commit is not None: + api_params['commit'] = commit + if rollback is not None: + api_params['rollback'] = rollback return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -274,7 +282,8 @@ def create_operations(self, transaction_id: str, operations: Optional[List[dict] api_path = api_path.replace('{transactionId}', transaction_id) - api_params['operations'] = operations + if operations is not None: + api_params['operations'] = operations return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -346,7 +355,8 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> api_path = api_path.replace('{databaseId}', database_id) api_params['name'] = name - api_params['enabled'] = enabled + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -417,9 +427,12 @@ def list_tables(self, database_id: str, queries: Optional[List[str]] = None, sea api_path = api_path.replace('{databaseId}', database_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -469,9 +482,12 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions: api_params['tableId'] = table_id api_params['name'] = name - api_params['permissions'] = permissions - api_params['rowSecurity'] = row_security - api_params['enabled'] = enabled + if permissions is not None: + api_params['permissions'] = permissions + if row_security is not None: + api_params['rowSecurity'] = row_security + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -559,9 +575,12 @@ def update_table(self, database_id: str, table_id: str, name: str, permissions: api_path = api_path.replace('{tableId}', table_id) api_params['name'] = name - api_params['permissions'] = permissions - api_params['rowSecurity'] = row_security - api_params['enabled'] = enabled + if permissions is not None: + api_params['permissions'] = permissions + if row_security is not None: + api_params['rowSecurity'] = row_security + if enabled is not None: + api_params['enabled'] = enabled return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -642,8 +661,10 @@ def list_columns(self, database_id: str, table_id: str, queries: Optional[List[s api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -698,8 +719,10 @@ def create_boolean_column(self, database_id: str, table_id: str, key: str, requi api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -755,7 +778,8 @@ def update_boolean_column(self, database_id: str, table_id: str, key: str, requi api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -810,8 +834,10 @@ def create_datetime_column(self, database_id: str, table_id: str, key: str, requ api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -867,7 +893,8 @@ def update_datetime_column(self, database_id: str, table_id: str, key: str, requ api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -923,8 +950,10 @@ def create_email_column(self, database_id: str, table_id: str, key: str, require api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -981,7 +1010,8 @@ def update_email_column(self, database_id: str, table_id: str, key: str, require api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1042,8 +1072,10 @@ def create_enum_column(self, database_id: str, table_id: str, key: str, elements api_params['key'] = key api_params['elements'] = elements api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1106,7 +1138,8 @@ def update_enum_column(self, database_id: str, table_id: str, key: str, elements api_params['elements'] = elements api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1166,10 +1199,14 @@ def create_float_column(self, database_id: str, table_id: str, key: str, require api_params['key'] = key api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['array'] = array + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1229,10 +1266,13 @@ def update_float_column(self, database_id: str, table_id: str, key: str, require api_path = api_path.replace('{key}', key) api_params['required'] = required - api_params['min'] = min - api_params['max'] = max + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1292,10 +1332,14 @@ def create_integer_column(self, database_id: str, table_id: str, key: str, requi api_params['key'] = key api_params['required'] = required - api_params['min'] = min - api_params['max'] = max - api_params['default'] = default - api_params['array'] = array + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1355,10 +1399,13 @@ def update_integer_column(self, database_id: str, table_id: str, key: str, requi api_path = api_path.replace('{key}', key) api_params['required'] = required - api_params['min'] = min - api_params['max'] = max + if min is not None: + api_params['min'] = min + if max is not None: + api_params['max'] = max api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1414,8 +1461,10 @@ def create_ip_column(self, database_id: str, table_id: str, key: str, required: api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1472,7 +1521,8 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1581,7 +1631,8 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1690,7 +1741,8 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1799,7 +1851,8 @@ def update_polygon_column(self, database_id: str, table_id: str, key: str, requi api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1859,10 +1912,14 @@ def create_relationship_column(self, database_id: str, table_id: str, related_ta api_params['relatedTableId'] = related_table_id api_params['type'] = type - api_params['twoWay'] = two_way - api_params['key'] = key - api_params['twoWayKey'] = two_way_key - api_params['onDelete'] = on_delete + if two_way is not None: + api_params['twoWay'] = two_way + if key is not None: + api_params['key'] = key + if two_way_key is not None: + api_params['twoWayKey'] = two_way_key + if on_delete is not None: + api_params['onDelete'] = on_delete return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1926,9 +1983,12 @@ def create_string_column(self, database_id: str, table_id: str, key: str, size: api_params['key'] = key api_params['size'] = size api_params['required'] = required - api_params['default'] = default - api_params['array'] = array - api_params['encrypt'] = encrypt + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array + if encrypt is not None: + api_params['encrypt'] = encrypt return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1987,8 +2047,10 @@ def update_string_column(self, database_id: str, table_id: str, key: str, requir api_params['required'] = required api_params['default'] = default - api_params['size'] = size - api_params['newKey'] = new_key + if size is not None: + api_params['size'] = size + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2044,8 +2106,10 @@ def create_url_column(self, database_id: str, table_id: str, key: str, required: api_params['key'] = key api_params['required'] = required - api_params['default'] = default - api_params['array'] = array + if default is not None: + api_params['default'] = default + if array is not None: + api_params['array'] = array return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2102,7 +2166,8 @@ def update_url_column(self, database_id: str, table_id: str, key: str, required: api_params['required'] = required api_params['default'] = default - api_params['newKey'] = new_key + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2239,8 +2304,10 @@ def update_relationship_column(self, database_id: str, table_id: str, key: str, api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{key}', key) - api_params['onDelete'] = on_delete - api_params['newKey'] = new_key + if on_delete is not None: + api_params['onDelete'] = on_delete + if new_key is not None: + api_params['newKey'] = new_key return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2283,8 +2350,10 @@ def list_indexes(self, database_id: str, table_id: str, queries: Optional[List[s api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -2345,8 +2414,10 @@ def create_index(self, database_id: str, table_id: str, key: str, type: IndexTyp api_params['key'] = key api_params['type'] = type api_params['columns'] = columns - api_params['orders'] = orders - api_params['lengths'] = lengths + if orders is not None: + api_params['orders'] = orders + if lengths is not None: + api_params['lengths'] = lengths return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2478,9 +2549,12 @@ def list_rows(self, database_id: str, table_id: str, queries: Optional[List[str] api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -2534,8 +2608,10 @@ 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 + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2582,7 +2658,8 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict], transac api_path = api_path.replace('{tableId}', table_id) api_params['rows'] = rows - api_params['transactionId'] = transaction_id + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -2630,7 +2707,8 @@ def upsert_rows(self, database_id: str, table_id: str, rows: List[dict], transac api_path = api_path.replace('{tableId}', table_id) api_params['rows'] = rows - api_params['transactionId'] = transaction_id + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -2675,9 +2753,12 @@ def update_rows(self, database_id: str, table_id: str, data: Optional[dict] = No api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['data'] = data - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if data is not None: + api_params['data'] = data + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2720,8 +2801,10 @@ def delete_rows(self, database_id: str, table_id: str, queries: Optional[List[st api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', @@ -2770,8 +2853,10 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: Optiona api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{rowId}', row_id) - api_params['queries'] = queries - api_params['transactionId'] = transaction_id + if queries is not None: + api_params['queries'] = queries + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('get', api_path, { }, api_params) @@ -2821,9 +2906,12 @@ def upsert_row(self, database_id: str, table_id: str, row_id: str, data: Optiona api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{rowId}', row_id) - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + if data is not None: + api_params['data'] = data + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('put', api_path, { 'content-type': 'application/json', @@ -2874,9 +2962,12 @@ def update_row(self, database_id: str, table_id: str, row_id: str, data: Optiona api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{rowId}', row_id) - api_params['data'] = data - api_params['permissions'] = permissions - api_params['transactionId'] = transaction_id + if data is not None: + api_params['data'] = data + if permissions is not None: + api_params['permissions'] = permissions + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -2923,7 +3014,8 @@ def delete_row(self, database_id: str, table_id: str, row_id: str, transaction_i api_path = api_path.replace('{tableId}', table_id) api_path = api_path.replace('{rowId}', row_id) - api_params['transactionId'] = transaction_id + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('delete', api_path, { 'content-type': 'application/json', @@ -2980,9 +3072,12 @@ def decrement_row_column(self, database_id: str, table_id: str, row_id: str, col api_path = api_path.replace('{rowId}', row_id) api_path = api_path.replace('{column}', column) - api_params['value'] = value - api_params['min'] = min - api_params['transactionId'] = transaction_id + if value is not None: + api_params['value'] = value + if min is not None: + api_params['min'] = min + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -3039,9 +3134,12 @@ def increment_row_column(self, database_id: str, table_id: str, row_id: str, col api_path = api_path.replace('{rowId}', row_id) api_path = api_path.replace('{column}', column) - api_params['value'] = value - api_params['max'] = max - api_params['transactionId'] = transaction_id + if value is not None: + api_params['value'] = value + if max is not None: + api_params['max'] = max + if transaction_id is not None: + api_params['transactionId'] = transaction_id return self.client.call('patch', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index cd456d9..1e15296 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -35,9 +35,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/teams' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -77,7 +80,8 @@ def create(self, team_id: str, name: str, roles: Optional[List[str]] = None) -> api_params['teamId'] = team_id api_params['name'] = name - api_params['roles'] = roles + if roles is not None: + api_params['roles'] = roles return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -217,9 +221,12 @@ def list_memberships(self, team_id: str, queries: Optional[List[str]] = None, se api_path = api_path.replace('{teamId}', team_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -273,12 +280,17 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str] api_path = api_path.replace('{teamId}', team_id) - api_params['email'] = email - api_params['userId'] = user_id - api_params['phone'] = phone + if email is not None: + api_params['email'] = email + if user_id is not None: + api_params['userId'] = user_id + if phone is not None: + api_params['phone'] = phone api_params['roles'] = roles - api_params['url'] = url - api_params['name'] = name + if url is not None: + api_params['url'] = url + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/tokens.py b/appwrite/services/tokens.py index 6aa51af..a5d9d63 100644 --- a/appwrite/services/tokens.py +++ b/appwrite/services/tokens.py @@ -45,8 +45,10 @@ def list(self, bucket_id: str, file_id: str, queries: Optional[List[str]] = None api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) diff --git a/appwrite/services/users.py b/appwrite/services/users.py index 1a65600..1a1bbca 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -38,9 +38,12 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None api_path = '/users' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -80,10 +83,14 @@ def create(self, user_id: str, email: Optional[str] = None, phone: Optional[str] api_params['userId'] = user_id - api_params['email'] = email - api_params['phone'] = phone - api_params['password'] = password - api_params['name'] = name + if email is not None: + api_params['email'] = email + if phone is not None: + api_params['phone'] = phone + if password is not None: + api_params['password'] = password + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -130,7 +137,8 @@ def create_argon2_user(self, user_id: str, email: str, password: str, name: Opti api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -177,7 +185,8 @@ def create_bcrypt_user(self, user_id: str, email: str, password: str, name: Opti api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -210,9 +219,12 @@ def list_identities(self, queries: Optional[List[str]] = None, search: Optional[ api_path = '/users/identities' api_params = {} - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -290,7 +302,8 @@ def create_md5_user(self, user_id: str, email: str, password: str, name: Optiona api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -337,7 +350,8 @@ def create_ph_pass_user(self, user_id: str, email: str, password: str, name: Opt api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -414,7 +428,8 @@ def create_scrypt_user(self, user_id: str, email: str, password: str, password_s api_params['passwordMemory'] = password_memory api_params['passwordParallel'] = password_parallel api_params['passwordLength'] = password_length - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -479,7 +494,8 @@ def create_scrypt_modified_user(self, user_id: str, email: str, password: str, p api_params['passwordSalt'] = password_salt api_params['passwordSaltSeparator'] = password_salt_separator api_params['passwordSignerKey'] = password_signer_key - api_params['name'] = name + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -528,8 +544,10 @@ def create_sha_user(self, user_id: str, email: str, password: str, password_vers api_params['userId'] = user_id api_params['email'] = email api_params['password'] = password - api_params['passwordVersion'] = password_version - api_params['name'] = name + if password_version is not None: + api_params['passwordVersion'] = password_version + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -667,8 +685,10 @@ def create_jwt(self, user_id: str, session_id: Optional[str] = None, duration: O api_path = api_path.replace('{userId}', user_id) - api_params['sessionId'] = session_id - api_params['duration'] = duration + if session_id is not None: + api_params['sessionId'] = session_id + if duration is not None: + api_params['duration'] = duration return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -745,8 +765,10 @@ def list_logs(self, user_id: str, queries: Optional[List[str]] = None, total: Op api_path = api_path.replace('{userId}', user_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -784,9 +806,12 @@ def list_memberships(self, user_id: str, queries: Optional[List[str]] = None, se api_path = api_path.replace('{userId}', user_id) - api_params['queries'] = queries - api_params['search'] = search - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if search is not None: + api_params['search'] = search + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -1205,7 +1230,8 @@ def list_sessions(self, user_id: str, total: Optional[bool] = None) -> Dict[str, api_path = api_path.replace('{userId}', user_id) - api_params['total'] = total + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -1383,8 +1409,10 @@ def list_targets(self, user_id: str, queries: Optional[List[str]] = None, total: api_path = api_path.replace('{userId}', user_id) - api_params['queries'] = queries - api_params['total'] = total + if queries is not None: + api_params['queries'] = queries + if total is not None: + api_params['total'] = total return self.client.call('get', api_path, { }, api_params) @@ -1438,8 +1466,10 @@ def create_target(self, user_id: str, target_id: str, provider_type: MessagingPr api_params['targetId'] = target_id api_params['providerType'] = provider_type api_params['identifier'] = identifier - api_params['providerId'] = provider_id - api_params['name'] = name + if provider_id is not None: + api_params['providerId'] = provider_id + if name is not None: + api_params['name'] = name return self.client.call('post', api_path, { 'content-type': 'application/json', @@ -1521,9 +1551,12 @@ def update_target(self, user_id: str, target_id: str, identifier: Optional[str] api_path = api_path.replace('{userId}', user_id) api_path = api_path.replace('{targetId}', target_id) - api_params['identifier'] = identifier - api_params['providerId'] = provider_id - api_params['name'] = name + if identifier is not None: + api_params['identifier'] = identifier + if provider_id is not None: + api_params['providerId'] = provider_id + if name is not None: + api_params['name'] = name return self.client.call('patch', api_path, { 'content-type': 'application/json', @@ -1599,8 +1632,10 @@ def create_token(self, user_id: str, length: Optional[float] = None, expire: Opt api_path = api_path.replace('{userId}', user_id) - api_params['length'] = length - api_params['expire'] = expire + if length is not None: + api_params['length'] = length + if expire is not None: + api_params['expire'] = expire return self.client.call('post', api_path, { 'content-type': 'application/json', diff --git a/setup.py b/setup.py index 4fe9b23..a0c9da0 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '13.6.0', + version = '13.6.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, @@ -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/13.6.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.6.1.tar.gz', install_requires=[ 'requests', ],