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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Change Log

## 22.0.0

* Breaking: removed `Health` service and all health models and enums
* Breaking: removed `Usage` service and `UsageMetric`, `UsageDataPoint`, `UsageEventList`, `UsageGaugeList` models
* Breaking: removed messaging `list_message_logs`, `list_provider_logs`, `list_subscriber_logs`, `list_topic_logs` methods
* Breaking: renamed `tables_db.create` parameter `dedicated_database_id` to `specification`
* Breaking: removed `countryCode` and `countryName` from `ActivityEvent` model
* Added: `Client.set_bearer` for OAuth access token authentication
* Added: `organization` service `get`, `update`, `delete` and membership CRUD methods
* Added: `oauth2` service `create_par`, `list_organizations`, `list_projects` methods
* Added: `resource`, `audience`, `request_uri` OAuth2 parameters; `scope` on `approve`
* Added: `appwrite` OAuth provider, `OAuth2Appwrite` model, `update_o_auth2_appwrite` method
* Added: `Query.vector_dot`, `Query.vector_cosine`, `Query.vector_euclidean` methods
* Added: `apps.update_labels` method and `labels` field on `App` model
* Added: `new_specification` parameter to `backups.create_restoration`
* Added: `type` parameter to `functions` and `sites` `list_specifications`
* Added: `token` parameter to `functions.get_deployment_download`
* Added: `prompt` and `max_age` parameters to `update_o_auth2_oidc`; `default_scopes` to `update_o_auth2_server`
* Added: `BillingPlan`, `Organization`, `Program`, `Oauth2PAR`, `DatabaseStatus`, `BillingPlanGroup` models and enums
* Added: `status` on `Database`, `mode` on `Block`, `onboarding` on `Project`, geolocation fields on `Locale`
* Added: organization, `project.oauth2`, and `stages` key scope enum values
* Fixed: booleans now serialized as `true`/`false` in flattened query parameters
* Fixed: `model_dump` on `Document`, `Row`, `Preferences` now includes dynamic `data`

## 21.0.0

* Added: `apps` service for managing apps and app secrets
Expand Down
13 changes: 11 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : f'AppwritePythonSDK/21.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
'user-agent' : f'AppwritePythonSDK/22.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': '21.0.0',
'x-sdk-version': '22.0.0',
'X-Appwrite-Response-Format' : '1.9.5',
}
self._config = {}
Expand Down Expand Up @@ -67,6 +67,13 @@ def set_jwt(self, value):
self._config['jwt'] = value
return self

def set_bearer(self, value):
"""The OAuth access token to authenticate with"""

self._global_headers['authorization'] = 'Bearer ' + value
self._config['bearer'] = value
return self
Comment thread
greptile-apps[bot] marked this conversation as resolved.

def set_locale(self, value):
self._global_headers['x-appwrite-locale'] = value
self._config['locale'] = value
Expand Down Expand Up @@ -341,6 +348,8 @@ def flatten(self, data, prefix='', stringify=False):

if isinstance(value, list) or isinstance(value, dict):
output = {**output, **self.flatten(value, finalKey, stringify)}
elif isinstance(value, bool):
output[finalKey] = 'true' if value else 'false'
else:
if stringify:
output[finalKey] = str(value)
Expand Down
26 changes: 15 additions & 11 deletions appwrite/encoders/value_class_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
from ..enums.vcs_reference_type import VCSReferenceType
from ..enums.deployment_download_type import DeploymentDownloadType
from ..enums.execution_method import ExecutionMethod
from ..enums.health_queue_name import HealthQueueName
from ..enums.message_priority import MessagePriority
from ..enums.smtp_encryption import SmtpEncryption
from ..enums.organization_key_scopes import OrganizationKeyScopes
from ..enums.region import Region
from ..enums.project_auth_method_id import ProjectAuthMethodId
from ..enums.project_o_auth2_google_prompt import ProjectOAuth2GooglePrompt
from ..enums.project_o_auth2_oidc_prompt import ProjectOAuth2OidcPrompt
from ..enums.project_o_auth_provider_id import ProjectOAuthProviderId
from ..enums.project_policy_id import ProjectPolicyId
from ..enums.project_protocol_id import ProjectProtocolId
Expand All @@ -46,19 +46,20 @@
from ..enums.password_hash import PasswordHash
from ..enums.messaging_provider_type import MessagingProviderType
from ..enums.database_type import DatabaseType
from ..enums.database_status import DatabaseStatus
from ..enums.attribute_status import AttributeStatus
from ..enums.column_status import ColumnStatus
from ..enums.index_status import IndexStatus
from ..enums.deployment_status import DeploymentStatus
from ..enums.execution_trigger import ExecutionTrigger
from ..enums.execution_status import ExecutionStatus
from ..enums.o_auth2_google_prompt import OAuth2GooglePrompt
from ..enums.o_auth2_oidc_prompt import OAuth2OidcPrompt
from ..enums.platform_type import PlatformType
from ..enums.health_antivirus_status import HealthAntivirusStatus
from ..enums.health_check_status import HealthCheckStatus
from ..enums.proxy_rule_deployment_resource_type import ProxyRuleDeploymentResourceType
from ..enums.proxy_rule_status import ProxyRuleStatus
from ..enums.message_status import MessageStatus
from ..enums.billing_plan_group import BillingPlanGroup

