diff --git a/CHANGELOG.md b/CHANGELOG.md index bae4c14..9766bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 18.0.0 + +* [BREAKING] Renamed Webhook model fields: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword`, `signatureKey` → `secret` +* [BREAKING] Renamed Webhook service parameters to match: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword` +* [BREAKING] Renamed `Webhooks.update_signature()` to `Webhooks.update_secret()` with new optional `secret` parameter +* Added `Client.get_headers()` method to retrieve request headers +* Added `secret` parameter to Webhook create and update methods +* Added `x` OAuth provider to `OAuthProvider` enum +* Added `userType` field to `Log` model +* Added `purge` parameter to `update_collection` and `update_table` for cache invalidation +* Added Project service: platform CRUD, key CRUD, protocol/service status management +* Added new models: `Key`, `KeyList`, `Project`, `DevKey`, `MockNumber`, `AuthProvider`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, `PlatformWeb`, `PlatformWindows`, `BillingLimits`, `Block` +* Added new enums: `PlatformType`, `ProtocolId`, `ServiceId` +* Updated `BuildRuntime`, `Runtime` enums with `dart-3.11` and `flutter-3.41` +* Updated `Scopes` enum with `keys_read`, `keys_write`, `platforms_read`, `platforms_write` +* Updated `X-Appwrite-Response-Format` header to `1.9.1` +* Updated TTL description for list caching in Databases and TablesDB +* Simplified `_parse_response()` by removing `union_models` parameter + ## 17.0.0 * [BREAKING] Changed `$sequence` type from `float` to `str` for `Row` and `Document` models diff --git a/README.md b/README.md index 093450f..f615f2f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Python SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.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 f0aacda..52ec0d1 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,12 +15,12 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/17.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/18.0.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': '17.0.0', - 'X-Appwrite-Response-Format' : '1.9.0', + 'x-sdk-version': '18.0.0', + 'X-Appwrite-Response-Format' : '1.9.1', } def set_self_signed(self, status=True): @@ -38,6 +38,9 @@ def add_header(self, key, value): self._global_headers[key.lower()] = value return self + def get_headers(self): + return dict(self._global_headers) + def set_project(self, value): """Your project ID""" diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 19c4fb4..3be7fa6 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -24,6 +24,8 @@ from ..enums.name import Name from ..enums.message_priority import MessagePriority from ..enums.smtp_encryption import SmtpEncryption +from ..enums.protocol_id import ProtocolId +from ..enums.service_id import ServiceId from ..enums.framework import Framework from ..enums.build_runtime import BuildRuntime from ..enums.adapter import Adapter @@ -39,6 +41,7 @@ from ..enums.deployment_status import DeploymentStatus from ..enums.execution_trigger import ExecutionTrigger from ..enums.execution_status import ExecutionStatus +from ..enums.platform_type import PlatformType from ..enums.health_antivirus_status import HealthAntivirusStatus from ..enums.health_check_status import HealthCheckStatus from ..enums.message_status import MessageStatus @@ -120,6 +123,12 @@ def default(self, o): if isinstance(o, SmtpEncryption): return o.value + if isinstance(o, ProtocolId): + return o.value + + if isinstance(o, ServiceId): + return o.value + if isinstance(o, Framework): return o.value @@ -165,6 +174,9 @@ def default(self, o): if isinstance(o, ExecutionStatus): return o.value + if isinstance(o, PlatformType): + return o.value + if isinstance(o, HealthAntivirusStatus): return o.value diff --git a/appwrite/enums/build_runtime.py b/appwrite/enums/build_runtime.py index 8fe21cb..eaa3216 100644 --- a/appwrite/enums/build_runtime.py +++ b/appwrite/enums/build_runtime.py @@ -49,6 +49,7 @@ class BuildRuntime(Enum): DART_3_8 = "dart-3.8" DART_3_9 = "dart-3.9" DART_3_10 = "dart-3.10" + DART_3_11 = "dart-3.11" DOTNET_6_0 = "dotnet-6.0" DOTNET_7_0 = "dotnet-7.0" DOTNET_8_0 = "dotnet-8.0" @@ -87,3 +88,4 @@ class BuildRuntime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" + FLUTTER_3_41 = "flutter-3.41" diff --git a/appwrite/enums/o_auth_provider.py b/appwrite/enums/o_auth_provider.py index b200f77..6d2e217 100644 --- a/appwrite/enums/o_auth_provider.py +++ b/appwrite/enums/o_auth_provider.py @@ -35,6 +35,7 @@ class OAuthProvider(Enum): TRADESHIFTBOX = "tradeshiftBox" TWITCH = "twitch" WORDPRESS = "wordpress" + X = "x" YAHOO = "yahoo" YAMMER = "yammer" YANDEX = "yandex" diff --git a/appwrite/enums/platform_type.py b/appwrite/enums/platform_type.py new file mode 100644 index 0000000..8a87d88 --- /dev/null +++ b/appwrite/enums/platform_type.py @@ -0,0 +1,8 @@ +from enum import Enum + +class PlatformType(Enum): + WINDOWS = "windows" + APPLE = "apple" + ANDROID = "android" + LINUX = "linux" + WEB = "web" diff --git a/appwrite/enums/protocol_id.py b/appwrite/enums/protocol_id.py new file mode 100644 index 0000000..9ec98f6 --- /dev/null +++ b/appwrite/enums/protocol_id.py @@ -0,0 +1,6 @@ +from enum import Enum + +class ProtocolId(Enum): + REST = "rest" + GRAPHQL = "graphql" + WEBSOCKET = "websocket" diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py index 171dbd9..4e18383 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -49,6 +49,7 @@ class Runtime(Enum): DART_3_8 = "dart-3.8" DART_3_9 = "dart-3.9" DART_3_10 = "dart-3.10" + DART_3_11 = "dart-3.11" DOTNET_6_0 = "dotnet-6.0" DOTNET_7_0 = "dotnet-7.0" DOTNET_8_0 = "dotnet-8.0" @@ -87,3 +88,4 @@ class Runtime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" + FLUTTER_3_41 = "flutter-3.41" diff --git a/appwrite/enums/scopes.py b/appwrite/enums/scopes.py index dfcedda..390fe6b 100644 --- a/appwrite/enums/scopes.py +++ b/appwrite/enums/scopes.py @@ -62,6 +62,10 @@ class Scopes(Enum): WEBHOOKS_WRITE = "webhooks.write" PROJECT_READ = "project.read" PROJECT_WRITE = "project.write" + KEYS_READ = "keys.read" + KEYS_WRITE = "keys.write" + PLATFORMS_READ = "platforms.read" + PLATFORMS_WRITE = "platforms.write" POLICIES_WRITE = "policies.write" POLICIES_READ = "policies.read" ARCHIVES_READ = "archives.read" diff --git a/appwrite/enums/service_id.py b/appwrite/enums/service_id.py new file mode 100644 index 0000000..54fddf6 --- /dev/null +++ b/appwrite/enums/service_id.py @@ -0,0 +1,20 @@ +from enum import Enum + +class ServiceId(Enum): + ACCOUNT = "account" + AVATARS = "avatars" + DATABASES = "databases" + TABLESDB = "tablesdb" + LOCALE = "locale" + HEALTH = "health" + PROJECT = "project" + STORAGE = "storage" + TEAMS = "teams" + USERS = "users" + VCS = "vcs" + SITES = "sites" + FUNCTIONS = "functions" + PROXY = "proxy" + GRAPHQL = "graphql" + MIGRATIONS = "migrations" + MESSAGING = "messaging" diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index 5bf9683..a9352e4 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -22,6 +22,7 @@ from .deployment_list import DeploymentList from .execution_list import ExecutionList from .webhook_list import WebhookList +from .key_list import KeyList from .country_list import CountryList from .continent_list import ContinentList from .language_list import LanguageList @@ -108,7 +109,18 @@ from .framework_adapter import FrameworkAdapter from .deployment import Deployment from .execution import Execution +from .project import Project from .webhook import Webhook +from .key import Key +from .dev_key import DevKey +from .mock_number import MockNumber +from .auth_provider import AuthProvider +from .platform_web import PlatformWeb +from .platform_apple import PlatformApple +from .platform_android import PlatformAndroid +from .platform_windows import PlatformWindows +from .platform_linux import PlatformLinux +from .platform_list import PlatformList from .variable import Variable from .country import Country from .continent import Continent @@ -134,6 +146,8 @@ from .target import Target from .activity_event import ActivityEvent from .backup_archive import BackupArchive +from .billing_limits import BillingLimits +from .block import Block from .backup_policy import BackupPolicy from .backup_restoration import BackupRestoration from .activity_event_list import ActivityEventList @@ -166,6 +180,7 @@ 'DeploymentList', 'ExecutionList', 'WebhookList', + 'KeyList', 'CountryList', 'ContinentList', 'LanguageList', @@ -252,7 +267,18 @@ 'FrameworkAdapter', 'Deployment', 'Execution', + 'Project', 'Webhook', + 'Key', + 'DevKey', + 'MockNumber', + 'AuthProvider', + 'PlatformWeb', + 'PlatformApple', + 'PlatformAndroid', + 'PlatformWindows', + 'PlatformLinux', + 'PlatformList', 'Variable', 'Country', 'Continent', @@ -278,6 +304,8 @@ 'Target', 'ActivityEvent', 'BackupArchive', + 'BillingLimits', + 'Block', 'BackupPolicy', 'BackupRestoration', 'ActivityEventList', diff --git a/appwrite/models/auth_provider.py b/appwrite/models/auth_provider.py new file mode 100644 index 0000000..4df1454 --- /dev/null +++ b/appwrite/models/auth_provider.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class AuthProvider(AppwriteModel): + """ + AuthProvider + + Attributes + ---------- + key : str + Auth Provider. + name : str + Auth Provider name. + appid : str + OAuth 2.0 application ID. + secret : str + OAuth 2.0 application secret. Might be JSON string if provider requires extra configuration. + enabled : bool + Auth Provider is active and can be used to create session. + """ + key: str = Field(..., alias='key') + name: str = Field(..., alias='name') + appid: str = Field(..., alias='appId') + secret: str = Field(..., alias='secret') + enabled: bool = Field(..., alias='enabled') diff --git a/appwrite/models/billing_limits.py b/appwrite/models/billing_limits.py new file mode 100644 index 0000000..c66878e --- /dev/null +++ b/appwrite/models/billing_limits.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class BillingLimits(AppwriteModel): + """ + BillingLimits + + Attributes + ---------- + bandwidth : float + Bandwidth limit + storage : float + Storage limit + users : float + Users limit + executions : float + Executions limit + gbhours : float + GBHours limit + imagetransformations : float + Image transformations limit + authphone : float + Auth phone limit + budgetlimit : float + Budget limit percentage + """ + bandwidth: float = Field(..., alias='bandwidth') + storage: float = Field(..., alias='storage') + users: float = Field(..., alias='users') + executions: float = Field(..., alias='executions') + gbhours: float = Field(..., alias='GBHours') + imagetransformations: float = Field(..., alias='imageTransformations') + authphone: float = Field(..., alias='authPhone') + budgetlimit: float = Field(..., alias='budgetLimit') diff --git a/appwrite/models/block.py b/appwrite/models/block.py new file mode 100644 index 0000000..6e5ebb0 --- /dev/null +++ b/appwrite/models/block.py @@ -0,0 +1,27 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class Block(AppwriteModel): + """ + Block + + Attributes + ---------- + createdat : str + Block creation date in ISO 8601 format. + resourcetype : str + Resource type that is blocked + resourceid : str + Resource identifier that is blocked + reason : Optional[str] + Reason for the block. Can be null if no reason was provided. + expiredat : Optional[str] + Block expiration date in ISO 8601 format. Can be null if the block does not expire. + """ + createdat: str = Field(..., alias='$createdAt') + resourcetype: str = Field(..., alias='resourceType') + resourceid: str = Field(..., alias='resourceId') + reason: Optional[str] = Field(default=None, alias='reason') + expiredat: Optional[str] = Field(default=None, alias='expiredAt') diff --git a/appwrite/models/dev_key.py b/appwrite/models/dev_key.py new file mode 100644 index 0000000..b77acfd --- /dev/null +++ b/appwrite/models/dev_key.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class DevKey(AppwriteModel): + """ + DevKey + + Attributes + ---------- + id : str + Key ID. + createdat : str + Key creation date in ISO 8601 format. + updatedat : str + Key update date in ISO 8601 format. + name : str + Key name. + expire : str + Key expiration date in ISO 8601 format. + secret : str + Secret key. + accessedat : str + Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + sdks : List[Any] + List of SDK user agents that used this key. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + expire: str = Field(..., alias='expire') + secret: str = Field(..., alias='secret') + accessedat: str = Field(..., alias='accessedAt') + sdks: List[Any] = Field(..., alias='sdks') diff --git a/appwrite/models/key.py b/appwrite/models/key.py new file mode 100644 index 0000000..2d148d5 --- /dev/null +++ b/appwrite/models/key.py @@ -0,0 +1,39 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class Key(AppwriteModel): + """ + Key + + Attributes + ---------- + id : str + Key ID. + createdat : str + Key creation date in ISO 8601 format. + updatedat : str + Key update date in ISO 8601 format. + name : str + Key name. + expire : str + Key expiration date in ISO 8601 format. + scopes : List[Any] + Allowed permission scopes. + secret : str + Secret key. + accessedat : str + Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + sdks : List[Any] + List of SDK user agents that used this key. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + expire: str = Field(..., alias='expire') + scopes: List[Any] = Field(..., alias='scopes') + secret: str = Field(..., alias='secret') + accessedat: str = Field(..., alias='accessedAt') + sdks: List[Any] = Field(..., alias='sdks') diff --git a/appwrite/models/key_list.py b/appwrite/models/key_list.py new file mode 100644 index 0000000..2512608 --- /dev/null +++ b/appwrite/models/key_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .key import Key + +class KeyList(AppwriteModel): + """ + API Keys List + + Attributes + ---------- + total : float + Total number of keys that matched your query. + keys : List[Key] + List of keys. + """ + total: float = Field(..., alias='total') + keys: List[Key] = Field(..., alias='keys') diff --git a/appwrite/models/log.py b/appwrite/models/log.py index d23732d..dc0e0c6 100644 --- a/appwrite/models/log.py +++ b/appwrite/models/log.py @@ -19,6 +19,8 @@ class Log(AppwriteModel): User name of the actor recorded for this log. During impersonation, this is the original impersonator. mode : str API mode when event triggered. + usertype : str + User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. ip : str IP session in use when the session was created. time : str @@ -57,6 +59,7 @@ class Log(AppwriteModel): useremail: str = Field(..., alias='userEmail') username: str = Field(..., alias='userName') mode: str = Field(..., alias='mode') + usertype: str = Field(..., alias='userType') ip: str = Field(..., alias='ip') time: str = Field(..., alias='time') oscode: str = Field(..., alias='osCode') diff --git a/appwrite/models/mock_number.py b/appwrite/models/mock_number.py new file mode 100644 index 0000000..5798dc7 --- /dev/null +++ b/appwrite/models/mock_number.py @@ -0,0 +1,18 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class MockNumber(AppwriteModel): + """ + Mock Number + + Attributes + ---------- + phone : str + Mock phone number for testing phone authentication. Useful for testing phone authentication without sending an SMS. + otp : str + Mock OTP for the number. + """ + phone: str = Field(..., alias='phone') + otp: str = Field(..., alias='otp') diff --git a/appwrite/models/platform_android.py b/appwrite/models/platform_android.py new file mode 100644 index 0000000..3ec3587 --- /dev/null +++ b/appwrite/models/platform_android.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.platform_type import PlatformType + +class PlatformAndroid(AppwriteModel): + """ + Platform Android + + Attributes + ---------- + id : str + Platform ID. + createdat : str + Platform creation date in ISO 8601 format. + updatedat : str + Platform update date in ISO 8601 format. + name : str + Platform name. + type : PlatformType + Platform type. Possible values are: windows, apple, android, linux, web. + applicationid : str + Android application ID. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + type: PlatformType = Field(..., alias='type') + applicationid: str = Field(..., alias='applicationId') diff --git a/appwrite/models/platform_apple.py b/appwrite/models/platform_apple.py new file mode 100644 index 0000000..3e94d78 --- /dev/null +++ b/appwrite/models/platform_apple.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.platform_type import PlatformType + +class PlatformApple(AppwriteModel): + """ + Platform Apple + + Attributes + ---------- + id : str + Platform ID. + createdat : str + Platform creation date in ISO 8601 format. + updatedat : str + Platform update date in ISO 8601 format. + name : str + Platform name. + type : PlatformType + Platform type. Possible values are: windows, apple, android, linux, web. + bundleidentifier : str + Apple bundle identifier. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + type: PlatformType = Field(..., alias='type') + bundleidentifier: str = Field(..., alias='bundleIdentifier') diff --git a/appwrite/models/platform_linux.py b/appwrite/models/platform_linux.py new file mode 100644 index 0000000..ead049a --- /dev/null +++ b/appwrite/models/platform_linux.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.platform_type import PlatformType + +class PlatformLinux(AppwriteModel): + """ + Platform Linux + + Attributes + ---------- + id : str + Platform ID. + createdat : str + Platform creation date in ISO 8601 format. + updatedat : str + Platform update date in ISO 8601 format. + name : str + Platform name. + type : PlatformType + Platform type. Possible values are: windows, apple, android, linux, web. + packagename : str + Linux package name. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + type: PlatformType = Field(..., alias='type') + packagename: str = Field(..., alias='packageName') diff --git a/appwrite/models/platform_list.py b/appwrite/models/platform_list.py new file mode 100644 index 0000000..07cca31 --- /dev/null +++ b/appwrite/models/platform_list.py @@ -0,0 +1,23 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .platform_web import PlatformWeb +from .platform_apple import PlatformApple +from .platform_android import PlatformAndroid +from .platform_windows import PlatformWindows +from .platform_linux import PlatformLinux + +class PlatformList(AppwriteModel): + """ + Platforms List + + Attributes + ---------- + total : float + Total number of platforms in the given project. + platforms : List[Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]] + List of platforms. + """ + total: float = Field(..., alias='total') + platforms: List[Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]] = Field(..., alias='platforms') diff --git a/appwrite/models/platform_web.py b/appwrite/models/platform_web.py new file mode 100644 index 0000000..7b143be --- /dev/null +++ b/appwrite/models/platform_web.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.platform_type import PlatformType + +class PlatformWeb(AppwriteModel): + """ + Platform Web + + Attributes + ---------- + id : str + Platform ID. + createdat : str + Platform creation date in ISO 8601 format. + updatedat : str + Platform update date in ISO 8601 format. + name : str + Platform name. + type : PlatformType + Platform type. Possible values are: windows, apple, android, linux, web. + hostname : str + Web app hostname. Empty string for other platforms. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + type: PlatformType = Field(..., alias='type') + hostname: str = Field(..., alias='hostname') diff --git a/appwrite/models/platform_windows.py b/appwrite/models/platform_windows.py new file mode 100644 index 0000000..78b2e0a --- /dev/null +++ b/appwrite/models/platform_windows.py @@ -0,0 +1,31 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.platform_type import PlatformType + +class PlatformWindows(AppwriteModel): + """ + Platform Windows + + Attributes + ---------- + id : str + Platform ID. + createdat : str + Platform creation date in ISO 8601 format. + updatedat : str + Platform update date in ISO 8601 format. + name : str + Platform name. + type : PlatformType + Platform type. Possible values are: windows, apple, android, linux, web. + packageidentifiername : str + Windows package identifier name. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + type: PlatformType = Field(..., alias='type') + packageidentifiername: str = Field(..., alias='packageIdentifierName') diff --git a/appwrite/models/project.py b/appwrite/models/project.py new file mode 100644 index 0000000..1228e6e --- /dev/null +++ b/appwrite/models/project.py @@ -0,0 +1,258 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .mock_number import MockNumber +from .auth_provider import AuthProvider +from .platform_web import PlatformWeb +from .platform_apple import PlatformApple +from .platform_android import PlatformAndroid +from .platform_windows import PlatformWindows +from .platform_linux import PlatformLinux +from .webhook import Webhook +from .key import Key +from .dev_key import DevKey +from .billing_limits import BillingLimits +from .block import Block + +class Project(AppwriteModel): + """ + Project + + Attributes + ---------- + id : str + Project ID. + createdat : str + Project creation date in ISO 8601 format. + updatedat : str + Project update date in ISO 8601 format. + name : str + Project name. + description : str + Project description. + teamid : str + Project team ID. + logo : str + Project logo file ID. + url : str + Project website URL. + legalname : str + Company legal name. + legalcountry : str + Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. + legalstate : str + State name. + legalcity : str + City name. + legaladdress : str + Company Address. + legaltaxid : str + Company Tax ID. + authduration : float + Session duration in seconds. + authlimit : float + Max users allowed. 0 is unlimited. + authsessionslimit : float + Max sessions allowed per user. 100 maximum. + authpasswordhistory : float + Max allowed passwords in the history list per user. Max passwords limit allowed in history is 20. Use 0 for disabling password history. + authpassworddictionary : bool + Whether or not to check user's password against most commonly used passwords. + authpersonaldatacheck : bool + Whether or not to check the user password for similarity with their personal data. + authdisposableemails : bool + Whether or not to disallow disposable email addresses during signup and email updates. + authcanonicalemails : bool + Whether or not to require canonical email addresses during signup and email updates. + authfreeemails : bool + Whether or not to disallow free email addresses during signup and email updates. + authmocknumbers : List[MockNumber] + An array of mock numbers and their corresponding verification codes (OTPs). + authsessionalerts : bool + Whether or not to send session alert emails to users. + authmembershipsusername : bool + Whether or not to show user names in the teams membership response. + authmembershipsuseremail : bool + Whether or not to show user emails in the teams membership response. + authmembershipsmfa : bool + Whether or not to show user MFA status in the teams membership response. + authinvalidatesessions : bool + Whether or not all existing sessions should be invalidated on password change + oauthproviders : List[AuthProvider] + List of Auth Providers. + platforms : List[Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]] + List of Platforms. + webhooks : List[Webhook] + List of Webhooks. + keys : List[Key] + List of API Keys. + devkeys : List[DevKey] + List of dev keys. + smtpenabled : bool + Status for custom SMTP + smtpsendername : str + SMTP sender name + smtpsenderemail : str + SMTP sender email + smtpreplyto : str + SMTP reply to email + smtphost : str + SMTP server host name + smtpport : float + SMTP server port + smtpusername : str + SMTP server username + smtppassword : str + SMTP server password + smtpsecure : str + SMTP server secure protocol + pingcount : float + Number of times the ping was received for this project. + pingedat : str + Last ping datetime in ISO 8601 format. + labels : List[Any] + Labels for the project. + status : str + Project status + authemailpassword : bool + Email/Password auth method status + authusersauthmagicurl : bool + Magic URL auth method status + authemailotp : bool + Email (OTP) auth method status + authanonymous : bool + Anonymous auth method status + authinvites : bool + Invites auth method status + authjwt : bool + JWT auth method status + authphone : bool + Phone auth method status + servicestatusforaccount : bool + Account service status + servicestatusforavatars : bool + Avatars service status + servicestatusfordatabases : bool + Databases (legacy) service status + servicestatusfortablesdb : bool + TablesDB service status + servicestatusforlocale : bool + Locale service status + servicestatusforhealth : bool + Health service status + servicestatusforproject : bool + Project service status + servicestatusforstorage : bool + Storage service status + servicestatusforteams : bool + Teams service status + servicestatusforusers : bool + Users service status + servicestatusforvcs : bool + VCS service status + servicestatusforsites : bool + Sites service status + servicestatusforfunctions : bool + Functions service status + servicestatusforproxy : bool + Proxy service status + servicestatusforgraphql : bool + GraphQL service status + servicestatusformigrations : bool + Migrations service status + servicestatusformessaging : bool + Messaging service status + protocolstatusforrest : bool + REST protocol status + protocolstatusforgraphql : bool + GraphQL protocol status + protocolstatusforwebsocket : bool + Websocket protocol status + region : str + Project region + billinglimits : BillingLimits + Billing limits reached + blocks : List[Block] + Project blocks information + consoleaccessedat : str + Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + description: str = Field(..., alias='description') + teamid: str = Field(..., alias='teamId') + logo: str = Field(..., alias='logo') + url: str = Field(..., alias='url') + legalname: str = Field(..., alias='legalName') + legalcountry: str = Field(..., alias='legalCountry') + legalstate: str = Field(..., alias='legalState') + legalcity: str = Field(..., alias='legalCity') + legaladdress: str = Field(..., alias='legalAddress') + legaltaxid: str = Field(..., alias='legalTaxId') + authduration: float = Field(..., alias='authDuration') + authlimit: float = Field(..., alias='authLimit') + authsessionslimit: float = Field(..., alias='authSessionsLimit') + authpasswordhistory: float = Field(..., alias='authPasswordHistory') + authpassworddictionary: bool = Field(..., alias='authPasswordDictionary') + authpersonaldatacheck: bool = Field(..., alias='authPersonalDataCheck') + authdisposableemails: bool = Field(..., alias='authDisposableEmails') + authcanonicalemails: bool = Field(..., alias='authCanonicalEmails') + authfreeemails: bool = Field(..., alias='authFreeEmails') + authmocknumbers: List[MockNumber] = Field(..., alias='authMockNumbers') + authsessionalerts: bool = Field(..., alias='authSessionAlerts') + authmembershipsusername: bool = Field(..., alias='authMembershipsUserName') + authmembershipsuseremail: bool = Field(..., alias='authMembershipsUserEmail') + authmembershipsmfa: bool = Field(..., alias='authMembershipsMfa') + authinvalidatesessions: bool = Field(..., alias='authInvalidateSessions') + oauthproviders: List[AuthProvider] = Field(..., alias='oAuthProviders') + platforms: List[Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]] = Field(..., alias='platforms') + webhooks: List[Webhook] = Field(..., alias='webhooks') + keys: List[Key] = Field(..., alias='keys') + devkeys: List[DevKey] = Field(..., alias='devKeys') + smtpenabled: bool = Field(..., alias='smtpEnabled') + smtpsendername: str = Field(..., alias='smtpSenderName') + smtpsenderemail: str = Field(..., alias='smtpSenderEmail') + smtpreplyto: str = Field(..., alias='smtpReplyTo') + smtphost: str = Field(..., alias='smtpHost') + smtpport: float = Field(..., alias='smtpPort') + smtpusername: str = Field(..., alias='smtpUsername') + smtppassword: str = Field(..., alias='smtpPassword') + smtpsecure: str = Field(..., alias='smtpSecure') + pingcount: float = Field(..., alias='pingCount') + pingedat: str = Field(..., alias='pingedAt') + labels: List[Any] = Field(..., alias='labels') + status: str = Field(..., alias='status') + authemailpassword: bool = Field(..., alias='authEmailPassword') + authusersauthmagicurl: bool = Field(..., alias='authUsersAuthMagicURL') + authemailotp: bool = Field(..., alias='authEmailOtp') + authanonymous: bool = Field(..., alias='authAnonymous') + authinvites: bool = Field(..., alias='authInvites') + authjwt: bool = Field(..., alias='authJWT') + authphone: bool = Field(..., alias='authPhone') + servicestatusforaccount: bool = Field(..., alias='serviceStatusForAccount') + servicestatusforavatars: bool = Field(..., alias='serviceStatusForAvatars') + servicestatusfordatabases: bool = Field(..., alias='serviceStatusForDatabases') + servicestatusfortablesdb: bool = Field(..., alias='serviceStatusForTablesdb') + servicestatusforlocale: bool = Field(..., alias='serviceStatusForLocale') + servicestatusforhealth: bool = Field(..., alias='serviceStatusForHealth') + servicestatusforproject: bool = Field(..., alias='serviceStatusForProject') + servicestatusforstorage: bool = Field(..., alias='serviceStatusForStorage') + servicestatusforteams: bool = Field(..., alias='serviceStatusForTeams') + servicestatusforusers: bool = Field(..., alias='serviceStatusForUsers') + servicestatusforvcs: bool = Field(..., alias='serviceStatusForVcs') + servicestatusforsites: bool = Field(..., alias='serviceStatusForSites') + servicestatusforfunctions: bool = Field(..., alias='serviceStatusForFunctions') + servicestatusforproxy: bool = Field(..., alias='serviceStatusForProxy') + servicestatusforgraphql: bool = Field(..., alias='serviceStatusForGraphql') + servicestatusformigrations: bool = Field(..., alias='serviceStatusForMigrations') + servicestatusformessaging: bool = Field(..., alias='serviceStatusForMessaging') + protocolstatusforrest: bool = Field(..., alias='protocolStatusForRest') + protocolstatusforgraphql: bool = Field(..., alias='protocolStatusForGraphql') + protocolstatusforwebsocket: bool = Field(..., alias='protocolStatusForWebsocket') + region: str = Field(..., alias='region') + billinglimits: BillingLimits = Field(..., alias='billingLimits') + blocks: List[Block] = Field(..., alias='blocks') + consoleaccessedat: str = Field(..., alias='consoleAccessedAt') diff --git a/appwrite/models/webhook.py b/appwrite/models/webhook.py index 0620cbf..01beb3b 100644 --- a/appwrite/models/webhook.py +++ b/appwrite/models/webhook.py @@ -21,14 +21,14 @@ class Webhook(AppwriteModel): Webhook URL endpoint. events : List[Any] Webhook trigger events. - security : bool - Indicated if SSL / TLS Certificate verification is enabled. - httpuser : str + tls : bool + Indicates if SSL / TLS certificate verification is enabled. + authusername : str HTTP basic authentication username. - httppass : str + authpassword : str HTTP basic authentication password. - signaturekey : str - Signature key which can be used to validated incoming + secret : str + Signature key which can be used to validate incoming webhook payloads. Only returned on creation and secret rotation. enabled : bool Indicates if this webhook is enabled. logs : str @@ -42,10 +42,10 @@ class Webhook(AppwriteModel): name: str = Field(..., alias='name') url: str = Field(..., alias='url') events: List[Any] = Field(..., alias='events') - security: bool = Field(..., alias='security') - httpuser: str = Field(..., alias='httpUser') - httppass: str = Field(..., alias='httpPass') - signaturekey: str = Field(..., alias='signatureKey') + tls: bool = Field(..., alias='tls') + authusername: str = Field(..., alias='authUsername') + authpassword: str = Field(..., alias='authPassword') + secret: str = Field(..., alias='secret') enabled: bool = Field(..., alias='enabled') logs: str = Field(..., alias='logs') attempts: float = Field(..., alias='attempts') diff --git a/appwrite/service.py b/appwrite/service.py index 4905af2..dcf43a0 100644 --- a/appwrite/service.py +++ b/appwrite/service.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, Optional, Tuple, Type, TypeVar +from typing import Any, Optional, Type, TypeVar from pydantic import ValidationError @@ -34,27 +34,17 @@ def _normalize_value(self, value: Any) -> Any: def _parse_response( self, response: Any, - model: Optional[Type[ModelType]] = None, - union_models: Optional[Tuple[Type[AppwriteModel], ...]] = None + model: Optional[Type[ModelType]] = None ) -> Any: - if model is None and not union_models: + if model is None: return response if not isinstance(response, dict): return response - if model is not None: - try: - return model.model_validate(response) - except ValidationError as error: - raise AppwriteException( - f'Unable to parse response into {model.__name__}: {error}' - ) from error - - for union_model in union_models or (): - try: - return union_model.model_validate(response) - except ValidationError: - continue - - raise AppwriteException('Unable to parse response into any known model') + try: + return model.model_validate(response) + except ValidationError as error: + raise AppwriteException( + f'Unable to parse response into {model.__name__}: {error}' + ) from error diff --git a/appwrite/services/account.py b/appwrite/services/account.py index ab3ef0c..4499c0d 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -1535,7 +1535,7 @@ def create_o_auth2_token( Parameters ---------- provider : OAuthProvider - OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, 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/databases.py b/appwrite/services/databases.py index e479546..22769df 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -702,7 +702,8 @@ def update_collection( name: Optional[str] = None, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, - enabled: Optional[bool] = None + enabled: Optional[bool] = None, + purge: Optional[bool] = None ) -> Collection: """ Update a collection by its unique ID. @@ -723,6 +724,8 @@ def update_collection( Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). enabled : Optional[bool] Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + purge : Optional[bool] + When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. Returns ------- @@ -753,6 +756,8 @@ def update_collection( api_params['documentSecurity'] = self._normalize_value(document_security) if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) + if purge is not None: + api_params['purge'] = self._normalize_value(purge) response = self.client.call('put', api_path, { 'content-type': 'application/json', @@ -3395,8 +3400,40 @@ def get_attribute( response = self.client.call('get', api_path, { }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') + + if response.get('type') == 'string' and response.get('format') == 'email': + return self._parse_response(response, model=AttributeEmail) + + if response.get('type') == 'string' and response.get('format') == 'enum': + return self._parse_response(response, model=AttributeEnum) + + if response.get('type') == 'string' and response.get('format') == 'url': + return self._parse_response(response, model=AttributeUrl) + + if response.get('type') == 'string' and response.get('format') == 'ip': + return self._parse_response(response, model=AttributeIp) + + if response.get('type') == 'boolean': + return self._parse_response(response, model=AttributeBoolean) + + if response.get('type') == 'integer': + return self._parse_response(response, model=AttributeInteger) + + if response.get('type') == 'double': + return self._parse_response(response, model=AttributeFloat) + + if response.get('type') == 'datetime': + return self._parse_response(response, model=AttributeDatetime) + + if response.get('type') == 'relationship': + return self._parse_response(response, model=AttributeRelationship) + + if response.get('type') == 'string': + return self._parse_response(response, model=AttributeString) - return self._parse_response(response, union_models=(AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString, )) + raise AppwriteException('Unable to match response to any known model') @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.delete_column` instead.") @@ -3483,7 +3520,7 @@ def list_documents( total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. ttl : Optional[float] - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). model_type : Type[T], optional Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 1aafa0b..7b0eaa6 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -227,6 +227,7 @@ def get_queue_audits( ) -> HealthQueue: """ Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. + Parameters ---------- diff --git a/appwrite/services/project.py b/appwrite/services/project.py index ee50438..822ad15 100644 --- a/appwrite/services/project.py +++ b/appwrite/services/project.py @@ -2,6 +2,18 @@ from typing import Any, Dict, List, Optional, Union from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..models.key_list import KeyList; +from ..enums.scopes import Scopes; +from ..models.key import Key; +from ..models.project import Project as ProjectModel; +from ..models.platform_list import PlatformList; +from ..models.platform_android import PlatformAndroid; +from ..models.platform_apple import PlatformApple; +from ..models.platform_linux import PlatformLinux; +from ..models.platform_web import PlatformWeb; +from ..models.platform_windows import PlatformWindows; +from ..enums.protocol_id import ProtocolId; +from ..enums.service_id import ServiceId; from ..models.variable_list import VariableList; from ..models.variable import Variable; @@ -10,6 +22,1013 @@ class Project(Service): def __init__(self, client) -> None: super(Project, self).__init__(client) + def list_keys( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> KeyList: + """ + Get a list of all API keys from the current project. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + KeyList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=KeyList) + + + def create_key( + self, + key_id: str, + name: str, + scopes: List[Scopes], + expire: Optional[str] = None + ) -> Key: + """ + Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + + Parameters + ---------- + key_id : str + Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Key name. Max length: 128 chars. + scopes : List[Scopes] + Key scopes list. Maximum of 100 scopes are allowed. + expire : Optional[str] + Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + + Returns + ------- + Key + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys' + api_params = {} + if key_id is None: + raise AppwriteException('Missing required parameter: "key_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if scopes is None: + raise AppwriteException('Missing required parameter: "scopes"') + + + api_params['keyId'] = self._normalize_value(key_id) + api_params['name'] = self._normalize_value(name) + api_params['scopes'] = self._normalize_value(scopes) + api_params['expire'] = self._normalize_value(expire) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Key) + + + def get_key( + self, + key_id: str + ) -> Key: + """ + Get a key by its unique ID. + + Parameters + ---------- + key_id : str + Key ID. + + Returns + ------- + Key + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys/{keyId}' + api_params = {} + if key_id is None: + raise AppwriteException('Missing required parameter: "key_id"') + + api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Key) + + + def update_key( + self, + key_id: str, + name: str, + scopes: List[Scopes], + expire: Optional[str] = None + ) -> Key: + """ + Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + + Parameters + ---------- + key_id : str + Key ID. + name : str + Key name. Max length: 128 chars. + scopes : List[Scopes] + Key scopes list. Maximum of 100 scopes are allowed. + expire : Optional[str] + Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + + Returns + ------- + Key + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys/{keyId}' + api_params = {} + if key_id is None: + raise AppwriteException('Missing required parameter: "key_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if scopes is None: + raise AppwriteException('Missing required parameter: "scopes"') + + api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) + + api_params['name'] = self._normalize_value(name) + api_params['scopes'] = self._normalize_value(scopes) + api_params['expire'] = self._normalize_value(expire) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Key) + + + def delete_key( + self, + key_id: str + ) -> Dict[str, Any]: + """ + Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + + Parameters + ---------- + key_id : str + Key ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/keys/{keyId}' + api_params = {} + if key_id is None: + raise AppwriteException('Missing required parameter: "key_id"') + + api_path = api_path.replace('{keyId}', str(self._normalize_value(key_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def update_labels( + self, + labels: List[str] + ) -> ProjectModel: + """ + Update the project labels. Labels can be used to easily filter projects in an organization. + + Parameters + ---------- + labels : List[str] + Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/labels' + api_params = {} + if labels is None: + raise AppwriteException('Missing required parameter: "labels"') + + + api_params['labels'] = self._normalize_value(labels) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def list_platforms( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> PlatformList: + """ + Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + PlatformList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=PlatformList) + + + def create_android_platform( + self, + platform_id: str, + name: str, + application_id: str + ) -> PlatformAndroid: + """ + Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Platform name. Max length: 128 chars. + application_id : str + Android application ID. Max length: 256 chars. + + Returns + ------- + PlatformAndroid + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/android' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if application_id is None: + raise AppwriteException('Missing required parameter: "application_id"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['applicationId'] = self._normalize_value(application_id) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformAndroid) + + + def update_android_platform( + self, + platform_id: str, + name: str, + application_id: str + ) -> PlatformAndroid: + """ + Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + application_id : str + Android application ID. Max length: 256 chars. + + Returns + ------- + PlatformAndroid + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/android/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if application_id is None: + raise AppwriteException('Missing required parameter: "application_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['applicationId'] = self._normalize_value(application_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformAndroid) + + + def create_apple_platform( + self, + platform_id: str, + name: str, + bundle_identifier: str + ) -> PlatformApple: + """ + Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Platform name. Max length: 128 chars. + bundle_identifier : str + Apple bundle identifier. Max length: 256 chars. + + Returns + ------- + PlatformApple + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/apple' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if bundle_identifier is None: + raise AppwriteException('Missing required parameter: "bundle_identifier"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformApple) + + + def update_apple_platform( + self, + platform_id: str, + name: str, + bundle_identifier: str + ) -> PlatformApple: + """ + Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + bundle_identifier : str + Apple bundle identifier. Max length: 256 chars. + + Returns + ------- + PlatformApple + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/apple/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if bundle_identifier is None: + raise AppwriteException('Missing required parameter: "bundle_identifier"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['bundleIdentifier'] = self._normalize_value(bundle_identifier) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformApple) + + + def create_linux_platform( + self, + platform_id: str, + name: str, + package_name: str + ) -> PlatformLinux: + """ + Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Platform name. Max length: 128 chars. + package_name : str + Linux package name. Max length: 256 chars. + + Returns + ------- + PlatformLinux + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/linux' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_name is None: + raise AppwriteException('Missing required parameter: "package_name"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['packageName'] = self._normalize_value(package_name) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformLinux) + + + def update_linux_platform( + self, + platform_id: str, + name: str, + package_name: str + ) -> PlatformLinux: + """ + Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + package_name : str + Linux package name. Max length: 256 chars. + + Returns + ------- + PlatformLinux + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/linux/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_name is None: + raise AppwriteException('Missing required parameter: "package_name"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['packageName'] = self._normalize_value(package_name) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformLinux) + + + def create_web_platform( + self, + platform_id: str, + name: str, + hostname: str + ) -> PlatformWeb: + """ + Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Platform name. Max length: 128 chars. + hostname : str + Platform web hostname. Max length: 256 chars. + + Returns + ------- + PlatformWeb + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/web' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if hostname is None: + raise AppwriteException('Missing required parameter: "hostname"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['hostname'] = self._normalize_value(hostname) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWeb) + + + def update_web_platform( + self, + platform_id: str, + name: str, + hostname: str + ) -> PlatformWeb: + """ + Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + hostname : str + Platform web hostname. Max length: 256 chars. + + Returns + ------- + PlatformWeb + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/web/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if hostname is None: + raise AppwriteException('Missing required parameter: "hostname"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['hostname'] = self._normalize_value(hostname) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWeb) + + + def create_windows_platform( + self, + platform_id: str, + name: str, + package_identifier_name: str + ) -> PlatformWindows: + """ + Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + + Parameters + ---------- + platform_id : str + Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Platform name. Max length: 128 chars. + package_identifier_name : str + Windows package identifier name. Max length: 256 chars. + + Returns + ------- + PlatformWindows + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/windows' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_identifier_name is None: + raise AppwriteException('Missing required parameter: "package_identifier_name"') + + + api_params['platformId'] = self._normalize_value(platform_id) + api_params['name'] = self._normalize_value(name) + api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWindows) + + + def update_windows_platform( + self, + platform_id: str, + name: str, + package_identifier_name: str + ) -> PlatformWindows: + """ + Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + + Parameters + ---------- + platform_id : str + Platform ID. + name : str + Platform name. Max length: 128 chars. + package_identifier_name : str + Windows package identifier name. Max length: 256 chars. + + Returns + ------- + PlatformWindows + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/windows/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if package_identifier_name is None: + raise AppwriteException('Missing required parameter: "package_identifier_name"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + api_params['name'] = self._normalize_value(name) + api_params['packageIdentifierName'] = self._normalize_value(package_identifier_name) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=PlatformWindows) + + + def get_platform( + self, + platform_id: str + ) -> Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux]: + """ + Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + + Parameters + ---------- + platform_id : str + Platform ID. + + Returns + ------- + Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] + API response as one of the typed response models + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') + + if response.get('type') == 'web': + return self._parse_response(response, model=PlatformWeb) + + if response.get('type') == 'apple': + return self._parse_response(response, model=PlatformApple) + + if response.get('type') == 'android': + return self._parse_response(response, model=PlatformAndroid) + + if response.get('type') == 'windows': + return self._parse_response(response, model=PlatformWindows) + + if response.get('type') == 'linux': + return self._parse_response(response, model=PlatformLinux) + + raise AppwriteException('Unable to match response to any known model') + + + def delete_platform( + self, + platform_id: str + ) -> Dict[str, Any]: + """ + Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + + Parameters + ---------- + platform_id : str + Platform ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/platforms/{platformId}' + api_params = {} + if platform_id is None: + raise AppwriteException('Missing required parameter: "platform_id"') + + api_path = api_path.replace('{platformId}', str(self._normalize_value(platform_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def update_protocol_status( + self, + protocol_id: ProtocolId, + enabled: bool + ) -> ProjectModel: + """ + Update the status of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + + Parameters + ---------- + protocol_id : ProtocolId + Protocol name. Can be one of: rest, graphql, websocket + enabled : bool + Protocol status. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/protocols/{protocolId}/status' + api_params = {} + if protocol_id is None: + raise AppwriteException('Missing required parameter: "protocol_id"') + + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + api_path = api_path.replace('{protocolId}', str(self._normalize_value(protocol_id))) + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + + def update_service_status( + self, + service_id: ServiceId, + enabled: bool + ) -> ProjectModel: + """ + Update the status of a specific service. Use this endpoint to enable or disable a service in your project. + + Parameters + ---------- + service_id : ServiceId + Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging + enabled : bool + Service status. + + Returns + ------- + ProjectModel + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/services/{serviceId}/status' + api_params = {} + if service_id is None: + raise AppwriteException('Missing required parameter: "service_id"') + + if enabled is None: + raise AppwriteException('Missing required parameter: "enabled"') + + api_path = api_path.replace('{serviceId}', str(self._normalize_value(service_id))) + + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=ProjectModel) + + def list_variables( self, queries: Optional[List[str]] = None, diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 4474038..2f1e3cc 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -677,7 +677,8 @@ def update_table( name: Optional[str] = None, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, - enabled: Optional[bool] = None + enabled: Optional[bool] = None, + purge: Optional[bool] = None ) -> Table: """ Update a table by its unique ID. @@ -696,6 +697,8 @@ def update_table( Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). enabled : Optional[bool] Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + purge : Optional[bool] + When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. Returns ------- @@ -726,6 +729,8 @@ def update_table( api_params['rowSecurity'] = self._normalize_value(row_security) if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) + if purge is not None: + api_params['purge'] = self._normalize_value(purge) response = self.client.call('put', api_path, { 'content-type': 'application/json', @@ -3224,8 +3229,40 @@ def get_column( response = self.client.call('get', api_path, { }, api_params) + if not isinstance(response, dict): + raise AppwriteException('Expected object response when hydrating a response model') + + if response.get('type') == 'string' and response.get('format') == 'email': + return self._parse_response(response, model=ColumnEmail) + + if response.get('type') == 'string' and response.get('format') == 'enum': + return self._parse_response(response, model=ColumnEnum) + + if response.get('type') == 'string' and response.get('format') == 'url': + return self._parse_response(response, model=ColumnUrl) + + if response.get('type') == 'string' and response.get('format') == 'ip': + return self._parse_response(response, model=ColumnIp) + + if response.get('type') == 'boolean': + return self._parse_response(response, model=ColumnBoolean) + + if response.get('type') == 'integer': + return self._parse_response(response, model=ColumnInteger) + + if response.get('type') == 'double': + return self._parse_response(response, model=ColumnFloat) + + if response.get('type') == 'datetime': + return self._parse_response(response, model=ColumnDatetime) + + if response.get('type') == 'relationship': + return self._parse_response(response, model=ColumnRelationship) + + if response.get('type') == 'string': + return self._parse_response(response, model=ColumnString) - return self._parse_response(response, union_models=(ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString, )) + raise AppwriteException('Unable to match response to any known model') def delete_column( @@ -3601,7 +3638,7 @@ def list_rows( total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. ttl : Optional[float] - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). model_type : Type[T], optional Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. diff --git a/appwrite/services/webhooks.py b/appwrite/services/webhooks.py index 71e779c..079c18b 100644 --- a/appwrite/services/webhooks.py +++ b/appwrite/services/webhooks.py @@ -21,7 +21,7 @@ def list( Parameters ---------- queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, authUsername, tls, events, enabled, logs, attempts total : Optional[bool] When set to false, the total count returned will be 0 and will not be calculated. @@ -57,9 +57,10 @@ def create( name: str, events: List[str], enabled: Optional[bool] = None, - security: Optional[bool] = None, - http_user: Optional[str] = None, - http_pass: Optional[str] = None + tls: Optional[bool] = None, + auth_username: Optional[str] = None, + auth_password: Optional[str] = None, + secret: Optional[str] = None ) -> Webhook: """ Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. @@ -76,12 +77,14 @@ def create( Events list. Maximum of 100 events are allowed. enabled : Optional[bool] Enable or disable a webhook. - security : Optional[bool] + tls : Optional[bool] Certificate verification, false for disabled or true for enabled. - http_user : Optional[str] + auth_username : Optional[str] Webhook HTTP user. Max length: 256 chars. - http_pass : Optional[str] + auth_password : Optional[str] Webhook HTTP password. Max length: 256 chars. + secret : Optional[str] + Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. Returns ------- @@ -115,12 +118,13 @@ def create( api_params['events'] = self._normalize_value(events) if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - if security is not None: - api_params['security'] = self._normalize_value(security) - if http_user is not None: - api_params['httpUser'] = self._normalize_value(http_user) - if http_pass is not None: - api_params['httpPass'] = self._normalize_value(http_pass) + if tls is not None: + api_params['tls'] = self._normalize_value(tls) + if auth_username is not None: + api_params['authUsername'] = self._normalize_value(auth_username) + if auth_password is not None: + api_params['authPassword'] = self._normalize_value(auth_password) + api_params['secret'] = self._normalize_value(secret) response = self.client.call('post', api_path, { 'content-type': 'application/json', @@ -173,9 +177,9 @@ def update( url: str, events: List[str], enabled: Optional[bool] = None, - security: Optional[bool] = None, - http_user: Optional[str] = None, - http_pass: Optional[str] = None + tls: Optional[bool] = None, + auth_username: Optional[str] = None, + auth_password: Optional[str] = None ) -> Webhook: """ Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. @@ -192,11 +196,11 @@ def update( Events list. Maximum of 100 events are allowed. enabled : Optional[bool] Enable or disable a webhook. - security : Optional[bool] + tls : Optional[bool] Certificate verification, false for disabled or true for enabled. - http_user : Optional[str] + auth_username : Optional[str] Webhook HTTP user. Max length: 256 chars. - http_pass : Optional[str] + auth_password : Optional[str] Webhook HTTP password. Max length: 256 chars. Returns @@ -231,12 +235,12 @@ def update( api_params['events'] = self._normalize_value(events) if enabled is not None: api_params['enabled'] = self._normalize_value(enabled) - if security is not None: - api_params['security'] = self._normalize_value(security) - if http_user is not None: - api_params['httpUser'] = self._normalize_value(http_user) - if http_pass is not None: - api_params['httpPass'] = self._normalize_value(http_pass) + if tls is not None: + api_params['tls'] = self._normalize_value(tls) + if auth_username is not None: + api_params['authUsername'] = self._normalize_value(auth_username) + if auth_password is not None: + api_params['authPassword'] = self._normalize_value(auth_password) response = self.client.call('put', api_path, { 'content-type': 'application/json', @@ -283,17 +287,20 @@ def delete( return response - def update_signature( + def update_secret( self, - webhook_id: str + webhook_id: str, + secret: Optional[str] = None ) -> Webhook: """ - Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook. + Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook. Parameters ---------- webhook_id : str Webhook ID. + secret : Optional[str] + Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. Returns ------- @@ -306,13 +313,14 @@ def update_signature( If API request fails """ - api_path = '/webhooks/{webhookId}/signature' + api_path = '/webhooks/{webhookId}/secret' api_params = {} if webhook_id is None: raise AppwriteException('Missing required parameter: "webhook_id"') api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) + api_params['secret'] = self._normalize_value(secret) response = self.client.call('patch', api_path, { 'content-type': 'application/json', diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index c8dc6c2..9ee99ca 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -15,7 +15,7 @@ result: AttributeDatetime = databases.create_datetime_attribute( collection_id = '', key = '', required = False, - default = '', # optional + default = '2020-10-15T06:38:00.000+00:00', # optional array = False # optional ) diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index cfb8040..85d5078 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -18,7 +18,8 @@ result: Collection = databases.update_collection( name = '', # optional permissions = [Permission.read(Role.any())], # optional document_security = False, # optional - enabled = False # optional + enabled = False, # optional + purge = False # optional ) print(result.model_dump()) diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index ca054b4..0c585a8 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -15,7 +15,7 @@ result: AttributeDatetime = databases.update_datetime_attribute( collection_id = '', key = '', required = False, - default = '', + default = '2020-10-15T06:38:00.000+00:00', new_key = '' # optional ) diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index c1a8a32..a6454e4 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -22,7 +22,7 @@ result: Message = messaging.create_email( attachments = [], # optional draft = False, # optional html = False, # optional - scheduled_at = '' # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional ) print(result.model_dump()) diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 1a7dcc1..81a15da 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -27,7 +27,7 @@ result: Message = messaging.create_push( tag = '', # optional badge = None, # optional draft = False, # optional - scheduled_at = '', # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional content_available = False, # optional critical = False, # optional priority = MessagePriority.NORMAL # optional diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 7eb94e8..7512a54 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -17,7 +17,7 @@ result: Message = messaging.create_sms( users = [], # optional targets = [], # optional draft = False, # optional - scheduled_at = '' # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional ) print(result.model_dump()) diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 9b78e6b..94d2d40 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -21,7 +21,7 @@ result: Message = messaging.update_email( html = False, # optional cc = [], # optional bcc = [], # optional - scheduled_at = '', # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional attachments = [] # optional ) diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index ac86bcb..913de5a 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -27,7 +27,7 @@ result: Message = messaging.update_push( tag = '', # optional badge = None, # optional draft = False, # optional - scheduled_at = '', # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00', # optional content_available = False, # optional critical = False, # optional priority = MessagePriority.NORMAL # optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 570c959..3269897 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -17,7 +17,7 @@ result: Message = messaging.update_sms( targets = [], # optional content = '', # optional draft = False, # optional - scheduled_at = '' # optional + scheduled_at = '2020-10-15T06:38:00.000+00:00' # optional ) print(result.model_dump()) diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md new file mode 100644 index 0000000..092376e --- /dev/null +++ b/docs/examples/project/create-android-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformAndroid + +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: PlatformAndroid = project.create_android_platform( + platform_id = '', + name = '', + application_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md new file mode 100644 index 0000000..3e190d4 --- /dev/null +++ b/docs/examples/project/create-apple-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformApple + +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: PlatformApple = project.create_apple_platform( + platform_id = '', + name = '', + bundle_identifier = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md new file mode 100644 index 0000000..17989e5 --- /dev/null +++ b/docs/examples/project/create-key.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Key +from appwrite.enums import Scopes + +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: Key = project.create_key( + key_id = '', + name = '', + scopes = [Scopes.SESSIONS_WRITE], + expire = '2020-10-15T06:38:00.000+00:00' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md new file mode 100644 index 0000000..e1ac1da --- /dev/null +++ b/docs/examples/project/create-linux-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformLinux + +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: PlatformLinux = project.create_linux_platform( + platform_id = '', + name = '', + package_name = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md new file mode 100644 index 0000000..c92e167 --- /dev/null +++ b/docs/examples/project/create-web-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformWeb + +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: PlatformWeb = project.create_web_platform( + platform_id = '', + name = '', + hostname = 'app.example.com' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md new file mode 100644 index 0000000..5f78214 --- /dev/null +++ b/docs/examples/project/create-windows-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformWindows + +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: PlatformWindows = project.create_windows_platform( + platform_id = '', + name = '', + package_identifier_name = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md new file mode 100644 index 0000000..8af3c0f --- /dev/null +++ b/docs/examples/project/delete-key.md @@ -0,0 +1,15 @@ +```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_key( + key_id = '' +) +``` diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md new file mode 100644 index 0000000..471bb83 --- /dev/null +++ b/docs/examples/project/delete-platform.md @@ -0,0 +1,15 @@ +```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_platform( + platform_id = '' +) +``` diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md new file mode 100644 index 0000000..0165746 --- /dev/null +++ b/docs/examples/project/get-key.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Key + +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: Key = project.get_key( + key_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md new file mode 100644 index 0000000..2075a70 --- /dev/null +++ b/docs/examples/project/get-platform.md @@ -0,0 +1,23 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformWeb +from appwrite.models import PlatformApple +from appwrite.models import PlatformAndroid +from appwrite.models import PlatformWindows +from appwrite.models import PlatformLinux +from typing import Union + +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: Union[PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] = project.get_platform( + platform_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md new file mode 100644 index 0000000..e72b20b --- /dev/null +++ b/docs/examples/project/list-keys.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import KeyList + +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: KeyList = project.list_keys( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md new file mode 100644 index 0000000..690f7a7 --- /dev/null +++ b/docs/examples/project/list-platforms.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformList + +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: PlatformList = project.list_platforms( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md new file mode 100644 index 0000000..1c915ac --- /dev/null +++ b/docs/examples/project/update-android-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformAndroid + +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: PlatformAndroid = project.update_android_platform( + platform_id = '', + name = '', + application_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md new file mode 100644 index 0000000..33fd9c7 --- /dev/null +++ b/docs/examples/project/update-apple-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformApple + +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: PlatformApple = project.update_apple_platform( + platform_id = '', + name = '', + bundle_identifier = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md new file mode 100644 index 0000000..3199fd4 --- /dev/null +++ b/docs/examples/project/update-key.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Key +from appwrite.enums import Scopes + +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: Key = project.update_key( + key_id = '', + name = '', + scopes = [Scopes.SESSIONS_WRITE], + expire = '2020-10-15T06:38:00.000+00:00' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md new file mode 100644 index 0000000..4fedceb --- /dev/null +++ b/docs/examples/project/update-labels.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel + +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_labels( + labels = [] +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md new file mode 100644 index 0000000..6612869 --- /dev/null +++ b/docs/examples/project/update-linux-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformLinux + +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: PlatformLinux = project.update_linux_platform( + platform_id = '', + name = '', + package_name = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-protocol-status.md b/docs/examples/project/update-protocol-status.md new file mode 100644 index 0000000..a9415cd --- /dev/null +++ b/docs/examples/project/update-protocol-status.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel +from appwrite.enums import ProtocolId + +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_protocol_status( + protocol_id = ProtocolId.REST, + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-service-status.md b/docs/examples/project/update-service-status.md new file mode 100644 index 0000000..ba607db --- /dev/null +++ b/docs/examples/project/update-service-status.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Project as ProjectModel +from appwrite.enums import ServiceId + +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_service_status( + service_id = ServiceId.ACCOUNT, + enabled = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md new file mode 100644 index 0000000..19f10b4 --- /dev/null +++ b/docs/examples/project/update-web-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformWeb + +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: PlatformWeb = project.update_web_platform( + platform_id = '', + name = '', + hostname = 'app.example.com' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md new file mode 100644 index 0000000..cf154e0 --- /dev/null +++ b/docs/examples/project/update-windows-platform.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import PlatformWindows + +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: PlatformWindows = project.update_windows_platform( + platform_id = '', + name = '', + package_identifier_name = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 1255834..4544827 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -15,7 +15,7 @@ result: ColumnDatetime = tables_db.create_datetime_column( table_id = '', key = '', required = False, - default = '', # optional + default = '2020-10-15T06:38:00.000+00:00', # optional array = False # optional ) diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index c525ace..9f9d57a 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -15,7 +15,7 @@ result: ColumnDatetime = tables_db.update_datetime_column( table_id = '', key = '', required = False, - default = '', + default = '2020-10-15T06:38:00.000+00:00', new_key = '' # optional ) diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index c810155..ee6bba0 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -18,7 +18,8 @@ result: Table = tables_db.update_table( name = '', # optional permissions = [Permission.read(Role.any())], # optional row_security = False, # optional - enabled = False # optional + enabled = False, # optional + purge = False # optional ) print(result.model_dump()) diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index 32dce32..73ad135 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -13,7 +13,7 @@ tokens = Tokens(client) result: ResourceToken = tokens.create_file_token( bucket_id = '', file_id = '', - expire = '' # optional + expire = '2020-10-15T06:38:00.000+00:00' # optional ) print(result.model_dump()) diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 4b57a60..6b5ad4b 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -12,7 +12,7 @@ tokens = Tokens(client) result: ResourceToken = tokens.update( token_id = '', - expire = '' # optional + expire = '2020-10-15T06:38:00.000+00:00' # optional ) print(result.model_dump()) diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 11b1598..d029222 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -16,9 +16,10 @@ result: Webhook = webhooks.create( name = '', events = [], enabled = False, # optional - security = False, # optional - http_user = '', # optional - http_pass = '' # optional + tls = False, # optional + auth_username = '', # optional + auth_password = '', # optional + secret = '' # optional ) print(result.model_dump()) diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-secret.md similarity index 78% rename from docs/examples/webhooks/update-signature.md rename to docs/examples/webhooks/update-secret.md index 94f739e..5e38b24 100644 --- a/docs/examples/webhooks/update-signature.md +++ b/docs/examples/webhooks/update-secret.md @@ -10,8 +10,9 @@ client.set_key('') # Your secret API key webhooks = Webhooks(client) -result: Webhook = webhooks.update_signature( - webhook_id = '' +result: Webhook = webhooks.update_secret( + webhook_id = '', + secret = '' # optional ) print(result.model_dump()) diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index e13b055..626d793 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -16,9 +16,9 @@ result: Webhook = webhooks.update( url = '', events = [], enabled = False, # optional - security = False, # optional - http_user = '', # optional - http_pass = '' # optional + tls = False, # optional + auth_username = '', # optional + auth_password = '' # optional ) print(result.model_dump()) diff --git a/pyproject.toml b/pyproject.toml index 858602a..91b5d2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite" -version = "17.0.0" +version = "18.0.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.9" diff --git a/setup.py b/setup.py index 5985828..12b1323 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '17.0.0', + version = '18.0.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/17.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/18.0.0.tar.gz', install_requires=[ 'requests', 'pydantic>=2,<3',