Skip to content

Commit 3cbd608

Browse files
authored
Merge pull request #114 from appwrite/dev
Add 1.8.x support
2 parents 7979edd + b58a6d4 commit 3cbd608

File tree

84 files changed

+3507
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3507
-343
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Appwrite Python SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).**
9+
**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).**
1010

1111
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

appwrite/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def __init__(self):
1414
self._endpoint = 'https://cloud.appwrite.io/v1'
1515
self._global_headers = {
1616
'content-type': '',
17-
'user-agent' : f'AppwritePythonSDK/11.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
17+
'user-agent' : f'AppwritePythonSDK/12.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
1818
'x-sdk-name': 'Python',
1919
'x-sdk-platform': 'server',
2020
'x-sdk-language': 'python',
21-
'x-sdk-version': '11.1.0',
22-
'X-Appwrite-Response-Format' : '1.7.0',
21+
'x-sdk-version': '12.0.0',
22+
'X-Appwrite-Response-Format' : '1.8.0',
2323
}
2424

2525
def set_self_signed(self, status=True):

appwrite/query.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,42 @@ def offset(offset):
9999
def contains(attribute, value):
100100
return str(Query("contains", attribute, value))
101101

102+
@staticmethod
103+
def not_contains(attribute, value):
104+
return str(Query("notContains", attribute, value))
105+
106+
@staticmethod
107+
def not_search(attribute, value):
108+
return str(Query("notSearch", attribute, value))
109+
110+
@staticmethod
111+
def not_between(attribute, start, end):
112+
return str(Query("notBetween", attribute, [start, end]))
113+
114+
@staticmethod
115+
def not_starts_with(attribute, value):
116+
return str(Query("notStartsWith", attribute, value))
117+
118+
@staticmethod
119+
def not_ends_with(attribute, value):
120+
return str(Query("notEndsWith", attribute, value))
121+
122+
@staticmethod
123+
def created_before(value):
124+
return str(Query("createdBefore", None, value))
125+
126+
@staticmethod
127+
def created_after(value):
128+
return str(Query("createdAfter", None, value))
129+
130+
@staticmethod
131+
def updated_before(value):
132+
return str(Query("updatedBefore", None, value))
133+
134+
@staticmethod
135+
def updated_after(value):
136+
return str(Query("updatedAfter", None, value))
137+
102138
@staticmethod
103139
def or_queries(queries):
104140
return str(Query("or", None, [json.loads(query) for query in queries]))