class ValueClassEncoder(json.JSONEncoder):
def default(self, o):
Expand Down Expand Up @@ -128,9 +129,6 @@ def default(self, o):
if isinstance(o, ExecutionMethod):
return o.value

if isinstance(o, HealthQueueName):
return o.value

if isinstance(o, MessagePriority):
return o.value

Expand All @@ -149,6 +147,9 @@ def default(self, o):
if isinstance(o, ProjectOAuth2GooglePrompt):
return o.value

if isinstance(o, ProjectOAuth2OidcPrompt):
return o.value

if isinstance(o, ProjectOAuthProviderId):
return o.value

Expand Down Expand Up @@ -203,6 +204,9 @@ def default(self, o):
if isinstance(o, DatabaseType):
return o.value

if isinstance(o, DatabaseStatus):
return o.value

if isinstance(o, AttributeStatus):
return o.value

Expand All @@ -224,13 +228,10 @@ def default(self, o):
if isinstance(o, OAuth2GooglePrompt):
return o.value

if isinstance(o, PlatformType):
return o.value

if isinstance(o, HealthAntivirusStatus):
if isinstance(o, OAuth2OidcPrompt):
return o.value

if isinstance(o, HealthCheckStatus):
if isinstance(o, PlatformType):
return o.value

if isinstance(o, ProxyRuleDeploymentResourceType):
Expand All @@ -242,4 +243,7 @@ def default(self, o):
if isinstance(o, MessageStatus):
return o.value

if isinstance(o, BillingPlanGroup):
return o.value

return super().default(o)
6 changes: 6 additions & 0 deletions appwrite/enums/billing_plan_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum

class BillingPlanGroup(Enum):
STARTER = "starter"
PRO = "pro"
SCALE = "scale"
6 changes: 6 additions & 0 deletions appwrite/enums/database_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum

class DatabaseStatus(Enum):
PROVISIONING = "provisioning"
READY = "ready"
FAILED = "failed"
6 changes: 0 additions & 6 deletions appwrite/enums/health_antivirus_status.py

This file was deleted.

5 changes: 0 additions & 5 deletions appwrite/enums/health_check_status.py

This file was deleted.

16 changes: 0 additions & 16 deletions appwrite/enums/health_queue_name.py

This file was deleted.

7 changes: 7 additions & 0 deletions appwrite/enums/o_auth2_oidc_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum import Enum

class OAuth2OidcPrompt(Enum):
NONE = "none"
LOGIN = "login"
CONSENT = "consent"
SELECT_ACCOUNT = "select_account"
1 change: 1 addition & 0 deletions appwrite/enums/o_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class OAuthProvider(Enum):
AMAZON = "amazon"
APPLE = "apple"
APPWRITE = "appwrite"
AUTH0 = "auth0"
AUTHENTIK = "authentik"
AUTODESK = "autodesk"
Expand Down
4 changes: 4 additions & 0 deletions appwrite/enums/organization_key_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class OrganizationKeyScopes(Enum):
DEVKEYS_WRITE = "devKeys.write"
ORGANIZATION_KEYS_READ = "organization.keys.read"
ORGANIZATION_KEYS_WRITE = "organization.keys.write"
ORGANIZATION_MEMBERSHIPS_READ = "organization.memberships.read"
ORGANIZATION_MEMBERSHIPS_WRITE = "organization.memberships.write"
ORGANIZATION_READ = "organization.read"
ORGANIZATION_WRITE = "organization.write"
DOMAINS_READ = "domains.read"
DOMAINS_WRITE = "domains.write"
KEYS_READ = "keys.read"
Expand Down
8 changes: 6 additions & 2 deletions appwrite/enums/project_key_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class ProjectKeyScopes(Enum):
POLICIES_WRITE = "policies.write"
PROJECT_POLICIES_READ = "project.policies.read"
PROJECT_POLICIES_WRITE = "project.policies.write"
PROJECT_OAUTH2_READ = "project.oauth2.read"
PROJECT_OAUTH2_WRITE = "project.oauth2.write"
TEMPLATES_READ = "templates.read"
TEMPLATES_WRITE = "templates.write"
OAUTH2_READ = "oauth2.read"
OAUTH2_WRITE = "oauth2.write"
STAGES_READ = "stages.read"
STAGES_WRITE = "stages.write"
USERS_READ = "users.read"
USERS_WRITE = "users.write"
SESSIONS_READ = "sessions.read"
Expand Down Expand Up @@ -97,4 +99,6 @@ class ProjectKeyScopes(Enum):
EVENTS_READ = "events.read"
APPS_READ = "apps.read"
APPS_WRITE = "apps.write"
OAUTH2_READ = "oauth2.read"
OAUTH2_WRITE = "oauth2.write"
USAGE_READ = "usage.read"
7 changes: 7 additions & 0 deletions appwrite/enums/project_o_auth2_oidc_prompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum import Enum

class ProjectOAuth2OidcPrompt(Enum):
NONE = "none"
LOGIN = "login"
CONSENT = "consent"
SELECT_ACCOUNT = "select_account"
1 change: 1 addition & 0 deletions appwrite/enums/project_o_auth_provider_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class ProjectOAuthProviderId(Enum):
AMAZON = "amazon"
APPLE = "apple"
APPWRITE = "appwrite"
AUTH0 = "auth0"
AUTHENTIK = "authentik"
AUTODESK = "autodesk"
Expand Down
Loading