Skip to content

Commit e127062

Browse files
authored
Merge pull request #119 from appwrite/dev
feat: Python SDK update for version 13.3.0
2 parents 94e08f6 + 414df8d commit e127062

File tree

9 files changed

+144
-35
lines changed

9 files changed

+144
-35
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 13.3.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 11.1.0
49

510
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service

appwrite/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def __init__(self):
1515
self._endpoint = 'https://cloud.appwrite.io/v1'
1616
self._global_headers = {
1717
'content-type': '',
18-
'user-agent' : f'AppwritePythonSDK/13.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
18+
'user-agent' : f'AppwritePythonSDK/13.3.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
1919
'x-sdk-name': 'Python',
2020
'x-sdk-platform': 'server',
2121
'x-sdk-language': 'python',
22-
'x-sdk-version': '13.2.0',
22+
'x-sdk-version': '13.3.0',
2323
'X-Appwrite-Response-Format' : '1.8.0',
2424
}
2525

appwrite/services/account.py

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,13 +1275,50 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]:
12751275
'content-type': 'application/json',
12761276
}, api_params)
12771277

1278+
def create_email_verification(self, url: str) -> Dict[str, Any]:
1279+
"""
1280+
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.
1281+
1282+
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.
1283+
1284+
1285+
Parameters
1286+
----------
1287+
url : str
1288+
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.
1289+
1290+
Returns
1291+
-------
1292+
Dict[str, Any]
1293+
API response as a dictionary
1294+
1295+
Raises
1296+
------
1297+
AppwriteException
1298+
If API request fails
1299+
"""
1300+
1301+
api_path = '/account/verifications/email'
1302+
api_params = {}
1303+
if url is None:
1304+
raise AppwriteException('Missing required parameter: "url"')
1305+
1306+
1307+
api_params['url'] = url
1308+
1309+
return self.client.call('post', api_path, {
1310+
'content-type': 'application/json',
1311+
}, api_params)
1312+
12781313
def create_verification(self, url: str) -> Dict[str, Any]:
12791314
"""
12801315
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.
12811316
12821317
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.
12831318
12841319
1320+
.. deprecated::1.8.0
1321+
This API has been deprecated since 1.8.0. Please use `account.create_email_verification` instead.
12851322
Parameters
12861323
----------
12871324
url : str
@@ -1298,7 +1335,7 @@ def create_verification(self, url: str) -> Dict[str, Any]:
12981335
If API request fails
12991336
"""
13001337

1301-
api_path = '/account/verification'
1338+
api_path = '/account/verifications/email'
13021339
api_params = {}
13031340
if url is None:
13041341
raise AppwriteException('Missing required parameter: "url"')
@@ -1310,10 +1347,50 @@ def create_verification(self, url: str) -> Dict[str, Any]:
13101347
'content-type': 'application/json',
13111348
}, api_params)
13121349

1350+
def update_email_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
1351+
"""
1352+
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.
1353+
1354+
Parameters
1355+
----------
1356+
user_id : str
1357+
User ID.
1358+
secret : str
1359+
Valid verification token.
1360+
1361+
Returns
1362+
-------
1363+
Dict[str, Any]
1364+
API response as a dictionary
1365+
1366+
Raises
1367+
------
1368+
AppwriteException
1369+
If API request fails
1370+
"""
1371+
1372+
api_path = '/account/verifications/email'
1373+
api_params = {}
1374+
if user_id is None:
1375+
raise AppwriteException('Missing required parameter: "user_id"')
1376+
1377+
if secret is None:
1378+
raise AppwriteException('Missing required parameter: "secret"')
1379+
1380+
1381+
api_params['userId'] = user_id
1382+
api_params['secret'] = secret
1383+
1384+
return self.client.call('put', api_path, {
1385+
'content-type': 'application/json',
1386+
}, api_params)
1387+
13131388
def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
13141389
"""
13151390
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.
13161391
1392+
.. deprecated::1.8.0
1393+
This API has been deprecated since 1.8.0. Please use `account.update_email_verification` instead.
13171394
Parameters
13181395
----------
13191396
user_id : str
@@ -1332,7 +1409,7 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
13321409
If API request fails
13331410
"""
13341411

1335-
api_path = '/account/verification'
1412+
api_path = '/account/verifications/email'
13361413
api_params = {}
13371414
if user_id is None:
13381415
raise AppwriteException('Missing required parameter: "user_id"')
@@ -1363,7 +1440,7 @@ def create_phone_verification(self) -> Dict[str, Any]:
13631440
If API request fails
13641441
"""
13651442

1366-
api_path = '/account/verification/phone'
1443+
api_path = '/account/verifications/phone'
13671444
api_params = {}
13681445

13691446
return self.client.call('post', api_path, {
@@ -1392,7 +1469,7 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any]
13921469
If API request fails
13931470
"""
13941471

1395-
api_path = '/account/verification/phone'
1472+
api_path = '/account/verifications/phone'
13961473
api_params = {}
13971474
if user_id is None:
13981475
raise AppwriteException('Missing required parameter: "user_id"')

appwrite/services/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def create_template_deployment(self, function_id: str, repository: str, owner: s
504504
"""
505505
Create a deployment based on a template.
506506
507-
Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details.
507+
Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details.
508508
509509
Parameters
510510
----------

appwrite/services/sites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def create_template_deployment(self, site_id: str, repository: str, owner: str,
507507
"""
508508
Create a deployment based on a template.
509509
510-
Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to find the template details.
510+
Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details.
511511
512512
Parameters
513513
----------

0 commit comments

Comments
 (0)