diff --git a/CHANGELOG.md b/CHANGELOG.md index ff63134..584aa5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 13.3.0 + +* Deprecate `createVerification` method in `Account` service +* Add `createEmailVerification` method in `Account` service + ## 11.1.0 * Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service diff --git a/appwrite/client.py b/appwrite/client.py index b174116..8240727 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,11 +15,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/13.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/13.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '13.2.0', + 'x-sdk-version': '13.3.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 7a15f01..08d3ae3 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1275,6 +1275,41 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]: 'content-type': 'application/json', }, api_params) + def create_email_verification(self, url: str) -> Dict[str, Any]: + """ + Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + + Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + + + Parameters + ---------- + url : str + URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verifications/email' + api_params = {} + if url is None: + raise AppwriteException('Missing required parameter: "url"') + + + api_params['url'] = url + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + def create_verification(self, url: str) -> Dict[str, Any]: """ Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. @@ -1282,6 +1317,8 @@ def create_verification(self, url: str) -> Dict[str, Any]: Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead. Parameters ---------- url : str @@ -1298,7 +1335,7 @@ def create_verification(self, url: str) -> Dict[str, Any]: If API request fails """ - api_path = '/account/verification' + api_path = '/account/verifications/email' api_params = {} if url is None: raise AppwriteException('Missing required parameter: "url"') @@ -1310,10 +1347,50 @@ def create_verification(self, url: str) -> Dict[str, Any]: 'content-type': 'application/json', }, api_params) + def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any]: + """ + Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + + Parameters + ---------- + user_id : str + User ID. + secret : str + Valid verification token. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/verifications/email' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if secret is None: + raise AppwriteException('Missing required parameter: "secret"') + + + api_params['userId'] = user_id + api_params['secret'] = secret + + return self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: """ Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `account.update_email_verification` instead. Parameters ---------- user_id : str @@ -1332,7 +1409,7 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]: If API request fails """ - api_path = '/account/verification' + api_path = '/account/verifications/email' api_params = {} if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') @@ -1363,7 +1440,7 @@ def create_phone_verification(self) -> Dict[str, Any]: If API request fails """ - api_path = '/account/verification/phone' + api_path = '/account/verifications/phone' api_params = {} return self.client.call('post', api_path, { @@ -1392,7 +1469,7 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any] If API request fails """ - api_path = '/account/verification/phone' + api_path = '/account/verifications/phone' api_params = {} if user_id is None: raise AppwriteException('Missing required parameter: "user_id"') diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 15cb8e2..ab0ab64 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -504,7 +504,7 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s """ Create a deployment based on a template. - Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details. + Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. Parameters ---------- diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index bcb7597..5a9c49a 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -507,7 +507,7 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str, """ Create a deployment based on a template. - Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details. + Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. Parameters ---------- diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index f6d3613..ec65274 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -226,7 +226,7 @@ def list_tables(self, database_id: str, queries: List[str] = None, search: str = def create_table(self, database_id: str, table_id: str, name: str, permissions: List[str] = None, row_security: bool = None, enabled: bool = None) -> Dict[str, Any]: """ - Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. Parameters ---------- @@ -455,7 +455,7 @@ def create_boolean_column(self, database_id: str, table_id: str, key: str, requi database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -511,7 +511,7 @@ def update_boolean_column(self, database_id: str, table_id: str, key: str, requi database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1284,7 +1284,7 @@ def create_line_column(self, database_id: str, table_id: str, key: str, required 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1337,7 +1337,7 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1393,7 +1393,7 @@ def create_point_column(self, database_id: str, table_id: str, key: str, require 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1446,7 +1446,7 @@ def update_point_column(self, database_id: str, table_id: str, key: str, require 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1502,7 +1502,7 @@ def create_polygon_column(self, database_id: str, table_id: str, key: str, requi 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1555,7 +1555,7 @@ def update_polygon_column(self, database_id: str, table_id: str, key: str, requi 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). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -1675,7 +1675,7 @@ def create_string_column(self, database_id: str, table_id: str, key: str, size: database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. size : float @@ -1741,7 +1741,7 @@ def update_string_column(self, database_id: str, table_id: str, key: str, requir database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Column Key. required : bool @@ -2052,7 +2052,7 @@ def list_indexes(self, database_id: str, table_id: str, queries: List[str] = Non database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). queries : List[str] Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error @@ -2093,7 +2093,7 @@ def create_index(self, database_id: str, table_id: str, key: str, type: IndexTyp database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Index Key. type : IndexType @@ -2155,7 +2155,7 @@ def get_index(self, database_id: str, table_id: str, key: str) -> Dict[str, Any] database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Index Key. @@ -2198,7 +2198,7 @@ def delete_index(self, database_id: str, table_id: str, key: str) -> Dict[str, A database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). key : str Index Key. @@ -2242,7 +2242,7 @@ def list_rows(self, database_id: str, table_id: str, queries: List[str] = None) database_id : str Database ID. table_id : str - Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). + Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). queries : List[str] Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. @@ -2275,14 +2275,14 @@ def list_rows(self, database_id: str, table_id: str, queries: List[str] = None) def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, permissions: List[str] = None) -> Dict[str, Any]: """ - Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. Parameters ---------- database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. row_id : str Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. data : dict @@ -2328,14 +2328,14 @@ def create_row(self, database_id: str, table_id: str, row_id: str, data: dict, p def create_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict[str, Any]: """ - Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. Parameters ---------- database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. rows : List[dict] Array of rows data as JSON objects. @@ -2372,7 +2372,7 @@ def create_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict def upsert_rows(self, database_id: str, table_id: str, rows: List[dict]) -> Dict[str, Any]: """ - Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. Parameters @@ -2468,7 +2468,7 @@ def delete_rows(self, database_id: str, table_id: str, queries: List[str] = None database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). queries : List[str] Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. @@ -2509,7 +2509,7 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[st database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). row_id : str Row ID. queries : List[str] @@ -2548,7 +2548,7 @@ def get_row(self, database_id: str, table_id: str, row_id: str, queries: List[st def upsert_row(self, database_id: str, table_id: str, row_id: str, data: dict = None, permissions: List[str] = None) -> Dict[str, Any]: """ - Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. + Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. Parameters ---------- @@ -2655,7 +2655,7 @@ def delete_row(self, database_id: str, table_id: str, row_id: str) -> Dict[str, database_id : str Database ID. table_id : str - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). row_id : str Row ID. diff --git a/docs/examples/account/create-email-verification.md b/docs/examples/account/create-email-verification.md new file mode 100644 index 0000000..a76a4bd --- /dev/null +++ b/docs/examples/account/create-email-verification.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.create_email_verification( + url = 'https://example.com' +) diff --git a/docs/examples/account/update-email-verification.md b/docs/examples/account/update-email-verification.md new file mode 100644 index 0000000..5e99587 --- /dev/null +++ b/docs/examples/account/update-email-verification.md @@ -0,0 +1,14 @@ +from appwrite.client import Client +from appwrite.services.account import Account + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +account = Account(client) + +result = account.update_email_verification( + user_id = '', + secret = '' +) diff --git a/setup.py b/setup.py index c49ebf4..6eef569 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'appwrite/encoders', 'appwrite/enums', ], - version = '13.2.0', + version = '13.3.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -23,7 +23,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/13.2.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/13.3.0.tar.gz', install_requires=[ 'requests', ],