Skip to content

Commit b7c2f75

Browse files
authored
Merge pull request #148 from appwrite/dev
feat: Python SDK update for version 20.1.0
2 parents 4c9c1ca + 71dd562 commit b7c2f75

44 files changed

Lines changed: 1567 additions & 148 deletions

Some content is hidden

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

CHANGELOG.md

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

3+
## 20.1.0
4+
5+
* Added: `createSesProvider` and `updateSesProvider` to `messaging`
6+
* Added: `updateOAuth2Server` to `project` for OAuth2 server settings
7+
* Added: `updatePasswordStrengthPolicy` and `PolicyPasswordStrength` to `project`
8+
* Added: `getAuditsDB` health check to `health`
9+
* Added: `password-strength` to `ProjectPolicyId`
10+
* Added: `apps.read` and `apps.write` to `ProjectKeyScopes`
11+
12+
313
## 20.0.0
414

515
* Breaking: Removed `githubImagine` and `googleImagine` from `ProjectOAuthProviderId`
@@ -8,7 +18,7 @@
818
* Added: `Organization` service for managing projects and API keys
919
* Added: `PolicyDenyAliasedEmail`, `PolicyDenyDisposableEmail`, and `PolicyDenyFreeEmail` policy models
1020
* Added: `deny-aliased-email`, `deny-disposable-email`, and `deny-free-email` to `ProjectPolicyId`
11-
* Added: `BrowserTheme`, `HealthQueueName`, `OrganizationKeyScopes`, and `Region` enums
21+
* Replaced: `BrowserTheme`, `HealthQueueName`, `OrganizationKeyScopes`, and `Region` enums
1222
* Added: `dart-3.12` and `flutter-3.44` runtimes
1323
* Added: `ProjectList` model and new attributes on `Function`, `Site`, and `UsageGauge`
1424
* Updated: `functions`, `sites`, `usage`, `health`, and `avatars` services

appwrite/client.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ def __init__(self):
1717
self._endpoint = 'https://cloud.appwrite.io/v1'
1818
self._global_headers = {
1919
'content-type': '',
20-
'user-agent' : f'AppwritePythonSDK/20.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
20+
'user-agent' : f'AppwritePythonSDK/20.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
2121
'x-sdk-name': 'Python',
2222
'x-sdk-platform': 'server',
2323
'x-sdk-language': 'python',
24-
'x-sdk-version': '20.0.0',
24+
'x-sdk-version': '20.1.0',
2525
'X-Appwrite-Response-Format' : '1.9.5',
2626
}
27+
self._config = {}
2728

2829
def set_self_signed(self, status=True):
2930
self._self_signed = status
@@ -43,68 +44,81 @@ def add_header(self, key, value):
4344
def get_headers(self):
4445
return dict(self._global_headers)
4546

47+
def get_config(self, key):
48+
return self._config.get(key, '')
49+
4650
def set_project(self, value):
4751
"""Your project ID"""
4852

49-
self._global_headers['x-appwrite-project'] = value
53+
self._config['project'] = value
5054
return self
5155

5256
def set_key(self, value):
5357
"""Your secret API key"""
5458

5559
self._global_headers['x-appwrite-key'] = value
60+
self._config['key'] = value
5661
return self
5762

5863
def set_jwt(self, value):
5964
"""Your secret JSON Web Token"""
6065

6166
self._global_headers['x-appwrite-jwt'] = value
67+
self._config['jwt'] = value
6268
return self
6369

6470
def set_locale(self, value):
6571
self._global_headers['x-appwrite-locale'] = value
72+
self._config['locale'] = value
6673
return self
6774

6875
def set_session(self, value):
6976
"""The user session to authenticate with"""
7077

7178
self._global_headers['x-appwrite-session'] = value
79+
self._config['session'] = value
7280
return self
7381

7482
def set_forwarded_user_agent(self, value):
7583
"""The user agent string of the client that made the request"""
7684

7785
self._global_headers['x-forwarded-user-agent'] = value
86+
self._config['forwardeduseragent'] = value
7887
return self
7988

8089
def set_dev_key(self, value):
8190
"""Your secret dev API key"""
8291

8392
self._global_headers['x-appwrite-dev-key'] = value
93+
self._config['devkey'] = value
8494
return self
8595

8696
def set_cookie(self, value):
8797
"""The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes."""
8898

