diff --git a/CHANGELOG.md b/CHANGELOG.md index 160d5aa..f662f5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 15.0.0 + +* Add array-based enum parameters (e.g., `permissions: list[BrowserPermission]`). +* Breaking change: `Output` enum has been removed; use `ImageFormat` instead. +* Add `getQueueAudits` support to `Health` service. +* Add longtext/mediumtext/text/varchar attribute and column helpers to `Databases` and `TablesDB` services. + ## 14.1.0 * Added ability to create columns and indexes synchronously while creating a table @@ -62,4 +69,4 @@ ## 9.0.3 -* Update sdk to use Numpy-style docstrings +* Update sdk to use Numpy-style docstrings \ No newline at end of file diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index a2dea19..4693d74 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # 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.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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) **This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-python/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Python SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/appwrite/client.py b/appwrite/client.py index c6ae723..b4d2231 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,11 +15,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/14.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/15.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': '14.1.0', + 'x-sdk-version': '15.0.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index cc9db59..74020c5 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -7,11 +7,14 @@ from ..enums.flag import Flag from ..enums.theme import Theme from ..enums.timezone import Timezone -from ..enums.output import Output +from ..enums.browser_permission import BrowserPermission +from ..enums.image_format import ImageFormat from ..enums.relationship_type import RelationshipType from ..enums.relation_mutate import RelationMutate from ..enums.index_type import IndexType +from ..enums.order_by import OrderBy from ..enums.runtime import Runtime +from ..enums.scopes import Scopes from ..enums.template_reference_type import TemplateReferenceType from ..enums.vcs_reference_type import VCSReferenceType from ..enums.deployment_download_type import DeploymentDownloadType @@ -24,7 +27,7 @@ from ..enums.adapter import Adapter from ..enums.compression import Compression from ..enums.image_gravity import ImageGravity -from ..enums.image_format import ImageFormat +from ..enums.roles import Roles from ..enums.password_hash import PasswordHash from ..enums.messaging_provider_type import MessagingProviderType from ..enums.database_type import DatabaseType @@ -64,7 +67,10 @@ def default(self, o): if isinstance(o, Timezone): return o.value - if isinstance(o, Output): + if isinstance(o, BrowserPermission): + return o.value + + if isinstance(o, ImageFormat): return o.value if isinstance(o, RelationshipType): @@ -76,9 +82,15 @@ def default(self, o): if isinstance(o, IndexType): return o.value + if isinstance(o, OrderBy): + return o.value + if isinstance(o, Runtime): return o.value + if isinstance(o, Scopes): + return o.value + if isinstance(o, TemplateReferenceType): return o.value @@ -115,7 +127,7 @@ def default(self, o): if isinstance(o, ImageGravity): return o.value - if isinstance(o, ImageFormat): + if isinstance(o, Roles): return o.value if isinstance(o, PasswordHash): diff --git a/appwrite/enums/browser_permission.py b/appwrite/enums/browser_permission.py new file mode 100644 index 0000000..f0c3769 --- /dev/null +++ b/appwrite/enums/browser_permission.py @@ -0,0 +1,23 @@ +from enum import Enum + +class BrowserPermission(Enum): + GEOLOCATION = "geolocation" + CAMERA = "camera" + MICROPHONE = "microphone" + NOTIFICATIONS = "notifications" + MIDI = "midi" + PUSH = "push" + CLIPBOARD_READ = "clipboard-read" + CLIPBOARD_WRITE = "clipboard-write" + PAYMENT_HANDLER = "payment-handler" + USB = "usb" + BLUETOOTH = "bluetooth" + ACCELEROMETER = "accelerometer" + GYROSCOPE = "gyroscope" + MAGNETOMETER = "magnetometer" + AMBIENT_LIGHT_SENSOR = "ambient-light-sensor" + BACKGROUND_SYNC = "background-sync" + PERSISTENT_STORAGE = "persistent-storage" + SCREEN_WAKE_LOCK = "screen-wake-lock" + WEB_SHARE = "web-share" + XR_SPATIAL_TRACKING = "xr-spatial-tracking" diff --git a/appwrite/enums/deployment_status.py b/appwrite/enums/deployment_status.py index 7cb6ae4..d728038 100644 --- a/appwrite/enums/deployment_status.py +++ b/appwrite/enums/deployment_status.py @@ -5,4 +5,5 @@ class DeploymentStatus(Enum): PROCESSING = "processing" BUILDING = "building" READY = "ready" + CANCELED = "canceled" FAILED = "failed" diff --git a/appwrite/enums/name.py b/appwrite/enums/name.py index c4b981e..7af7da7 100644 --- a/appwrite/enums/name.py +++ b/appwrite/enums/name.py @@ -11,5 +11,6 @@ class Name(Enum): V1_WEBHOOKS = "v1-webhooks" V1_CERTIFICATES = "v1-certificates" V1_BUILDS = "v1-builds" + V1_SCREENSHOTS = "v1-screenshots" V1_MESSAGING = "v1-messaging" V1_MIGRATIONS = "v1-migrations" diff --git a/appwrite/enums/o_auth_provider.py b/appwrite/enums/o_auth_provider.py index 6c1e6bd..b200f77 100644 --- a/appwrite/enums/o_auth_provider.py +++ b/appwrite/enums/o_auth_provider.py @@ -40,4 +40,3 @@ class OAuthProvider(Enum): YANDEX = "yandex" ZOHO = "zoho" ZOOM = "zoom" - MOCK = "mock" diff --git a/appwrite/enums/order_by.py b/appwrite/enums/order_by.py new file mode 100644 index 0000000..2651039 --- /dev/null +++ b/appwrite/enums/order_by.py @@ -0,0 +1,5 @@ +from enum import Enum + +class OrderBy(Enum): + ASC = "asc" + DESC = "desc" diff --git a/appwrite/enums/output.py b/appwrite/enums/output.py deleted file mode 100644 index c76e835..0000000 --- a/appwrite/enums/output.py +++ /dev/null @@ -1,10 +0,0 @@ -from enum import Enum - -class Output(Enum): - JPG = "jpg" - JPEG = "jpeg" - PNG = "png" - WEBP = "webp" - HEIC = "heic" - AVIF = "avif" - GIF = "gif" diff --git a/appwrite/enums/roles.py b/appwrite/enums/roles.py new file mode 100644 index 0000000..b721a21 --- /dev/null +++ b/appwrite/enums/roles.py @@ -0,0 +1,6 @@ +from enum import Enum + +class Roles(Enum): + ADMIN = "admin" + DEVELOPER = "developer" + OWNER = "owner" diff --git a/appwrite/enums/scopes.py b/appwrite/enums/scopes.py new file mode 100644 index 0000000..50afa9e --- /dev/null +++ b/appwrite/enums/scopes.py @@ -0,0 +1,58 @@ +from enum import Enum + +class Scopes(Enum): + SESSIONS_WRITE = "sessions.write" + USERS_READ = "users.read" + USERS_WRITE = "users.write" + TEAMS_READ = "teams.read" + TEAMS_WRITE = "teams.write" + DATABASES_READ = "databases.read" + DATABASES_WRITE = "databases.write" + COLLECTIONS_READ = "collections.read" + COLLECTIONS_WRITE = "collections.write" + TABLES_READ = "tables.read" + TABLES_WRITE = "tables.write" + ATTRIBUTES_READ = "attributes.read" + ATTRIBUTES_WRITE = "attributes.write" + COLUMNS_READ = "columns.read" + COLUMNS_WRITE = "columns.write" + INDEXES_READ = "indexes.read" + INDEXES_WRITE = "indexes.write" + DOCUMENTS_READ = "documents.read" + DOCUMENTS_WRITE = "documents.write" + ROWS_READ = "rows.read" + ROWS_WRITE = "rows.write" + FILES_READ = "files.read" + FILES_WRITE = "files.write" + BUCKETS_READ = "buckets.read" + BUCKETS_WRITE = "buckets.write" + FUNCTIONS_READ = "functions.read" + FUNCTIONS_WRITE = "functions.write" + SITES_READ = "sites.read" + SITES_WRITE = "sites.write" + LOG_READ = "log.read" + LOG_WRITE = "log.write" + EXECUTION_READ = "execution.read" + EXECUTION_WRITE = "execution.write" + LOCALE_READ = "locale.read" + AVATARS_READ = "avatars.read" + HEALTH_READ = "health.read" + PROVIDERS_READ = "providers.read" + PROVIDERS_WRITE = "providers.write" + MESSAGES_READ = "messages.read" + MESSAGES_WRITE = "messages.write" + TOPICS_READ = "topics.read" + TOPICS_WRITE = "topics.write" + SUBSCRIBERS_READ = "subscribers.read" + SUBSCRIBERS_WRITE = "subscribers.write" + TARGETS_READ = "targets.read" + TARGETS_WRITE = "targets.write" + RULES_READ = "rules.read" + RULES_WRITE = "rules.write" + MIGRATIONS_READ = "migrations.read" + MIGRATIONS_WRITE = "migrations.write" + VCS_READ = "vcs.read" + VCS_WRITE = "vcs.write" + ASSISTANT_READ = "assistant.read" + TOKENS_READ = "tokens.read" + TOKENS_WRITE = "tokens.write" diff --git a/appwrite/operator.py b/appwrite/operator.py index f4ced58..ddec91e 100644 --- a/appwrite/operator.py +++ b/appwrite/operator.py @@ -2,7 +2,6 @@ import math from enum import Enum - class Condition(Enum): EQUAL = "equal" NOT_EQUAL = "notEqual" @@ -14,7 +13,6 @@ class Condition(Enum): IS_NULL = "isNull" IS_NOT_NULL = "isNotNull" - class Operator(): def __init__(self, method, values=None): self.method = method diff --git a/appwrite/query.py b/appwrite/query.py index b989a76..1693189 100644 --- a/appwrite/query.py +++ b/appwrite/query.py @@ -1,6 +1,5 @@ import json - # Inherit from dict to allow for easy serialization class Query(): def __init__(self, method, attribute=None, values=None): @@ -27,6 +26,20 @@ def equal(attribute, value): def not_equal(attribute, value): return str(Query("notEqual", attribute, value)) + @staticmethod + def regex(attribute, pattern): + """ + Filter resources where attribute matches a regular expression pattern. + + Args: + attribute: The attribute to filter on. + pattern: The regular expression pattern to match. + + Returns: + The query string. + """ + return str(Query("regex", attribute, pattern)) + @staticmethod def less_than(attribute, value): return str(Query("lessThan", attribute, value)) @@ -51,6 +64,32 @@ def is_null(attribute): def is_not_null(attribute): return str(Query("isNotNull", attribute, None)) + @staticmethod + def exists(attributes): + """ + Filter resources where the specified attributes exist. + + Args: + attributes: The list of attributes that must exist. + + Returns: + The query string. + """ + return str(Query("exists", None, attributes)) + + @staticmethod + def not_exists(attributes): + """ + Filter resources where the specified attributes do not exist. + + Args: + attributes: The list of attributes that must not exist. + + Returns: + The query string. + """ + return str(Query("notExists", None, attributes)) + @staticmethod def between(attribute, start, end): return str(Query("between", attribute, [start, end])) @@ -155,6 +194,20 @@ def or_queries(queries): def and_queries(queries): return str(Query("and", None, [json.loads(query) for query in queries])) + @staticmethod + def elem_match(attribute, queries): + """ + Filter array elements where at least one element matches all the specified queries. + + Args: + attribute: The attribute containing the array to filter on. + queries: The list of query strings to match against array elements. + + Returns: + The query string. + """ + return str(Query("elemMatch", attribute, [json.loads(query) for query in queries])) + @staticmethod def distance_equal(attribute, values, distance, meters=True): return str(Query("distanceEqual", attribute, [[values, distance, meters]])) diff --git a/appwrite/service.py b/appwrite/service.py index b5b60e6..f5e2adb 100644 --- a/appwrite/service.py +++ b/appwrite/service.py @@ -1,6 +1,5 @@ from .client import Client - class Service: def __init__(self, client: Client): self.client = client diff --git a/appwrite/services/account.py b/appwrite/services/account.py index b7bf1e4..29bfd00 100644 --- a/appwrite/services/account.py +++ b/appwrite/services/account.py @@ -185,10 +185,15 @@ def delete_identity(self, identity_id: str) -> Dict[str, Any]: 'content-type': 'application/json', }, api_params) - def create_jwt(self) -> Dict[str, Any]: + def create_jwt(self, duration: Optional[float] = None) -> Dict[str, Any]: """ Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + Parameters + ---------- + duration : Optional[float] + Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + Returns ------- Dict[str, Any] @@ -203,6 +208,9 @@ def create_jwt(self) -> Dict[str, Any]: api_path = '/account/jwts' api_params = {} + if duration is not None: + api_params['duration'] = duration + return self.client.call('post', api_path, { 'content-type': 'application/json', }, api_params) diff --git a/appwrite/services/avatars.py b/appwrite/services/avatars.py index db5efeb..ef41db9 100644 --- a/appwrite/services/avatars.py +++ b/appwrite/services/avatars.py @@ -7,7 +7,8 @@ from ..enums.flag import Flag; from ..enums.theme import Theme; from ..enums.timezone import Timezone; -from ..enums.output import Output; +from ..enums.browser_permission import BrowserPermission; +from ..enums.image_format import ImageFormat; class Avatars(Service): @@ -317,7 +318,7 @@ def get_qr(self, text: str, size: Optional[float] = None, margin: Optional[float return self.client.call('get', api_path, { }, api_params) - def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_width: Optional[float] = None, viewport_height: Optional[float] = None, scale: Optional[float] = None, theme: Optional[Theme] = None, user_agent: Optional[str] = None, fullpage: Optional[bool] = None, locale: Optional[str] = None, timezone: Optional[Timezone] = None, latitude: Optional[float] = None, longitude: Optional[float] = None, accuracy: Optional[float] = None, touch: Optional[bool] = None, permissions: Optional[List[str]] = None, sleep: Optional[float] = None, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None, output: Optional[Output] = None) -> bytes: + def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_width: Optional[float] = None, viewport_height: Optional[float] = None, scale: Optional[float] = None, theme: Optional[Theme] = None, user_agent: Optional[str] = None, fullpage: Optional[bool] = None, locale: Optional[str] = None, timezone: Optional[Timezone] = None, latitude: Optional[float] = None, longitude: Optional[float] = None, accuracy: Optional[float] = None, touch: Optional[bool] = None, permissions: Optional[List[BrowserPermission]] = None, sleep: Optional[float] = None, width: Optional[float] = None, height: Optional[float] = None, quality: Optional[float] = None, output: Optional[ImageFormat] = None) -> bytes: """ Use this endpoint to capture a screenshot of any website URL. This endpoint uses a headless browser to render the webpage and capture it as an image. @@ -355,7 +356,7 @@ def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_widt Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0. touch : Optional[bool] Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0. - permissions : Optional[List[str]] + permissions : Optional[List[BrowserPermission]] Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty. sleep : Optional[float] Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0. @@ -365,7 +366,7 @@ def get_screenshot(self, url: str, headers: Optional[dict] = None, viewport_widt Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). quality : Optional[float] Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. - output : Optional[Output] + output : Optional[ImageFormat] Output format type (jpeg, jpg, png, gif and webp). Returns diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index b2f96d5..b2a834a 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -5,6 +5,7 @@ from ..enums.relationship_type import RelationshipType; from ..enums.relation_mutate import RelationMutate; from ..enums.index_type import IndexType; +from ..enums.order_by import OrderBy; class Databases(Service): @@ -330,7 +331,7 @@ def get(self, database_id: str) -> Dict[str, Any]: }, api_params) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update` instead.") - def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update(self, database_id: str, name: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: """ Update a database by its unique ID. @@ -340,7 +341,7 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> ---------- database_id : str Database ID. - name : str + name : Optional[str] Database name. Max length: 128 chars. enabled : Optional[bool] Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. @@ -361,12 +362,10 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) - api_params['name'] = name + if name is not None: + api_params['name'] = name if enabled is not None: api_params['enabled'] = enabled @@ -562,7 +561,7 @@ def get_collection(self, database_id: str, collection_id: str) -> Dict[str, Any] }, api_params) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_table` instead.") - def update_collection(self, database_id: str, collection_id: str, name: str, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update_collection(self, database_id: str, collection_id: str, name: Optional[str] = None, permissions: Optional[List[str]] = None, document_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: """ Update a collection by its unique ID. @@ -574,7 +573,7 @@ def update_collection(self, database_id: str, collection_id: str, name: str, per Database ID. collection_id : str Collection ID. - name : str + name : Optional[str] Collection name. Max length: 128 chars. permissions : Optional[List[str]] An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -602,13 +601,11 @@ def update_collection(self, database_id: str, collection_id: str, name: str, per if collection_id is None: raise AppwriteException('Missing required parameter: "collection_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) - api_params['name'] = name + if name is not None: + api_params['name'] = name api_params['permissions'] = permissions if document_security is not None: api_params['documentSecurity'] = document_security @@ -1703,6 +1700,236 @@ def update_line_attribute(self, database_id: str, collection_id: str, key: str, 'content-type': 'application/json', }, api_params) + def create_longtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a longtext attribute. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + array : Optional[bool] + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_longtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a longtext attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_mediumtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a mediumtext attribute. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + array : Optional[bool] + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mediumtext_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a mediumtext attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_point_column` instead.") def create_point_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: """ @@ -2135,6 +2362,121 @@ def update_string_attribute(self, database_id: str, collection_id: str, key: str 'content-type': 'application/json', }, api_params) + def create_text_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a text attribute. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + array : Optional[bool] + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_text_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a text attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_url_column` instead.") def create_url_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: """ @@ -2256,6 +2598,130 @@ def update_url_attribute(self, database_id: str, collection_id: str, key: str, r 'content-type': 'application/json', }, api_params) + def create_varchar_attribute(self, database_id: str, collection_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a varchar attribute. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + size : float + Attribute size for varchar attributes, in number of characters. Maximum size is 16381. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + array : Optional[bool] + Is attribute an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if size is None: + raise AppwriteException('Missing required parameter: "size"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + + api_params['key'] = key + api_params['size'] = size + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_varchar_attribute(self, database_id: str, collection_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a varchar attribute. Changing the `default` value will not update already existing documents. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + key : str + Attribute Key. + required : bool + Is attribute required? + default : Optional[str] + Default value for attribute when not provided. Cannot be set when attribute is required. + size : Optional[float] + Maximum size of the varchar attribute. + new_key : Optional[str] + New Attribute Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if collection_id is None: + raise AppwriteException('Missing required parameter: "collection_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{collectionId}', collection_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['size'] = size + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.get_column` instead.") def get_attribute(self, database_id: str, collection_id: str, key: str) -> Dict[str, Any]: """ @@ -2770,7 +3236,7 @@ def get_document(self, database_id: str, collection_id: str, document_id: str, q }, api_params) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.upsert_row` instead.") - def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: dict, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: + def upsert_document(self, database_id: str, collection_id: str, document_id: str, data: Optional[dict] = None, permissions: Optional[List[str]] = None, transaction_id: Optional[str] = None) -> Dict[str, Any]: """ Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. @@ -2784,7 +3250,7 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str Collection ID. document_id : str Document ID. - data : dict + data : Optional[dict] Document data as JSON object. Include all required attributes of the document to be created or updated. permissions : Optional[List[str]] An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -2813,14 +3279,12 @@ def upsert_document(self, database_id: str, collection_id: str, document_id: str if document_id is None: raise AppwriteException('Missing required parameter: "document_id"') - if data is None: - raise AppwriteException('Missing required parameter: "data"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{collectionId}', collection_id) api_path = api_path.replace('{documentId}', document_id) - api_params['data'] = data + if data is not None: + api_params['data'] = data api_params['permissions'] = permissions api_params['transactionId'] = transaction_id @@ -3110,7 +3574,7 @@ def list_indexes(self, database_id: str, collection_id: str, queries: Optional[L }, api_params) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_index` instead.") - def create_index(self, database_id: str, collection_id: str, key: str, type: IndexType, attributes: List[str], orders: Optional[List[str]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: + def create_index(self, database_id: str, collection_id: str, key: str, type: IndexType, attributes: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: """ Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. Attributes can be `key`, `fulltext`, and `unique`. @@ -3129,7 +3593,7 @@ def create_index(self, database_id: str, collection_id: str, key: str, type: Ind Index type. attributes : List[str] Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - orders : Optional[List[str]] + orders : Optional[List[OrderBy]] Array of index orders. Maximum of 100 orders are allowed. lengths : Optional[List[float]] Length of index. Maximum of 100 diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index 4828816..e4cc261 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -3,6 +3,7 @@ from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated from ..enums.runtime import Runtime; +from ..enums.scopes import Scopes; from ..input_file import InputFile from ..enums.template_reference_type import TemplateReferenceType; from ..enums.vcs_reference_type import VCSReferenceType; @@ -51,7 +52,7 @@ def list(self, queries: Optional[List[str]] = None, search: Optional[str] = None return self.client.call('get', api_path, { }, api_params) - def create(self, function_id: str, name: str, runtime: Runtime, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[str]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + def create(self, function_id: str, name: str, runtime: Runtime, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[Scopes]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: """ Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. @@ -79,7 +80,7 @@ def create(self, function_id: str, name: str, runtime: Runtime, execute: Optiona Entrypoint File. This path is relative to the "providerRootDirectory". commands : Optional[str] Build Commands. - scopes : Optional[List[str]] + scopes : Optional[List[Scopes]] List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. installation_id : Optional[str] Appwrite Installation ID for VCS (Version Control System) deployment. @@ -228,7 +229,7 @@ def get(self, function_id: str) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) - def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[str]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: + def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, execute: Optional[List[str]] = None, events: Optional[List[str]] = None, schedule: Optional[str] = None, timeout: Optional[float] = None, enabled: Optional[bool] = None, logging: Optional[bool] = None, entrypoint: Optional[str] = None, commands: Optional[str] = None, scopes: Optional[List[Scopes]] = None, installation_id: Optional[str] = None, provider_repository_id: Optional[str] = None, provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, specification: Optional[str] = None) -> Dict[str, Any]: """ Update function by its unique ID. @@ -256,7 +257,7 @@ def update(self, function_id: str, name: str, runtime: Optional[Runtime] = None, Entrypoint File. This path is relative to the "providerRootDirectory". commands : Optional[str] Build Commands. - scopes : Optional[List[str]] + scopes : Optional[List[Scopes]] List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. installation_id : Optional[str] Appwrite Installation ID for VCS (Version Controle System) deployment. diff --git a/appwrite/services/health.py b/appwrite/services/health.py index c6250a1..47ab563 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -143,6 +143,35 @@ def get_pub_sub(self) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) + def get_queue_audits(self, threshold: Optional[float] = None) -> Dict[str, Any]: + """ + Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. + + Parameters + ---------- + threshold : Optional[float] + Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/health/queue/audits' + api_params = {} + + if threshold is not None: + api_params['threshold'] = threshold + + return self.client.call('get', api_path, { + }, api_params) + def get_queue_builds(self, threshold: Optional[float] = None) -> Dict[str, Any]: """ Get the number of builds that are waiting to be processed in the Appwrite internal queue server. diff --git a/appwrite/services/storage.py b/appwrite/services/storage.py index d07b1fc..655df2e 100644 --- a/appwrite/services/storage.py +++ b/appwrite/services/storage.py @@ -70,7 +70,7 @@ def create_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st allowed_file_extensions : Optional[List[str]] Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. compression : Optional[Compression] - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled encryption : Optional[bool] Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled antivirus : Optional[bool] @@ -174,7 +174,7 @@ def update_bucket(self, bucket_id: str, name: str, permissions: Optional[List[st allowed_file_extensions : Optional[List[str]] Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. compression : Optional[Compression] - Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled encryption : Optional[bool] Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled antivirus : Optional[bool] @@ -408,13 +408,13 @@ def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, Parameters ---------- bucket_id : str - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + Bucket unique ID. file_id : str - File unique ID. + File ID. name : Optional[str] - Name of the file + File name. permissions : Optional[List[str]] - An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). Returns ------- @@ -438,7 +438,8 @@ def update_file(self, bucket_id: str, file_id: str, name: Optional[str] = None, api_path = api_path.replace('{bucketId}', bucket_id) api_path = api_path.replace('{fileId}', file_id) - api_params['name'] = name + if name is not None: + api_params['name'] = name api_params['permissions'] = permissions return self.client.call('put', api_path, { diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index a99e684..dece20d 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -5,6 +5,7 @@ from ..enums.relationship_type import RelationshipType; from ..enums.relation_mutate import RelationMutate; from ..enums.index_type import IndexType; +from ..enums.order_by import OrderBy; class TablesDB(Service): @@ -320,7 +321,7 @@ def get(self, database_id: str) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) - def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update(self, database_id: str, name: Optional[str] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: """ Update a database by its unique ID. @@ -328,7 +329,7 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> ---------- database_id : str Database ID. - name : str + name : Optional[str] Database name. Max length: 128 chars. enabled : Optional[bool] Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. @@ -349,12 +350,10 @@ def update(self, database_id: str, name: str, enabled: Optional[bool] = None) -> if database_id is None: raise AppwriteException('Missing required parameter: "database_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) - api_params['name'] = name + if name is not None: + api_params['name'] = name if enabled is not None: api_params['enabled'] = enabled @@ -537,7 +536,7 @@ def get_table(self, database_id: str, table_id: str) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) - def update_table(self, database_id: str, table_id: str, name: str, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + def update_table(self, database_id: str, table_id: str, name: Optional[str] = None, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: """ Update a table by its unique ID. @@ -547,7 +546,7 @@ def update_table(self, database_id: str, table_id: str, name: str, permissions: Database ID. table_id : str Table ID. - name : str + name : Optional[str] Table name. Max length: 128 chars. permissions : Optional[List[str]] An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -575,13 +574,11 @@ def update_table(self, database_id: str, table_id: str, name: str, permissions: if table_id is None: raise AppwriteException('Missing required parameter: "table_id"') - if name is None: - raise AppwriteException('Missing required parameter: "name"') - api_path = api_path.replace('{databaseId}', database_id) api_path = api_path.replace('{tableId}', table_id) - api_params['name'] = name + if name is not None: + api_params['name'] = name api_params['permissions'] = permissions if row_security is not None: api_params['rowSecurity'] = row_security @@ -1621,6 +1618,236 @@ def update_line_column(self, database_id: str, table_id: str, key: str, required 'content-type': 'application/json', }, api_params) + def create_longtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a longtext column. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + array : Optional[bool] + Is column an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_longtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a longtext column. Changing the `default` value will not update already existing rows. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + new_key : Optional[str] + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + def create_mediumtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a mediumtext column. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + array : Optional[bool] + Is column an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_mediumtext_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a mediumtext column. Changing the `default` value will not update already existing rows. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + new_key : Optional[str] + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + def create_point_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[List[Any]] = None) -> Dict[str, Any]: """ Create a geometric point column. @@ -1904,11 +2131,14 @@ def create_relationship_column(self, database_id: str, table_id: str, related_ta 'content-type': 'application/json', }, api_params) + @deprecated("This API has been deprecated since 1.9.0. Please use `tablesDB.create_text_column` instead.") def create_string_column(self, database_id: str, table_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None, encrypt: Optional[bool] = None) -> Dict[str, Any]: """ Create a string column. + .. deprecated::1.9.0 + This API has been deprecated since 1.9.0. Please use `tablesDB.create_text_column` instead. Parameters ---------- database_id : str @@ -1972,11 +2202,14 @@ def create_string_column(self, database_id: str, table_id: str, key: str, size: 'content-type': 'application/json', }, api_params) + @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.update_text_column` instead.") def update_string_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: """ Update a string column. Changing the `default` value will not update already existing rows. + .. deprecated::1.8.0 + This API has been deprecated since 1.8.0. Please use `tablesDB.update_text_column` instead. Parameters ---------- database_id : str @@ -2032,6 +2265,121 @@ def update_string_column(self, database_id: str, table_id: str, key: str, requir 'content-type': 'application/json', }, api_params) + def create_text_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a text column. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + array : Optional[bool] + Is column an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_text_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a text column. Changing the `default` value will not update already existing rows. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + new_key : Optional[str] + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + def create_url_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: """ Create a URL column. @@ -2147,6 +2495,130 @@ def update_url_column(self, database_id: str, table_id: str, key: str, required: 'content-type': 'application/json', }, api_params) + def create_varchar_column(self, database_id: str, table_id: str, key: str, size: float, required: bool, default: Optional[str] = None, array: Optional[bool] = None) -> Dict[str, Any]: + """ + Create a varchar column. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + size : float + Column size for varchar columns, in number of characters. Maximum size is 16381. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + array : Optional[bool] + Is column an array? + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if size is None: + raise AppwriteException('Missing required parameter: "size"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + + api_params['key'] = key + api_params['size'] = size + api_params['required'] = required + api_params['default'] = default + if array is not None: + api_params['array'] = array + + return self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + def update_varchar_column(self, database_id: str, table_id: str, key: str, required: bool, default: Optional[str], size: Optional[float] = None, new_key: Optional[str] = None) -> Dict[str, Any]: + """ + Update a varchar column. Changing the `default` value will not update already existing rows. + + + Parameters + ---------- + database_id : str + Database ID. + table_id : str + Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + key : str + Column Key. + required : bool + Is column required? + default : Optional[str] + Default value for column when not provided. Cannot be set when column is required. + size : Optional[float] + Maximum size of the varchar column. + new_key : Optional[str] + New Column Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if table_id is None: + raise AppwriteException('Missing required parameter: "table_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if required is None: + raise AppwriteException('Missing required parameter: "required"') + + api_path = api_path.replace('{databaseId}', database_id) + api_path = api_path.replace('{tableId}', table_id) + api_path = api_path.replace('{key}', key) + + api_params['required'] = required + api_params['default'] = default + api_params['size'] = size + api_params['newKey'] = new_key + + return self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + def get_column(self, database_id: str, table_id: str, key: str) -> Dict[str, Any]: """ Get column by ID. @@ -2330,7 +2802,7 @@ def list_indexes(self, database_id: str, table_id: str, queries: Optional[List[s return self.client.call('get', api_path, { }, api_params) - def create_index(self, database_id: str, table_id: str, key: str, type: IndexType, columns: List[str], orders: Optional[List[str]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: + def create_index(self, database_id: str, table_id: str, key: str, type: IndexType, columns: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None) -> Dict[str, Any]: """ Creates an index on the columns listed. Your index should include all the columns you will query in a single request. Type can be `key`, `fulltext`, or `unique`. @@ -2347,7 +2819,7 @@ def create_index(self, database_id: str, table_id: str, key: str, type: IndexTyp Index type. columns : List[str] Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. - orders : Optional[List[str]] + orders : Optional[List[OrderBy]] Array of index orders. Maximum of 100 orders are allowed. lengths : Optional[List[float]] Length of index. Maximum of 100 diff --git a/appwrite/services/teams.py b/appwrite/services/teams.py index 1e15296..a5dd4c3 100644 --- a/appwrite/services/teams.py +++ b/appwrite/services/teams.py @@ -2,6 +2,7 @@ from typing import List, Dict, Any, Optional from ..exception import AppwriteException from appwrite.utils.deprecated import deprecated +from ..enums.roles import Roles; class Teams(Service): @@ -231,7 +232,7 @@ def list_memberships(self, team_id: str, queries: Optional[List[str]] = None, se return self.client.call('get', api_path, { }, api_params) - def create_membership(self, team_id: str, roles: List[str], email: Optional[str] = None, user_id: Optional[str] = None, phone: Optional[str] = None, url: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: + def create_membership(self, team_id: str, roles: List[Roles], email: Optional[str] = None, user_id: Optional[str] = None, phone: Optional[str] = None, url: Optional[str] = None, name: Optional[str] = None) -> Dict[str, Any]: """ Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. @@ -246,7 +247,7 @@ def create_membership(self, team_id: str, roles: List[str], email: Optional[str] ---------- team_id : str Team ID. - roles : List[str] + roles : List[Roles] Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. email : Optional[str] Email of the new team member. @@ -333,7 +334,7 @@ def get_membership(self, team_id: str, membership_id: str) -> Dict[str, Any]: return self.client.call('get', api_path, { }, api_params) - def update_membership(self, team_id: str, membership_id: str, roles: List[str]) -> Dict[str, Any]: + def update_membership(self, team_id: str, membership_id: str, roles: List[Roles]) -> Dict[str, Any]: """ Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). @@ -344,7 +345,7 @@ def update_membership(self, team_id: str, membership_id: str, roles: List[str]) Team ID. membership_id : str Membership ID. - roles : List[str] + roles : List[Roles] An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. Returns diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 9b5fd90..6f95338 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -8,4 +8,6 @@ client.set_session('') # The user session to authenticate with account = Account(client) -result = account.create_jwt() +result = account.create_jwt( + duration = 0 # optional +) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 4375594..6ad99db 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -2,7 +2,8 @@ from appwrite.client import Client from appwrite.services.avatars import Avatars from appwrite.enums import Theme from appwrite.enums import Timezone -from appwrite.enums import Output +from appwrite.enums import BrowserPermission +from appwrite.enums import ImageFormat client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -20,19 +21,19 @@ result = avatars.get_screenshot( viewport_width = 1920, # optional viewport_height = 1080, # optional scale = 2, # optional - theme = Theme.LIGHT, # optional + theme = Theme.DARK, # optional user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', # optional fullpage = True, # optional locale = 'en-US', # optional - timezone = Timezone.AFRICA_ABIDJAN, # optional + timezone = Timezone.AMERICA_NEW_YORK, # optional latitude = 37.7749, # optional longitude = -122.4194, # optional accuracy = 100, # optional touch = True, # optional - permissions = ["geolocation","notifications"], # optional + permissions = [BrowserPermission.GEOLOCATION, BrowserPermission.NOTIFICATIONS], # optional sleep = 3, # optional width = 800, # optional height = 600, # optional quality = 85, # optional - output = Output.JPG # optional + output = ImageFormat.JPEG # optional ) diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index f7bb455..8eb38c1 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,6 +1,7 @@ from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.enums import IndexType +from appwrite.enums import OrderBy client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -15,6 +16,6 @@ result = databases.create_index( key = '', type = IndexType.KEY, attributes = [], - orders = [], # optional + orders = [OrderBy.ASC], # optional lengths = [] # optional ) diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md new file mode 100644 index 0000000..348af9d --- /dev/null +++ b/docs/examples/databases/create-longtext-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_longtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md new file mode 100644 index 0000000..f7bf2a0 --- /dev/null +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_mediumtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md new file mode 100644 index 0000000..3a3804e --- /dev/null +++ b/docs/examples/databases/create-text-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_text_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md new file mode 100644 index 0000000..0182380 --- /dev/null +++ b/docs/examples/databases/create-varchar-attribute.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.create_varchar_attribute( + database_id = '', + collection_id = '', + key = '', + size = 1, + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 5f357f5..8fcc58c 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -13,7 +13,7 @@ databases = Databases(client) result = databases.update_collection( database_id = '', collection_id = '', - name = '', + name = '', # optional permissions = [Permission.read(Role.any())], # optional document_security = False, # optional enabled = False # optional diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index a396b9e..91d233d 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -14,7 +14,13 @@ result = databases.update_document( database_id = '', collection_id = '', document_id = '', - data = {}, # optional + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": False + }, # optional permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 2aab8c6..cbf6f64 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -11,7 +11,13 @@ databases = Databases(client) result = databases.update_documents( database_id = '', collection_id = '', - data = {}, # optional + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": False + }, # optional queries = [], # optional transaction_id = '' # optional ) diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md new file mode 100644 index 0000000..8f2b5de --- /dev/null +++ b/docs/examples/databases/update-longtext-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.update_longtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md new file mode 100644 index 0000000..a368cf1 --- /dev/null +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.update_mediumtext_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md new file mode 100644 index 0000000..cfbbd8c --- /dev/null +++ b/docs/examples/databases/update-text-attribute.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.update_text_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md new file mode 100644 index 0000000..359e307 --- /dev/null +++ b/docs/examples/databases/update-varchar-attribute.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.databases import Databases + +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 + +databases = Databases(client) + +result = databases.update_varchar_attribute( + database_id = '', + collection_id = '', + key = '', + required = False, + default = '', + size = 1, # optional + new_key = '' # optional +) diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 35d2c0c..c88c389 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -10,6 +10,6 @@ databases = Databases(client) result = databases.update( database_id = '', - name = '', + name = '', # optional enabled = False # optional ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index ac53ae1..0d0f1b2 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -14,7 +14,13 @@ result = databases.upsert_document( database_id = '', collection_id = '', document_id = '', - data = {}, + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": False + }, # optional permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 98e16eb..6f4acab 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,6 +1,7 @@ from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.enums import Runtime +from appwrite.enums import Scopes client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -21,7 +22,7 @@ result = functions.create( logging = False, # optional entrypoint = '', # optional commands = '', # optional - scopes = [], # optional + scopes = [Scopes.SESSIONS_WRITE], # optional installation_id = '', # optional provider_repository_id = '', # optional provider_branch = '', # optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 841c1eb..02fd751 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,6 +1,7 @@ from appwrite.client import Client from appwrite.services.functions import Functions from appwrite.enums import Runtime +from appwrite.enums import Scopes client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -21,7 +22,7 @@ result = functions.update( logging = False, # optional entrypoint = '', # optional commands = '', # optional - scopes = [], # optional + scopes = [Scopes.SESSIONS_WRITE], # optional installation_id = '', # optional provider_repository_id = '', # optional provider_branch = '', # optional diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/health/get-queue-audits.md new file mode 100644 index 0000000..7db4390 --- /dev/null +++ b/docs/examples/health/get-queue-audits.md @@ -0,0 +1,13 @@ +from appwrite.client import Client +from appwrite.services.health import Health + +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 + +health = Health(client) + +result = health.get_queue_audits( + threshold = None # optional +) diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index e4aaa83..9b5959d 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -1,6 +1,7 @@ from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.enums import IndexType +from appwrite.enums import OrderBy client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -15,6 +16,6 @@ result = tables_db.create_index( key = '', type = IndexType.KEY, columns = [], - orders = [], # optional + orders = [OrderBy.ASC], # optional lengths = [] # optional ) diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md new file mode 100644 index 0000000..e060642 --- /dev/null +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_longtext_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md new file mode 100644 index 0000000..2582649 --- /dev/null +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_mediumtext_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md new file mode 100644 index 0000000..d4b2364 --- /dev/null +++ b/docs/examples/tablesdb/create-text-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_text_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md new file mode 100644 index 0000000..385c777 --- /dev/null +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.create_varchar_column( + database_id = '', + table_id = '', + key = '', + size = 1, + required = False, + default = '', # optional + array = False # optional +) diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md new file mode 100644 index 0000000..d4abf30 --- /dev/null +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.update_longtext_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md new file mode 100644 index 0000000..a7aa045 --- /dev/null +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.update_mediumtext_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 3d34264..d6a55c6 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -14,7 +14,13 @@ result = tables_db.update_row( database_id = '', table_id = '', row_id = '', - data = {}, # optional + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": False + }, # optional permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 4717581..77360af 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -11,7 +11,13 @@ tables_db = TablesDB(client) result = tables_db.update_rows( database_id = '', table_id = '', - data = {}, # optional + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": False + }, # optional queries = [], # optional transaction_id = '' # optional ) diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index c3e0115..4d1a572 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -13,7 +13,7 @@ tables_db = TablesDB(client) result = tables_db.update_table( database_id = '', table_id = '', - name = '', + name = '', # optional permissions = [Permission.read(Role.any())], # optional row_security = False, # optional enabled = False # optional diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md new file mode 100644 index 0000000..5dd4b4a --- /dev/null +++ b/docs/examples/tablesdb/update-text-column.md @@ -0,0 +1,18 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.update_text_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md new file mode 100644 index 0000000..5e16a2e --- /dev/null +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -0,0 +1,19 @@ +from appwrite.client import Client +from appwrite.services.tables_db import TablesDB + +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 + +tables_db = TablesDB(client) + +result = tables_db.update_varchar_column( + database_id = '', + table_id = '', + key = '', + required = False, + default = '', + size = 1, # optional + new_key = '' # optional +) diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 15c4eb7..b86d088 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -10,6 +10,6 @@ tables_db = TablesDB(client) result = tables_db.update( database_id = '', - name = '', + name = '', # optional enabled = False # optional ) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index a89d657..d0520b3 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -14,7 +14,13 @@ result = tables_db.upsert_row( database_id = '', table_id = '', row_id = '', - data = {}, # optional + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": False + }, # optional permissions = [Permission.read(Role.any())], # optional transaction_id = '' # optional ) diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cb3bf73..aa811be 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,5 +1,6 @@ from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.enums import Roles client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -10,7 +11,7 @@ teams = Teams(client) result = teams.create_membership( team_id = '', - roles = [], + roles = [Roles.ADMIN], email = 'email@example.com', # optional user_id = '', # optional phone = '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index db20c5a..dc6be18 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,5 +1,6 @@ from appwrite.client import Client from appwrite.services.teams import Teams +from appwrite.enums import Roles client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -11,5 +12,5 @@ teams = Teams(client) result = teams.update_membership( team_id = '', membership_id = '', - roles = [] + roles = [Roles.ADMIN] ) diff --git a/setup.py b/setup.py index 3c922e7..4404000 100644 --- a/setup.py +++ b/setup.py @@ -8,9 +8,9 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '14.1.0', + version = '15.0.0', license='BSD-3-Clause', - description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', + 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, long_description_content_type = 'text/markdown', author = 'Appwrite Team', @@ -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/14.1.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/15.0.0.tar.gz', install_requires=[ 'requests', ],