From 77841bc3b054d16f9ee412d2c5a4ad47c123582d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 01:30:50 +1200 Subject: [PATCH 1/6] Add time between queries --- appwrite/client.py | 4 +- appwrite/enums/credit_card.py | 2 +- appwrite/enums/execution_method.py | 1 + appwrite/enums/index_type.py | 1 + appwrite/query.py | 8 + appwrite/services/account.py | 8 +- appwrite/services/avatars.py | 2 +- appwrite/services/databases.py | 341 +++++++++++++++++- appwrite/services/functions.py | 2 +- appwrite/services/tables_db.py | 327 +++++++++++++++++ .../databases/create-line-attribute.md | 17 + .../databases/create-point-attribute.md | 17 + .../databases/create-polygon-attribute.md | 17 + .../databases/update-line-attribute.md | 18 + .../databases/update-point-attribute.md | 18 + .../databases/update-polygon-attribute.md | 18 + docs/examples/tablesdb/create-line-column.md | 17 + docs/examples/tablesdb/create-point-column.md | 17 + .../tablesdb/create-polygon-column.md | 17 + docs/examples/tablesdb/update-line-column.md | 18 + docs/examples/tablesdb/update-point-column.md | 18 + .../tablesdb/update-polygon-column.md | 18 + setup.py | 4 +- 23 files changed, 898 insertions(+), 12 deletions(-) create mode 100644 docs/examples/databases/create-line-attribute.md create mode 100644 docs/examples/databases/create-point-attribute.md create mode 100644 docs/examples/databases/create-polygon-attribute.md create mode 100644 docs/examples/databases/update-line-attribute.md create mode 100644 docs/examples/databases/update-point-attribute.md create mode 100644 docs/examples/databases/update-polygon-attribute.md create mode 100644 docs/examples/tablesdb/create-line-column.md create mode 100644 docs/examples/tablesdb/create-point-column.md create mode 100644 docs/examples/tablesdb/create-polygon-column.md create mode 100644 docs/examples/tablesdb/update-line-column.md create mode 100644 docs/examples/tablesdb/update-point-column.md create mode 100644 docs/examples/tablesdb/update-polygon-column.md diff --git a/appwrite/client.py b/appwrite/client.py index 93897d89..8de261e4 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -14,11 +14,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/12.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/12.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '12.0.0', + 'x-sdk-version': '12.1.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/enums/credit_card.py b/appwrite/enums/credit_card.py index 3f770a37..71393b34 100644 --- a/appwrite/enums/credit_card.py +++ b/appwrite/enums/credit_card.py @@ -13,7 +13,7 @@ class CreditCard(Enum): MASTERCARD = "mastercard" NARANJA = "naranja" TARJETA_SHOPPING = "targeta-shopping" - UNION_CHINA_PAY = "union-china-pay" + UNION_PAY = "unionpay" VISA = "visa" MIR = "mir" MAESTRO = "maestro" diff --git a/appwrite/enums/execution_method.py b/appwrite/enums/execution_method.py index 23df3b9a..d260384b 100644 --- a/appwrite/enums/execution_method.py +++ b/appwrite/enums/execution_method.py @@ -7,3 +7,4 @@ class ExecutionMethod(Enum): PATCH = "PATCH" DELETE = "DELETE" OPTIONS = "OPTIONS" + HEAD = "HEAD" diff --git a/appwrite/enums/index_type.py b/appwrite/enums/index_type.py index f4c9e4c5..842240f6 100644 --- a/appwrite/enums/index_type.py +++ b/appwrite/enums/index_type.py @@ -4,3 +4,4 @@ class IndexType(Enum): KEY = "key" FULLTEXT = "fulltext" UNIQUE = "unique" + SPATIAL = "spatial" diff --git a/appwrite/query.py b/appwrite/query.py index 80f105cd..ce972504 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -127,6 +127,10 @@ def created_before(value): def created_after(value): return str(Query("createdAfter", None, value)) + @staticmethod + def created_between(start, end): + return str(Query("createdBetween", None, [start, end])) + @staticmethod def updated_before(value): return str(Query("updatedBefore", None, value)) @@ -135,6 +139,10 @@ def updated_before(value): def updated_after(value): return str(Query("updatedAfter", None, value)) + @staticmethod + def updated_between(start, end): + return str(Query("updatedBetween", None, [start, end])) + @staticmethod def or_queries(queries): return str(Query("or", None, [json.loads(query) for query in queries])) diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 200af46d..7a15f019 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -869,8 +869,8 @@ def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - .. deprecated:: - This API has been deprecated. + .. deprecated::1.6.0 + This API has been deprecated since 1.6.0. Please use `account.create_session` instead. Parameters ---------- user_id : str @@ -909,8 +909,8 @@ def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]: """ Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. - .. deprecated:: - This API has been deprecated. + .. deprecated::1.6.0 + This API has been deprecated since 1.6.0. Please use `account.create_session` instead. Parameters ---------- user_id : str diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 6ee1d4f0..a72e14fd 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -62,7 +62,7 @@ def get_credit_card(self, code: CreditCard, width: float = None, height: float = Parameters ---------- code : CreditCard - Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. + Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. width : float Image width. Pass an integer between 0 to 2000. Defaults to 100. height : float diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 898bc41d..9525698c 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -49,7 +49,7 @@ def create(self, database_id: str, name: str, enabled: bool = None) -> Dict[str, .. deprecated::1.8.0 - This API has been deprecated since 1.8.0. Please use `tablesDB.create_database` instead. + This API has been deprecated since 1.8.0. Please use `tablesDB.create` instead. Parameters ---------- database_id : str @@ -1326,6 +1326,345 @@ def update_ip_attribute(self, database_id: str, collection_id: str, key: str, re 'content-type': 'application/json', }, api_params) + def create_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric line attribute. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.create_line_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a line attribute. Changing the `default` value will not update already existing documents. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_line_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric 2d point attribute. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.create_point_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a point attribute. Changing the `default` value will not update already existing documents. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_point_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric polygon attribute. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.create_polygon_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a polygon attribute. Changing the `default` value will not update already existing documents. + + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_polygon_column` instead. + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : str + Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + new_key : str + New attribute key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + def create_relationship_attribute(self, database_id: str, collection_id: str, related_collection_id: str, type: RelationshipType, two_way: bool = None, key: str = None, two_way_key: str = None, on_delete: RelationMutate = None) -> Dict[str, Any]: """ Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 9dce4257..15cb8e2d 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -812,7 +812,7 @@ def create_execution(self, function_id: str, body: str = None, xasync: bool = No path : str HTTP path of execution. Path can include query params. Default value is / method : ExecutionMethod - HTTP method of execution. Default value is GET. + HTTP method of execution. Default value is POST. headers : dict HTTP headers of execution. Defaults to empty. scheduled_at : str diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 578e880b..5f213d38 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -1275,6 +1275,333 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: 'content-type': 'application/json', }, api_params) + def create_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric line attribute. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a line column. Changing the `default` value will not update already existing documents. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + new_key : str + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric point attribute. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a point column. Changing the `default` value will not update already existing documents. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + new_key : str + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + """ + Create a geometric polygon attribute. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a polygon column. Changing the `default` value will not update already existing documents. + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + key : str + Column Key. + required : bool + Is column required? + default : str + Default value for column when not provided, as JSON string. Cannot be set when column is required. + new_key : str + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + def create_relationship_column(self, database_id: str, table_id: str, related_table_id: str, type: RelationshipType, two_way: bool = None, key: str = None, two_way_key: str = None, on_delete: RelationMutate = None) -> Dict[str, Any]: """ Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 00000000..3521cc90 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_line_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 00000000..8a808c44 --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_point_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 00000000..478a3692 --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.create_polygon_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 00000000..378e5a9b --- /dev/null +++ b/docs/examples/databases/update-line-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_line_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 00000000..a7d96d0b --- /dev/null +++ b/docs/examples/databases/update-point-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_point_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 00000000..b6ac782d --- /dev/null +++ b/docs/examples/databases/update-polygon-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +databases = Databases(client) + +result = databases.update_polygon_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 00000000..9c6a1b76 --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.create_line_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 00000000..4a9e92b5 --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.create_point_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 00000000..6863fdd8 --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,17 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.create_polygon_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '' # optional +) diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 00000000..b1a64755 --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.update_line_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 00000000..47c94395 --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.update_point_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 00000000..a38acbaf --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +tables_db = TablesDB(client) + +result = tables_db.update_polygon_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + new_key = '' # optional +) diff --git a/setup.py b/setup.py index f0bb2534..ace94f61 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '12.0.0', + version = '12.1.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/12.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/12.1.0.tar.gz', install_requires=[ 'requests', ], From 235cc10501095810fb4820ba74ecd906d5419c99 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 02:14:54 +1200 Subject: [PATCH 2/6] Update version --- appwrite/client.py | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appwrite/client.py b/appwrite/client.py index 8de261e4..caa1f4bb 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -14,11 +14,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/12.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/13.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '12.1.0', + 'x-sdk-version': '13.0.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/setup.py b/setup.py index ace94f61..78836525 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '12.1.0', + version = '13.0.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/12.1.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.0.0.tar.gz', install_requires=[ 'requests', ], From 4d1d92e4252b9469f7cdc4f8638ca35795ac13b0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 21:41:22 +1200 Subject: [PATCH 3/6] Add spatial queries --- appwrite/query.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/appwrite/query.py b/appwrite/query.py index ce972504..f4885a8e 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -150,3 +150,51 @@ def or_queries(queries): @staticmethod def and_queries(queries): return str(Query("and", None, [json.loads(query) for query in queries])) + + @staticmethod + def distance_equal(attribute, values, distance, meters=True): + return str(Query("distanceEqual", attribute, [values, distance, meters])) + + @staticmethod + def distance_not_equal(attribute, values, distance, meters=True): + return str(Query("distanceNotEqual", attribute, [values, distance, meters])) + + @staticmethod + def distance_greater_than(attribute, values, distance, meters=True): + return str(Query("distanceGreaterThan", attribute, [values, distance, meters])) + + @staticmethod + def distance_less_than(attribute, values, distance, meters=True): + return str(Query("distanceLessThan", attribute, [values, distance, meters])) + + @staticmethod + def intersects(attribute, values): + return str(Query("intersects", attribute, values)) + + @staticmethod + def not_intersects(attribute, values): + return str(Query("notIntersects", attribute, values)) + + @staticmethod + def crosses(attribute, values): + return str(Query("crosses", attribute, values)) + + @staticmethod + def not_crosses(attribute, values): + return str(Query("notCrosses", attribute, values)) + + @staticmethod + def overlaps(attribute, values): + return str(Query("overlaps", attribute, values)) + + @staticmethod + def not_overlaps(attribute, values): + return str(Query("notOverlaps", attribute, values)) + + @staticmethod + def touches(attribute, values): + return str(Query("touches", attribute, values)) + + @staticmethod + def not_touches(attribute, values): + return str(Query("notTouches", attribute, values)) From 05c96662b2fd9f1f99589ace61b56c103fedda06 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 22:01:25 +1200 Subject: [PATCH 4/6] Fix refs --- appwrite/services/databases.py | 2 +- appwrite/services/tables_db.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 9525698c..40d924f2 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1441,7 +1441,7 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: """ - Create a geometric 2d point attribute. + Create a geometric point attribute. .. deprecated::1.8.0 This API has been deprecated since 1.8.0. Please use `tablesDB.create_point_column` instead. diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 5f213d38..5034fd79 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -1277,7 +1277,7 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: def create_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: """ - Create a geometric line attribute. + Create a geometric line column. Parameters ---------- @@ -1330,7 +1330,7 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required def update_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: """ - Update a line column. Changing the `default` value will not update already existing documents. + Update a line column. Changing the `default` value will not update already existing rows. Parameters ---------- @@ -1386,7 +1386,7 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: """ - Create a geometric point attribute. + Create a geometric point column. Parameters ---------- @@ -1439,7 +1439,7 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require def update_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: """ - Update a point column. Changing the `default` value will not update already existing documents. + Update a point column. Changing the `default` value will not update already existing rows. Parameters ---------- @@ -1495,7 +1495,7 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require def create_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: """ - Create a geometric polygon attribute. + Create a geometric polygon column. Parameters ---------- @@ -1548,7 +1548,7 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi def update_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: """ - Update a polygon column. Changing the `default` value will not update already existing documents. + Update a polygon column. Changing the `default` value will not update already existing rows. Parameters ---------- From 9911dcc00dd1d5651c39e525193d94218ecf152b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 6 Sep 2025 04:57:45 +1200 Subject: [PATCH 5/6] Fix spatial default --- appwrite/services/databases.py | 36 +++++++++---------- appwrite/services/tables_db.py | 36 +++++++++---------- docs/examples/account/update-prefs.md | 6 +++- docs/examples/databases/create-document.md | 8 ++++- .../databases/create-line-attribute.md | 2 +- .../databases/create-point-attribute.md | 2 +- .../databases/create-polygon-attribute.md | 2 +- .../databases/update-line-attribute.md | 2 +- .../databases/update-point-attribute.md | 2 +- .../databases/update-polygon-attribute.md | 2 +- docs/examples/tablesdb/create-line-column.md | 2 +- docs/examples/tablesdb/create-point-column.md | 2 +- .../tablesdb/create-polygon-column.md | 2 +- docs/examples/tablesdb/create-row.md | 8 ++++- docs/examples/tablesdb/update-line-column.md | 2 +- docs/examples/tablesdb/update-point-column.md | 2 +- .../tablesdb/update-polygon-column.md | 2 +- 17 files changed, 67 insertions(+), 51 deletions(-) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 40d924f2..708cbe61 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -1326,7 +1326,7 @@ def update_ip_attribute(self, database_id: str, collection_id: str, key: str, re 'content-type': 'application/json', }, api_params) - def create_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric line attribute. @@ -1342,8 +1342,8 @@ def create_line_attribute(self, database_id: str, collection_id: str, key: str, Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. Returns ------- @@ -1381,7 +1381,7 @@ def create_line_attribute(self, database_id: str, collection_id: str, key: str, 'content-type': 'application/json', }, api_params) - def update_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_line_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a line attribute. Changing the `default` value will not update already existing documents. @@ -1397,8 +1397,8 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. new_key : str New attribute key. @@ -1439,7 +1439,7 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, 'content-type': 'application/json', }, api_params) - def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric point attribute. @@ -1455,8 +1455,8 @@ def create_point_attribute(self, database_id: str, collection_id: str, key: str, Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. Returns ------- @@ -1494,7 +1494,7 @@ def create_point_attribute(self, database_id: str, collection_id: str, key: str, 'content-type': 'application/json', }, api_params) - def update_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a point attribute. Changing the `default` value will not update already existing documents. @@ -1510,8 +1510,8 @@ def update_point_attribute(self, database_id: str, collection_id: str, key: str, Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. new_key : str New attribute key. @@ -1552,7 +1552,7 @@ def update_point_attribute(self, database_id: str, collection_id: str, key: str, 'content-type': 'application/json', }, api_params) - def create_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric polygon attribute. @@ -1568,8 +1568,8 @@ def create_polygon_attribute(self, database_id: str, collection_id: str, key: st Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. Returns ------- @@ -1607,7 +1607,7 @@ def create_polygon_attribute(self, database_id: str, collection_id: str, key: st 'content-type': 'application/json', }, api_params) - def update_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_polygon_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a polygon attribute. Changing the `default` value will not update already existing documents. @@ -1623,8 +1623,8 @@ def update_polygon_attribute(self, database_id: str, collection_id: str, key: st Attribute Key. required : bool Is attribute required? - default : str - Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. + default : List[Any] + Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. new_key : str New attribute key. diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 5034fd79..4bf5cc2f 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -1275,7 +1275,7 @@ def update_ip_column(self, database_id: str, table_id: str, key: str, required: 'content-type': 'application/json', }, api_params) - def create_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric line column. @@ -1289,8 +1289,8 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. Returns ------- @@ -1328,7 +1328,7 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required 'content-type': 'application/json', }, api_params) - def update_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_line_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a line column. Changing the `default` value will not update already existing rows. @@ -1342,8 +1342,8 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. new_key : str New Column Key. @@ -1384,7 +1384,7 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required 'content-type': 'application/json', }, api_params) - def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric point column. @@ -1398,8 +1398,8 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. Returns ------- @@ -1437,7 +1437,7 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require 'content-type': 'application/json', }, api_params) - def update_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a point column. Changing the `default` value will not update already existing rows. @@ -1451,8 +1451,8 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. new_key : str New Column Key. @@ -1493,7 +1493,7 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require 'content-type': 'application/json', }, api_params) - def create_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None) -> Dict[str, Any]: + def create_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None) -> Dict[str, Any]: """ Create a geometric polygon column. @@ -1507,8 +1507,8 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. Returns ------- @@ -1546,7 +1546,7 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi 'content-type': 'application/json', }, api_params) - def update_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: str = None, new_key: str = None) -> Dict[str, Any]: + def update_polygon_column(self, database_id: str, table_id: str, key: str, required: bool, default: List[Any] = None, new_key: str = None) -> Dict[str, Any]: """ Update a polygon column. Changing the `default` value will not update already existing rows. @@ -1560,8 +1560,8 @@ def update_polygon_column(self, database_id: str, table_id: str, key: str, requi Column Key. required : bool Is column required? - default : str - Default value for column when not provided, as JSON string. Cannot be set when column is required. + default : List[Any] + Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. new_key : str New Column Key. diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index e2ac7a28..8981af83 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -9,5 +9,9 @@ client.set_session('') # The user session to authenticate with account = Account(client) result = account.update_prefs( - prefs = {} + prefs = { + "language": "en", + "timezone": "UTC", + "darkTheme": True + } ) diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 1eaf0246..3d7dee1a 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -12,6 +12,12 @@ result = databases.create_document( database_id = '', collection_id = '', document_id = '', - data = {}, + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": False + }, permissions = ["read("any")"] # optional ) diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 3521cc90..ccb8fec7 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -13,5 +13,5 @@ result = databases.create_line_attribute( collection_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 8a808c44..f0b1f2d5 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -13,5 +13,5 @@ result = databases.create_point_attribute( collection_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 478a3692..dec3111b 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -13,5 +13,5 @@ result = databases.create_polygon_attribute( collection_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index 378e5a9b..9bd33e6c 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -13,6 +13,6 @@ result = databases.update_line_attribute( collection_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index a7d96d0b..90f2df57 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -13,6 +13,6 @@ result = databases.update_point_attribute( collection_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index b6ac782d..07d17478 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -13,6 +13,6 @@ result = databases.update_polygon_attribute( collection_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 9c6a1b76..82482b31 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -13,5 +13,5 @@ result = tables_db.create_line_column( table_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 4a9e92b5..9d866aab 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -13,5 +13,5 @@ result = tables_db.create_point_column( table_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 6863fdd8..94877f19 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -13,5 +13,5 @@ result = tables_db.create_polygon_column( table_id = '', key = '', required = False, - default = '' # optional + default = [[1,2], [3, 4]] # optional ) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 69fee149..d4c1cdad 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -12,6 +12,12 @@ result = tables_db.create_row( database_id = '', table_id = '', row_id = '', - data = {}, + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": False + }, permissions = ["read("any")"] # optional ) diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index b1a64755..c59681d8 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -13,6 +13,6 @@ result = tables_db.update_line_column( table_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 47c94395..5901280a 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -13,6 +13,6 @@ result = tables_db.update_point_column( table_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index a38acbaf..e936964d 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -13,6 +13,6 @@ result = tables_db.update_polygon_column( table_id = '', key = '', required = False, - default = '', # optional + default = [[1,2], [3, 4]], # optional new_key = '' # optional ) From 5db08603263856f8bb849e120558a2ea40c2d5d6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 8 Sep 2025 21:42:10 +1200 Subject: [PATCH 6/6] Update spatial queries --- appwrite/query.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/appwrite/query.py b/appwrite/query.py index f4885a8e..a0127e57 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -153,48 +153,48 @@ def and_queries(queries): @staticmethod def distance_equal(attribute, values, distance, meters=True): - return str(Query("distanceEqual", attribute, [values, distance, meters])) + return str(Query("distanceEqual", attribute, [[values, distance, meters]])) @staticmethod def distance_not_equal(attribute, values, distance, meters=True): - return str(Query("distanceNotEqual", attribute, [values, distance, meters])) + return str(Query("distanceNotEqual", attribute, [[values, distance, meters]])) @staticmethod def distance_greater_than(attribute, values, distance, meters=True): - return str(Query("distanceGreaterThan", attribute, [values, distance, meters])) + return str(Query("distanceGreaterThan", attribute, [[values, distance, meters]])) @staticmethod def distance_less_than(attribute, values, distance, meters=True): - return str(Query("distanceLessThan", attribute, [values, distance, meters])) + return str(Query("distanceLessThan", attribute, [[values, distance, meters]])) @staticmethod def intersects(attribute, values): - return str(Query("intersects", attribute, values)) + return str(Query("intersects", attribute, [values])) @staticmethod def not_intersects(attribute, values): - return str(Query("notIntersects", attribute, values)) + return str(Query("notIntersects", attribute, [values])) @staticmethod def crosses(attribute, values): - return str(Query("crosses", attribute, values)) + return str(Query("crosses", attribute, [values])) @staticmethod def not_crosses(attribute, values): - return str(Query("notCrosses", attribute, values)) + return str(Query("notCrosses", attribute, [values])) @staticmethod def overlaps(attribute, values): - return str(Query("overlaps", attribute, values)) + return str(Query("overlaps", attribute, [values])) @staticmethod def not_overlaps(attribute, values): - return str(Query("notOverlaps", attribute, values)) + return str(Query("notOverlaps", attribute, [values])) @staticmethod def touches(attribute, values): - return str(Query("touches", attribute, values)) + return str(Query("touches", attribute, [values])) @staticmethod def not_touches(attribute, values): - return str(Query("notTouches", attribute, values)) + return str(Query("notTouches", attribute, [values]))