8999
self._global_headers['cookie'] = value
100+
self._config['cookie'] = value
90101
return self
91102

92103
def set_impersonate_user_id(self, value):
93104
"""Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data."""
94105

95106
self._global_headers['x-appwrite-impersonate-user-id'] = value
107+
self._config['impersonateuserid'] = value
96108
return self
97109

98110
def set_impersonate_user_email(self, value):
99111
"""Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data."""
100112

101113
self._global_headers['x-appwrite-impersonate-user-email'] = value
114+
self._config['impersonateuseremail'] = value
102115
return self
103116

104117
def set_impersonate_user_phone(self, value):
105118
"""Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data."""
106119

107120
self._global_headers['x-appwrite-impersonate-user-phone'] = value
121+
self._config['impersonateuserphone'] = value
108122
return self
109123

110124
def call(self, method, path='', headers=None, params=None, response_type='json'):

appwrite/enums/project_key_scopes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ class ProjectKeyScopes(Enum):
9494
DOMAINS_READ = "domains.read"
9595
DOMAINS_WRITE = "domains.write"
9696
EVENTS_READ = "events.read"
97+
APPS_READ = "apps.read"
98+
APPS_WRITE = "apps.write"
9799
USAGE_READ = "usage.read"

appwrite/enums/project_policy_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class ProjectPolicyId(Enum):
44
PASSWORD_DICTIONARY = "password-dictionary"
55
PASSWORD_HISTORY = "password-history"
6+
PASSWORD_STRENGTH = "password-strength"
67
PASSWORD_PERSONAL_DATA = "password-personal-data"
78
SESSION_ALERT = "session-alert"
89
SESSION_DURATION = "session-duration"

appwrite/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
from .o_auth2_provider_list import OAuth2ProviderList
173173
from .policy_password_dictionary import PolicyPasswordDictionary
174174
from .policy_password_history import PolicyPasswordHistory
175+
from .policy_password_strength import PolicyPasswordStrength
175176
from .policy_password_personal_data import PolicyPasswordPersonalData
176177
from .policy_session_alert import PolicySessionAlert
177178
from .policy_session_duration import PolicySessionDuration
@@ -406,6 +407,7 @@
406407
'OAuth2ProviderList',
407408
'PolicyPasswordDictionary',
408409
'PolicyPasswordHistory',
410+
'PolicyPasswordStrength',
409411
'PolicyPasswordPersonalData',
410412
'PolicySessionAlert',
411413
'PolicySessionDuration',

