diff --git a/CHANGELOG.md b/CHANGELOG.md index b00d409e..43fac9a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## 27.3.0 + +* Added: `account.create_ldap_session` for LDAP sign-in +* Added: `project.update_ldap` and `project.create_ldap_test` to configure and test a project's LDAP directory, the `ProjectLDAPEncryption` enum and `ldap*` fields on `Project` +* Added: `project.update_o_auth2_naver`, the `OAuth2Naver` model and `OAuthProvider.NAVER` +* Added: `project.delete_passwords` to force every user to reset their password +* Added: `sites.update_analytics` and `analyticsEnabled` and `analyticsPropertyId` on `Site` +* Added: `reason` on `DomainPrice`, set when a domain was not priced for the requested registration type +* Added: `ImageFormat.AUTO` on `Storage.getFilePreview` and the avatar endpoints, serving avif or webp when the `Accept` header supports it +* Added: response fields that hold secrets carry `format: password`, readable from `Model.model_fields[name].json_schema_extra`, so callers can keep them out of logs +* Updated: requests send `X-Appwrite-Response-Format: 2.7.2` + ## 27.2.0 * Updated: `project.list_environments`, `project.create_environment`, `project.get_environment`, `project.update_environment` return `Environment` models instead of `Project` diff --git a/README.md b/README.md index ab249496..0ff42137 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Python SDK ![License](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.7.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.7.2-blue.svg?style=flat-square) [![X Account](https://img.shields.io/badge/follow-%40appwrite-000000?logo=x&style=flat-square)](https://x.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/appwrite/client.py b/appwrite/client.py index cbb26b92..13e7ae2c 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -20,12 +20,12 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent': f'AppwritePythonSDK/27.2.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent': f'AppwritePythonSDK/27.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': '27.2.0', - 'X-Appwrite-Response-Format': '2.7.1', + 'x-sdk-version': '27.3.0', + 'X-Appwrite-Response-Format': '2.7.2', } self._config = {} diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 8f3adfef..c2243620 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -35,6 +35,7 @@ from ..enums.region import Region from ..enums.project_auth_method_id import ProjectAuthMethodId from ..enums.environment_resource import EnvironmentResource +from ..enums.project_ldap_encryption import ProjectLDAPEncryption from ..enums.project_o_auth2_auth0_prompt import ProjectOAuth2Auth0Prompt from ..enums.project_o_auth2_discord_prompt import ProjectOAuth2DiscordPrompt from ..enums.project_o_auth2_git_hub_prompt import ProjectOAuth2GitHubPrompt @@ -203,6 +204,9 @@ def default(self, o): if isinstance(o, EnvironmentResource): return o.value + if isinstance(o, ProjectLDAPEncryption): + return o.value + if isinstance(o, ProjectOAuth2Auth0Prompt): return o.value diff --git a/appwrite/enums/image_format.py b/appwrite/enums/image_format.py index c5e2ec80..ceee6797 100644 --- a/appwrite/enums/image_format.py +++ b/appwrite/enums/image_format.py @@ -9,3 +9,4 @@ class ImageFormat(Enum): HEIC = "heic" AVIF = "avif" GIF = "gif" + AUTO = "auto" diff --git a/appwrite/enums/o_auth_provider.py b/appwrite/enums/o_auth_provider.py index 8c3f4b58..072f2419 100644 --- a/appwrite/enums/o_auth_provider.py +++ b/appwrite/enums/o_auth_provider.py @@ -29,6 +29,7 @@ class OAuthProvider(Enum): KICK = "kick" LINKEDIN = "linkedin" MICROSOFT = "microsoft" + NAVER = "naver" NOTION = "notion" OIDC = "oidc" OKTA = "okta" diff --git a/appwrite/enums/project_auth_method_id.py b/appwrite/enums/project_auth_method_id.py index 834fe51c..ed84857e 100644 --- a/appwrite/enums/project_auth_method_id.py +++ b/appwrite/enums/project_auth_method_id.py @@ -10,3 +10,4 @@ class ProjectAuthMethodId(Enum): JWT = "jwt" PHONE = "phone" PASSKEY = "passkey" + LDAP = "ldap" diff --git a/appwrite/enums/project_key_scopes.py b/appwrite/enums/project_key_scopes.py index fd444a37..76ec3b84 100644 --- a/appwrite/enums/project_key_scopes.py +++ b/appwrite/enums/project_key_scopes.py @@ -15,8 +15,11 @@ class ProjectKeyScopes(Enum): POLICIES_WRITE = "policies.write" PROJECT_POLICIES_READ = "project.policies.read" PROJECT_POLICIES_WRITE = "project.policies.write" + PROJECT_VIDEOS_PROFILES_READ = "project.videos.profiles.read" + PROJECT_VIDEOS_PROFILES_WRITE = "project.videos.profiles.write" PROJECT_OAUTH2_READ = "project.oauth2.read" PROJECT_OAUTH2_WRITE = "project.oauth2.write" + PROJECT_LDAP_WRITE = "project.ldap.write" TEMPLATES_READ = "templates.read" TEMPLATES_WRITE = "templates.write" STAGES_READ = "stages.read" @@ -113,6 +116,9 @@ class ProjectKeyScopes(Enum): REVIEWS_WRITE = "reviews.write" PRESENCES_READ = "presences.read" PRESENCES_WRITE = "presences.write" + VIDEOS_PLAY = "videos.play" + VIDEOS_READ = "videos.read" + VIDEOS_WRITE = "videos.write" DEDICATEDDATABASES_EXECUTE = "dedicatedDatabases.execute" BACKUPS_POLICIES_READ = "backups.policies.read" BACKUPS_POLICIES_WRITE = "backups.policies.write" diff --git a/appwrite/enums/project_ldap_encryption.py b/appwrite/enums/project_ldap_encryption.py new file mode 100644 index 00000000..30aaf4b9 --- /dev/null +++ b/appwrite/enums/project_ldap_encryption.py @@ -0,0 +1,7 @@ +from enum import Enum + + +class ProjectLDAPEncryption(Enum): + NONE = "none" + LDAPS = "ldaps" + STARTTLS = "starttls" diff --git a/appwrite/enums/project_o_auth_provider_id.py b/appwrite/enums/project_o_auth_provider_id.py index 638a0abb..a792ba93 100644 --- a/appwrite/enums/project_o_auth_provider_id.py +++ b/appwrite/enums/project_o_auth_provider_id.py @@ -29,6 +29,7 @@ class ProjectOAuthProviderId(Enum): KICK = "kick" LINKEDIN = "linkedin" MICROSOFT = "microsoft" + NAVER = "naver" NOTION = "notion" OIDC = "oidc" OKTA = "okta" diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index 54085966..24b79d7e 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -182,6 +182,7 @@ from .o_auth2_resend import OAuth2Resend from .o_auth2_tik_tok import OAuth2TikTok from .o_auth2_kakao import OAuth2Kakao +from .o_auth2_naver import OAuth2Naver from .o_auth2_provider_list import OAuth2ProviderList from .policy_password_dictionary import PolicyPasswordDictionary from .policy_password_history import PolicyPasswordHistory @@ -514,6 +515,7 @@ 'OAuth2Resend', 'OAuth2TikTok', 'OAuth2Kakao', + 'OAuth2Naver', 'OAuth2ProviderList', 'PolicyPasswordDictionary', 'PolicyPasswordHistory', diff --git a/appwrite/models/algo_scrypt_modified.py b/appwrite/models/algo_scrypt_modified.py index 708491ed..e039a069 100644 --- a/appwrite/models/algo_scrypt_modified.py +++ b/appwrite/models/algo_scrypt_modified.py @@ -23,7 +23,7 @@ class AlgoScryptModified(AppwriteModel): type: str = Field(..., alias='type') salt: str = Field(..., alias='salt') saltseparator: str = Field(..., alias='saltSeparator') - signerkey: str = Field(..., alias='signerKey') + signerkey: str = Field(..., alias='signerKey', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/app_key.py b/appwrite/models/app_key.py index fd4caccd..388e7f85 100644 --- a/appwrite/models/app_key.py +++ b/appwrite/models/app_key.py @@ -34,7 +34,7 @@ class AppKey(AppwriteModel): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') appid: str = Field(..., alias='appId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) hint: str = Field(..., alias='hint') createdbyid: str = Field(..., alias='createdById') createdbyname: str = Field(..., alias='createdByName') diff --git a/appwrite/models/app_secret.py b/appwrite/models/app_secret.py index 41c1052f..d4364e42 100644 --- a/appwrite/models/app_secret.py +++ b/appwrite/models/app_secret.py @@ -34,7 +34,7 @@ class AppSecret(AppwriteModel): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') appid: str = Field(..., alias='appId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) hint: str = Field(..., alias='hint') createdbyid: str = Field(..., alias='createdById') createdbyname: str = Field(..., alias='createdByName') diff --git a/appwrite/models/app_secret_plaintext.py b/appwrite/models/app_secret_plaintext.py index 0b06766c..76ef72aa 100644 --- a/appwrite/models/app_secret_plaintext.py +++ b/appwrite/models/app_secret_plaintext.py @@ -34,7 +34,7 @@ class AppSecretPlaintext(AppwriteModel): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') appid: str = Field(..., alias='appId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) hint: str = Field(..., alias='hint') createdbyid: str = Field(..., alias='createdById') createdbyname: str = Field(..., alias='createdByName') diff --git a/appwrite/models/dedicated_database.py b/appwrite/models/dedicated_database.py index 69aea701..c92c99fa 100644 --- a/appwrite/models/dedicated_database.py +++ b/appwrite/models/dedicated_database.py @@ -129,9 +129,9 @@ class DedicatedDatabase(AppwriteModel): hostname: str = Field(..., alias='hostname') connectionport: Optional[float] = Field(default=None, alias='connectionPort') connectionuser: str = Field(..., alias='connectionUser') - connectionpassword: str = Field(..., alias='connectionPassword') + connectionpassword: str = Field(..., alias='connectionPassword', json_schema_extra={'format': 'password'}) credentialgeneration: Optional[float] = Field(default=None, alias='credentialGeneration') - connectionstring: str = Field(..., alias='connectionString') + connectionstring: str = Field(..., alias='connectionString', json_schema_extra={'format': 'password'}) ssl: bool = Field(..., alias='ssl') status: str = Field(..., alias='status') containerstatus: str = Field(..., alias='containerStatus') diff --git a/appwrite/models/dedicated_database_branch.py b/appwrite/models/dedicated_database_branch.py index 76b02b70..9b463da5 100644 --- a/appwrite/models/dedicated_database_branch.py +++ b/appwrite/models/dedicated_database_branch.py @@ -44,10 +44,10 @@ class DedicatedDatabaseBranch(AppwriteModel): port: Optional[float] = Field(default=None, alias='port') database: str = Field(..., alias='database') username: str = Field(..., alias='username') - password: str = Field(..., alias='password') + password: str = Field(..., alias='password', json_schema_extra={'format': 'password'}) ssl: bool = Field(..., alias='ssl') engine: str = Field(..., alias='engine') - connectionstring: str = Field(..., alias='connectionString') + connectionstring: str = Field(..., alias='connectionString', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/device.py b/appwrite/models/device.py index cf47471c..e195b62f 100644 --- a/appwrite/models/device.py +++ b/appwrite/models/device.py @@ -33,7 +33,7 @@ class Device(AppwriteModel): expire: str = Field(..., alias='expire') activesessionid: str = Field(..., alias='activeSessionId') sessions: List[Session] = Field(..., alias='sessions') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/domain_price.py b/appwrite/models/domain_price.py index 6ab77ae3..d3e5142d 100644 --- a/appwrite/models/domain_price.py +++ b/appwrite/models/domain_price.py @@ -26,6 +26,8 @@ class DomainPrice(AppwriteModel): Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. renewalperiodyears : float Renewal price period in years. + reason : Optional[str] + Why the domain was not priced for the requested registration type, for example a transfer of an unregistered domain. Empty otherwise. """ domain: str = Field(..., alias='domain') @@ -36,6 +38,7 @@ class DomainPrice(AppwriteModel): premium: bool = Field(..., alias='premium') renewalprice: Optional[float] = Field(default=None, alias='renewalPrice') renewalperiodyears: float = Field(..., alias='renewalPeriodYears') + reason: Optional[str] = Field(default=None, alias='reason') @model_validator(mode='before') @classmethod diff --git a/appwrite/models/ephemeral_key.py b/appwrite/models/ephemeral_key.py index 1fda1395..9524c5a5 100644 --- a/appwrite/models/ephemeral_key.py +++ b/appwrite/models/ephemeral_key.py @@ -39,7 +39,7 @@ class EphemeralKey(AppwriteModel): description: str = Field(..., alias='description') expire: str = Field(..., alias='expire') scopes: List[Any] = Field(..., alias='scopes') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) accessedat: str = Field(..., alias='accessedAt') sdks: List[Any] = Field(..., alias='sdks') diff --git a/appwrite/models/identity.py b/appwrite/models/identity.py index 5366f7dd..34cc7014 100644 --- a/appwrite/models/identity.py +++ b/appwrite/models/identity.py @@ -41,10 +41,10 @@ class Identity(AppwriteModel): provider: str = Field(..., alias='provider') provideruid: str = Field(..., alias='providerUid') provideremail: str = Field(..., alias='providerEmail') - provideraccesstoken: str = Field(..., alias='providerAccessToken') + provideraccesstoken: str = Field(..., alias='providerAccessToken', json_schema_extra={'format': 'password'}) provideraccesstokenexpiry: str = Field(..., alias='providerAccessTokenExpiry') - providerrefreshtoken: str = Field(..., alias='providerRefreshToken') - provideridtoken: str = Field(..., alias='providerIdToken') + providerrefreshtoken: str = Field(..., alias='providerRefreshToken', json_schema_extra={'format': 'password'}) + provideridtoken: str = Field(..., alias='providerIdToken', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/jwt.py b/appwrite/models/jwt.py index f51ad977..a4869cce 100644 --- a/appwrite/models/jwt.py +++ b/appwrite/models/jwt.py @@ -14,7 +14,7 @@ class Jwt(AppwriteModel): JWT encoded string. """ - jwt: str = Field(..., alias='jwt') + jwt: str = Field(..., alias='jwt', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/key.py b/appwrite/models/key.py index 7888c9de..67df738f 100644 --- a/appwrite/models/key.py +++ b/appwrite/models/key.py @@ -39,7 +39,7 @@ class Key(AppwriteModel): description: str = Field(..., alias='description') expire: str = Field(..., alias='expire') scopes: List[Any] = Field(..., alias='scopes') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) accessedat: str = Field(..., alias='accessedAt') sdks: List[Any] = Field(..., alias='sdks') diff --git a/appwrite/models/mfa_challenge_secret.py b/appwrite/models/mfa_challenge_secret.py index 2eab2511..6b7d6913 100644 --- a/appwrite/models/mfa_challenge_secret.py +++ b/appwrite/models/mfa_challenge_secret.py @@ -26,7 +26,7 @@ class MfaChallengeSecret(AppwriteModel): createdat: str = Field(..., alias='$createdAt') userid: str = Field(..., alias='userId') expire: str = Field(..., alias='expire') - code: str = Field(..., alias='code') + code: str = Field(..., alias='code', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/mfa_recovery_codes.py b/appwrite/models/mfa_recovery_codes.py index 52ff1d66..c48b5b76 100644 --- a/appwrite/models/mfa_recovery_codes.py +++ b/appwrite/models/mfa_recovery_codes.py @@ -14,7 +14,7 @@ class MfaRecoveryCodes(AppwriteModel): Recovery codes. """ - recoverycodes: List[Any] = Field(..., alias='recoveryCodes') + recoverycodes: List[Any] = Field(..., alias='recoveryCodes', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/mfa_type.py b/appwrite/models/mfa_type.py index 1afba454..3b5792b6 100644 --- a/appwrite/models/mfa_type.py +++ b/appwrite/models/mfa_type.py @@ -16,8 +16,8 @@ class MfaType(AppwriteModel): URI for authenticator apps. """ - secret: str = Field(..., alias='secret') - uri: str = Field(..., alias='uri') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) + uri: str = Field(..., alias='uri', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_amazon.py b/appwrite/models/o_auth2_amazon.py index 4d7b7b9a..eb13fa7f 100644 --- a/appwrite/models/o_auth2_amazon.py +++ b/appwrite/models/o_auth2_amazon.py @@ -23,7 +23,7 @@ class OAuth2Amazon(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_apple.py b/appwrite/models/o_auth2_apple.py index 4acb8fbc..eacbbcd6 100644 --- a/appwrite/models/o_auth2_apple.py +++ b/appwrite/models/o_auth2_apple.py @@ -33,7 +33,7 @@ class OAuth2Apple(AppwriteModel): serviceid: str = Field(..., alias='serviceId') keyid: str = Field(..., alias='keyId') teamid: str = Field(..., alias='teamId') - p8file: str = Field(..., alias='p8File') + p8file: str = Field(..., alias='p8File', json_schema_extra={'format': 'password'}) nativeenabled: bool = Field(..., alias='nativeEnabled') nativeclientids: List[Any] = Field(..., alias='nativeClientIds') diff --git a/appwrite/models/o_auth2_appwrite.py b/appwrite/models/o_auth2_appwrite.py index f80a0bb8..28922241 100644 --- a/appwrite/models/o_auth2_appwrite.py +++ b/appwrite/models/o_auth2_appwrite.py @@ -23,7 +23,7 @@ class OAuth2Appwrite(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_auth0.py b/appwrite/models/o_auth2_auth0.py index d27f4797..07decb3e 100644 --- a/appwrite/models/o_auth2_auth0.py +++ b/appwrite/models/o_auth2_auth0.py @@ -28,7 +28,7 @@ class OAuth2Auth0(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2Auth0Prompt] = Field(..., alias='prompt') endpoint: str = Field(..., alias='endpoint') diff --git a/appwrite/models/o_auth2_authentik.py b/appwrite/models/o_auth2_authentik.py index 12e29212..7404bbfa 100644 --- a/appwrite/models/o_auth2_authentik.py +++ b/appwrite/models/o_auth2_authentik.py @@ -25,7 +25,7 @@ class OAuth2Authentik(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) endpoint: str = Field(..., alias='endpoint') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_autodesk.py b/appwrite/models/o_auth2_autodesk.py index d58de659..05b3f57b 100644 --- a/appwrite/models/o_auth2_autodesk.py +++ b/appwrite/models/o_auth2_autodesk.py @@ -23,7 +23,7 @@ class OAuth2Autodesk(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_bitbucket.py b/appwrite/models/o_auth2_bitbucket.py index 247f3b9c..2e67f692 100644 --- a/appwrite/models/o_auth2_bitbucket.py +++ b/appwrite/models/o_auth2_bitbucket.py @@ -23,7 +23,7 @@ class OAuth2Bitbucket(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') key: str = Field(..., alias='key') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_bitly.py b/appwrite/models/o_auth2_bitly.py index 00e893ed..1c7bb93a 100644 --- a/appwrite/models/o_auth2_bitly.py +++ b/appwrite/models/o_auth2_bitly.py @@ -23,7 +23,7 @@ class OAuth2Bitly(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_box.py b/appwrite/models/o_auth2_box.py index 492bc38d..ec0bdea0 100644 --- a/appwrite/models/o_auth2_box.py +++ b/appwrite/models/o_auth2_box.py @@ -23,7 +23,7 @@ class OAuth2Box(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_cloudflare.py b/appwrite/models/o_auth2_cloudflare.py index 5d977c6e..d9486142 100644 --- a/appwrite/models/o_auth2_cloudflare.py +++ b/appwrite/models/o_auth2_cloudflare.py @@ -23,7 +23,7 @@ class OAuth2Cloudflare(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_dailymotion.py b/appwrite/models/o_auth2_dailymotion.py index d8e3ece8..8f3f3e6b 100644 --- a/appwrite/models/o_auth2_dailymotion.py +++ b/appwrite/models/o_auth2_dailymotion.py @@ -23,7 +23,7 @@ class OAuth2Dailymotion(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') apikey: str = Field(..., alias='apiKey') - apisecret: str = Field(..., alias='apiSecret') + apisecret: str = Field(..., alias='apiSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_discord.py b/appwrite/models/o_auth2_discord.py index 0921e557..bd980f8a 100644 --- a/appwrite/models/o_auth2_discord.py +++ b/appwrite/models/o_auth2_discord.py @@ -26,7 +26,7 @@ class OAuth2Discord(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2DiscordPrompt] = Field(..., alias='prompt') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_disqus.py b/appwrite/models/o_auth2_disqus.py index f534f160..01e03dfd 100644 --- a/appwrite/models/o_auth2_disqus.py +++ b/appwrite/models/o_auth2_disqus.py @@ -23,7 +23,7 @@ class OAuth2Disqus(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') publickey: str = Field(..., alias='publicKey') - secretkey: str = Field(..., alias='secretKey') + secretkey: str = Field(..., alias='secretKey', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_dropbox.py b/appwrite/models/o_auth2_dropbox.py index 1e598082..8ad0aaa1 100644 --- a/appwrite/models/o_auth2_dropbox.py +++ b/appwrite/models/o_auth2_dropbox.py @@ -23,7 +23,7 @@ class OAuth2Dropbox(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') appkey: str = Field(..., alias='appKey') - appsecret: str = Field(..., alias='appSecret') + appsecret: str = Field(..., alias='appSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_etsy.py b/appwrite/models/o_auth2_etsy.py index 8226ae65..afb77e21 100644 --- a/appwrite/models/o_auth2_etsy.py +++ b/appwrite/models/o_auth2_etsy.py @@ -23,7 +23,7 @@ class OAuth2Etsy(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') keystring: str = Field(..., alias='keyString') - sharedsecret: str = Field(..., alias='sharedSecret') + sharedsecret: str = Field(..., alias='sharedSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_facebook.py b/appwrite/models/o_auth2_facebook.py index 640ca559..26494611 100644 --- a/appwrite/models/o_auth2_facebook.py +++ b/appwrite/models/o_auth2_facebook.py @@ -23,7 +23,7 @@ class OAuth2Facebook(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') appid: str = Field(..., alias='appId') - appsecret: str = Field(..., alias='appSecret') + appsecret: str = Field(..., alias='appSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_figma.py b/appwrite/models/o_auth2_figma.py index 5c650b1b..74d7229f 100644 --- a/appwrite/models/o_auth2_figma.py +++ b/appwrite/models/o_auth2_figma.py @@ -23,7 +23,7 @@ class OAuth2Figma(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_fusion_auth.py b/appwrite/models/o_auth2_fusion_auth.py index 25d57023..ffc4c8b2 100644 --- a/appwrite/models/o_auth2_fusion_auth.py +++ b/appwrite/models/o_auth2_fusion_auth.py @@ -25,7 +25,7 @@ class OAuth2FusionAuth(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) endpoint: str = Field(..., alias='endpoint') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_github.py b/appwrite/models/o_auth2_github.py index e8305891..7c8a4738 100644 --- a/appwrite/models/o_auth2_github.py +++ b/appwrite/models/o_auth2_github.py @@ -26,7 +26,7 @@ class OAuth2Github(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2GithubPrompt] = Field(..., alias='prompt') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_gitlab.py b/appwrite/models/o_auth2_gitlab.py index 2c61563f..84948193 100644 --- a/appwrite/models/o_auth2_gitlab.py +++ b/appwrite/models/o_auth2_gitlab.py @@ -25,7 +25,7 @@ class OAuth2Gitlab(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') applicationid: str = Field(..., alias='applicationId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) endpoint: str = Field(..., alias='endpoint') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_google.py b/appwrite/models/o_auth2_google.py index 8a77adf6..4e57736c 100644 --- a/appwrite/models/o_auth2_google.py +++ b/appwrite/models/o_auth2_google.py @@ -30,7 +30,7 @@ class OAuth2Google(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2GooglePrompt] = Field(..., alias='prompt') nativeenabled: bool = Field(..., alias='nativeEnabled') nativeclientids: List[Any] = Field(..., alias='nativeClientIds') diff --git a/appwrite/models/o_auth2_hugging_face.py b/appwrite/models/o_auth2_hugging_face.py index 80dd65ad..4af4c3ab 100644 --- a/appwrite/models/o_auth2_hugging_face.py +++ b/appwrite/models/o_auth2_hugging_face.py @@ -23,7 +23,7 @@ class OAuth2HuggingFace(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_kakao.py b/appwrite/models/o_auth2_kakao.py index 0277a6e7..2cd30a74 100644 --- a/appwrite/models/o_auth2_kakao.py +++ b/appwrite/models/o_auth2_kakao.py @@ -26,7 +26,7 @@ class OAuth2Kakao(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2KakaoPrompt] = Field(..., alias='prompt') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_keycloak.py b/appwrite/models/o_auth2_keycloak.py index 941e44ca..c4af3745 100644 --- a/appwrite/models/o_auth2_keycloak.py +++ b/appwrite/models/o_auth2_keycloak.py @@ -27,7 +27,7 @@ class OAuth2Keycloak(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) endpoint: str = Field(..., alias='endpoint') realmname: str = Field(..., alias='realmName') diff --git a/appwrite/models/o_auth2_kick.py b/appwrite/models/o_auth2_kick.py index 1615abac..2d56d23b 100644 --- a/appwrite/models/o_auth2_kick.py +++ b/appwrite/models/o_auth2_kick.py @@ -23,7 +23,7 @@ class OAuth2Kick(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_linkedin.py b/appwrite/models/o_auth2_linkedin.py index 7ebf1b76..6b8b1630 100644 --- a/appwrite/models/o_auth2_linkedin.py +++ b/appwrite/models/o_auth2_linkedin.py @@ -23,7 +23,7 @@ class OAuth2Linkedin(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - primaryclientsecret: str = Field(..., alias='primaryClientSecret') + primaryclientsecret: str = Field(..., alias='primaryClientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_microsoft.py b/appwrite/models/o_auth2_microsoft.py index 5b3461cf..420a8f6a 100644 --- a/appwrite/models/o_auth2_microsoft.py +++ b/appwrite/models/o_auth2_microsoft.py @@ -28,7 +28,7 @@ class OAuth2Microsoft(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') applicationid: str = Field(..., alias='applicationId') - applicationsecret: str = Field(..., alias='applicationSecret') + applicationsecret: str = Field(..., alias='applicationSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2MicrosoftPrompt] = Field(..., alias='prompt') tenant: str = Field(..., alias='tenant') diff --git a/appwrite/models/o_auth2_naver.py b/appwrite/models/o_auth2_naver.py new file mode 100644 index 00000000..395506d4 --- /dev/null +++ b/appwrite/models/o_auth2_naver.py @@ -0,0 +1,43 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr, model_validator + +from .base_model import AppwriteModel + + +class OAuth2Naver(AppwriteModel): + """ + OAuth2Naver + + Attributes + ---------- + id : str + OAuth2 provider ID. + enabled : bool + OAuth2 provider is active and can be used to create sessions. + clientid : str + Naver OAuth2 client ID. + clientsecret : str + Naver OAuth2 client secret. + """ + + id: str = Field(..., alias='$id') + enabled: bool = Field(..., alias='enabled') + clientid: str = Field(..., alias='clientId') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) + + @model_validator(mode='before') + @classmethod + def _apply_defaults(cls, data: Any) -> Any: + if not isinstance(data, dict): + return data + + data = dict(data) + if '$id' not in data and 'id' not in data: + data['$id'] = '' + if 'enabled' not in data: + data['enabled'] = False + if 'clientId' not in data and 'clientid' not in data: + data['clientId'] = '' + if 'clientSecret' not in data and 'clientsecret' not in data: + data['clientSecret'] = '' + return data diff --git a/appwrite/models/o_auth2_notion.py b/appwrite/models/o_auth2_notion.py index d36eced4..017c0d8a 100644 --- a/appwrite/models/o_auth2_notion.py +++ b/appwrite/models/o_auth2_notion.py @@ -23,7 +23,7 @@ class OAuth2Notion(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') oauthclientid: str = Field(..., alias='oauthClientId') - oauthclientsecret: str = Field(..., alias='oauthClientSecret') + oauthclientsecret: str = Field(..., alias='oauthClientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_oidc.py b/appwrite/models/o_auth2_oidc.py index 0024b934..515a6b44 100644 --- a/appwrite/models/o_auth2_oidc.py +++ b/appwrite/models/o_auth2_oidc.py @@ -36,7 +36,7 @@ class OAuth2Oidc(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2OidcPrompt] = Field(..., alias='prompt') wellknownurl: str = Field(..., alias='wellKnownURL') authorizationurl: str = Field(..., alias='authorizationURL') diff --git a/appwrite/models/o_auth2_okta.py b/appwrite/models/o_auth2_okta.py index d07ff410..44f67773 100644 --- a/appwrite/models/o_auth2_okta.py +++ b/appwrite/models/o_auth2_okta.py @@ -30,7 +30,7 @@ class OAuth2Okta(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2OktaPrompt] = Field(..., alias='prompt') domain: str = Field(..., alias='domain') authorizationserverid: str = Field(..., alias='authorizationServerId') diff --git a/appwrite/models/o_auth2_paypal.py b/appwrite/models/o_auth2_paypal.py index d5fda507..31241b58 100644 --- a/appwrite/models/o_auth2_paypal.py +++ b/appwrite/models/o_auth2_paypal.py @@ -23,7 +23,7 @@ class OAuth2Paypal(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - secretkey: str = Field(..., alias='secretKey') + secretkey: str = Field(..., alias='secretKey', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_podio.py b/appwrite/models/o_auth2_podio.py index f533a4a6..d28667be 100644 --- a/appwrite/models/o_auth2_podio.py +++ b/appwrite/models/o_auth2_podio.py @@ -23,7 +23,7 @@ class OAuth2Podio(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_provider_list.py b/appwrite/models/o_auth2_provider_list.py index 5d3cbf20..4717f7ce 100644 --- a/appwrite/models/o_auth2_provider_list.py +++ b/appwrite/models/o_auth2_provider_list.py @@ -49,6 +49,7 @@ from .o_auth2_cloudflare import OAuth2Cloudflare from .o_auth2_tik_tok import OAuth2TikTok from .o_auth2_kakao import OAuth2Kakao +from .o_auth2_naver import OAuth2Naver from .o_auth2_vipps import OAuth2Vipps @@ -60,7 +61,7 @@ class OAuth2ProviderList(AppwriteModel): ---------- total : float Total number of OAuth2 providers in the given project. - providers : List[Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Appwrite, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2TikTok, OAuth2Kakao, OAuth2Vipps]] + providers : List[Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Appwrite, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2TikTok, OAuth2Kakao, OAuth2Naver, OAuth2Vipps]] List of OAuth2 providers. """ @@ -114,6 +115,7 @@ class OAuth2ProviderList(AppwriteModel): OAuth2Cloudflare, OAuth2TikTok, OAuth2Kakao, + OAuth2Naver, OAuth2Vipps, ] ] = Field(..., alias='providers') diff --git a/appwrite/models/o_auth2_resend.py b/appwrite/models/o_auth2_resend.py index 6209c774..5e020895 100644 --- a/appwrite/models/o_auth2_resend.py +++ b/appwrite/models/o_auth2_resend.py @@ -23,7 +23,7 @@ class OAuth2Resend(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_salesforce.py b/appwrite/models/o_auth2_salesforce.py index fde028a4..7b7252ca 100644 --- a/appwrite/models/o_auth2_salesforce.py +++ b/appwrite/models/o_auth2_salesforce.py @@ -26,7 +26,7 @@ class OAuth2Salesforce(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') customerkey: str = Field(..., alias='customerKey') - customersecret: str = Field(..., alias='customerSecret') + customersecret: str = Field(..., alias='customerSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2SalesforcePrompt] = Field(..., alias='prompt') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_slack.py b/appwrite/models/o_auth2_slack.py index b5a0bb58..d7f718c8 100644 --- a/appwrite/models/o_auth2_slack.py +++ b/appwrite/models/o_auth2_slack.py @@ -23,7 +23,7 @@ class OAuth2Slack(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_spotify.py b/appwrite/models/o_auth2_spotify.py index 17108a75..e0812342 100644 --- a/appwrite/models/o_auth2_spotify.py +++ b/appwrite/models/o_auth2_spotify.py @@ -23,7 +23,7 @@ class OAuth2Spotify(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_stripe.py b/appwrite/models/o_auth2_stripe.py index bedfef2d..71d7e8ab 100644 --- a/appwrite/models/o_auth2_stripe.py +++ b/appwrite/models/o_auth2_stripe.py @@ -23,7 +23,7 @@ class OAuth2Stripe(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - apisecretkey: str = Field(..., alias='apiSecretKey') + apisecretkey: str = Field(..., alias='apiSecretKey', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_tik_tok.py b/appwrite/models/o_auth2_tik_tok.py index 8a35b76b..db5c45c7 100644 --- a/appwrite/models/o_auth2_tik_tok.py +++ b/appwrite/models/o_auth2_tik_tok.py @@ -23,7 +23,7 @@ class OAuth2TikTok(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_tradeshift.py b/appwrite/models/o_auth2_tradeshift.py index 834f81f7..22609b91 100644 --- a/appwrite/models/o_auth2_tradeshift.py +++ b/appwrite/models/o_auth2_tradeshift.py @@ -23,7 +23,7 @@ class OAuth2Tradeshift(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') oauth2clientid: str = Field(..., alias='oauth2ClientId') - oauth2clientsecret: str = Field(..., alias='oauth2ClientSecret') + oauth2clientsecret: str = Field(..., alias='oauth2ClientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_twitch.py b/appwrite/models/o_auth2_twitch.py index 35188582..d5ecdee0 100644 --- a/appwrite/models/o_auth2_twitch.py +++ b/appwrite/models/o_auth2_twitch.py @@ -23,7 +23,7 @@ class OAuth2Twitch(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_vipps.py b/appwrite/models/o_auth2_vipps.py index 5ee21f87..8c5c4a7e 100644 --- a/appwrite/models/o_auth2_vipps.py +++ b/appwrite/models/o_auth2_vipps.py @@ -23,7 +23,7 @@ class OAuth2Vipps(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_webflow.py b/appwrite/models/o_auth2_webflow.py index b1e2fe02..24fec800 100644 --- a/appwrite/models/o_auth2_webflow.py +++ b/appwrite/models/o_auth2_webflow.py @@ -23,7 +23,7 @@ class OAuth2Webflow(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_word_press.py b/appwrite/models/o_auth2_word_press.py index 5b289c19..97ae8418 100644 --- a/appwrite/models/o_auth2_word_press.py +++ b/appwrite/models/o_auth2_word_press.py @@ -23,7 +23,7 @@ class OAuth2WordPress(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_x.py b/appwrite/models/o_auth2_x.py index f4299708..1dd56766 100644 --- a/appwrite/models/o_auth2_x.py +++ b/appwrite/models/o_auth2_x.py @@ -23,7 +23,7 @@ class OAuth2X(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') customerkey: str = Field(..., alias='customerKey') - secretkey: str = Field(..., alias='secretKey') + secretkey: str = Field(..., alias='secretKey', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_yahoo.py b/appwrite/models/o_auth2_yahoo.py index 0c0f8be9..83395b7f 100644 --- a/appwrite/models/o_auth2_yahoo.py +++ b/appwrite/models/o_auth2_yahoo.py @@ -23,7 +23,7 @@ class OAuth2Yahoo(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_yandex.py b/appwrite/models/o_auth2_yandex.py index de65d949..083ce040 100644 --- a/appwrite/models/o_auth2_yandex.py +++ b/appwrite/models/o_auth2_yandex.py @@ -23,7 +23,7 @@ class OAuth2Yandex(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/o_auth2_zoho.py b/appwrite/models/o_auth2_zoho.py index f1ecd743..ee53e041 100644 --- a/appwrite/models/o_auth2_zoho.py +++ b/appwrite/models/o_auth2_zoho.py @@ -26,7 +26,7 @@ class OAuth2Zoho(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) prompt: List[OAuth2ZohoPrompt] = Field(..., alias='prompt') @model_validator(mode='before') diff --git a/appwrite/models/o_auth2_zoom.py b/appwrite/models/o_auth2_zoom.py index 384e019d..e138e12c 100644 --- a/appwrite/models/o_auth2_zoom.py +++ b/appwrite/models/o_auth2_zoom.py @@ -23,7 +23,7 @@ class OAuth2Zoom(AppwriteModel): id: str = Field(..., alias='$id') enabled: bool = Field(..., alias='enabled') clientid: str = Field(..., alias='clientId') - clientsecret: str = Field(..., alias='clientSecret') + clientsecret: str = Field(..., alias='clientSecret', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/oauth2_device_authorization.py b/appwrite/models/oauth2_device_authorization.py index df9f9d30..a5d6eedf 100644 --- a/appwrite/models/oauth2_device_authorization.py +++ b/appwrite/models/oauth2_device_authorization.py @@ -24,7 +24,7 @@ class Oauth2DeviceAuthorization(AppwriteModel): Minimum polling interval for the token endpoint in seconds. """ - device_code: str = Field(..., alias='device_code') + device_code: str = Field(..., alias='device_code', json_schema_extra={'format': 'password'}) user_code: str = Field(..., alias='user_code') verification_uri: str = Field(..., alias='verification_uri') verification_uri_complete: str = Field(..., alias='verification_uri_complete') diff --git a/appwrite/models/oauth2_token.py b/appwrite/models/oauth2_token.py index f57d8995..8f9795c5 100644 --- a/appwrite/models/oauth2_token.py +++ b/appwrite/models/oauth2_token.py @@ -26,13 +26,13 @@ class Oauth2Token(AppwriteModel): OpenID Connect ID token. Returned when the `openid` scope is granted. """ - access_token: str = Field(..., alias='access_token') + access_token: str = Field(..., alias='access_token', json_schema_extra={'format': 'password'}) token_type: str = Field(..., alias='token_type') expires_in: float = Field(..., alias='expires_in') - refresh_token: str = Field(..., alias='refresh_token') + refresh_token: str = Field(..., alias='refresh_token', json_schema_extra={'format': 'password'}) scope: str = Field(..., alias='scope') authorization_details: Optional[str] = Field(default=None, alias='authorization_details') - id_token: Optional[str] = Field(default=None, alias='id_token') + id_token: Optional[str] = Field(default=None, alias='id_token', json_schema_extra={'format': 'password'}) @model_validator(mode='before') @classmethod diff --git a/appwrite/models/project.py b/appwrite/models/project.py index 41ae1d6e..4f83c7ef 100644 --- a/appwrite/models/project.py +++ b/appwrite/models/project.py @@ -50,6 +50,38 @@ class Project(AppwriteModel, Generic[T]): SMTP server password. This property is write-only and always returned empty. smtpsecure : str SMTP server secure protocol + ldapenabled : bool + Status for LDAP sign-in + ldaphosts : List[Any] + LDAP directory hosts, tried in order. + ldapport : float + LDAP directory port. + ldapencryption : str + LDAP transport encryption: none, ldaps or starttls. + ldapverification : bool + Whether the LDAP directory certificate is verified. + ldapcertificate : str + Certificate in PEM format of the authority that signed the LDAP directory certificate, or the directory certificate itself when it is self-signed. Empty for the system trust store. + ldaptimeout : float + Seconds to wait for the LDAP directory to connect and answer. + ldapbasedn : str + LDAP subtree the user search starts from. + ldapbinddn : str + LDAP service account used to search for users, empty for anonymous search. + ldapbindpassword : str + LDAP service account password. This property is write-only and always returned empty. + ldapuserfilter : str + LDAP filter that finds the user signing in, with {username} where the username they enter goes. + ldaprequiredgroupdn : str + LDAP group a user must belong to in order to sign in, empty to allow every user. + ldapidattribute : str + LDAP attribute holding the identifier that stays the same when an entry is renamed or moved. + ldapemailattribute : str + LDAP attribute holding the email address. + ldapnameattribute : str + LDAP attribute holding the display name. + ldapphoneattribute : str + LDAP attribute holding the phone number, empty when unmapped. pingcount : float Number of times the ping was received for this project. pingedat : str @@ -134,8 +166,24 @@ class Project(AppwriteModel, Generic[T]): smtphost: str = Field(..., alias='smtpHost') smtpport: float = Field(..., alias='smtpPort') smtpusername: str = Field(..., alias='smtpUsername') - smtppassword: str = Field(..., alias='smtpPassword') + smtppassword: str = Field(..., alias='smtpPassword', json_schema_extra={'format': 'password'}) smtpsecure: str = Field(..., alias='smtpSecure') + ldapenabled: bool = Field(..., alias='ldapEnabled') + ldaphosts: List[Any] = Field(..., alias='ldapHosts') + ldapport: float = Field(..., alias='ldapPort') + ldapencryption: str = Field(..., alias='ldapEncryption') + ldapverification: bool = Field(..., alias='ldapVerification') + ldapcertificate: str = Field(..., alias='ldapCertificate') + ldaptimeout: float = Field(..., alias='ldapTimeout') + ldapbasedn: str = Field(..., alias='ldapBaseDn') + ldapbinddn: str = Field(..., alias='ldapBindDn') + ldapbindpassword: str = Field(..., alias='ldapBindPassword', json_schema_extra={'format': 'password'}) + ldapuserfilter: str = Field(..., alias='ldapUserFilter') + ldaprequiredgroupdn: str = Field(..., alias='ldapRequiredGroupDn') + ldapidattribute: str = Field(..., alias='ldapIdAttribute') + ldapemailattribute: str = Field(..., alias='ldapEmailAttribute') + ldapnameattribute: str = Field(..., alias='ldapNameAttribute') + ldapphoneattribute: str = Field(..., alias='ldapPhoneAttribute') pingcount: float = Field(..., alias='pingCount') pingedat: str = Field(..., alias='pingedAt') labels: List[Any] = Field(..., alias='labels') @@ -222,6 +270,38 @@ def _apply_defaults(cls, data: Any) -> Any: data['smtpPassword'] = '' if 'smtpSecure' not in data and 'smtpsecure' not in data: data['smtpSecure'] = '' + if 'ldapEnabled' not in data and 'ldapenabled' not in data: + data['ldapEnabled'] = False + if 'ldapHosts' not in data and 'ldaphosts' not in data: + data['ldapHosts'] = [] + if 'ldapPort' not in data and 'ldapport' not in data: + data['ldapPort'] = 636 + if 'ldapEncryption' not in data and 'ldapencryption' not in data: + data['ldapEncryption'] = 'ldaps' + if 'ldapVerification' not in data and 'ldapverification' not in data: + data['ldapVerification'] = True + if 'ldapCertificate' not in data and 'ldapcertificate' not in data: + data['ldapCertificate'] = '' + if 'ldapTimeout' not in data and 'ldaptimeout' not in data: + data['ldapTimeout'] = 10 + if 'ldapBaseDn' not in data and 'ldapbasedn' not in data: + data['ldapBaseDn'] = '' + if 'ldapBindDn' not in data and 'ldapbinddn' not in data: + data['ldapBindDn'] = '' + if 'ldapBindPassword' not in data and 'ldapbindpassword' not in data: + data['ldapBindPassword'] = '' + if 'ldapUserFilter' not in data and 'ldapuserfilter' not in data: + data['ldapUserFilter'] = '(uid={username})' + if 'ldapRequiredGroupDn' not in data and 'ldaprequiredgroupdn' not in data: + data['ldapRequiredGroupDn'] = '' + if 'ldapIdAttribute' not in data and 'ldapidattribute' not in data: + data['ldapIdAttribute'] = 'entryUUID' + if 'ldapEmailAttribute' not in data and 'ldapemailattribute' not in data: + data['ldapEmailAttribute'] = 'mail' + if 'ldapNameAttribute' not in data and 'ldapnameattribute' not in data: + data['ldapNameAttribute'] = 'cn' + if 'ldapPhoneAttribute' not in data and 'ldapphoneattribute' not in data: + data['ldapPhoneAttribute'] = '' if 'pingCount' not in data and 'pingcount' not in data: data['pingCount'] = 0 if 'pingedAt' not in data and 'pingedat' not in data: diff --git a/appwrite/models/resource_token.py b/appwrite/models/resource_token.py index 12fbd31a..65881fcb 100644 --- a/appwrite/models/resource_token.py +++ b/appwrite/models/resource_token.py @@ -31,7 +31,7 @@ class ResourceToken(AppwriteModel): resourceid: str = Field(..., alias='resourceId') resourcetype: str = Field(..., alias='resourceType') expire: str = Field(..., alias='expire') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) accessedat: str = Field(..., alias='accessedAt') @model_validator(mode='before') diff --git a/appwrite/models/session.py b/appwrite/models/session.py index 136a91c9..30e8f412 100644 --- a/appwrite/models/session.py +++ b/appwrite/models/session.py @@ -80,9 +80,9 @@ class Session(AppwriteModel): expire: str = Field(..., alias='expire') provider: str = Field(..., alias='provider') provideruid: str = Field(..., alias='providerUid') - provideraccesstoken: str = Field(..., alias='providerAccessToken') + provideraccesstoken: str = Field(..., alias='providerAccessToken', json_schema_extra={'format': 'password'}) provideraccesstokenexpiry: str = Field(..., alias='providerAccessTokenExpiry') - providerrefreshtoken: str = Field(..., alias='providerRefreshToken') + providerrefreshtoken: str = Field(..., alias='providerRefreshToken', json_schema_extra={'format': 'password'}) ip: str = Field(..., alias='ip') oscode: str = Field(..., alias='osCode') osname: str = Field(..., alias='osName') @@ -100,7 +100,7 @@ class Session(AppwriteModel): countryname: str = Field(..., alias='countryName') current: bool = Field(..., alias='current') factors: List[Any] = Field(..., alias='factors') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) mfaupdatedat: str = Field(..., alias='mfaUpdatedAt') @model_validator(mode='before') diff --git a/appwrite/models/site.py b/appwrite/models/site.py index 346e7fae..b2ef0b16 100644 --- a/appwrite/models/site.py +++ b/appwrite/models/site.py @@ -83,6 +83,10 @@ class Site(AppwriteModel): Site framework adapter. fallbackfile : str Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + analyticsenabled : bool + Whether the analytics tracker is injected into pages served on the site's production domains. + analyticspropertyid : str + ID of the analytics property the site reports to. Kept when analytics is turned off, so turning it back on resumes the same property. """ id: str = Field(..., alias='$id') @@ -121,6 +125,8 @@ class Site(AppwriteModel): buildruntime: str = Field(..., alias='buildRuntime') adapter: str = Field(..., alias='adapter') fallbackfile: str = Field(..., alias='fallbackFile') + analyticsenabled: bool = Field(..., alias='analyticsEnabled') + analyticspropertyid: str = Field(..., alias='analyticsPropertyId') @model_validator(mode='before') @classmethod @@ -197,4 +203,8 @@ def _apply_defaults(cls, data: Any) -> Any: data['runtimeSpecification'] = 's-1vcpu-512mb' if 'buildRuntime' not in data and 'buildruntime' not in data: data['buildRuntime'] = '' + if 'analyticsEnabled' not in data and 'analyticsenabled' not in data: + data['analyticsEnabled'] = False + if 'analyticsPropertyId' not in data and 'analyticspropertyid' not in data: + data['analyticsPropertyId'] = '' return data diff --git a/appwrite/models/token.py b/appwrite/models/token.py index 614b43c6..90f5a268 100644 --- a/appwrite/models/token.py +++ b/appwrite/models/token.py @@ -27,7 +27,7 @@ class Token(AppwriteModel): id: str = Field(..., alias='$id') createdat: str = Field(..., alias='$createdAt') userid: str = Field(..., alias='userId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) expire: str = Field(..., alias='expire') phrase: str = Field(..., alias='phrase') diff --git a/appwrite/models/token_secret.py b/appwrite/models/token_secret.py index c745ea11..fd5e6268 100644 --- a/appwrite/models/token_secret.py +++ b/appwrite/models/token_secret.py @@ -27,7 +27,7 @@ class TokenSecret(AppwriteModel): id: str = Field(..., alias='$id') createdat: str = Field(..., alias='$createdAt') userid: str = Field(..., alias='userId') - secret: str = Field(..., alias='secret') + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) expire: str = Field(..., alias='expire') phrase: str = Field(..., alias='phrase') diff --git a/appwrite/models/user.py b/appwrite/models/user.py index 4a1c1d9a..af6d8915 100644 --- a/appwrite/models/user.py +++ b/appwrite/models/user.py @@ -81,7 +81,7 @@ class User(AppwriteModel, Generic[T]): createdat: str = Field(..., alias='$createdAt') updatedat: str = Field(..., alias='$updatedAt') name: str = Field(..., alias='name') - password: Optional[str] = Field(default=None, alias='password') + password: Optional[str] = Field(default=None, alias='password', json_schema_extra={'format': 'password'}) hash: Optional[str] = Field(default=None, alias='hash') hashoptions: Optional[ Union[ diff --git a/appwrite/models/webhook.py b/appwrite/models/webhook.py index db6fc715..d967e1e1 100644 --- a/appwrite/models/webhook.py +++ b/appwrite/models/webhook.py @@ -49,8 +49,8 @@ class Webhook(AppwriteModel): events: List[Any] = Field(..., alias='events') tls: bool = Field(..., alias='tls') authusername: str = Field(..., alias='authUsername') - authpassword: str = Field(..., alias='authPassword') - secret: str = Field(..., alias='secret') + authpassword: str = Field(..., alias='authPassword', json_schema_extra={'format': 'password'}) + secret: str = Field(..., alias='secret', json_schema_extra={'format': 'password'}) enabled: bool = Field(..., alias='enabled') logs: str = Field(..., alias='logs') attempts: float = Field(..., alias='attempts') diff --git a/appwrite/services/account.py b/appwrite/services/account.py index 7be4175a..85f4d498 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -2085,6 +2085,58 @@ def create_id_token_session( return self._parse_response(response, model=Session) + def create_ldap_session( + self, + username: str, + password: str, + duration: Optional[float] = None, + ) -> Session: + """ + Allow the user to login into their account by providing the username and password they use in the project's LDAP directory. The directory verifies the password; on the first sign-in an account is created from the directory entry, and on later sign-ins the name, email and phone follow the directory. This endpoint requires LDAP to be configured and enabled for the project. 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). + + Parameters + ---------- + username : str + Directory username, matched against the username attribute of the project's LDAP configuration. + password : str + Directory password. + duration : Optional[float] + Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. + Returns + ------- + Session + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/account/sessions/ldap' + api_params = {} + if username is None: + raise AppwriteException('Missing required parameter: "username"') + if password is None: + raise AppwriteException('Missing required parameter: "password"') + api_params['username'] = self._normalize_value(username) + api_params['password'] = self._normalize_value(password) + if duration is not None: + api_params['duration'] = self._normalize_value(duration) + + response = self.client.call( + 'post', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return self._parse_response(response, model=Session) + @deprecated("This API has been deprecated since 1.6.0. Please use `account.create_session` instead.") def update_magic_url_session( self, @@ -2526,7 +2578,7 @@ def create_o_auth2_token( Parameters ---------- provider : OAuthProvider - OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, vippsSandbox, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, naver, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, vippsSandbox, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. success : Optional[str] URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. failure : Optional[str] diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index 0f5429ed..501f6b1a 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -595,6 +595,8 @@ def get_screenshot( When width and height are specified, the image is resized accordingly. If both dimensions are 0, the API provides an image at original size. If dimensions are not specified, the default viewport size is 1280x720px. + Set `output` to `auto` to receive avif or webp when the `Accept` header of your request supports it, falling back to png. + Parameters ---------- url : str @@ -636,7 +638,7 @@ def get_screenshot( quality : Optional[float] Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. output : Optional[ImageFormat] - Output format type (jpeg, jpg, png, gif and webp). + Output format type (jpeg, jpg, png, gif, webp, heic and avif). Pass auto to serve avif or webp when the Accept header of your request supports it, falling back to png. Returns ------- bytes @@ -697,7 +699,7 @@ def get_screenshot( api_path, { 'X-Appwrite-Project': self.client.get_config('project'), - 'accept': 'image/png', + 'accept': 'image/*', }, api_params, ) diff --git a/appwrite/services/domains.py b/appwrite/services/domains.py index b4946df4..a810932f 100644 --- a/appwrite/services/domains.py +++ b/appwrite/services/domains.py @@ -174,7 +174,7 @@ def list_prices( registration_type: Optional[DomainRegistrationType] = None, ) -> DomainPricesList: """ - Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. + Check availability and get the requested registration price for one or more domain names. Availability is resolved for all domains in a single registrar lookup. Unavailable domains have a null price for new registrations, but can still be priced for renewal, transfer, or trade. Available domains have a null price for transfers, since an unregistered domain cannot be transferred, and the reason says so. Every priced domain also carries its renewal price for the same period, so a separate renewal lookup is not needed. A domain whose price could not be resolved, for example because its TLD is not supported, is returned with a null price. Parameters ---------- diff --git a/appwrite/services/project.py b/appwrite/services/project.py index 736944aa..09880bcd 100644 --- a/appwrite/services/project.py +++ b/appwrite/services/project.py @@ -12,6 +12,7 @@ from ..enums.project_key_scopes import ProjectKeyScopes from ..models.ephemeral_key import EphemeralKey from ..models.key import Key +from ..enums.project_ldap_encryption import ProjectLDAPEncryption from ..models.mock_number_list import MockNumberList from ..models.mock_number import MockNumber from ..models.o_auth2_provider_list import OAuth2ProviderList @@ -48,6 +49,7 @@ from ..models.o_auth2_linkedin import OAuth2Linkedin from ..enums.project_o_auth2_microsoft_prompt import ProjectOAuth2MicrosoftPrompt from ..models.o_auth2_microsoft import OAuth2Microsoft +from ..models.o_auth2_naver import OAuth2Naver from ..models.o_auth2_notion import OAuth2Notion from ..enums.project_o_auth2_oidc_prompt import ProjectOAuth2OidcPrompt from ..models.o_auth2_oidc import OAuth2Oidc @@ -203,7 +205,7 @@ def update_auth_method( Parameters ---------- method_id : ProjectAuthMethodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey + Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey,ldap enabled : bool Auth method status. model_type : Type[T], optional @@ -750,6 +752,170 @@ def update_labels( return ProjectModel.with_data(response, model_type) + def update_ldap( + self, + enabled: Optional[bool] = None, + hosts: Optional[List[str]] = None, + port: Optional[float] = None, + encryption: Optional[ProjectLDAPEncryption] = None, + verification: Optional[bool] = None, + certificate: Optional[str] = None, + timeout: Optional[float] = None, + base_dn: Optional[str] = None, + bind_dn: Optional[str] = None, + bind_password: Optional[str] = None, + user_filter: Optional[str] = None, + required_group_dn: Optional[str] = None, + id_attribute: Optional[str] = None, + email_attribute: Optional[str] = None, + name_attribute: Optional[str] = None, + phone_attribute: Optional[str] = None, + model_type: Type[T] = dict, + ) -> ProjectModel[T]: + """ + Update the LDAP configuration for your project. Use this endpoint to connect your project to an LDAP directory, such as OpenLDAP or Active Directory, so users can sign in with their directory credentials. Omitted parameters keep their stored value. Enabling LDAP connects to the directory and binds as the service account, so a project cannot be left enabled with a configuration that cannot sign anyone in. + + Parameters + ---------- + enabled : Optional[bool] + Enable or disable LDAP sign-in. Enabling connects to the directory to validate the configuration. + hosts : Optional[List[str]] + Directory hostnames or IP addresses, tried in order until one answers. IPv6 addresses can be written with or without square brackets. Maximum of 10 hosts are allowed. For example: ["ldap.example.com"] + port : Optional[float] + Directory port. Defaults to 636 for LDAPS and 389 otherwise. + encryption : Optional[ProjectLDAPEncryption] + Transport encryption. Use "ldaps" for TLS from the first byte, "starttls" to upgrade a plain connection, or "none" for a trusted network only. Allowed values are: none, ldaps, starttls. Defaults to ldaps. + verification : Optional[bool] + Certificate verification, false for disabled or true for enabled. Defaults to true. Has no effect when encryption is none. + certificate : Optional[str] + Certificate in PEM format of the authority that signed the directory certificate, or the directory certificate itself when it is self-signed. Several certificates can be given one after another. Leave empty to use the system trust store. Pass an empty string to clear a previously set value. + timeout : Optional[float] + Seconds to wait for the directory to connect and answer each operation. Maximum is 30 seconds. Defaults to 10. + base_dn : Optional[str] + Subtree the user search starts from. For example: ou=people,dc=example,dc=com + bind_dn : Optional[str] + Service account used to search for users. Pass an empty string if the directory allows anonymous search. For example: cn=appwrite,ou=services,dc=example,dc=com + bind_password : Optional[str] + Service account password. This property is stored securely and cannot be read in future (write-only). Required again when hosts, port, encryption, verification, certificate or bindDn change. + user_filter : Optional[str] + LDAP filter that finds the user signing in. {username} is replaced with the username they enter and must appear at least once. Pass an empty string to use the default, (uid={username}). For example: (sAMAccountName={username}) on Active Directory, or (|(uid={username})(mail={username})) to accept a username or an email address. + required_group_dn : Optional[str] + Group a user must belong to in order to sign in, checked on every sign-in. Pass an empty string to allow every user the directory authenticates. For example: cn=staff,ou=groups,dc=example,dc=com + id_attribute : Optional[str] + Attribute holding the identifier that stays the same when an entry is renamed or moved. Defaults to entryUUID; use objectGUID on Active Directory. + email_attribute : Optional[str] + Attribute holding the email address. Defaults to mail. + name_attribute : Optional[str] + Attribute holding the display name. Defaults to cn. + phone_attribute : Optional[str] + Attribute holding the phone number, in international format. Leave empty, the default, to leave the phone unmapped. For example: mobile + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + ProjectModel[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/ldap' + api_params = {} + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + if hosts is not None: + api_params['hosts'] = self._normalize_value(hosts) + if port is not None: + api_params['port'] = self._normalize_value(port) + if encryption is not None: + api_params['encryption'] = self._normalize_value(encryption) + if verification is not None: + api_params['verification'] = self._normalize_value(verification) + if certificate is not None: + api_params['certificate'] = self._normalize_value(certificate) + if timeout is not None: + api_params['timeout'] = self._normalize_value(timeout) + if base_dn is not None: + api_params['baseDn'] = self._normalize_value(base_dn) + if bind_dn is not None: + api_params['bindDn'] = self._normalize_value(bind_dn) + if bind_password is not None: + api_params['bindPassword'] = self._normalize_value(bind_password) + if user_filter is not None: + api_params['userFilter'] = self._normalize_value(user_filter) + if required_group_dn is not None: + api_params['requiredGroupDn'] = self._normalize_value(required_group_dn) + if id_attribute is not None: + api_params['idAttribute'] = self._normalize_value(id_attribute) + if email_attribute is not None: + api_params['emailAttribute'] = self._normalize_value(email_attribute) + if name_attribute is not None: + api_params['nameAttribute'] = self._normalize_value(name_attribute) + if phone_attribute is not None: + api_params['phoneAttribute'] = self._normalize_value(phone_attribute) + + response = self.client.call( + 'patch', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return ProjectModel.with_data(response, model_type) + + def create_ldap_test( + self, + username: Optional[str] = None, + password: Optional[str] = None, + ) -> Dict[str, Any]: + """ + Test the stored LDAP configuration against the directory without signing anyone in. Connects to the directory, binds as the service account and reads the base DN. Pass a username to also look the user up and check the required group, and a password to also verify it. The error names the step that failed. + + Parameters + ---------- + username : Optional[str] + Username to look up in the directory. Leave empty to test the connection and service account only. + password : Optional[str] + Password of the user to verify. Only used together with a username. + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/ldap/tests' + api_params = {} + if username is not None: + api_params['username'] = self._normalize_value(username) + if password is not None: + api_params['password'] = self._normalize_value(password) + + response = self.client.call( + 'post', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return response + def list_mock_phones( self, queries: Optional[List[str]] = None, @@ -2579,6 +2745,56 @@ def update_o_auth2_microsoft( return self._parse_response(response, model=OAuth2Microsoft) + def update_o_auth2_naver( + self, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + enabled: Optional[bool] = None, + ) -> OAuth2Naver: + """ + Update the project OAuth2 Naver configuration. + + Parameters + ---------- + client_id : Optional[str] + 'Client ID' of Naver OAuth2 app. For example: jK8pQ0000000000000Zv + client_secret : Optional[str] + 'Client Secret' of Naver OAuth2 app. For example: 9f42A0000000000c1dEb. Find it under Application > My Applications, on the overview of your app + enabled : Optional[bool] + OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + Returns + ------- + OAuth2Naver + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/oauth2/naver' + api_params = {} + if client_id is not None: + api_params['clientId'] = self._normalize_value(client_id) + if client_secret is not None: + api_params['clientSecret'] = self._normalize_value(client_secret) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call( + 'patch', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return self._parse_response(response, model=OAuth2Naver) + def update_o_auth2_notion( self, oauth_client_id: Optional[str] = None, @@ -3884,6 +4100,7 @@ def get_o_auth2_provider( OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao, + OAuth2Naver, OAuth2Vipps, ]: """ @@ -3895,7 +4112,7 @@ def get_o_auth2_provider( OAuth2 provider key. For example: github, google, apple. Returns ------- - Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao, OAuth2Vipps] + Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao, OAuth2Naver, OAuth2Vipps] API response as one of the typed response models Raises @@ -4066,6 +4283,9 @@ def get_o_auth2_provider( if response.get('$id') == 'kakao': return self._parse_response(response, model=OAuth2Kakao) + if response.get('$id') == 'naver': + return self._parse_response(response, model=OAuth2Naver) + if response.get('$id') == 'vipps': return self._parse_response(response, model=OAuth2Vipps) @@ -4074,6 +4294,38 @@ def get_o_auth2_provider( raise AppwriteException('Unable to match response to any known model') + def delete_passwords( + self, + ) -> Dict[str, Any]: + """ + Delete all passwords in the project, forcing every user to reset their password. Any password set before this request stops working for email and password sign-in immediately: signing in returns a `user_password_reset_required` error until the user sets a new password through password recovery, or until a new password is set for them with the Users API. Existing sessions are not affected; call the delete sessions endpoint to sign users out as well. Users without a password and API keys are not affected by this action. + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/passwords' + api_params = {} + + response = self.client.call( + 'delete', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return response + def list_platforms( self, queries: Optional[List[str]] = None, diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 23bbad9a..a6c19446 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -568,6 +568,53 @@ def delete( return response + def update_analytics( + self, + site_id: str, + enabled: bool, + ) -> Site: + """ + Turn analytics on or off for a site. Turning it on links an analytics property named after the site, creating one on first use, and injects the tracker into pages served on the site's production domains. Turning it on also needs the `analytics.write` scope. Turning it off stops the injection and keeps the property and its data. + + Parameters + ---------- + site_id : str + Site ID. + enabled : bool + Inject the analytics tracker into the site's production domains. Injected pageviews and events are billed as analytics usage. + Returns + ------- + Site + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/sites/{siteId}/analytics' + api_params = {} + if site_id is None or site_id == '': + raise AppwriteException('Missing required parameter: "site_id"') + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + api_path = api_path.replace('{siteId}', self._encode_path(site_id)) + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call( + 'patch', + api_path, + { + 'X-Appwrite-Project': self.client.get_config('project'), + 'content-type': 'application/json', + 'accept': 'application/json', + }, + api_params, + ) + + return self._parse_response(response, model=Site) + def update_site_deployment( self, site_id: str, diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index d9415682..5e2b7458 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -707,7 +707,7 @@ def get_file_preview( token: Optional[str] = None, ) -> bytes: """ - Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. + Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Set `output` to `auto` to receive avif or webp when the client's `Accept` header supports it, falling back to the original image format. Preview is supported only for image files smaller than 10MB. Parameters ---------- @@ -736,7 +736,7 @@ def get_file_preview( background : Optional[str] Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. output : Optional[ImageFormat] - Output format type (jpeg, jpg, png, gif and webp). + Output format type (jpeg, jpg, png, gif, webp, heic and avif). Pass auto to serve avif or webp when the client's Accept header supports it, falling back to the original format. token : Optional[str] File token for accessing this file. Returns diff --git a/docs/examples/account/create-ldap-session.md b/docs/examples/account/create-ldap-session.md new file mode 100644 index 00000000..a6169600 --- /dev/null +++ b/docs/examples/account/create-ldap-session.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.account import Account +from appwrite.models import Session + +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: Session = account.create_ldap_session( + username = '', + password = 'password', + duration = 60 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-ldap-test.md b/docs/examples/project/create-ldap-test.md new file mode 100644 index 00000000..9a57db64 --- /dev/null +++ b/docs/examples/project/create-ldap-test.md @@ -0,0 +1,16 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.create_ldap_test( + username = '', # optional + password = 'password' # optional +) +``` diff --git a/docs/examples/project/delete-passwords.md b/docs/examples/project/delete-passwords.md new file mode 100644 index 00000000..e837f446 --- /dev/null +++ b/docs/examples/project/delete-passwords.md @@ -0,0 +1,13 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.delete_passwords() +``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md index ca5387ff..81c8d759 100644 --- a/docs/examples/project/get-o-auth-2-provider.md +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -47,6 +47,7 @@ from appwrite.models import OAuth2Kick from appwrite.models import OAuth2Microsoft from appwrite.models import OAuth2TikTok from appwrite.models import OAuth2Kakao +from appwrite.models import OAuth2Naver from appwrite.models import OAuth2Vipps from typing import Union from appwrite.enums.project_o_auth_provider_id import ProjectOAuthProviderId @@ -58,7 +59,7 @@ client.set_key('') # Your secret API key project = Project(client) -result: Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao, OAuth2Vipps] = project.get_o_auth2_provider( +result: Union[OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao, OAuth2Naver, OAuth2Vipps] = project.get_o_auth2_provider( provider_id = ProjectOAuthProviderId.AMAZON ) diff --git a/docs/examples/project/update-ldap.md b/docs/examples/project/update-ldap.md new file mode 100644 index 00000000..de45154a --- /dev/null +++ b/docs/examples/project/update-ldap.md @@ -0,0 +1,34 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel +from appwrite.enums.project_ldap_encryption import ProjectLDAPEncryption + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: ProjectModel = project.update_ldap( + enabled = False, # optional + hosts = ["ldap.example.com"], # optional + port = 636, # optional + encryption = ProjectLDAPEncryption.NONE, # optional + verification = False, # optional + certificate = '', # optional + timeout = 10, # optional + base_dn = 'ou=people,dc=example,dc=com', # optional + bind_dn = 'cn=appwrite,ou=services,dc=example,dc=com', # optional + bind_password = 'password', # optional + user_filter = '(uid={username})', # optional + required_group_dn = 'cn=staff,ou=groups,dc=example,dc=com', # optional + id_attribute = 'entryUUID', # optional + email_attribute = 'mail', # optional + name_attribute = 'cn', # optional + phone_attribute = 'mobile' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-o-auth-2-naver.md b/docs/examples/project/update-o-auth-2-naver.md new file mode 100644 index 00000000..9c066fed --- /dev/null +++ b/docs/examples/project/update-o-auth-2-naver.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import OAuth2Naver + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: OAuth2Naver = project.update_o_auth2_naver( + client_id = '', # optional + client_secret = '', # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/sites/update-analytics.md b/docs/examples/sites/update-analytics.md new file mode 100644 index 00000000..d60bd508 --- /dev/null +++ b/docs/examples/sites/update-analytics.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.sites import Sites +from appwrite.models import Site + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +sites = Sites(client) + +result: Site = sites.update_analytics( + site_id = '', + enabled = False +) + +print(result.model_dump()) +``` diff --git a/pyproject.toml b/pyproject.toml index 106f5d3a..62e46a2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite" -version = "27.2.0" +version = "27.3.0" description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API" readme = "README.md" requires-python = ">=3.10" diff --git a/setup.py b/setup.py index 6b0ee0e6..9c71ba88 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name='appwrite', packages=setuptools.find_packages(), - version='27.2.0', + version='27.3.0', license='BSD-3-Clause', description='Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API', long_description=long_description, @@ -18,7 +18,7 @@ maintainer='Appwrite Team', maintainer_email='team@appwrite.io', url='https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/27.2.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/27.3.0.tar.gz', install_requires=[ 'requests>=2.34.2,<3', 'urllib3>=2.8.0,<3', diff --git a/test/services/test_account.py b/test/services/test_account.py index e6965ad1..04e7dcb8 100644 --- a/test/services/test_account.py +++ b/test/services/test_account.py @@ -1969,6 +1969,69 @@ def test_create_id_token_session(self, m): ) self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() + def test_create_ldap_session(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "userId": "5e5bb8c16897e", + "userName": "John Doe", + "expire": "2020-10-15T06:38:00.000+00:00", + "provider": "email", + "providerUid": "user@example.com", + "providerAccessToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerAccessTokenExpiry": "2020-10-15T06:38:00.000+00:00", + "providerRefreshToken": "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "ip": "127.0.0.1", + "osCode": "Mac", + "osName": "Mac", + "osVersion": "Mac", + "clientType": "browser", + "clientCode": "CM", + "clientName": "Chrome Mobile iOS", + "clientVersion": "84.0", + "clientEngine": "WebKit", + "clientEngineVersion": "605.1.15", + "deviceName": "smartphone", + "deviceBrand": "Google", + "deviceModel": "Nexus 5", + "countryCode": "US", + "countryName": "United States", + "current": True, + "factors": [], + "secret": "5e5bb8c16897e", + "mfaUpdatedAt": "2020-10-15T06:38:00.000+00:00", + } + headers = {'Content-Type': 'application/json'} + m.request( + 'POST', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.account.create_ldap_session( + '', + 'password', + duration=1, + ) + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/account/sessions/ldap', + ) + sent = json.loads(request.body or '{}') + self.assertEqual( + sent, + { + 'username': '', + 'password': 'password', + 'duration': 1, + }, + ) + self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() def test_update_magic_url_session(self, m): data = { diff --git a/test/services/test_organization.py b/test/services/test_organization.py index 1a0ff912..05b1739e 100644 --- a/test/services/test_organization.py +++ b/test/services/test_organization.py @@ -43,7 +43,7 @@ def test_get(self, m): "screenshotsGenerated": 50.0, "webhooks": 25.0, "wafRules": 2.0, - "environments": 5.0, + "environments": 3.0, "projects": 2.0, "platforms": 3.0, "users": 25.0, @@ -152,7 +152,7 @@ def test_update(self, m): "screenshotsGenerated": 50.0, "webhooks": 25.0, "wafRules": 2.0, - "environments": 5.0, + "environments": 3.0, "projects": 2.0, "platforms": 3.0, "users": 25.0, @@ -677,6 +677,22 @@ def test_create_project(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -736,6 +752,22 @@ def test_get_project(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -786,6 +818,22 @@ def test_update_project(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], diff --git a/test/services/test_project.py b/test/services/test_project.py index 30ed0b91..2f72e472 100644 --- a/test/services/test_project.py +++ b/test/services/test_project.py @@ -35,6 +35,22 @@ def test_get(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -104,6 +120,22 @@ def test_update_auth_method(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -493,6 +525,22 @@ def test_update_labels(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -529,6 +577,137 @@ def test_update_labels(self, m): ) self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() + def test_update_ldap(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "New Project", + "teamId": "1592981250", + "region": "fra", + "smtpEnabled": True, + "smtpSenderName": "John Appwrite", + "smtpSenderEmail": "john@appwrite.io", + "smtpReplyToName": "Support Team", + "smtpReplyToEmail": "support@appwrite.io", + "smtpHost": "mail.appwrite.io", + "smtpPort": 25.0, + "smtpUsername": "emailuser", + "smtpPassword": "smtp-password", + "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", + "pingCount": 1.0, + "pingedAt": "2020-10-15T06:38:00.000+00:00", + "labels": [], + "status": "active", + "onboarding": {}, + "authMethods": [], + "services": [], + "protocols": [], + "blocks": [], + "consoleAccessedAt": "2020-10-15T06:38:00.000+00:00", + } + headers = {'Content-Type': 'application/json'} + m.request( + 'PATCH', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.project.update_ldap( + enabled=False, + hosts=[], + port=1, + encryption='none', + verification=False, + certificate='', + timeout=1, + base_dn='ou=people,dc=example,dc=com', + bind_dn='cn=appwrite,ou=services,dc=example,dc=com', + bind_password='password', + user_filter='(uid={username})', + required_group_dn='cn=staff,ou=groups,dc=example,dc=com', + id_attribute='entryUUID', + email_attribute='mail', + name_attribute='cn', + phone_attribute='mobile', + ) + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/project/ldap', + ) + sent = json.loads(request.body or '{}') + self.assertEqual( + sent, + { + 'enabled': False, + 'hosts': [], + 'port': 1, + 'encryption': 'none', + 'verification': False, + 'certificate': '', + 'timeout': 1, + 'baseDn': 'ou=people,dc=example,dc=com', + 'bindDn': 'cn=appwrite,ou=services,dc=example,dc=com', + 'bindPassword': 'password', + 'userFilter': '(uid={username})', + 'requiredGroupDn': 'cn=staff,ou=groups,dc=example,dc=com', + 'idAttribute': 'entryUUID', + 'emailAttribute': 'mail', + 'nameAttribute': 'cn', + 'phoneAttribute': 'mobile', + }, + ) + self.assertEqual(response.to_dict(), data) + + @requests_mock.Mocker() + def test_create_ldap_test(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request( + 'POST', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.project.create_ldap_test( + username='', + password='password', + ) + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/project/ldap/tests', + ) + sent = json.loads(request.body or '{}') + self.assertEqual( + sent, + { + 'username': '', + 'password': 'password', + }, + ) + self.assertEqual(response, data) + @requests_mock.Mocker() def test_list_mock_phones(self, m): data = { @@ -732,6 +911,22 @@ def test_update_o_auth2_server(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -1854,6 +2049,43 @@ def test_update_o_auth2_microsoft(self, m): ) self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() + def test_update_o_auth2_naver(self, m): + data = { + "$id": "github", + "enabled": True, + "clientId": "jK8pQ0000000000000Zv", + "clientSecret": "9f42A0000000000c1dEb", + } + headers = {'Content-Type': 'application/json'} + m.request( + 'PATCH', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.project.update_o_auth2_naver( + client_id='', + client_secret='', + enabled=False, + ) + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/project/oauth2/naver', + ) + sent = json.loads(request.body or '{}') + self.assertEqual( + sent, + { + 'clientId': '', + 'clientSecret': '', + 'enabled': False, + }, + ) + self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() def test_update_o_auth2_notion(self, m): data = { @@ -2803,6 +3035,27 @@ def test_get_o_auth2_provider(self, m): self.assertEqual(sent, {}) self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() + def test_delete_passwords(self, m): + data = '' + headers = {'Content-Type': 'application/json'} + m.request( + 'DELETE', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.project.delete_passwords() + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/project/passwords', + ) + sent = json.loads(request.body or '{}') + self.assertEqual(sent, {}) + self.assertEqual(response, data) + @requests_mock.Mocker() def test_list_platforms(self, m): data = { @@ -3330,6 +3583,22 @@ def test_update_account_devices_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3385,6 +3654,22 @@ def test_update_deny_aliased_email_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3440,6 +3725,22 @@ def test_update_deny_corporate_email_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3495,6 +3796,22 @@ def test_update_deny_disposable_email_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3550,6 +3867,22 @@ def test_update_deny_free_email_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3605,6 +3938,22 @@ def test_update_deny_realtime_guests_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3660,6 +4009,22 @@ def test_update_membership_privacy_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3725,6 +4090,22 @@ def test_update_mfa_factors_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3786,6 +4167,22 @@ def test_update_passkey_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3841,6 +4238,22 @@ def test_update_password_dictionary_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3898,6 +4311,22 @@ def test_update_password_history_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -3953,6 +4382,22 @@ def test_update_password_personal_data_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4010,6 +4455,22 @@ def test_update_password_pwned_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4069,6 +4530,22 @@ def test_update_password_rotation_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4169,6 +4646,22 @@ def test_update_session_alert_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4224,6 +4717,22 @@ def test_update_session_duration_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4279,6 +4788,22 @@ def test_update_session_invalidation_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4334,6 +4859,22 @@ def test_update_session_limit_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4389,6 +4930,22 @@ def test_update_user_limit_policy(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4520,6 +5077,22 @@ def test_update_protocol(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4576,6 +5149,22 @@ def test_update_service(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], @@ -4653,6 +5242,22 @@ def test_update_smtp(self, m): "smtpUsername": "emailuser", "smtpPassword": "smtp-password", "smtpSecure": "tls", + "ldapEnabled": True, + "ldapHosts": [], + "ldapPort": 636.0, + "ldapEncryption": "ldaps", + "ldapVerification": True, + "ldapCertificate": "", + "ldapTimeout": 10.0, + "ldapBaseDn": "ou=people,dc=example,dc=com", + "ldapBindDn": "cn=appwrite,ou=services,dc=example,dc=com", + "ldapBindPassword": "ldap-password", + "ldapUserFilter": "(uid={username})", + "ldapRequiredGroupDn": "cn=staff,ou=groups,dc=example,dc=com", + "ldapIdAttribute": "entryUUID", + "ldapEmailAttribute": "mail", + "ldapNameAttribute": "cn", + "ldapPhoneAttribute": "mobile", "pingCount": 1.0, "pingedAt": "2020-10-15T06:38:00.000+00:00", "labels": [], diff --git a/test/services/test_sites.py b/test/services/test_sites.py index 9fedd1c3..72e61804 100644 --- a/test/services/test_sites.py +++ b/test/services/test_sites.py @@ -89,6 +89,8 @@ def test_create(self, m): "buildRuntime": "node-22", "adapter": "static", "fallbackFile": "index.html", + "analyticsEnabled": True, + "analyticsPropertyId": "5e5ea5c16897e", } headers = {'Content-Type': 'application/json'} m.request( @@ -266,6 +268,8 @@ def test_get(self, m): "buildRuntime": "node-22", "adapter": "static", "fallbackFile": "index.html", + "analyticsEnabled": True, + "analyticsPropertyId": "5e5ea5c16897e", } headers = {'Content-Type': 'application/json'} m.request( @@ -326,6 +330,8 @@ def test_update(self, m): "buildRuntime": "node-22", "adapter": "static", "fallbackFile": "index.html", + "analyticsEnabled": True, + "analyticsPropertyId": "5e5ea5c16897e", } headers = {'Content-Type': 'application/json'} m.request( @@ -422,6 +428,74 @@ def test_delete(self, m): self.assertEqual(sent, {}) self.assertEqual(response, data) + @requests_mock.Mocker() + def test_update_analytics(self, m): + data = { + "$id": "5e5ea5c16897e", + "$createdAt": "2020-10-15T06:38:00.000+00:00", + "$updatedAt": "2020-10-15T06:38:00.000+00:00", + "name": "My Site", + "description": "Marketing site for the spring launch.", + "enabled": True, + "live": True, + "logging": True, + "framework": "react", + "deploymentRetention": 7.0, + "deploymentId": "5e5ea5c16897e", + "deploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "deploymentScreenshotLight": "5e5ea5c16897e", + "deploymentScreenshotDark": "5e5ea5c16897e", + "latestDeploymentId": "5e5ea5c16897e", + "latestDeploymentCreatedAt": "2020-10-15T06:38:00.000+00:00", + "latestDeploymentStatus": "ready", + "scopes": [], + "vars": [], + "timeout": 300.0, + "installCommand": "npm install", + "buildCommand": "npm run build", + "startCommand": "node custom-server.mjs", + "outputDirectory": "build", + "installationId": "6m40at4ejk5h2u9s1hboo", + "providerRepositoryId": "appwrite", + "providerBranch": "main", + "providerRootDirectory": "sites\/helloWorld", + "providerSilentMode": True, + "providerBranches": [], + "providerPaths": [], + "buildSpecification": "s-1vcpu-512mb", + "runtimeSpecification": "s-1vcpu-512mb", + "buildRuntime": "node-22", + "adapter": "static", + "fallbackFile": "index.html", + "analyticsEnabled": True, + "analyticsPropertyId": "5e5ea5c16897e", + } + headers = {'Content-Type': 'application/json'} + m.request( + 'PATCH', + requests_mock.ANY, + text=json.dumps(data), + headers=headers, + ) + response = self.sites.update_analytics( + '', + False, + ) + request = m.last_request + url = urlsplit(request.url) + self.assertEqual( + unquote(url.path), + '/v1/sites//analytics', + ) + sent = json.loads(request.body or '{}') + self.assertEqual( + sent, + { + 'enabled': False, + }, + ) + self.assertEqual(response.to_dict(), data) + @requests_mock.Mocker() def test_update_site_deployment(self, m): data = { @@ -461,6 +535,8 @@ def test_update_site_deployment(self, m): "buildRuntime": "node-22", "adapter": "static", "fallbackFile": "index.html", + "analyticsEnabled": True, + "analyticsPropertyId": "5e5ea5c16897e", } headers = {'Content-Type': 'application/json'} m.request(