Skip to content

Commit e6987a3

Browse files
authored
Merge pull request #149 from appwrite/dev
feat: Python SDK update for version 21.0.0
2 parents b7c2f75 + 6d99a66 commit e6987a3

105 files changed

Lines changed: 3484 additions & 501 deletions

File tree

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Change Log
22

3+
## 21.0.0
4+
5+
* Added: `apps` service for managing apps and app secrets
6+
* Added: `oauth2` service for the OAuth2 authorization, device, and token flows
7+
* Added: device authorization grant parameters (`verificationUrl`, `userCodeLength`, `userCodeFormat`, `deviceCodeDuration`) to `updateOAuth2Server`
8+
* Added: `emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, and `emailIsCanonical` to the `User` model
9+
* Added: `userAccessedAt` to the `Membership` model
10+
* Added: `PolicyDenyCorporateEmail` and `deny-corporate-email` to `ProjectPolicyId`
11+
* Added: `dedicatedDatabases.execute` to `ProjectKeyScopes`
12+
* Breaking: `usage.listEvents` now takes a required `metrics` array with `resource`, `interval`, and `dimensions` instead of `queries` and `total`
13+
* Breaking: Replaced `UsageEvent` and `UsageGauge` models with `UsageDataPoint` and `UsageMetric`
14+
* Updated: Send an `Accept: application/json` header on all requests
15+
16+
317
## 20.1.0
418

519
* Added: `createSesProvider` and `updateSesProvider` to `messaging`

appwrite/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def __init__(self):
1717
self._endpoint = 'https://cloud.appwrite.io/v1'
1818
self._global_headers = {
1919
'content-type': '',
20-
'user-agent' : f'AppwritePythonSDK/20.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
20+
'user-agent' : f'AppwritePythonSDK/21.0.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.1.0',
24+
'x-sdk-version': '21.0.0',
2525
'X-Appwrite-Response-Format' : '1.9.5',
2626
}
2727
self._config = {}
@@ -101,21 +101,21 @@ def set_cookie(self, value):
101101
return self
102102

103103
def set_impersonate_user_id(self, value):
104-
"""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."""
104+
"""Impersonate a user by ID"""
105105

106106
self._global_headers['x-appwrite-impersonate-user-id'] = value
107107
self._config['impersonateuserid'] = value
108108
return self
109109

110110
def set_impersonate_user_email(self, value):
111-
"""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."""
111+
"""Impersonate a user by email"""
112112

113113
self._global_headers['x-appwrite-impersonate-user-email'] = value
114114
self._config['impersonateuseremail'] = value
115115
return self
116116

117117
def set_impersonate_user_phone(self, value):
118-
"""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."""
118+
"""Impersonate a user by phone"""
119119

120120
self._global_headers['x-appwrite-impersonate-user-phone'] = value
121121
self._config['impersonateuserphone'] = value

appwrite/enums/project_key_scopes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class ProjectKeyScopes(Enum):
9191
ARCHIVES_WRITE = "archives.write"
9292
RESTORATIONS_READ = "restorations.read"
9393
RESTORATIONS_WRITE = "restorations.write"
94+
DEDICATEDDATABASES_EXECUTE = "dedicatedDatabases.execute"
9495
DOMAINS_READ = "domains.read"
9596
DOMAINS_WRITE = "domains.write"
9697
EVENTS_READ = "events.read"

appwrite/enums/project_policy_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ class ProjectPolicyId(Enum):
1414
DENY_ALIASED_EMAIL = "deny-aliased-email"
1515
DENY_DISPOSABLE_EMAIL = "deny-disposable-email"
1616
DENY_FREE_EMAIL = "deny-free-email"
17+
DENY_CORPORATE_EMAIL = "deny-corporate-email"

appwrite/enums/project_service_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ class ProjectServiceId(Enum):
1919
MIGRATIONS = "migrations"
2020
MESSAGING = "messaging"
2121
ADVISOR = "advisor"
22+
OAUTH2 = "oauth2"

appwrite/models/__init__.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,27 @@
222222
from .policy_deny_aliased_email import PolicyDenyAliasedEmail
223223
from .policy_deny_disposable_email import PolicyDenyDisposableEmail
224224
from .policy_deny_free_email import PolicyDenyFreeEmail
225+
from .policy_deny_corporate_email import PolicyDenyCorporateEmail
225226
from .backup_restoration import BackupRestoration
226-
from .usage_event import UsageEvent
227-
from .usage_gauge import UsageGauge
227+
from .usage_data_point import UsageDataPoint
228+
from .usage_event_list import UsageEventList
229+
from .usage_gauge_list import UsageGaugeList
230+
from .usage_metric import UsageMetric
231+
from .app import App
232+
from .app_secret import AppSecret
233+
from .app_secret_plaintext import AppSecretPlaintext
234+
from .oauth2_authorize import Oauth2Authorize
235+
from .oauth2_approve import Oauth2Approve
236+
from .oauth2_reject import Oauth2Reject
237+
from .oauth2_grant import Oauth2Grant
238+
from .oauth2_device_authorization import Oauth2DeviceAuthorization
239+
from .oauth2_token import Oauth2Token
228240
from .activity_event_list import ActivityEventList
229241
from .backup_archive_list import BackupArchiveList
230242
from .backup_policy_list import BackupPolicyList
231243
from .backup_restoration_list import BackupRestorationList
232-
from .usage_event_list import UsageEventList
233-
from .usage_gauge_list import UsageGaugeList
244+
from .apps_list import AppsList
245+
from .app_secret_list import AppSecretList
234246

235247
__all__ = [
236248
'AppwriteModel',
@@ -457,13 +469,25 @@
457469
'PolicyDenyAliasedEmail',
458470
'PolicyDenyDisposableEmail',
459471
'PolicyDenyFreeEmail',
472+
'PolicyDenyCorporateEmail',
460473
'BackupRestoration',
461-
'UsageEvent',
462-
'UsageGauge',
474+
'UsageDataPoint',
475+
'UsageEventList',
476+
'UsageGaugeList',
477+
'UsageMetric',
478+
'App',
479+
'AppSecret',
480+
'AppSecretPlaintext',
481+
'Oauth2Authorize',
482+
'Oauth2Approve',
483+
'Oauth2Reject',
484+
'Oauth2Grant',
485+
'Oauth2DeviceAuthorization',
486+
'Oauth2Token',
463487
'ActivityEventList',
464488
'BackupArchiveList',
465489
'BackupPolicyList',
466490
'BackupRestorationList',
467-
'UsageEventList',
468-
'UsageGaugeList',
491+
'AppsList',
492+
'AppSecretList',
469493
]

appwrite/models/activity_event.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,6 @@ class ActivityEvent(AppwriteModel):
4545
Team ID.
4646
hostname : str
4747
Hostname.
48-
oscode : str
49-
Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
50-
osname : str
51-
Operating system name.
52-
osversion : str
53-
Operating system version.
54-
clienttype : str
55-
Client type.
56-
clientcode : str
57-
Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).
58-
clientname : str
59-
Client name.
60-
clientversion : str
61-
Client version.
62-
clientengine : str
63-
Client engine name.
64-
clientengineversion : str
65-
Client engine name.
66-
devicename : str
67-
Device name.
68-
devicebrand : str
69-
Device brand name.
70-
devicemodel : str
71-
Device model name.
7248
countrycode : str
7349
Country two-character ISO 3166-1 alpha code.
7450
countryname : str
@@ -92,17 +68,5 @@ class ActivityEvent(AppwriteModel):
9268
projectid: str = Field(..., alias='projectId')
9369
teamid: str = Field(..., alias='teamId')
9470
hostname: str = Field(..., alias='hostname')
95-
oscode: str = Field(..., alias='osCode')
96-
osname: str = Field(..., alias='osName')
97-
osversion: str = Field(..., alias='osVersion')
98-
clienttype: str = Field(..., alias='clientType')
99-
clientcode: str = Field(..., alias='clientCode')
100-
clientname: str = Field(..., alias='clientName')
101-
clientversion: str = Field(..., alias='clientVersion')
102-
clientengine: str = Field(..., alias='clientEngine')
103-
clientengineversion: str = Field(..., alias='clientEngineVersion')
104-
devicename: str = Field(..., alias='deviceName')
105-
devicebrand: str = Field(..., alias='deviceBrand')
106-
devicemodel: str = Field(..., alias='deviceModel')
10771
countrycode: str = Field(..., alias='countryCode')
10872
countryname: str = Field(..., alias='countryName')

appwrite/models/app.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from typing import Any, Dict, List, Optional, Union, cast
2+
from pydantic import Field, PrivateAttr
3+
4+
from .base_model import AppwriteModel
5+
from .app_secret import AppSecret
6+
7+
class App(AppwriteModel):
8+
"""
9+
App
10+
11+
Attributes
12+
----------
13+
id : str
14+
App ID.
15+
createdat : str
16+
App creation time in ISO 8601 format.
17+
updatedat : str
18+
App update date in ISO 8601 format.
19+
name : str
20+
Application name.
21+
description : str
22+
Application description shown to users during OAuth2 consent.
23+
clienturi : str
24+
Application homepage URL shown to users during OAuth2 consent.
25+
logouri : str
26+
Application logo URL shown to users during OAuth2 consent.
27+
privacypolicyurl : str
28+
Application privacy policy URL shown to users during OAuth2 consent.
29+
termsurl : str
30+
Application terms of service URL shown to users during OAuth2 consent.
31+
contacts : List[Any]
32+
Application support or security contact emails.
33+
tagline : str
34+
Application tagline shown to users during OAuth2 consent.
35+
tags : List[Any]
36+
Application tags shown to users during OAuth2 consent.
37+
images : List[Any]
38+
Application image URLs shown to users during OAuth2 consent.
39+
supporturl : str
40+
Application support URL shown to users during OAuth2 consent.
41+
datadeletionurl : str
42+
Application data deletion URL shown to users during OAuth2 consent.
43+
redirecturis : List[Any]
44+
List of authorized redirect URIs. These URIs can be used to redirect users after they authenticate.
45+
postlogoutredirecturis : List[Any]
46+
List of authorized post-logout redirect URIs for OpenID Connect RP-Initiated Logout. The logout endpoint only redirects users to URIs in this list after ending their session.
47+
enabled : bool
48+
Whether the app is enabled or not.
49+
type : str
50+
OAuth2 client type. `public` for SPAs, mobile, and native apps that cannot keep a client secret (PKCE required); `confidential` for server-side clients that authenticate with a client secret.
51+
deviceflow : bool
52+
Whether this client may use the OAuth2 Device Authorization Grant (RFC 8628).
53+
teamid : str
54+
ID of team that owns the application, if owned by team. Otherwise, user ID will be used.
55+
userid : str
56+
ID of user who owns the application, if owned by user. Otherwise, team ID will be used.
57+
secrets : List[AppSecret]
58+
List of application secrets.
59+
"""
60+
id: str = Field(..., alias='$id')
61+
createdat: str = Field(..., alias='$createdAt')
62+
updatedat: str = Field(..., alias='$updatedAt')
63+
name: str = Field(..., alias='name')
64+
description: str = Field(..., alias='description')
65+
clienturi: str = Field(..., alias='clientUri')
66+
logouri: str = Field(..., alias='logoUri')
67+
privacypolicyurl: str = Field(..., alias='privacyPolicyUrl')
68+
termsurl: str = Field(..., alias='termsUrl')
69+
contacts: List[Any] = Field(..., alias='contacts')
70+
tagline: str = Field(..., alias='tagline')
71+
tags: List[Any] = Field(..., alias='tags')
72+
images: List[Any] = Field(..., alias='images')
73+
supporturl: str = Field(..., alias='supportUrl')
74+
datadeletionurl: str = Field(..., alias='dataDeletionUrl')
75+
redirecturis: List[Any] = Field(..., alias='redirectUris')
76+
postlogoutredirecturis: List[Any] = Field(..., alias='postLogoutRedirectUris')
77+
enabled: bool = Field(..., alias='enabled')
78+
type: str = Field(..., alias='type')
79+
deviceflow: bool = Field(..., alias='deviceFlow')
80+
teamid: str = Field(..., alias='teamId')
81+
userid: str = Field(..., alias='userId')
82+
secrets: List[AppSecret] = Field(..., alias='secrets')

appwrite/models/app_secret.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 AppSecret(AppwriteModel):
7+
"""
8+
AppSecret
9+
10+
Attributes
11+
----------
12+
id : str
13+
Secret ID.
14+
createdat : str
15+
Secret creation time in ISO 8601 format.
16+
updatedat : str
17+
Secret update time in ISO 8601 format.
18+
appid : str
19+
Application ID this secret belongs to.
20+
secret : str
21+
Hashed application client secret.
22+
hint : str
23+
Last few characters of the client secret, used to help identify it.
24+
createdbyid : str
25+
ID of the user who created the secret.
26+
createdbyname : str
27+
Name of the user who created the secret.
28+
lastaccessedat : Optional[str]
29+
Time the secret was last used for authentication in ISO 8601 format. Null if never used.
30+
"""
31+
id: str = Field(..., alias='$id')
32+
createdat: str = Field(..., alias='$createdAt')
33+
updatedat: str = Field(..., alias='$updatedAt')
34+
appid: str = Field(..., alias='appId')
35+
secret: str = Field(..., alias='secret')
36+
hint: str = Field(..., alias='hint')
37+
createdbyid: str = Field(..., alias='createdById')
38+
createdbyname: str = Field(..., alias='createdByName')
39+
lastaccessedat: Optional[str] = Field(default=None, alias='lastAccessedAt')

appwrite/models/app_secret_list.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import Any, Dict, List, Optional, Union, cast
2+
from pydantic import Field, PrivateAttr
3+
4+
from .base_model import AppwriteModel
5+
from .app_secret import AppSecret
6+
7+
class AppSecretList(AppwriteModel):
8+
"""
9+
App secrets list
10+
11+
Attributes
12+
----------
13+
total : float
14+
Total number of secrets that matched your query.
15+
secrets : List[AppSecret]
16+
List of secrets.
17+
"""
18+
total: float = Field(..., alias='total')
19+
secrets: List[AppSecret] = Field(..., alias='secrets')

0 commit comments

Comments
 (0)