appwrite/models/policy_list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .base_model import AppwriteModel
55
from .policy_password_dictionary import PolicyPasswordDictionary
66
from .policy_password_history import PolicyPasswordHistory
7+
from .policy_password_strength import PolicyPasswordStrength
78
from .policy_password_personal_data import PolicyPasswordPersonalData
89
from .policy_session_alert import PolicySessionAlert
910
from .policy_session_duration import PolicySessionDuration
@@ -23,8 +24,8 @@ class PolicyList(AppwriteModel):
2324
----------
2425
total : float
2526
Total number of policies in the given project.
26-
policies : List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail]]
27+
policies : List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail]]
2728
List of policies.
2829
"""
2930
total: float = Field(..., alias='total')
30-
policies: List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail]] = Field(..., alias='policies')
31+
policies: List[Union[PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail]] = Field(..., alias='policies')
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from typing import Any, Dict, List, Optional, Union, cast
2+
from pydantic import Field, PrivateAttr
3+
4+
from .base_model import AppwriteModel
5+
6+
class PolicyPasswordStrength(AppwriteModel):
7+
"""
8+
Policy Password Strength
9+
10+
Attributes
11+
----------
12+
id : str
13+
Policy ID.
14+
min : float
15+
Minimum password length required for user passwords.
16+
uppercase : bool
17+
Whether passwords must include at least one uppercase letter.
18+
lowercase : bool
19+
Whether passwords must include at least one lowercase letter.
20+
number : bool
21+
Whether passwords must include at least one number.
22+
symbols : bool
23+
Whether passwords must include at least one symbol.
24+
"""
25+
id: str = Field(..., alias='$id')
26+
min: float = Field(..., alias='min')
27+
uppercase: bool = Field(..., alias='uppercase')
28+
lowercase: bool = Field(..., alias='lowercase')
29+
number: bool = Field(..., alias='number')
30+
symbols: bool = Field(..., alias='symbols')

appwrite/models/project.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from .project_auth_method import ProjectAuthMethod
77
from .project_service import ProjectService
88
from .project_protocol import ProjectProtocol
9-
from .billing_limits import BillingLimits
109
from .block import Block
10+
from .billing_limits import BillingLimits
1111

1212
class Project(AppwriteModel):
1313
"""
@@ -25,6 +25,8 @@ class Project(AppwriteModel):
2525
Project name.
2626
teamid : str
2727
Project team ID.
28+
region : str
29+
Project region
2830
devkeys : List[DevKey]
2931
Deprecated since 1.9.5: List of dev keys.
3032
smtpenabled : bool
@@ -61,20 +63,37 @@ class Project(AppwriteModel):
6163
List of services.
6264
protocols : List[ProjectProtocol]
6365
List of protocols.
64-
region : str
65-
Project region
66-
billinglimits : Optional[BillingLimits]
67-
Billing limits reached
6866
blocks : List[Block]
6967
Project blocks information
7068
consoleaccessedat : str
7169
Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused.
70+
billinglimits : Optional[BillingLimits]
71+
Billing limits reached
72+
oauth2serverenabled : bool
73+
OAuth2 server status
74+
oauth2serverauthorizationurl : str
75+
OAuth2 server authorization URL
76+
oauth2serverscopes : List[Any]
77+
OAuth2 server allowed scopes
78+
oauth2serveraccesstokenduration : float
79+
OAuth2 server access token duration in seconds for confidential clients
80+
oauth2serverrefreshtokenduration : float
81+
OAuth2 server refresh token duration in seconds for confidential clients
82+
oauth2serverpublicaccesstokenduration : float
83+
OAuth2 server access token duration in seconds for public clients (SPAs, mobile, native)
84+
oauth2serverpublicrefreshtokenduration : float
85+
OAuth2 server refresh token duration in seconds for public clients (SPAs, mobile, native)
86+
oauth2serverconfidentialpkce : bool
87+
When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting.
88+
oauth2serverdiscoveryurl : str
89+
OAuth2 server discovery URL
7290
"""
7391
id: str = Field(..., alias='$id')
7492
createdat: str = Field(..., alias='$createdAt')
7593
updatedat: str = Field(..., alias='$updatedAt')
7694
name: str = Field(..., alias='name')
7795
teamid: str = Field(..., alias='teamId')
96+
region: str = Field(..., alias='region')
7897
devkeys: List[DevKey] = Field(..., alias='devKeys')
7998
smtpenabled: bool = Field(..., alias='smtpEnabled')
8099
smtpsendername: str = Field(..., alias='smtpSenderName')
@@ -93,7 +112,15 @@ class Project(AppwriteModel):
93112
authmethods: List[ProjectAuthMethod] = Field(..., alias='authMethods')
94113
services: List[ProjectService] = Field(..., alias='services')
95114
protocols: List[ProjectProtocol] = Field(..., alias='protocols')
96-
region: str = Field(..., alias='region')
97-
billinglimits: Optional[BillingLimits] = Field(default=None, alias='billingLimits')
98115
blocks: List[Block] = Field(..., alias='blocks')
99116
consoleaccessedat: str = Field(..., alias='consoleAccessedAt')
117+
billinglimits: Optional[BillingLimits] = Field(default=None, alias='billingLimits')
118+
oauth2serverenabled: bool = Field(..., alias='oAuth2ServerEnabled')
119+
oauth2serverauthorizationurl: str = Field(..., alias='oAuth2ServerAuthorizationUrl')
120+
oauth2serverscopes: List[Any] = Field(..., alias='oAuth2ServerScopes')
121+
oauth2serveraccesstokenduration: float = Field(..., alias='oAuth2ServerAccessTokenDuration')
122+
oauth2serverrefreshtokenduration: float = Field(..., alias='oAuth2ServerRefreshTokenDuration')
123+
oauth2serverpublicaccesstokenduration: float = Field(..., alias='oAuth2ServerPublicAccessTokenDuration')
124+
oauth2serverpublicrefreshtokenduration: float = Field(..., alias='oAuth2ServerPublicRefreshTokenDuration')
125+
oauth2serverconfidentialpkce: bool = Field(..., alias='oAuth2ServerConfidentialPkce')
126+
oauth2serverdiscoveryurl: str = Field(..., alias='oAuth2ServerDiscoveryUrl')

0 commit comments

Comments
 (0)