Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 6 additions & 3 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"""

Expand Down
12 changes: 12 additions & 0 deletions appwrite/encoders/value_class_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions appwrite/enums/build_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
1 change: 1 addition & 0 deletions appwrite/enums/o_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OAuthProvider(Enum):
TRADESHIFTBOX = "tradeshiftBox"
TWITCH = "twitch"
WORDPRESS = "wordpress"
X = "x"
YAHOO = "yahoo"
YAMMER = "yammer"
YANDEX = "yandex"
Expand Down
8 changes: 8 additions & 0 deletions appwrite/enums/platform_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from enum import Enum

class PlatformType(Enum):
WINDOWS = "windows"
APPLE = "apple"
ANDROID = "android"
LINUX = "linux"
WEB = "web"
6 changes: 6 additions & 0 deletions appwrite/enums/protocol_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum

class ProtocolId(Enum):
REST = "rest"
GRAPHQL = "graphql"
WEBSOCKET = "websocket"
2 changes: 2 additions & 0 deletions appwrite/enums/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
4 changes: 4 additions & 0 deletions appwrite/enums/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions appwrite/enums/service_id.py
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 28 additions & 0 deletions appwrite/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -166,6 +180,7 @@
'DeploymentList',
'ExecutionList',
'WebhookList',
'KeyList',
'CountryList',
'ContinentList',
'LanguageList',
Expand Down Expand Up @@ -252,7 +267,18 @@
'FrameworkAdapter',
'Deployment',
'Execution',
'Project',
'Webhook',
'Key',
'DevKey',
'MockNumber',
'AuthProvider',
'PlatformWeb',
'PlatformApple',
'PlatformAndroid',
'PlatformWindows',
'PlatformLinux',
'PlatformList',
'Variable',
'Country',
'Continent',
Expand All @@ -278,6 +304,8 @@
'Target',
'ActivityEvent',
'BackupArchive',
'BillingLimits',
'Block',
'BackupPolicy',
'BackupRestoration',
'ActivityEventList',
Expand Down
27 changes: 27 additions & 0 deletions appwrite/models/auth_provider.py
Original file line number Diff line number Diff line change
@@ -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')
36 changes: 36 additions & 0 deletions appwrite/models/billing_limits.py
Original file line number Diff line number Diff line change
@@ -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')
27 changes: 27 additions & 0 deletions appwrite/models/block.py
Original file line number Diff line number Diff line change
@@ -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')
36 changes: 36 additions & 0 deletions appwrite/models/dev_key.py
Original file line number Diff line number Diff line change
@@ -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')
Comment thread
ChiragAgg5k marked this conversation as resolved.
accessedat: str = Field(..., alias='accessedAt')
sdks: List[Any] = Field(..., alias='sdks')
Loading