diff --git a/appwrite/client.py b/appwrite/client.py index 93897d8..caa1f4b 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/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.0.0', + 'x-sdk-version': '13.0.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/enums/credit_card.py b/appwrite/enums/credit_card.py index 3f770a3..71393b3 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 23df3b9..d260384 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 f4c9e4c..842240f 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 80f105c..a0127e5 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])) @@ -142,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])) diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 200af46..7a15f01 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 6ee1d4f..a72e14f 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 898bc41..708cbe6 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: List[Any] = 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 : 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 + ------- + 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: List[Any] = 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 : 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. + + 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: List[Any] = None) -> Dict[str, Any]: + """ + 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. + 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 : 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 + ------- + 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: List[Any] = 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 : 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. + + 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: List[Any] = 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 : 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 + ------- + 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: List[Any] = 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 : 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. + + 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 9dce425..15cb8e2 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 578e880..4bf5cc2 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: List[Any] = None) -> Dict[str, Any]: + """ + Create a geometric line column. + + 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 : 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 + ------- + 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: List[Any] = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a line column. Changing the `default` value will not update already existing rows. + + 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 : 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. + + 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: List[Any] = None) -> Dict[str, Any]: + """ + Create a geometric point column. + + 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 : 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 + ------- + 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: List[Any] = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a point column. Changing the `default` value will not update already existing rows. + + 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 : 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. + + 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: List[Any] = None) -> Dict[str, Any]: + """ + Create a geometric polygon column. + + 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 : 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 + ------- + 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: List[Any] = None, new_key: str = None) -> Dict[str, Any]: + """ + Update a polygon column. Changing the `default` value will not update already existing rows. + + 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 : 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. + + 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/account/update-prefs.md b/docs/examples/account/update-prefs.md index e2ac7a2..8981af8 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 1eaf024..3d7dee1 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 new file mode 100644 index 0000000..ccb8fec --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 0000000..f0b1f2d --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 0000000..dec3111 --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 0000000..9bd33e6 --- /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 = [[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 new file mode 100644 index 0000000..90f2df5 --- /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 = [[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 new file mode 100644 index 0000000..07d1747 --- /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 = [[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 new file mode 100644 index 0000000..82482b3 --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 0000000..9d866aa --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 0000000..94877f1 --- /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 = [[1,2], [3, 4]] # optional +) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 69fee14..d4c1cda 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 new file mode 100644 index 0000000..c59681d --- /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 = [[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 new file mode 100644 index 0000000..5901280 --- /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 = [[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 new file mode 100644 index 0000000..e936964 --- /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 = [[1,2], [3, 4]], # optional + new_key = '' # optional +) diff --git a/setup.py b/setup.py index f0bb253..7883652 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '12.0.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.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.0.0.tar.gz', install_requires=[ 'requests', ],