appwrite/services/account.py

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def create(self, user_id: str, email: str, password: str, name: str = None) -> D
3535
"""
3636
Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).
3737
38-
3938
Parameters
4039
----------
4140
user_id : str
@@ -85,7 +84,6 @@ def update_email(self, email: str, password: str) -> Dict[str, Any]:
8584
This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.
8685
8786
88-
8987
Parameters
9088
----------
9189
email : str
@@ -124,7 +122,6 @@ def list_identities(self, queries: List[str] = None) -> Dict[str, Any]:
124122
"""
125123
Get the list of identities for the currently logged in user.
126124
127-
128125
Parameters
129126
----------
130127
queries : List[str]
@@ -153,7 +150,6 @@ def delete_identity(self, identity_id: str) -> Dict[str, Any]:
153150
"""
154151
Delete an identity by its unique ID.
155152
156-
157153
Parameters
158154
----------
159155
identity_id : str
@@ -208,7 +204,6 @@ def list_logs(self, queries: List[str] = None) -> Dict[str, Any]:
208204
"""
209205
Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, ___location and date and time of log.
210206
211-
212207
Parameters
213208
----------
214209
queries : List[str]
@@ -237,7 +232,6 @@ def update_mfa(self, mfa: bool) -> Dict[str, Any]:
237232
"""
238233
Enable or disable MFA on an account.
239234
240-
241235
Parameters
242236
----------
243237
mfa : bool
@@ -270,7 +264,6 @@ def create_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]:
270264
"""
271265
Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
272266
273-
274267
Parameters
275268
----------
276269
type : AuthenticatorType
@@ -303,7 +296,6 @@ def update_mfa_authenticator(self, type: AuthenticatorType, otp: str) -> Dict[st
303296
"""
304297
Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.
305298
306-
307299
Parameters
308300
----------
309301
type : AuthenticatorType
@@ -342,7 +334,6 @@ def delete_mfa_authenticator(self, type: AuthenticatorType) -> Dict[str, Any]:
342334
"""
343335
Delete an authenticator for a user by ID.
344336
345-
346337
Parameters
347338
----------
348339
type : AuthenticatorType
@@ -375,7 +366,6 @@ def create_mfa_challenge(self, factor: AuthenticationFactor) -> Dict[str, Any]:
375366
"""
376367
Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
377368
378-
379369
Parameters
380370
----------
381371
factor : AuthenticationFactor
@@ -408,7 +398,6 @@ def update_mfa_challenge(self, challenge_id: str, otp: str) -> Dict[str, Any]:
408398
"""
409399
Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
410400
411-
412401
Parameters
413402
----------
414403
challenge_id : str
@@ -533,7 +522,6 @@ def update_name(self, name: str) -> Dict[str, Any]:
533522
"""
534523
Update currently logged in user account name.
535524
536-
537525
Parameters
538526
----------
539527
name : str
@@ -566,7 +554,6 @@ def update_password(self, password: str, old_password: str = None) -> Dict[str,
566554
"""
567555
Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.
568556
569-
570557
Parameters
571558
----------
572559
password : str
@@ -602,7 +589,6 @@ def update_phone(self, phone: str, password: str) -> Dict[str, Any]:
602589
"""
603590
Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS.
604591
605-
606592
Parameters
607593
----------
608594
phone : str
@@ -662,7 +648,6 @@ def update_prefs(self, prefs: dict) -> Dict[str, Any]:
662648
"""
663649
Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
664650
665-
666651
Parameters
667652
----------
668653
prefs : dict
@@ -695,7 +680,6 @@ def create_recovery(self, email: str, url: str) -> Dict[str, Any]:
695680
"""
696681
Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour.
697682
698-
699683
Parameters
700684
----------
701685
email : str
@@ -736,7 +720,6 @@ def update_recovery(self, user_id: str, secret: str, password: str) -> Dict[str,
736720
737721
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.
738722
739-
740723
Parameters
741724
----------
742725
user_id : str
@@ -848,7 +831,6 @@ def create_email_password_session(self, email: str, password: str) -> Dict[str,
848831
849832
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
850833
851-
852834
Parameters
853835
----------
854836
email : str
@@ -887,7 +869,8 @@ def update_magic_url_session(self, user_id: str, secret: str) -> Dict[str, Any]:
887869
"""
888870
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.
889871
890-
872+
.. deprecated::
873+
This API has been deprecated.
891874
Parameters
892875
----------
893876
user_id : str
@@ -926,7 +909,8 @@ def update_phone_session(self, user_id: str, secret: str) -> Dict[str, Any]:
926909
"""
927910
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.
928911
929-
912+
.. deprecated::
913+
This API has been deprecated.
930914
Parameters
931915
----------
932916
user_id : str
@@ -965,7 +949,6 @@ def create_session(self, user_id: str, secret: str) -> Dict[str, Any]:
965949
"""
966950
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.
967951
968-
969952
Parameters
970953
----------
971954
user_id : str
@@ -1004,7 +987,6 @@ def get_session(self, session_id: str) -> Dict[str, Any]:
1004987
"""
1005988
Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.
1006989
1007-
1008990
Parameters
1009991
----------
1010992
session_id : str
@@ -1036,7 +1018,6 @@ def update_session(self, session_id: str) -> Dict[str, Any]:
10361018
"""
10371019
Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider.
10381020
1039-
10401021
Parameters
10411022
----------
10421023
session_id : str
@@ -1069,7 +1050,6 @@ def delete_session(self, session_id: str) -> Dict[str, Any]:
10691050
"""
10701051
Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead.
10711052
1072-
10731053
Parameters
10741054
----------
10751055
session_id : str
@@ -1122,15 +1102,15 @@ def update_status(self) -> Dict[str, Any]:
11221102

11231103
def create_email_token(self, user_id: str, email: str, phrase: bool = None) -> Dict[str, Any]:
11241104
"""
1125-
Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.
1105+
Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.
11261106
11271107
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
1128-
1108+
11291109
11301110
Parameters
11311111
----------
11321112
user_id : str
1133-
User 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.
1113+
User 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.
11341114
email : str
11351115
User email.
11361116
phrase : bool
@@ -1171,11 +1151,10 @@ def create_magic_url_token(self, user_id: str, email: str, url: str = None, phra
11711151
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
11721152
11731153
1174-
11751154
Parameters
11761155
----------
11771156
user_id : str
1178-
Unique 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.
1157+
Unique 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.
11791158
email : str
11801159
User email.
11811160
url : str
@@ -1220,7 +1199,6 @@ def create_o_auth2_token(self, provider: OAuthProvider, success: str = None, fai
12201199
12211200
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
12221201
1223-
12241202
Parameters
12251203
----------
12261204
provider : OAuthProvider
@@ -1263,11 +1241,10 @@ def create_phone_token(self, user_id: str, phone: str) -> Dict[str, Any]:
12631241
12641242
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
12651243
1266-
12671244
Parameters
12681245
----------
12691246
user_id : str
1270-
Unique 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.
1247+
Unique 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored.
12711248
phone : str
12721249
Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
12731250
@@ -1305,7 +1282,6 @@ def create_verification(self, url: str) -> Dict[str, Any]:
13051282
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.
13061283
13071284
1308-
13091285
Parameters
13101286
----------
13111287
url : str
@@ -1338,7 +1314,6 @@ def update_verification(self, user_id: str, secret: str) -> Dict[str, Any]:
13381314
"""
13391315
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.
13401316
1341-
13421317
Parameters
13431318
----------
13441319
user_id : str
@@ -1399,7 +1374,6 @@ def update_phone_verification(self, user_id: str, secret: str) -> Dict[str, Any]
13991374
"""
14001375
Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code.
14011376
1402-
14031377
Parameters
14041378
----------
14051379
user_id : str

0 commit comments

Comments
 (0)