From 2424ff333860c2449eb94bbcbeb68b343f214f5e Mon Sep 17 00:00:00 2001 From: root Date: Tue, 24 Mar 2026 13:07:47 +0000 Subject: [PATCH 1/9] feat: update Python SDK to 16.0.0 * No user-facing SDK changes --- README.md | 2 +- appwrite/client.py | 20 +- appwrite/encoders/value_class_encoder.py | 20 +- appwrite/enums/backup_services.py | 3 + appwrite/enums/build_runtime.py | 86 + appwrite/enums/database_type.py | 2 + appwrite/enums/databases_index_type.py | 7 + appwrite/enums/documents_db_index_type.py | 7 + appwrite/enums/model.py | 4 + appwrite/enums/runtime.py | 86 + appwrite/enums/scopes.py | 4 + ...{index_type.py => tables_db_index_type.py} | 2 +- appwrite/enums/vectors_db_index_type.py | 9 + appwrite/models/__init__.py | 16 + appwrite/models/attribute_object.py | 37 + appwrite/models/attribute_vector.py | 40 + appwrite/models/document.py | 4 +- appwrite/models/embedding.py | 24 + appwrite/models/embedding_list.py | 19 + appwrite/models/function.py | 12 +- appwrite/models/log.py | 6 +- appwrite/models/row.py | 4 +- appwrite/models/site.py | 15 +- appwrite/models/user.py | 6 + appwrite/models/vectorsdb_collection.py | 54 + appwrite/models/vectorsdb_collection_list.py | 19 + appwrite/models/webhook.py | 51 + appwrite/models/webhook_list.py | 19 + appwrite/services/databases.py | 6 +- appwrite/services/documents_db.py | 1796 +++++++++++++++++ appwrite/services/functions.py | 40 +- appwrite/services/project.py | 233 +++ appwrite/services/sites.py | 50 +- appwrite/services/tables_db.py | 6 +- appwrite/services/users.py | 52 +- appwrite/services/vectors_db.py | 1685 ++++++++++++++++ appwrite/services/webhooks.py | 322 +++ docs/examples/databases/create-index.md | 4 +- docs/examples/databases/upsert-documents.md | 2 +- .../examples/documentsdb/create-collection.md | 27 + docs/examples/documentsdb/create-document.md | 30 + docs/examples/documentsdb/create-documents.md | 20 + docs/examples/documentsdb/create-index.md | 26 + .../examples/documentsdb/create-operations.md | 29 + .../documentsdb/create-transaction.md | 18 + docs/examples/documentsdb/create.md | 20 + .../decrement-document-attribute.md | 24 + .../examples/documentsdb/delete-collection.md | 16 + docs/examples/documentsdb/delete-document.md | 18 + docs/examples/documentsdb/delete-documents.md | 21 + docs/examples/documentsdb/delete-index.md | 17 + .../documentsdb/delete-transaction.md | 15 + docs/examples/documentsdb/delete.md | 15 + docs/examples/documentsdb/get-collection.md | 19 + docs/examples/documentsdb/get-document.md | 22 + docs/examples/documentsdb/get-index.md | 20 + docs/examples/documentsdb/get-transaction.md | 18 + docs/examples/documentsdb/get.md | 18 + .../increment-document-attribute.md | 24 + docs/examples/documentsdb/list-collections.md | 21 + docs/examples/documentsdb/list-documents.md | 23 + docs/examples/documentsdb/list-indexes.md | 21 + .../examples/documentsdb/list-transactions.md | 18 + docs/examples/documentsdb/list.md | 20 + .../examples/documentsdb/update-collection.md | 25 + docs/examples/documentsdb/update-document.md | 25 + docs/examples/documentsdb/update-documents.md | 22 + .../documentsdb/update-transaction.md | 20 + docs/examples/documentsdb/update.md | 20 + docs/examples/documentsdb/upsert-document.md | 25 + docs/examples/documentsdb/upsert-documents.md | 21 + docs/examples/functions/create.md | 4 +- docs/examples/functions/update.md | 4 +- docs/examples/project/create-variable.md | 21 + docs/examples/project/delete-variable.md | 15 + docs/examples/project/get-variable.md | 18 + docs/examples/project/list-variables.md | 19 + docs/examples/project/update-variable.md | 21 + docs/examples/sites/create.md | 5 +- docs/examples/sites/update.md | 5 +- docs/examples/tablesdb/create-index.md | 4 +- docs/examples/users/update-impersonator.md | 19 + docs/examples/vectorsdb/create-collection.md | 26 + docs/examples/vectorsdb/create-document.md | 34 + docs/examples/vectorsdb/create-documents.md | 20 + docs/examples/vectorsdb/create-index.md | 26 + docs/examples/vectorsdb/create-operations.md | 29 + .../vectorsdb/create-text-embeddings.md | 20 + docs/examples/vectorsdb/create-transaction.md | 18 + docs/examples/vectorsdb/create.md | 20 + docs/examples/vectorsdb/delete-collection.md | 16 + docs/examples/vectorsdb/delete-document.md | 18 + docs/examples/vectorsdb/delete-documents.md | 21 + docs/examples/vectorsdb/delete-index.md | 17 + docs/examples/vectorsdb/delete-transaction.md | 15 + docs/examples/vectorsdb/delete.md | 15 + docs/examples/vectorsdb/get-collection.md | 19 + docs/examples/vectorsdb/get-document.md | 22 + docs/examples/vectorsdb/get-index.md | 20 + docs/examples/vectorsdb/get-transaction.md | 18 + docs/examples/vectorsdb/get.md | 18 + docs/examples/vectorsdb/list-collections.md | 21 + docs/examples/vectorsdb/list-documents.md | 23 + docs/examples/vectorsdb/list-indexes.md | 21 + docs/examples/vectorsdb/list-transactions.md | 18 + docs/examples/vectorsdb/list.md | 20 + docs/examples/vectorsdb/update-collection.md | 26 + docs/examples/vectorsdb/update-document.md | 25 + docs/examples/vectorsdb/update-documents.md | 22 + docs/examples/vectorsdb/update-transaction.md | 20 + docs/examples/vectorsdb/update.md | 20 + docs/examples/vectorsdb/upsert-document.md | 25 + docs/examples/vectorsdb/upsert-documents.md | 21 + docs/examples/webhooks/create.md | 25 + docs/examples/webhooks/delete.md | 15 + docs/examples/webhooks/get.md | 18 + docs/examples/webhooks/list.md | 19 + docs/examples/webhooks/update-signature.md | 18 + docs/examples/webhooks/update.md | 25 + 119 files changed, 6307 insertions(+), 54 deletions(-) create mode 100644 appwrite/enums/databases_index_type.py create mode 100644 appwrite/enums/documents_db_index_type.py create mode 100644 appwrite/enums/model.py rename appwrite/enums/{index_type.py => tables_db_index_type.py} (78%) create mode 100644 appwrite/enums/vectors_db_index_type.py create mode 100644 appwrite/models/attribute_object.py create mode 100644 appwrite/models/attribute_vector.py create mode 100644 appwrite/models/embedding.py create mode 100644 appwrite/models/embedding_list.py create mode 100644 appwrite/models/vectorsdb_collection.py create mode 100644 appwrite/models/vectorsdb_collection_list.py create mode 100644 appwrite/models/webhook.py create mode 100644 appwrite/models/webhook_list.py create mode 100644 appwrite/services/documents_db.py create mode 100644 appwrite/services/project.py create mode 100644 appwrite/services/vectors_db.py create mode 100644 appwrite/services/webhooks.py create mode 100644 docs/examples/documentsdb/create-collection.md create mode 100644 docs/examples/documentsdb/create-document.md create mode 100644 docs/examples/documentsdb/create-documents.md create mode 100644 docs/examples/documentsdb/create-index.md create mode 100644 docs/examples/documentsdb/create-operations.md create mode 100644 docs/examples/documentsdb/create-transaction.md create mode 100644 docs/examples/documentsdb/create.md create mode 100644 docs/examples/documentsdb/decrement-document-attribute.md create mode 100644 docs/examples/documentsdb/delete-collection.md create mode 100644 docs/examples/documentsdb/delete-document.md create mode 100644 docs/examples/documentsdb/delete-documents.md create mode 100644 docs/examples/documentsdb/delete-index.md create mode 100644 docs/examples/documentsdb/delete-transaction.md create mode 100644 docs/examples/documentsdb/delete.md create mode 100644 docs/examples/documentsdb/get-collection.md create mode 100644 docs/examples/documentsdb/get-document.md create mode 100644 docs/examples/documentsdb/get-index.md create mode 100644 docs/examples/documentsdb/get-transaction.md create mode 100644 docs/examples/documentsdb/get.md create mode 100644 docs/examples/documentsdb/increment-document-attribute.md create mode 100644 docs/examples/documentsdb/list-collections.md create mode 100644 docs/examples/documentsdb/list-documents.md create mode 100644 docs/examples/documentsdb/list-indexes.md create mode 100644 docs/examples/documentsdb/list-transactions.md create mode 100644 docs/examples/documentsdb/list.md create mode 100644 docs/examples/documentsdb/update-collection.md create mode 100644 docs/examples/documentsdb/update-document.md create mode 100644 docs/examples/documentsdb/update-documents.md create mode 100644 docs/examples/documentsdb/update-transaction.md create mode 100644 docs/examples/documentsdb/update.md create mode 100644 docs/examples/documentsdb/upsert-document.md create mode 100644 docs/examples/documentsdb/upsert-documents.md create mode 100644 docs/examples/project/create-variable.md create mode 100644 docs/examples/project/delete-variable.md create mode 100644 docs/examples/project/get-variable.md create mode 100644 docs/examples/project/list-variables.md create mode 100644 docs/examples/project/update-variable.md create mode 100644 docs/examples/users/update-impersonator.md create mode 100644 docs/examples/vectorsdb/create-collection.md create mode 100644 docs/examples/vectorsdb/create-document.md create mode 100644 docs/examples/vectorsdb/create-documents.md create mode 100644 docs/examples/vectorsdb/create-index.md create mode 100644 docs/examples/vectorsdb/create-operations.md create mode 100644 docs/examples/vectorsdb/create-text-embeddings.md create mode 100644 docs/examples/vectorsdb/create-transaction.md create mode 100644 docs/examples/vectorsdb/create.md create mode 100644 docs/examples/vectorsdb/delete-collection.md create mode 100644 docs/examples/vectorsdb/delete-document.md create mode 100644 docs/examples/vectorsdb/delete-documents.md create mode 100644 docs/examples/vectorsdb/delete-index.md create mode 100644 docs/examples/vectorsdb/delete-transaction.md create mode 100644 docs/examples/vectorsdb/delete.md create mode 100644 docs/examples/vectorsdb/get-collection.md create mode 100644 docs/examples/vectorsdb/get-document.md create mode 100644 docs/examples/vectorsdb/get-index.md create mode 100644 docs/examples/vectorsdb/get-transaction.md create mode 100644 docs/examples/vectorsdb/get.md create mode 100644 docs/examples/vectorsdb/list-collections.md create mode 100644 docs/examples/vectorsdb/list-documents.md create mode 100644 docs/examples/vectorsdb/list-indexes.md create mode 100644 docs/examples/vectorsdb/list-transactions.md create mode 100644 docs/examples/vectorsdb/list.md create mode 100644 docs/examples/vectorsdb/update-collection.md create mode 100644 docs/examples/vectorsdb/update-document.md create mode 100644 docs/examples/vectorsdb/update-documents.md create mode 100644 docs/examples/vectorsdb/update-transaction.md create mode 100644 docs/examples/vectorsdb/update.md create mode 100644 docs/examples/vectorsdb/upsert-document.md create mode 100644 docs/examples/vectorsdb/upsert-documents.md create mode 100644 docs/examples/webhooks/create.md create mode 100644 docs/examples/webhooks/delete.md create mode 100644 docs/examples/webhooks/get.md create mode 100644 docs/examples/webhooks/list.md create mode 100644 docs/examples/webhooks/update-signature.md create mode 100644 docs/examples/webhooks/update.md diff --git a/README.md b/README.md index a1316dc8..85039c66 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Python SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/appwrite/client.py b/appwrite/client.py index ce32bff9..426706e5 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -20,7 +20,7 @@ def __init__(self): 'x-sdk-platform': 'server', 'x-sdk-language': 'python', 'x-sdk-version': '16.0.0', - 'X-Appwrite-Response-Format' : '1.8.0', + 'X-Appwrite-Response-Format' : '1.9.0', } def set_self_signed(self, status=True): @@ -72,6 +72,24 @@ def set_forwarded_user_agent(self, value): self._global_headers['x-forwarded-user-agent'] = value return self + def set_impersonate_user_id(self, value): + """Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.""" + + self._global_headers['x-appwrite-impersonate-user-id'] = value + return self + + def set_impersonate_user_email(self, value): + """Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.""" + + self._global_headers['x-appwrite-impersonate-user-email'] = value + return self + + def set_impersonate_user_phone(self, value): + """Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.""" + + self._global_headers['x-appwrite-impersonate-user-phone'] = value + return self + def call(self, method, path='', headers=None, params=None, response_type='json'): if headers is None: headers = {} diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 4b83e257..0c420123 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -13,8 +13,9 @@ from ..enums.backup_services import BackupServices from ..enums.relationship_type import RelationshipType from ..enums.relation_mutate import RelationMutate -from ..enums.index_type import IndexType +from ..enums.databases_index_type import DatabasesIndexType from ..enums.order_by import OrderBy +from ..enums.documents_db_index_type import DocumentsDBIndexType from ..enums.runtime import Runtime from ..enums.scopes import Scopes from ..enums.template_reference_type import TemplateReferenceType @@ -29,8 +30,11 @@ from ..enums.adapter import Adapter from ..enums.compression import Compression from ..enums.image_gravity import ImageGravity +from ..enums.tables_db_index_type import TablesDBIndexType from ..enums.password_hash import PasswordHash from ..enums.messaging_provider_type import MessagingProviderType +from ..enums.model import Model +from ..enums.vectors_db_index_type import VectorsDBIndexType from ..enums.database_type import DatabaseType from ..enums.attribute_status import AttributeStatus from ..enums.column_status import ColumnStatus @@ -86,12 +90,15 @@ def default(self, o): if isinstance(o, RelationMutate): return o.value - if isinstance(o, IndexType): + if isinstance(o, DatabasesIndexType): return o.value if isinstance(o, OrderBy): return o.value + if isinstance(o, DocumentsDBIndexType): + return o.value + if isinstance(o, Runtime): return o.value @@ -134,12 +141,21 @@ def default(self, o): if isinstance(o, ImageGravity): return o.value + if isinstance(o, TablesDBIndexType): + return o.value + if isinstance(o, PasswordHash): return o.value if isinstance(o, MessagingProviderType): return o.value + if isinstance(o, Model): + return o.value + + if isinstance(o, VectorsDBIndexType): + return o.value + if isinstance(o, DatabaseType): return o.value diff --git a/appwrite/enums/backup_services.py b/appwrite/enums/backup_services.py index c3eac0f9..20b99791 100644 --- a/appwrite/enums/backup_services.py +++ b/appwrite/enums/backup_services.py @@ -2,5 +2,8 @@ class BackupServices(Enum): DATABASES = "databases" + TABLESDB = "tablesdb" + DOCUMENTSDB = "documentsdb" + VECTORSDB = "vectorsdb" FUNCTIONS = "functions" STORAGE = "storage" diff --git a/appwrite/enums/build_runtime.py b/appwrite/enums/build_runtime.py index 8fe21cbc..a6c3fb88 100644 --- a/appwrite/enums/build_runtime.py +++ b/appwrite/enums/build_runtime.py @@ -87,3 +87,89 @@ class BuildRuntime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" + NODE_14_5_RC = "node-14.5-rc" + NODE_16_0_RC = "node-16.0-rc" + NODE_18_0_RC = "node-18.0-rc" + NODE_19_0_RC = "node-19.0-rc" + NODE_20_0_RC = "node-20.0-rc" + NODE_21_0_RC = "node-21.0-rc" + NODE_22_RC = "node-22-rc" + NODE_23_RC = "node-23-rc" + NODE_24_RC = "node-24-rc" + NODE_25_RC = "node-25-rc" + PHP_8_0_RC = "php-8.0-rc" + PHP_8_1_RC = "php-8.1-rc" + PHP_8_2_RC = "php-8.2-rc" + PHP_8_3_RC = "php-8.3-rc" + PHP_8_4_RC = "php-8.4-rc" + RUBY_3_0_RC = "ruby-3.0-rc" + RUBY_3_1_RC = "ruby-3.1-rc" + RUBY_3_2_RC = "ruby-3.2-rc" + RUBY_3_3_RC = "ruby-3.3-rc" + RUBY_3_4_RC = "ruby-3.4-rc" + RUBY_4_0_RC = "ruby-4.0-rc" + PYTHON_3_8_RC = "python-3.8-rc" + PYTHON_3_9_RC = "python-3.9-rc" + PYTHON_3_10_RC = "python-3.10-rc" + PYTHON_3_11_RC = "python-3.11-rc" + PYTHON_3_12_RC = "python-3.12-rc" + PYTHON_3_13_RC = "python-3.13-rc" + PYTHON_3_14_RC = "python-3.14-rc" + PYTHON_ML_3_11_RC = "python-ml-3.11-rc" + PYTHON_ML_3_12_RC = "python-ml-3.12-rc" + PYTHON_ML_3_13_RC = "python-ml-3.13-rc" + DENO_1_40_RC = "deno-1.40-rc" + DENO_1_46_RC = "deno-1.46-rc" + DENO_2_0_RC = "deno-2.0-rc" + DENO_2_5_RC = "deno-2.5-rc" + DENO_2_6_RC = "deno-2.6-rc" + DART_2_15_RC = "dart-2.15-rc" + DART_2_16_RC = "dart-2.16-rc" + DART_2_17_RC = "dart-2.17-rc" + DART_2_18_RC = "dart-2.18-rc" + DART_2_19_RC = "dart-2.19-rc" + DART_3_0_RC = "dart-3.0-rc" + DART_3_1_RC = "dart-3.1-rc" + DART_3_3_RC = "dart-3.3-rc" + DART_3_5_RC = "dart-3.5-rc" + DART_3_8_RC = "dart-3.8-rc" + DART_3_9_RC = "dart-3.9-rc" + DART_3_10_RC = "dart-3.10-rc" + DOTNET_6_0_RC = "dotnet-6.0-rc" + DOTNET_7_0_RC = "dotnet-7.0-rc" + DOTNET_8_0_RC = "dotnet-8.0-rc" + DOTNET_10_RC = "dotnet-10-rc" + JAVA_8_0_RC = "java-8.0-rc" + JAVA_11_0_RC = "java-11.0-rc" + JAVA_17_0_RC = "java-17.0-rc" + JAVA_18_0_RC = "java-18.0-rc" + JAVA_21_0_RC = "java-21.0-rc" + JAVA_22_RC = "java-22-rc" + JAVA_25_RC = "java-25-rc" + SWIFT_5_5_RC = "swift-5.5-rc" + SWIFT_5_8_RC = "swift-5.8-rc" + SWIFT_5_9_RC = "swift-5.9-rc" + SWIFT_5_10_RC = "swift-5.10-rc" + SWIFT_6_2_RC = "swift-6.2-rc" + KOTLIN_1_6_RC = "kotlin-1.6-rc" + KOTLIN_1_8_RC = "kotlin-1.8-rc" + KOTLIN_1_9_RC = "kotlin-1.9-rc" + KOTLIN_2_0_RC = "kotlin-2.0-rc" + KOTLIN_2_3_RC = "kotlin-2.3-rc" + CPP_17_RC = "cpp-17-rc" + CPP_20_RC = "cpp-20-rc" + BUN_1_0_RC = "bun-1.0-rc" + BUN_1_1_RC = "bun-1.1-rc" + BUN_1_2_RC = "bun-1.2-rc" + BUN_1_3_RC = "bun-1.3-rc" + GO_1_23_RC = "go-1.23-rc" + GO_1_24_RC = "go-1.24-rc" + GO_1_25_RC = "go-1.25-rc" + GO_1_26_RC = "go-1.26-rc" + STATIC_1_RC = "static-1-rc" + FLUTTER_3_24_RC = "flutter-3.24-rc" + FLUTTER_3_27_RC = "flutter-3.27-rc" + FLUTTER_3_29_RC = "flutter-3.29-rc" + FLUTTER_3_32_RC = "flutter-3.32-rc" + FLUTTER_3_35_RC = "flutter-3.35-rc" + FLUTTER_3_38_RC = "flutter-3.38-rc" diff --git a/appwrite/enums/database_type.py b/appwrite/enums/database_type.py index a4e48dfb..5d2d0aeb 100644 --- a/appwrite/enums/database_type.py +++ b/appwrite/enums/database_type.py @@ -3,3 +3,5 @@ class DatabaseType(Enum): LEGACY = "legacy" TABLESDB = "tablesdb" + DOCUMENTSDB = "documentsdb" + VECTORSDB = "vectorsdb" diff --git a/appwrite/enums/databases_index_type.py b/appwrite/enums/databases_index_type.py new file mode 100644 index 00000000..7f897a13 --- /dev/null +++ b/appwrite/enums/databases_index_type.py @@ -0,0 +1,7 @@ +from enum import Enum + +class DatabasesIndexType(Enum): + KEY = "key" + FULLTEXT = "fulltext" + UNIQUE = "unique" + SPATIAL = "spatial" diff --git a/appwrite/enums/documents_db_index_type.py b/appwrite/enums/documents_db_index_type.py new file mode 100644 index 00000000..30cb9e7c --- /dev/null +++ b/appwrite/enums/documents_db_index_type.py @@ -0,0 +1,7 @@ +from enum import Enum + +class DocumentsDBIndexType(Enum): + KEY = "key" + FULLTEXT = "fulltext" + UNIQUE = "unique" + SPATIAL = "spatial" diff --git a/appwrite/enums/model.py b/appwrite/enums/model.py new file mode 100644 index 00000000..88068045 --- /dev/null +++ b/appwrite/enums/model.py @@ -0,0 +1,4 @@ +from enum import Enum + +class Model(Enum): + EMBEDDINGGEMMA = "embeddinggemma" diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py index 171dbd95..89003e70 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -87,3 +87,89 @@ class Runtime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" + NODE_14_5_RC = "node-14.5-rc" + NODE_16_0_RC = "node-16.0-rc" + NODE_18_0_RC = "node-18.0-rc" + NODE_19_0_RC = "node-19.0-rc" + NODE_20_0_RC = "node-20.0-rc" + NODE_21_0_RC = "node-21.0-rc" + NODE_22_RC = "node-22-rc" + NODE_23_RC = "node-23-rc" + NODE_24_RC = "node-24-rc" + NODE_25_RC = "node-25-rc" + PHP_8_0_RC = "php-8.0-rc" + PHP_8_1_RC = "php-8.1-rc" + PHP_8_2_RC = "php-8.2-rc" + PHP_8_3_RC = "php-8.3-rc" + PHP_8_4_RC = "php-8.4-rc" + RUBY_3_0_RC = "ruby-3.0-rc" + RUBY_3_1_RC = "ruby-3.1-rc" + RUBY_3_2_RC = "ruby-3.2-rc" + RUBY_3_3_RC = "ruby-3.3-rc" + RUBY_3_4_RC = "ruby-3.4-rc" + RUBY_4_0_RC = "ruby-4.0-rc" + PYTHON_3_8_RC = "python-3.8-rc" + PYTHON_3_9_RC = "python-3.9-rc" + PYTHON_3_10_RC = "python-3.10-rc" + PYTHON_3_11_RC = "python-3.11-rc" + PYTHON_3_12_RC = "python-3.12-rc" + PYTHON_3_13_RC = "python-3.13-rc" + PYTHON_3_14_RC = "python-3.14-rc" + PYTHON_ML_3_11_RC = "python-ml-3.11-rc" + PYTHON_ML_3_12_RC = "python-ml-3.12-rc" + PYTHON_ML_3_13_RC = "python-ml-3.13-rc" + DENO_1_40_RC = "deno-1.40-rc" + DENO_1_46_RC = "deno-1.46-rc" + DENO_2_0_RC = "deno-2.0-rc" + DENO_2_5_RC = "deno-2.5-rc" + DENO_2_6_RC = "deno-2.6-rc" + DART_2_15_RC = "dart-2.15-rc" + DART_2_16_RC = "dart-2.16-rc" + DART_2_17_RC = "dart-2.17-rc" + DART_2_18_RC = "dart-2.18-rc" + DART_2_19_RC = "dart-2.19-rc" + DART_3_0_RC = "dart-3.0-rc" + DART_3_1_RC = "dart-3.1-rc" + DART_3_3_RC = "dart-3.3-rc" + DART_3_5_RC = "dart-3.5-rc" + DART_3_8_RC = "dart-3.8-rc" + DART_3_9_RC = "dart-3.9-rc" + DART_3_10_RC = "dart-3.10-rc" + DOTNET_6_0_RC = "dotnet-6.0-rc" + DOTNET_7_0_RC = "dotnet-7.0-rc" + DOTNET_8_0_RC = "dotnet-8.0-rc" + DOTNET_10_RC = "dotnet-10-rc" + JAVA_8_0_RC = "java-8.0-rc" + JAVA_11_0_RC = "java-11.0-rc" + JAVA_17_0_RC = "java-17.0-rc" + JAVA_18_0_RC = "java-18.0-rc" + JAVA_21_0_RC = "java-21.0-rc" + JAVA_22_RC = "java-22-rc" + JAVA_25_RC = "java-25-rc" + SWIFT_5_5_RC = "swift-5.5-rc" + SWIFT_5_8_RC = "swift-5.8-rc" + SWIFT_5_9_RC = "swift-5.9-rc" + SWIFT_5_10_RC = "swift-5.10-rc" + SWIFT_6_2_RC = "swift-6.2-rc" + KOTLIN_1_6_RC = "kotlin-1.6-rc" + KOTLIN_1_8_RC = "kotlin-1.8-rc" + KOTLIN_1_9_RC = "kotlin-1.9-rc" + KOTLIN_2_0_RC = "kotlin-2.0-rc" + KOTLIN_2_3_RC = "kotlin-2.3-rc" + CPP_17_RC = "cpp-17-rc" + CPP_20_RC = "cpp-20-rc" + BUN_1_0_RC = "bun-1.0-rc" + BUN_1_1_RC = "bun-1.1-rc" + BUN_1_2_RC = "bun-1.2-rc" + BUN_1_3_RC = "bun-1.3-rc" + GO_1_23_RC = "go-1.23-rc" + GO_1_24_RC = "go-1.24-rc" + GO_1_25_RC = "go-1.25-rc" + GO_1_26_RC = "go-1.26-rc" + STATIC_1_RC = "static-1-rc" + FLUTTER_3_24_RC = "flutter-3.24-rc" + FLUTTER_3_27_RC = "flutter-3.27-rc" + FLUTTER_3_29_RC = "flutter-3.29-rc" + FLUTTER_3_32_RC = "flutter-3.32-rc" + FLUTTER_3_35_RC = "flutter-3.35-rc" + FLUTTER_3_38_RC = "flutter-3.38-rc" diff --git a/appwrite/enums/scopes.py b/appwrite/enums/scopes.py index 100c9cb2..dfcedda2 100644 --- a/appwrite/enums/scopes.py +++ b/appwrite/enums/scopes.py @@ -58,6 +58,10 @@ class Scopes(Enum): ASSISTANT_READ = "assistant.read" TOKENS_READ = "tokens.read" TOKENS_WRITE = "tokens.write" + WEBHOOKS_READ = "webhooks.read" + WEBHOOKS_WRITE = "webhooks.write" + PROJECT_READ = "project.read" + PROJECT_WRITE = "project.write" POLICIES_WRITE = "policies.write" POLICIES_READ = "policies.read" ARCHIVES_READ = "archives.read" diff --git a/appwrite/enums/index_type.py b/appwrite/enums/tables_db_index_type.py similarity index 78% rename from appwrite/enums/index_type.py rename to appwrite/enums/tables_db_index_type.py index 842240f6..5707dd7a 100644 --- a/appwrite/enums/index_type.py +++ b/appwrite/enums/tables_db_index_type.py @@ -1,6 +1,6 @@ from enum import Enum -class IndexType(Enum): +class TablesDBIndexType(Enum): KEY = "key" FULLTEXT = "fulltext" UNIQUE = "unique" diff --git a/appwrite/enums/vectors_db_index_type.py b/appwrite/enums/vectors_db_index_type.py new file mode 100644 index 00000000..651be5d3 --- /dev/null +++ b/appwrite/enums/vectors_db_index_type.py @@ -0,0 +1,9 @@ +from enum import Enum + +class VectorsDBIndexType(Enum): + HNSW_EUCLIDEAN = "hnsw_euclidean" + HNSW_DOT = "hnsw_dot" + HNSW_COSINE = "hnsw_cosine" + OBJECT = "object" + KEY = "key" + UNIQUE = "unique" diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index 630e17d7..9282f487 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -21,6 +21,7 @@ from .runtime_list import RuntimeList from .deployment_list import DeploymentList from .execution_list import ExecutionList +from .webhook_list import WebhookList from .country_list import CountryList from .continent_list import ContinentList from .language_list import LanguageList @@ -36,7 +37,10 @@ from .target_list import TargetList from .transaction_list import TransactionList from .specification_list import SpecificationList +from .vectorsdb_collection_list import VectorsdbCollectionList +from .embedding_list import EmbeddingList from .database import Database +from .embedding import Embedding from .collection import Collection from .attribute_list import AttributeList from .attribute_string import AttributeString @@ -56,6 +60,9 @@ from .attribute_text import AttributeText from .attribute_mediumtext import AttributeMediumtext from .attribute_longtext import AttributeLongtext +from .vectorsdb_collection import VectorsdbCollection +from .attribute_object import AttributeObject +from .attribute_vector import AttributeVector from .table import Table from .column_list import ColumnList from .column_string import ColumnString @@ -107,6 +114,7 @@ from .framework_adapter import FrameworkAdapter from .deployment import Deployment from .execution import Execution +from .webhook import Webhook from .variable import Variable from .country import Country from .continent import Continent @@ -163,6 +171,7 @@ 'RuntimeList', 'DeploymentList', 'ExecutionList', + 'WebhookList', 'CountryList', 'ContinentList', 'LanguageList', @@ -178,7 +187,10 @@ 'TargetList', 'TransactionList', 'SpecificationList', + 'VectorsdbCollectionList', + 'EmbeddingList', 'Database', + 'Embedding', 'Collection', 'AttributeList', 'AttributeString', @@ -198,6 +210,9 @@ 'AttributeText', 'AttributeMediumtext', 'AttributeLongtext', + 'VectorsdbCollection', + 'AttributeObject', + 'AttributeVector', 'Table', 'ColumnList', 'ColumnString', @@ -249,6 +264,7 @@ 'FrameworkAdapter', 'Deployment', 'Execution', + 'Webhook', 'Variable', 'Country', 'Continent', diff --git a/appwrite/models/attribute_object.py b/appwrite/models/attribute_object.py new file mode 100644 index 00000000..20438c7b --- /dev/null +++ b/appwrite/models/attribute_object.py @@ -0,0 +1,37 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeObject(AppwriteModel): + """ + AttributeObject + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') diff --git a/appwrite/models/attribute_vector.py b/appwrite/models/attribute_vector.py new file mode 100644 index 00000000..1b5f9909 --- /dev/null +++ b/appwrite/models/attribute_vector.py @@ -0,0 +1,40 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from ..enums.attribute_status import AttributeStatus + +class AttributeVector(AppwriteModel): + """ + AttributeVector + + Attributes + ---------- + key : str + Attribute Key. + type : str + Attribute type. + status : AttributeStatus + Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + error : str + Error message. Displays error generated on failure of creating or deleting an attribute. + required : bool + Is attribute required? + array : Optional[bool] + Is attribute an array? + createdat : str + Attribute creation date in ISO 8601 format. + updatedat : str + Attribute update date in ISO 8601 format. + size : float + Vector dimensions. + """ + key: str = Field(..., alias='key') + type: str = Field(..., alias='type') + status: AttributeStatus = Field(..., alias='status') + error: str = Field(..., alias='error') + required: bool = Field(..., alias='required') + array: Optional[bool] = Field(default=None, alias='array') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + size: float = Field(..., alias='size') diff --git a/appwrite/models/document.py b/appwrite/models/document.py index 8b3913bf..8cc031b4 100644 --- a/appwrite/models/document.py +++ b/appwrite/models/document.py @@ -13,7 +13,7 @@ class Document(AppwriteModel, Generic[T]): ---------- id : str Document ID. - sequence : float + sequence : str Document sequence ID. collectionid : str Collection ID. @@ -27,7 +27,7 @@ class Document(AppwriteModel, Generic[T]): Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). """ id: str = Field(..., alias='$id') - sequence: float = Field(..., alias='$sequence') + sequence: str = Field(..., alias='$sequence') collectionid: str = Field(..., alias='$collectionId') databaseid: str = Field(..., alias='$databaseId') createdat: str = Field(..., alias='$createdAt') diff --git a/appwrite/models/embedding.py b/appwrite/models/embedding.py new file mode 100644 index 00000000..9da9bab5 --- /dev/null +++ b/appwrite/models/embedding.py @@ -0,0 +1,24 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class Embedding(AppwriteModel): + """ + Embedding + + Attributes + ---------- + model : str + Embedding model used to generate embeddings. + dimension : float + Number of dimensions for each embedding vector. + embedding : List[Any] + Embedding vector values. If an error occurs, this will be an empty array. + error : str + Error message if embedding generation fails. Empty string if no error. + """ + model: str = Field(..., alias='model') + dimension: float = Field(..., alias='dimension') + embedding: List[Any] = Field(..., alias='embedding') + error: str = Field(..., alias='error') diff --git a/appwrite/models/embedding_list.py b/appwrite/models/embedding_list.py new file mode 100644 index 00000000..d8f437e7 --- /dev/null +++ b/appwrite/models/embedding_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .embedding import Embedding + +class EmbeddingList(AppwriteModel): + """ + Embedding list + + Attributes + ---------- + total : float + Total number of embeddings that matched your query. + embeddings : List[Embedding] + List of embeddings. + """ + total: float = Field(..., alias='total') + embeddings: List[Embedding] = Field(..., alias='embeddings') diff --git a/appwrite/models/function.py b/appwrite/models/function.py index 1f6c1d6c..b7f5a208 100644 --- a/appwrite/models/function.py +++ b/appwrite/models/function.py @@ -28,6 +28,8 @@ class Function(AppwriteModel): When disabled, executions will exclude logs and errors, and will be slightly faster. runtime : str Function execution and build runtime. + deploymentretention : float + How many days to keep the non-active deployments before they will be automatically deleted. deploymentid : str Function's active deployment ID. deploymentcreatedat : str @@ -64,8 +66,10 @@ class Function(AppwriteModel): Path to function in VCS (Version Control System) repository providersilentmode : bool Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests - specification : str - Machine specification for builds and executions. + buildspecification : str + Machine specification for deployment builds. + runtimespecification : str + Machine specification for executions. """ id: str = Field(..., alias='$id') createdat: str = Field(..., alias='$createdAt') @@ -76,6 +80,7 @@ class Function(AppwriteModel): live: bool = Field(..., alias='live') logging: bool = Field(..., alias='logging') runtime: str = Field(..., alias='runtime') + deploymentretention: float = Field(..., alias='deploymentRetention') deploymentid: str = Field(..., alias='deploymentId') deploymentcreatedat: str = Field(..., alias='deploymentCreatedAt') latestdeploymentid: str = Field(..., alias='latestDeploymentId') @@ -94,4 +99,5 @@ class Function(AppwriteModel): providerbranch: str = Field(..., alias='providerBranch') providerrootdirectory: str = Field(..., alias='providerRootDirectory') providersilentmode: bool = Field(..., alias='providerSilentMode') - specification: str = Field(..., alias='specification') + buildspecification: str = Field(..., alias='buildSpecification') + runtimespecification: str = Field(..., alias='runtimeSpecification') diff --git a/appwrite/models/log.py b/appwrite/models/log.py index c2ccd089..d23732da 100644 --- a/appwrite/models/log.py +++ b/appwrite/models/log.py @@ -12,11 +12,11 @@ class Log(AppwriteModel): event : str Event name. userid : str - User ID. + User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. useremail : str - User Email. + User email of the actor recorded for this log. During impersonation, this is the original impersonator. username : str - User Name. + User name of the actor recorded for this log. During impersonation, this is the original impersonator. mode : str API mode when event triggered. ip : str diff --git a/appwrite/models/row.py b/appwrite/models/row.py index 9508143f..fca9d70b 100644 --- a/appwrite/models/row.py +++ b/appwrite/models/row.py @@ -13,7 +13,7 @@ class Row(AppwriteModel, Generic[T]): ---------- id : str Row ID. - sequence : float + sequence : str Row sequence ID. tableid : str Table ID. @@ -27,7 +27,7 @@ class Row(AppwriteModel, Generic[T]): Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). """ id: str = Field(..., alias='$id') - sequence: float = Field(..., alias='$sequence') + sequence: str = Field(..., alias='$sequence') tableid: str = Field(..., alias='$tableId') databaseid: str = Field(..., alias='$databaseId') createdat: str = Field(..., alias='$createdAt') diff --git a/appwrite/models/site.py b/appwrite/models/site.py index 718f2820..4874c046 100644 --- a/appwrite/models/site.py +++ b/appwrite/models/site.py @@ -26,6 +26,8 @@ class Site(AppwriteModel): When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. framework : str Site framework. + deploymentretention : float + How many days to keep the non-active deployments before they will be automatically deleted. deploymentid : str Site's active deployment ID. deploymentcreatedat : str @@ -48,6 +50,8 @@ class Site(AppwriteModel): The install command used to install the site dependencies. buildcommand : str The build command used to build the site. + startcommand : str + Custom command to use when starting site runtime. outputdirectory : str The directory where the site build output is located. installationid : str @@ -60,8 +64,10 @@ class Site(AppwriteModel): Path to site in VCS (Version Control System) repository providersilentmode : bool Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests - specification : str - Machine specification for builds and executions. + buildspecification : str + Machine specification for deployment builds. + runtimespecification : str + Machine specification for SSR executions. buildruntime : str Site build runtime. adapter : str @@ -77,6 +83,7 @@ class Site(AppwriteModel): live: bool = Field(..., alias='live') logging: bool = Field(..., alias='logging') framework: str = Field(..., alias='framework') + deploymentretention: float = Field(..., alias='deploymentRetention') deploymentid: str = Field(..., alias='deploymentId') deploymentcreatedat: str = Field(..., alias='deploymentCreatedAt') deploymentscreenshotlight: str = Field(..., alias='deploymentScreenshotLight') @@ -88,13 +95,15 @@ class Site(AppwriteModel): timeout: float = Field(..., alias='timeout') installcommand: str = Field(..., alias='installCommand') buildcommand: str = Field(..., alias='buildCommand') + startcommand: str = Field(..., alias='startCommand') outputdirectory: str = Field(..., alias='outputDirectory') installationid: str = Field(..., alias='installationId') providerrepositoryid: str = Field(..., alias='providerRepositoryId') providerbranch: str = Field(..., alias='providerBranch') providerrootdirectory: str = Field(..., alias='providerRootDirectory') providersilentmode: bool = Field(..., alias='providerSilentMode') - specification: str = Field(..., alias='specification') + buildspecification: str = Field(..., alias='buildSpecification') + runtimespecification: str = Field(..., alias='runtimeSpecification') buildruntime: str = Field(..., alias='buildRuntime') adapter: str = Field(..., alias='adapter') fallbackfile: str = Field(..., alias='fallbackFile') diff --git a/appwrite/models/user.py b/appwrite/models/user.py index 51a12239..58c5080d 100644 --- a/appwrite/models/user.py +++ b/appwrite/models/user.py @@ -58,6 +58,10 @@ class User(AppwriteModel, Generic[T]): A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. accessedat : str Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + impersonator : Optional[bool] + Whether the user can impersonate other users. + impersonatoruserid : Optional[str] + ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. """ id: str = Field(..., alias='$id') createdat: str = Field(..., alias='$createdAt') @@ -78,6 +82,8 @@ class User(AppwriteModel, Generic[T]): prefs: Preferences[T] = Field(..., alias='prefs') targets: List[Target] = Field(..., alias='targets') accessedat: str = Field(..., alias='accessedAt') + impersonator: Optional[bool] = Field(default=None, alias='impersonator') + impersonatoruserid: Optional[str] = Field(default=None, alias='impersonatorUserId') @classmethod def with_data(cls, data: Dict[str, Any], model_type: Type[T] = dict) -> 'User[T]': diff --git a/appwrite/models/vectorsdb_collection.py b/appwrite/models/vectorsdb_collection.py new file mode 100644 index 00000000..ed0ed0e2 --- /dev/null +++ b/appwrite/models/vectorsdb_collection.py @@ -0,0 +1,54 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .attribute_object import AttributeObject +from .attribute_vector import AttributeVector +from .index import Index + +class VectorsdbCollection(AppwriteModel): + """ + VectorsDB Collection + + Attributes + ---------- + id : str + Collection ID. + createdat : str + Collection creation date in ISO 8601 format. + updatedat : str + Collection update date in ISO 8601 format. + permissions : List[Any] + Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + databaseid : str + Database ID. + name : str + Collection name. + enabled : bool + Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. + documentsecurity : bool + Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + attributes : List[Union[AttributeObject, AttributeVector]] + Collection attributes. + indexes : List[Index] + Collection indexes. + bytesmax : float + Maximum document size in bytes. Returns 0 when no limit applies. + bytesused : float + Currently used document size in bytes based on defined attributes. + dimension : float + Embedding dimension. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + permissions: List[Any] = Field(..., alias='$permissions') + databaseid: str = Field(..., alias='databaseId') + name: str = Field(..., alias='name') + enabled: bool = Field(..., alias='enabled') + documentsecurity: bool = Field(..., alias='documentSecurity') + attributes: List[Union[AttributeObject, AttributeVector]] = Field(..., alias='attributes') + indexes: List[Index] = Field(..., alias='indexes') + bytesmax: float = Field(..., alias='bytesMax') + bytesused: float = Field(..., alias='bytesUsed') + dimension: float = Field(..., alias='dimension') diff --git a/appwrite/models/vectorsdb_collection_list.py b/appwrite/models/vectorsdb_collection_list.py new file mode 100644 index 00000000..2ed72af5 --- /dev/null +++ b/appwrite/models/vectorsdb_collection_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .vectorsdb_collection import VectorsdbCollection + +class VectorsdbCollectionList(AppwriteModel): + """ + VectorsDB Collections List + + Attributes + ---------- + total : float + Total number of collections that matched your query. + collections : List[VectorsdbCollection] + List of collections. + """ + total: float = Field(..., alias='total') + collections: List[VectorsdbCollection] = Field(..., alias='collections') diff --git a/appwrite/models/webhook.py b/appwrite/models/webhook.py new file mode 100644 index 00000000..0620cbfb --- /dev/null +++ b/appwrite/models/webhook.py @@ -0,0 +1,51 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel + +class Webhook(AppwriteModel): + """ + Webhook + + Attributes + ---------- + id : str + Webhook ID. + createdat : str + Webhook creation date in ISO 8601 format. + updatedat : str + Webhook update date in ISO 8601 format. + name : str + Webhook name. + url : str + Webhook URL endpoint. + events : List[Any] + Webhook trigger events. + security : bool + Indicated if SSL / TLS Certificate verification is enabled. + httpuser : str + HTTP basic authentication username. + httppass : str + HTTP basic authentication password. + signaturekey : str + Signature key which can be used to validated incoming + enabled : bool + Indicates if this webhook is enabled. + logs : str + Webhook error logs from the most recent failure. + attempts : float + Number of consecutive failed webhook attempts. + """ + id: str = Field(..., alias='$id') + createdat: str = Field(..., alias='$createdAt') + updatedat: str = Field(..., alias='$updatedAt') + name: str = Field(..., alias='name') + url: str = Field(..., alias='url') + events: List[Any] = Field(..., alias='events') + security: bool = Field(..., alias='security') + httpuser: str = Field(..., alias='httpUser') + httppass: str = Field(..., alias='httpPass') + signaturekey: str = Field(..., alias='signatureKey') + enabled: bool = Field(..., alias='enabled') + logs: str = Field(..., alias='logs') + attempts: float = Field(..., alias='attempts') diff --git a/appwrite/models/webhook_list.py b/appwrite/models/webhook_list.py new file mode 100644 index 00000000..fca455a8 --- /dev/null +++ b/appwrite/models/webhook_list.py @@ -0,0 +1,19 @@ +from typing import Any, Dict, List, Optional, Union, cast +from pydantic import Field, PrivateAttr + +from .base_model import AppwriteModel +from .webhook import Webhook + +class WebhookList(AppwriteModel): + """ + Webhooks List + + Attributes + ---------- + total : float + Total number of webhooks that matched your query. + webhooks : List[Webhook] + List of webhooks. + """ + total: float = Field(..., alias='total') + webhooks: List[Webhook] = Field(..., alias='webhooks') diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index f68dc40f..e4795469 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -31,7 +31,7 @@ from ..models.document_list import DocumentList; from ..models.document import Document; from ..models.index_list import IndexList; -from ..enums.index_type import IndexType; +from ..enums.databases_index_type import DatabasesIndexType; from ..enums.order_by import OrderBy; from ..models.index import Index; @@ -4345,7 +4345,7 @@ def create_index( database_id: str, collection_id: str, key: str, - type: IndexType, + type: DatabasesIndexType, attributes: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None @@ -4364,7 +4364,7 @@ def create_index( Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). key : str Index Key. - type : IndexType + type : DatabasesIndexType Index type. attributes : List[str] Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. diff --git a/appwrite/services/documents_db.py b/appwrite/services/documents_db.py new file mode 100644 index 00000000..99ec7277 --- /dev/null +++ b/appwrite/services/documents_db.py @@ -0,0 +1,1796 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union, Type, TypeVar +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.database_list import DatabaseList; +from ..models.database import Database; +from ..models.transaction_list import TransactionList; +from ..models.transaction import Transaction; +from ..models.collection_list import CollectionList; +from ..models.collection import Collection; +from ..models.document_list import DocumentList; +from ..models.document import Document; +from ..models.index_list import IndexList; +from ..enums.documents_db_index_type import DocumentsDBIndexType; +from ..enums.order_by import OrderBy; +from ..models.index import Index; + +T = TypeVar('T') + +class DocumentsDB(Service): + + def __init__(self, client) -> None: + super(DocumentsDB, self).__init__(client) + + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None + ) -> DatabaseList: + """ + Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + search : Optional[str] + Search term to filter your list results. Max length: 256 chars. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + DatabaseList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if search is not None: + api_params['search'] = self._normalize_value(search) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=DatabaseList) + + + def create( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None + ) -> Database: + """ + Create a new Database. + + + Parameters + ---------- + database_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Database name. Max length: 128 chars. + enabled : Optional[bool] + Is the 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. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['databaseId'] = self._normalize_value(database_id) + api_params['name'] = self._normalize_value(name) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Database) + + + def list_transactions( + self, + queries: Optional[List[str]] = None + ) -> TransactionList: + """ + + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + + Returns + ------- + TransactionList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=TransactionList) + + + def create_transaction( + self, + ttl: Optional[float] = None + ) -> Transaction: + """ + + + Parameters + ---------- + ttl : Optional[float] + Seconds before the transaction expires. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions' + api_params = {} + + if ttl is not None: + api_params['ttl'] = self._normalize_value(ttl) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def get_transaction( + self, + transaction_id: str + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def update_transaction( + self, + transaction_id: str, + commit: Optional[bool] = None, + rollback: Optional[bool] = None + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + commit : Optional[bool] + Commit transaction? + rollback : Optional[bool] + Rollback transaction? + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + if commit is not None: + api_params['commit'] = self._normalize_value(commit) + if rollback is not None: + api_params['rollback'] = self._normalize_value(rollback) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def delete_transaction( + self, + transaction_id: str + ) -> Dict[str, Any]: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def create_operations( + self, + transaction_id: str, + operations: Optional[List[Dict[str, Any]]] = None + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + operations : Optional[List[Dict[str, Any]]] + Array of staged operations. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/transactions/{transactionId}/operations' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + if operations is not None: + api_params['operations'] = self._normalize_value(operations) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def get( + self, + database_id: str + ) -> Database: + """ + Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Database) + + + def update( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None + ) -> Database: + """ + Update a database by its unique ID. + + Parameters + ---------- + database_id : str + Database ID. + name : 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. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}' + api_params = {} + 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}', str(self._normalize_value(database_id))) + + api_params['name'] = self._normalize_value(name) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Database) + + + def delete( + self, + database_id: str + ) -> Dict[str, Any]: + """ + Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_collections( + self, + database_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None + ) -> CollectionList: + """ + Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + + Parameters + ---------- + database_id : str + Database ID. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + search : Optional[str] + Search term to filter your list results. Max length: 256 chars. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + CollectionList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if search is not None: + api_params['search'] = self._normalize_value(search) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=CollectionList) + + + def create_collection( + self, + database_id: str, + collection_id: str, + name: str, + permissions: Optional[List[str]] = None, + document_security: Optional[bool] = None, + enabled: Optional[bool] = None, + attributes: Optional[List[Dict[str, Any]]] = None, + indexes: Optional[List[Dict[str, Any]]] = None + ) -> Collection: + """ + Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Collection name. Max length: 128 chars. + permissions : Optional[List[str]] + An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + document_security : Optional[bool] + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : Optional[bool] + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + attributes : Optional[List[Dict[str, Any]]] + Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + indexes : Optional[List[Dict[str, Any]]] + Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + + Returns + ------- + Collection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections' + 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 name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + api_params['collectionId'] = self._normalize_value(collection_id) + api_params['name'] = self._normalize_value(name) + api_params['permissions'] = self._normalize_value(permissions) + if document_security is not None: + api_params['documentSecurity'] = self._normalize_value(document_security) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + if attributes is not None: + api_params['attributes'] = self._normalize_value(attributes) + if indexes is not None: + api_params['indexes'] = self._normalize_value(indexes) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Collection) + + + def get_collection( + self, + database_id: str, + collection_id: str + ) -> Collection: + """ + Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + Collection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Collection) + + + 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 + ) -> Collection: + """ + Update a collection by its unique ID. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + name : 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). + document_security : Optional[bool] + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : Optional[bool] + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + + Returns + ------- + Collection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + 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 name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['name'] = self._normalize_value(name) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if document_security is not None: + api_params['documentSecurity'] = self._normalize_value(document_security) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Collection) + + + def delete_collection( + self, + database_id: str, + collection_id: str + ) -> Dict[str, Any]: + """ + Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + total: Optional[bool] = None, + ttl: Optional[float] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID to read uncommitted changes within the transaction. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + ttl : Optional[float] + TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + if total is not None: + api_params['total'] = self._normalize_value(total) + if ttl is not None: + api_params['ttl'] = self._normalize_value(ttl) + + response = self.client.call('get', api_path, { + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def create_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Dict[str, Any], + permissions: Optional[List[str]] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + + 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). Make sure to define attributes before creating documents. + document_id : str + Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + data : Dict[str, Any] + Document data as JSON object. + permissions : Optional[List[str]] + An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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 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}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documentId'] = self._normalize_value(document_id) + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def create_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + + 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). Make sure to define attributes before creating documents. + documents : List[Dict[str, Any]] + Array of documents data as JSON objects. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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 documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documents'] = self._normalize_value(documents) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def upsert_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + documents : List[Dict[str, Any]] + Array of document data as JSON objects. May contain partial documents. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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 documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documents'] = self._normalize_value(documents) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def update_documents( + self, + database_id: str, + collection_id: str, + data: Optional[Dict[str, Any]] = None, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include only attribute and value pairs to be updated. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def delete_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + Bulk delete documents using queries, if no queries are passed then all documents are deleted. + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def get_document( + self, + database_id: str, + collection_id: str, + document_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + + 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). + document_id : str + Document ID. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID to read uncommitted changes within the transaction. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('get', api_path, { + }, api_params) + + return Document.with_data(response, model_type) + + + def upsert_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + 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#documentsDBCreateCollection) API or directly from your database console. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include all required fields 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). + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def update_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include only fields and value pairs to be 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). + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def delete_document( + self, + database_id: str, + collection_id: str, + document_id: str, + transaction_id: Optional[str] = None + ) -> Dict[str, Any]: + """ + Delete a document by its unique ID. + + 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). + document_id : str + Document ID. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def decrement_document_attribute( + self, + database_id: str, + collection_id: str, + document_id: str, + attribute: str, + value: Optional[float] = None, + min: Optional[float] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + Decrement a specific column of a row by a given value. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + attribute : str + Attribute key. + value : Optional[float] + Value to decrement the attribute by. The value must be a number. + min : Optional[float] + Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if attribute is None: + raise AppwriteException('Missing required parameter: "attribute"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) + + if value is not None: + api_params['value'] = self._normalize_value(value) + if min is not None: + api_params['min'] = self._normalize_value(min) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def increment_document_attribute( + self, + database_id: str, + collection_id: str, + document_id: str, + attribute: str, + value: Optional[float] = None, + max: Optional[float] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + Increment a specific column of a row by a given value. + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + attribute : str + Attribute key. + value : Optional[float] + Value to increment the attribute by. The value must be a number. + max : Optional[float] + Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + if attribute is None: + raise AppwriteException('Missing required parameter: "attribute"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) + + if value is not None: + api_params['value'] = self._normalize_value(value) + if max is not None: + api_params['max'] = self._normalize_value(max) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def list_indexes( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> IndexList: + """ + List indexes in the collection. + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + IndexList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=IndexList) + + + def create_index( + self, + database_id: str, + collection_id: str, + key: str, + type: DocumentsDBIndexType, + attributes: List[str], + orders: Optional[List[OrderBy]] = None, + lengths: Optional[List[float]] = None + ) -> Index: + """ + 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`. + + 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 + Index Key. + type : DocumentsDBIndexType + Index type. + attributes : List[str] + Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + orders : Optional[List[OrderBy]] + Array of index orders. Maximum of 100 orders are allowed. + lengths : Optional[List[float]] + Length of index. Maximum of 100 + + Returns + ------- + Index + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + 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 type is None: + raise AppwriteException('Missing required parameter: "type"') + + if attributes is None: + raise AppwriteException('Missing required parameter: "attributes"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['key'] = self._normalize_value(key) + api_params['type'] = self._normalize_value(type) + api_params['attributes'] = self._normalize_value(attributes) + if orders is not None: + api_params['orders'] = self._normalize_value(orders) + if lengths is not None: + api_params['lengths'] = self._normalize_value(lengths) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Index) + + + def get_index( + self, + database_id: str, + collection_id: str, + key: str + ) -> Index: + """ + Get index by ID. + + 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 + Index Key. + + Returns + ------- + Index + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Index) + + + def delete_index( + self, + database_id: str, + collection_id: str, + key: str + ) -> Dict[str, Any]: + """ + Delete an index. + + 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 + Index Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + diff --git a/appwrite/services/functions.py b/appwrite/services/functions.py index e637020e..5023a180 100644 --- a/appwrite/services/functions.py +++ b/appwrite/services/functions.py @@ -89,7 +89,9 @@ def create( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None + build_specification: Optional[str] = None, + runtime_specification: Optional[str] = None, + deployment_retention: Optional[float] = None ) -> Function: """ 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. @@ -130,8 +132,12 @@ def create( Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. provider_root_directory : Optional[str] Path to function code in the linked repo. - specification : Optional[str] - Runtime specification for the function and builds. + build_specification : Optional[str] + Build specification for the function deployments. + runtime_specification : Optional[str] + Runtime specification for the function executions. + deployment_retention : Optional[float] + Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. Returns ------- @@ -187,8 +193,12 @@ def create( api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) - if specification is not None: - api_params['specification'] = self._normalize_value(specification) + if build_specification is not None: + api_params['buildSpecification'] = self._normalize_value(build_specification) + if runtime_specification is not None: + api_params['runtimeSpecification'] = self._normalize_value(runtime_specification) + if deployment_retention is not None: + api_params['deploymentRetention'] = self._normalize_value(deployment_retention) response = self.client.call('post', api_path, { 'content-type': 'application/json', @@ -305,7 +315,9 @@ def update( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None + build_specification: Optional[str] = None, + runtime_specification: Optional[str] = None, + deployment_retention: Optional[float] = None ) -> Function: """ Update function by its unique ID. @@ -346,8 +358,12 @@ def update( Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. provider_root_directory : Optional[str] Path to function code in the linked repo. - specification : Optional[str] - Runtime specification for the function and builds. + build_specification : Optional[str] + Build specification for the function deployments. + runtime_specification : Optional[str] + Runtime specification for the function executions. + deployment_retention : Optional[float] + Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. Returns ------- @@ -400,8 +416,12 @@ def update( api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) - if specification is not None: - api_params['specification'] = self._normalize_value(specification) + if build_specification is not None: + api_params['buildSpecification'] = self._normalize_value(build_specification) + if runtime_specification is not None: + api_params['runtimeSpecification'] = self._normalize_value(runtime_specification) + if deployment_retention is not None: + api_params['deploymentRetention'] = self._normalize_value(deployment_retention) response = self.client.call('put', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/project.py b/appwrite/services/project.py new file mode 100644 index 00000000..ee504389 --- /dev/null +++ b/appwrite/services/project.py @@ -0,0 +1,233 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.variable_list import VariableList; +from ..models.variable import Variable; + +class Project(Service): + + def __init__(self, client) -> None: + super(Project, self).__init__(client) + + def list_variables( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> VariableList: + """ + Get a list of all project environment variables. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + VariableList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/variables' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=VariableList) + + + def create_variable( + self, + variable_id: str, + key: str, + value: str, + secret: Optional[bool] = None + ) -> Variable: + """ + Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + + Parameters + ---------- + variable_id : str + Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + key : str + Variable key. Max length: 255 chars. + value : str + Variable value. Max length: 8192 chars. + secret : Optional[bool] + Secret variables can be updated or deleted, but only projects can read them during build and runtime. + + Returns + ------- + Variable + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/variables' + api_params = {} + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + if key is None: + raise AppwriteException('Missing required parameter: "key"') + + if value is None: + raise AppwriteException('Missing required parameter: "value"') + + + api_params['variableId'] = self._normalize_value(variable_id) + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) + if secret is not None: + api_params['secret'] = self._normalize_value(secret) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Variable) + + + def get_variable( + self, + variable_id: str + ) -> Variable: + """ + Get a variable by its unique ID. + + Parameters + ---------- + variable_id : str + Variable ID. + + Returns + ------- + Variable + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/variables/{variableId}' + api_params = {} + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Variable) + + + def update_variable( + self, + variable_id: str, + key: Optional[str] = None, + value: Optional[str] = None, + secret: Optional[bool] = None + ) -> Variable: + """ + Update variable by its unique ID. + + Parameters + ---------- + variable_id : str + Variable ID. + key : Optional[str] + Variable key. Max length: 255 chars. + value : Optional[str] + Variable value. Max length: 8192 chars. + secret : Optional[bool] + Secret variables can be updated or deleted, but only projects can read them during build and runtime. + + Returns + ------- + Variable + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/variables/{variableId}' + api_params = {} + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) + + api_params['key'] = self._normalize_value(key) + api_params['value'] = self._normalize_value(value) + api_params['secret'] = self._normalize_value(secret) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Variable) + + + def delete_variable( + self, + variable_id: str + ) -> Dict[str, Any]: + """ + Delete a variable by its unique ID. + + Parameters + ---------- + variable_id : str + Variable ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/project/variables/{variableId}' + api_params = {} + if variable_id is None: + raise AppwriteException('Missing required parameter: "variable_id"') + + api_path = api_path.replace('{variableId}', str(self._normalize_value(variable_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + diff --git a/appwrite/services/sites.py b/appwrite/services/sites.py index 86ebd6b9..627e4dac 100644 --- a/appwrite/services/sites.py +++ b/appwrite/services/sites.py @@ -81,6 +81,7 @@ def create( timeout: Optional[float] = None, install_command: Optional[str] = None, build_command: Optional[str] = None, + start_command: Optional[str] = None, output_directory: Optional[str] = None, adapter: Optional[Adapter] = None, installation_id: Optional[str] = None, @@ -89,7 +90,9 @@ def create( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None + build_specification: Optional[str] = None, + runtime_specification: Optional[str] = None, + deployment_retention: Optional[float] = None ) -> Site: """ Create a new site. @@ -114,6 +117,8 @@ def create( Install Command. build_command : Optional[str] Build Command. + start_command : Optional[str] + Custom start command. Leave empty to use default. output_directory : Optional[str] Output Directory for site. adapter : Optional[Adapter] @@ -130,8 +135,12 @@ def create( Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. provider_root_directory : Optional[str] Path to site code in the linked repo. - specification : Optional[str] - Framework specification for the site and builds. + build_specification : Optional[str] + Build specification for the site deployments. + runtime_specification : Optional[str] + Runtime specification for the SSR executions. + deployment_retention : Optional[float] + Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. Returns ------- @@ -172,6 +181,8 @@ def create( api_params['installCommand'] = self._normalize_value(install_command) if build_command is not None: api_params['buildCommand'] = self._normalize_value(build_command) + if start_command is not None: + api_params['startCommand'] = self._normalize_value(start_command) if output_directory is not None: api_params['outputDirectory'] = self._normalize_value(output_directory) api_params['buildRuntime'] = self._normalize_value(build_runtime) @@ -189,8 +200,12 @@ def create( api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) - if specification is not None: - api_params['specification'] = self._normalize_value(specification) + if build_specification is not None: + api_params['buildSpecification'] = self._normalize_value(build_specification) + if runtime_specification is not None: + api_params['runtimeSpecification'] = self._normalize_value(runtime_specification) + if deployment_retention is not None: + api_params['deploymentRetention'] = self._normalize_value(deployment_retention) response = self.client.call('post', api_path, { 'content-type': 'application/json', @@ -298,6 +313,7 @@ def update( timeout: Optional[float] = None, install_command: Optional[str] = None, build_command: Optional[str] = None, + start_command: Optional[str] = None, output_directory: Optional[str] = None, build_runtime: Optional[BuildRuntime] = None, adapter: Optional[Adapter] = None, @@ -307,7 +323,9 @@ def update( provider_branch: Optional[str] = None, provider_silent_mode: Optional[bool] = None, provider_root_directory: Optional[str] = None, - specification: Optional[str] = None + build_specification: Optional[str] = None, + runtime_specification: Optional[str] = None, + deployment_retention: Optional[float] = None ) -> Site: """ Update site by its unique ID. @@ -330,6 +348,8 @@ def update( Install Command. build_command : Optional[str] Build Command. + start_command : Optional[str] + Custom start command. Leave empty to use default. output_directory : Optional[str] Output Directory for site. build_runtime : Optional[BuildRuntime] @@ -348,8 +368,12 @@ def update( Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. provider_root_directory : Optional[str] Path to site code in the linked repo. - specification : Optional[str] - Framework specification for the site and builds. + build_specification : Optional[str] + Build specification for the site deployments. + runtime_specification : Optional[str] + Runtime specification for the SSR executions. + deployment_retention : Optional[float] + Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. Returns ------- @@ -387,6 +411,8 @@ def update( api_params['installCommand'] = self._normalize_value(install_command) if build_command is not None: api_params['buildCommand'] = self._normalize_value(build_command) + if start_command is not None: + api_params['startCommand'] = self._normalize_value(start_command) if output_directory is not None: api_params['outputDirectory'] = self._normalize_value(output_directory) if build_runtime is not None: @@ -405,8 +431,12 @@ def update( api_params['providerSilentMode'] = self._normalize_value(provider_silent_mode) if provider_root_directory is not None: api_params['providerRootDirectory'] = self._normalize_value(provider_root_directory) - if specification is not None: - api_params['specification'] = self._normalize_value(specification) + if build_specification is not None: + api_params['buildSpecification'] = self._normalize_value(build_specification) + if runtime_specification is not None: + api_params['runtimeSpecification'] = self._normalize_value(runtime_specification) + if deployment_retention is not None: + api_params['deploymentRetention'] = self._normalize_value(deployment_retention) response = self.client.call('put', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index 949c6be7..4474038d 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -29,7 +29,7 @@ from ..models.column_url import ColumnUrl; from ..models.column_varchar import ColumnVarchar; from ..models.column_index_list import ColumnIndexList; -from ..enums.index_type import IndexType; +from ..enums.tables_db_index_type import TablesDBIndexType; from ..enums.order_by import OrderBy; from ..models.column_index import ColumnIndex; from ..models.row_list import RowList; @@ -3400,7 +3400,7 @@ def create_index( database_id: str, table_id: str, key: str, - type: IndexType, + type: TablesDBIndexType, columns: List[str], orders: Optional[List[OrderBy]] = None, lengths: Optional[List[float]] = None @@ -3417,7 +3417,7 @@ def create_index( 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 Index Key. - type : IndexType + type : TablesDBIndexType Index type. columns : List[str] Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. diff --git a/appwrite/services/users.py b/appwrite/services/users.py index 605af8cd..62eb4cd3 100644 --- a/appwrite/services/users.py +++ b/appwrite/services/users.py @@ -40,7 +40,7 @@ def list( Parameters ---------- queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator search : Optional[str] Search term to filter your list results. Max length: 256 chars. total : Optional[bool] @@ -835,6 +835,56 @@ def update_email( return User.with_data(response, model_type) + def update_impersonator( + self, + user_id: str, + impersonator: bool, + model_type: Type[T] = dict + ) -> User[T]: + """ + Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + + + Parameters + ---------- + user_id : str + User ID. + impersonator : bool + Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + User[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/users/{userId}/impersonator' + api_params = {} + if user_id is None: + raise AppwriteException('Missing required parameter: "user_id"') + + if impersonator is None: + raise AppwriteException('Missing required parameter: "impersonator"') + + api_path = api_path.replace('{userId}', str(self._normalize_value(user_id))) + + api_params['impersonator'] = self._normalize_value(impersonator) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return User.with_data(response, model_type) + + def create_jwt( self, user_id: str, diff --git a/appwrite/services/vectors_db.py b/appwrite/services/vectors_db.py new file mode 100644 index 00000000..f402e342 --- /dev/null +++ b/appwrite/services/vectors_db.py @@ -0,0 +1,1685 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union, Type, TypeVar +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.database_list import DatabaseList; +from ..models.database import Database; +from ..enums.model import Model; +from ..models.embedding_list import EmbeddingList; +from ..models.transaction_list import TransactionList; +from ..models.transaction import Transaction; +from ..models.vectorsdb_collection_list import VectorsdbCollectionList; +from ..models.vectorsdb_collection import VectorsdbCollection; +from ..models.document_list import DocumentList; +from ..models.document import Document; +from ..models.index_list import IndexList; +from ..enums.vectors_db_index_type import VectorsDBIndexType; +from ..enums.order_by import OrderBy; +from ..models.index import Index; + +T = TypeVar('T') + +class VectorsDB(Service): + + def __init__(self, client) -> None: + super(VectorsDB, self).__init__(client) + + def list( + self, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None + ) -> DatabaseList: + """ + + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + search : Optional[str] + Search term to filter your list results. Max length: 256 chars. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + DatabaseList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if search is not None: + api_params['search'] = self._normalize_value(search) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=DatabaseList) + + + def create( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None + ) -> Database: + """ + + + Parameters + ---------- + database_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Database name. Max length: 128 chars. + enabled : Optional[bool] + Is the 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. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + + api_params['databaseId'] = self._normalize_value(database_id) + api_params['name'] = self._normalize_value(name) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Database) + + + def create_text_embeddings( + self, + texts: List[str], + model: Optional[Model] = None + ) -> EmbeddingList: + """ + + + Parameters + ---------- + texts : List[str] + Array of text to generate embeddings. + model : Optional[Model] + The embedding model to use for generating vector embeddings. + + Returns + ------- + EmbeddingList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/embeddings/text' + api_params = {} + if texts is None: + raise AppwriteException('Missing required parameter: "texts"') + + + api_params['texts'] = self._normalize_value(texts) + if model is not None: + api_params['model'] = self._normalize_value(model) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=EmbeddingList) + + + def list_transactions( + self, + queries: Optional[List[str]] = None + ) -> TransactionList: + """ + + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + + Returns + ------- + TransactionList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=TransactionList) + + + def create_transaction( + self, + ttl: Optional[float] = None + ) -> Transaction: + """ + + + Parameters + ---------- + ttl : Optional[float] + Seconds before the transaction expires. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions' + api_params = {} + + if ttl is not None: + api_params['ttl'] = self._normalize_value(ttl) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def get_transaction( + self, + transaction_id: str + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def update_transaction( + self, + transaction_id: str, + commit: Optional[bool] = None, + rollback: Optional[bool] = None + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + commit : Optional[bool] + Commit transaction? + rollback : Optional[bool] + Rollback transaction? + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + if commit is not None: + api_params['commit'] = self._normalize_value(commit) + if rollback is not None: + api_params['rollback'] = self._normalize_value(rollback) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def delete_transaction( + self, + transaction_id: str + ) -> Dict[str, Any]: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions/{transactionId}' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def create_operations( + self, + transaction_id: str, + operations: Optional[List[Dict[str, Any]]] = None + ) -> Transaction: + """ + + + Parameters + ---------- + transaction_id : str + Transaction ID. + operations : Optional[List[Dict[str, Any]]] + Array of staged operations. + + Returns + ------- + Transaction + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/transactions/{transactionId}/operations' + api_params = {} + if transaction_id is None: + raise AppwriteException('Missing required parameter: "transaction_id"') + + api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) + + if operations is not None: + api_params['operations'] = self._normalize_value(operations) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Transaction) + + + def get( + self, + database_id: str + ) -> Database: + """ + + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Database) + + + def update( + self, + database_id: str, + name: str, + enabled: Optional[bool] = None + ) -> Database: + """ + + + Parameters + ---------- + database_id : str + Database ID. + name : 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. + + Returns + ------- + Database + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}' + api_params = {} + 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}', str(self._normalize_value(database_id))) + + api_params['name'] = self._normalize_value(name) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Database) + + + def delete( + self, + database_id: str + ) -> Dict[str, Any]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_collections( + self, + database_id: str, + queries: Optional[List[str]] = None, + search: Optional[str] = None, + total: Optional[bool] = None + ) -> VectorsdbCollectionList: + """ + + + Parameters + ---------- + database_id : str + Database ID. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + search : Optional[str] + Search term to filter your list results. Max length: 256 chars. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + VectorsdbCollectionList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections' + api_params = {} + if database_id is None: + raise AppwriteException('Missing required parameter: "database_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if search is not None: + api_params['search'] = self._normalize_value(search) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=VectorsdbCollectionList) + + + def create_collection( + self, + database_id: str, + collection_id: str, + name: str, + dimension: float, + permissions: Optional[List[str]] = None, + document_security: Optional[bool] = None, + enabled: Optional[bool] = None + ) -> VectorsdbCollection: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + name : str + Collection name. Max length: 128 chars. + dimension : float + Embedding dimension. + permissions : Optional[List[str]] + An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + document_security : Optional[bool] + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : Optional[bool] + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + + Returns + ------- + VectorsdbCollection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections' + 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 name is None: + raise AppwriteException('Missing required parameter: "name"') + + if dimension is None: + raise AppwriteException('Missing required parameter: "dimension"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + + api_params['collectionId'] = self._normalize_value(collection_id) + api_params['name'] = self._normalize_value(name) + api_params['dimension'] = self._normalize_value(dimension) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if document_security is not None: + api_params['documentSecurity'] = self._normalize_value(document_security) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=VectorsdbCollection) + + + def get_collection( + self, + database_id: str, + collection_id: str + ) -> VectorsdbCollection: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + VectorsdbCollection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=VectorsdbCollection) + + + def update_collection( + self, + database_id: str, + collection_id: str, + name: str, + dimension: Optional[float] = None, + permissions: Optional[List[str]] = None, + document_security: Optional[bool] = None, + enabled: Optional[bool] = None + ) -> VectorsdbCollection: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + name : str + Collection name. Max length: 128 chars. + dimension : Optional[float] + Embedding dimensions. + 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). + document_security : Optional[bool] + Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + enabled : Optional[bool] + Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + + Returns + ------- + VectorsdbCollection + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + 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 name is None: + raise AppwriteException('Missing required parameter: "name"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['name'] = self._normalize_value(name) + if dimension is not None: + api_params['dimension'] = self._normalize_value(dimension) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if document_security is not None: + api_params['documentSecurity'] = self._normalize_value(document_security) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=VectorsdbCollection) + + + def delete_collection( + self, + database_id: str, + collection_id: str + ) -> Dict[str, Any]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + total: Optional[bool] = None, + ttl: Optional[float] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID to read uncommitted changes within the transaction. + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + ttl : Optional[float] + TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + if total is not None: + api_params['total'] = self._normalize_value(total) + if ttl is not None: + api_params['ttl'] = self._normalize_value(ttl) + + response = self.client.call('get', api_path, { + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def create_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Dict[str, Any], + permissions: Optional[List[str]] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + + + 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). Make sure to define attributes before creating documents. + document_id : str + Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + data : Dict[str, Any] + Document data as JSON object. + permissions : Optional[List[str]] + An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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 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}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documentId'] = self._normalize_value(document_id) + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def create_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + + + 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). Make sure to define attributes before creating documents. + documents : List[Dict[str, Any]] + Array of documents data as JSON objects. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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 documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documents'] = self._normalize_value(documents) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def upsert_documents( + self, + database_id: str, + collection_id: str, + documents: List[Dict[str, Any]], + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + documents : List[Dict[str, Any]] + Array of document data as JSON objects. May contain partial documents. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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 documents is None: + raise AppwriteException('Missing required parameter: "documents"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['documents'] = self._normalize_value(documents) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def update_documents( + self, + database_id: str, + collection_id: str, + data: Optional[Dict[str, Any]] = None, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include only attribute and value pairs to be updated. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def delete_documents( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> DocumentList[T]: + """ + + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + DocumentList[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return DocumentList.with_data(response, model_type) + + + def get_document( + self, + database_id: str, + collection_id: str, + document_id: str, + queries: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + + + 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). + document_id : str + Document ID. + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + transaction_id : Optional[str] + Transaction ID to read uncommitted changes within the transaction. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('get', api_path, { + }, api_params) + + return Document.with_data(response, model_type) + + + def upsert_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include all required fields 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). + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def update_document( + self, + database_id: str, + collection_id: str, + document_id: str, + data: Optional[Dict[str, Any]] = None, + permissions: Optional[List[str]] = None, + transaction_id: Optional[str] = None, + model_type: Type[T] = dict + ) -> Document[T]: + """ + + + Parameters + ---------- + database_id : str + Database ID. + collection_id : str + Collection ID. + document_id : str + Document ID. + data : Optional[Dict[str, Any]] + Document data as JSON object. Include only fields and value pairs to be 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). + transaction_id : Optional[str] + Transaction ID for staging the operation. + + model_type : Type[T], optional + Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. + + Returns + ------- + Document[T] + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if data is not None: + api_params['data'] = self._normalize_value(data) + if permissions is not None: + api_params['permissions'] = self._normalize_value(permissions) + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return Document.with_data(response, model_type) + + + def delete_document( + self, + database_id: str, + collection_id: str, + document_id: str, + transaction_id: Optional[str] = None + ) -> Dict[str, Any]: + """ + + + 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). + document_id : str + Document ID. + transaction_id : Optional[str] + Transaction ID for staging the operation. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + 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 document_id is None: + raise AppwriteException('Missing required parameter: "document_id"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) + + if transaction_id is not None: + api_params['transactionId'] = self._normalize_value(transaction_id) + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def list_indexes( + self, + database_id: str, + collection_id: str, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> IndexList: + """ + + + 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). + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + IndexList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + 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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=IndexList) + + + def create_index( + self, + database_id: str, + collection_id: str, + key: str, + type: VectorsDBIndexType, + attributes: List[str], + orders: Optional[List[OrderBy]] = None, + lengths: Optional[List[float]] = None + ) -> Index: + """ + + + 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 + Index Key. + type : VectorsDBIndexType + Index type. + attributes : List[str] + Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + orders : Optional[List[OrderBy]] + Array of index orders. Maximum of 100 orders are allowed. + lengths : Optional[List[float]] + Length of index. Maximum of 100 + + Returns + ------- + Index + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + 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 type is None: + raise AppwriteException('Missing required parameter: "type"') + + if attributes is None: + raise AppwriteException('Missing required parameter: "attributes"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + + api_params['key'] = self._normalize_value(key) + api_params['type'] = self._normalize_value(type) + api_params['attributes'] = self._normalize_value(attributes) + if orders is not None: + api_params['orders'] = self._normalize_value(orders) + if lengths is not None: + api_params['lengths'] = self._normalize_value(lengths) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Index) + + + def get_index( + self, + database_id: str, + collection_id: str, + key: str + ) -> Index: + """ + + + 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 + Index Key. + + Returns + ------- + Index + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Index) + + + def delete_index( + self, + database_id: str, + collection_id: str, + key: str + ) -> Dict[str, Any]: + """ + + + 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 + Index Key. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{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"') + + api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) + api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) + api_path = api_path.replace('{key}', str(self._normalize_value(key))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + diff --git a/appwrite/services/webhooks.py b/appwrite/services/webhooks.py new file mode 100644 index 00000000..71e779cc --- /dev/null +++ b/appwrite/services/webhooks.py @@ -0,0 +1,322 @@ +from ..service import Service +from typing import Any, Dict, List, Optional, Union +from ..exception import AppwriteException +from appwrite.utils.deprecated import deprecated +from ..models.webhook_list import WebhookList; +from ..models.webhook import Webhook; + +class Webhooks(Service): + + def __init__(self, client) -> None: + super(Webhooks, self).__init__(client) + + def list( + self, + queries: Optional[List[str]] = None, + total: Optional[bool] = None + ) -> WebhookList: + """ + Get a list of all webhooks belonging to the project. You can use the query params to filter your results. + + Parameters + ---------- + queries : Optional[List[str]] + Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + total : Optional[bool] + When set to false, the total count returned will be 0 and will not be calculated. + + Returns + ------- + WebhookList + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks' + api_params = {} + + if queries is not None: + api_params['queries'] = self._normalize_value(queries) + if total is not None: + api_params['total'] = self._normalize_value(total) + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=WebhookList) + + + def create( + self, + webhook_id: str, + url: str, + name: str, + events: List[str], + enabled: Optional[bool] = None, + security: Optional[bool] = None, + http_user: Optional[str] = None, + http_pass: Optional[str] = None + ) -> Webhook: + """ + Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + + Parameters + ---------- + webhook_id : str + Webhook ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + url : str + Webhook URL. + name : str + Webhook name. Max length: 128 chars. + events : List[str] + Events list. Maximum of 100 events are allowed. + enabled : Optional[bool] + Enable or disable a webhook. + security : Optional[bool] + Certificate verification, false for disabled or true for enabled. + http_user : Optional[str] + Webhook HTTP user. Max length: 256 chars. + http_pass : Optional[str] + Webhook HTTP password. Max length: 256 chars. + + Returns + ------- + Webhook + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks' + api_params = {} + if webhook_id is None: + raise AppwriteException('Missing required parameter: "webhook_id"') + + if url is None: + raise AppwriteException('Missing required parameter: "url"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if events is None: + raise AppwriteException('Missing required parameter: "events"') + + + api_params['webhookId'] = self._normalize_value(webhook_id) + api_params['url'] = self._normalize_value(url) + api_params['name'] = self._normalize_value(name) + api_params['events'] = self._normalize_value(events) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + if security is not None: + api_params['security'] = self._normalize_value(security) + if http_user is not None: + api_params['httpUser'] = self._normalize_value(http_user) + if http_pass is not None: + api_params['httpPass'] = self._normalize_value(http_pass) + + response = self.client.call('post', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Webhook) + + + def get( + self, + webhook_id: str + ) -> Webhook: + """ + Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + + Parameters + ---------- + webhook_id : str + Webhook ID. + + Returns + ------- + Webhook + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks/{webhookId}' + api_params = {} + if webhook_id is None: + raise AppwriteException('Missing required parameter: "webhook_id"') + + api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) + + + response = self.client.call('get', api_path, { + }, api_params) + + return self._parse_response(response, model=Webhook) + + + def update( + self, + webhook_id: str, + name: str, + url: str, + events: List[str], + enabled: Optional[bool] = None, + security: Optional[bool] = None, + http_user: Optional[str] = None, + http_pass: Optional[str] = None + ) -> Webhook: + """ + Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + + Parameters + ---------- + webhook_id : str + Webhook ID. + name : str + Webhook name. Max length: 128 chars. + url : str + Webhook URL. + events : List[str] + Events list. Maximum of 100 events are allowed. + enabled : Optional[bool] + Enable or disable a webhook. + security : Optional[bool] + Certificate verification, false for disabled or true for enabled. + http_user : Optional[str] + Webhook HTTP user. Max length: 256 chars. + http_pass : Optional[str] + Webhook HTTP password. Max length: 256 chars. + + Returns + ------- + Webhook + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks/{webhookId}' + api_params = {} + if webhook_id is None: + raise AppwriteException('Missing required parameter: "webhook_id"') + + if name is None: + raise AppwriteException('Missing required parameter: "name"') + + if url is None: + raise AppwriteException('Missing required parameter: "url"') + + if events is None: + raise AppwriteException('Missing required parameter: "events"') + + api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) + + api_params['name'] = self._normalize_value(name) + api_params['url'] = self._normalize_value(url) + api_params['events'] = self._normalize_value(events) + if enabled is not None: + api_params['enabled'] = self._normalize_value(enabled) + if security is not None: + api_params['security'] = self._normalize_value(security) + if http_user is not None: + api_params['httpUser'] = self._normalize_value(http_user) + if http_pass is not None: + api_params['httpPass'] = self._normalize_value(http_pass) + + response = self.client.call('put', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Webhook) + + + def delete( + self, + webhook_id: str + ) -> Dict[str, Any]: + """ + Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + + Parameters + ---------- + webhook_id : str + Webhook ID. + + Returns + ------- + Dict[str, Any] + API response as a dictionary + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks/{webhookId}' + api_params = {} + if webhook_id is None: + raise AppwriteException('Missing required parameter: "webhook_id"') + + api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) + + + response = self.client.call('delete', api_path, { + 'content-type': 'application/json', + }, api_params) + + return response + + + def update_signature( + self, + webhook_id: str + ) -> Webhook: + """ + Update the webhook signature key. This endpoint can be used to regenerate the signature key used to sign and validate payload deliveries for a specific webhook. + + Parameters + ---------- + webhook_id : str + Webhook ID. + + Returns + ------- + Webhook + API response as a typed Pydantic model + + Raises + ------ + AppwriteException + If API request fails + """ + + api_path = '/webhooks/{webhookId}/signature' + api_params = {} + if webhook_id is None: + raise AppwriteException('Missing required parameter: "webhook_id"') + + api_path = api_path.replace('{webhookId}', str(self._normalize_value(webhook_id))) + + + response = self.client.call('patch', api_path, { + 'content-type': 'application/json', + }, api_params) + + return self._parse_response(response, model=Webhook) + diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 21cd229a..e973ae0b 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -2,7 +2,7 @@ from appwrite.client import Client from appwrite.services.databases import Databases from appwrite.models import Index -from appwrite.enums import IndexType +from appwrite.enums import DatabasesIndexType from appwrite.enums import OrderBy client = Client() @@ -16,7 +16,7 @@ result: Index = databases.create_index( database_id = '', collection_id = '', key = '', - type = IndexType.KEY, + type = DatabasesIndexType.KEY, attributes = [], orders = [OrderBy.ASC], # optional lengths = [] # optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 5039ccb0..50b78fc1 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -6,7 +6,7 @@ from appwrite.models import DocumentList 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 +client.set_session('') # The user session to authenticate with databases = Databases(client) diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md new file mode 100644 index 00000000..b717460f --- /dev/null +++ b/docs/examples/documentsdb/create-collection.md @@ -0,0 +1,27 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Collection +from appwrite.permission import Permission +from appwrite.role import Role + +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 + +documents_db = DocumentsDB(client) + +result: Collection = documents_db.create_collection( + database_id = '', + collection_id = '', + name = '', + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False, # optional + attributes = [], # optional + indexes = [] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md new file mode 100644 index 00000000..1fa38033 --- /dev/null +++ b/docs/examples/documentsdb/create-document.md @@ -0,0 +1,30 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.create_document( + database_id = '', + collection_id = '', + document_id = '', + data = { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": False + }, + permissions = [Permission.read(Role.any())] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md new file mode 100644 index 00000000..661c32dd --- /dev/null +++ b/docs/examples/documentsdb/create-documents.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DocumentList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: DocumentList = documents_db.create_documents( + database_id = '', + collection_id = '', + documents = [] +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md new file mode 100644 index 00000000..3f2fcf0b --- /dev/null +++ b/docs/examples/documentsdb/create-index.md @@ -0,0 +1,26 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Index +from appwrite.enums import DocumentsDBIndexType +from appwrite.enums import OrderBy + +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 + +documents_db = DocumentsDB(client) + +result: Index = documents_db.create_index( + database_id = '', + collection_id = '', + key = '', + type = DocumentsDBIndexType.KEY, + attributes = [], + orders = [OrderBy.ASC], # optional + lengths = [] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md new file mode 100644 index 00000000..23128e81 --- /dev/null +++ b/docs/examples/documentsdb/create-operations.md @@ -0,0 +1,29 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Transaction + +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 + +documents_db = DocumentsDB(client) + +result: Transaction = documents_db.create_operations( + transaction_id = '', + operations = [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md new file mode 100644 index 00000000..d34b358e --- /dev/null +++ b/docs/examples/documentsdb/create-transaction.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Transaction + +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 + +documents_db = DocumentsDB(client) + +result: Transaction = documents_db.create_transaction( + ttl = 60 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md new file mode 100644 index 00000000..753759be --- /dev/null +++ b/docs/examples/documentsdb/create.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Database + +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 + +documents_db = DocumentsDB(client) + +result: Database = documents_db.create( + database_id = '', + name = '', + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md new file mode 100644 index 00000000..d10b6f2b --- /dev/null +++ b/docs/examples/documentsdb/decrement-document-attribute.md @@ -0,0 +1,24 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.decrement_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = None, # optional + min = None, # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md new file mode 100644 index 00000000..1652ab2b --- /dev/null +++ b/docs/examples/documentsdb/delete-collection.md @@ -0,0 +1,16 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB + +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 + +documents_db = DocumentsDB(client) + +result = documents_db.delete_collection( + database_id = '', + collection_id = '' +) +``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md new file mode 100644 index 00000000..e588088e --- /dev/null +++ b/docs/examples/documentsdb/delete-document.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result = documents_db.delete_document( + database_id = '', + collection_id = '', + document_id = '', + transaction_id = '' # optional +) +``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md new file mode 100644 index 00000000..8bc343de --- /dev/null +++ b/docs/examples/documentsdb/delete-documents.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DocumentList + +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 + +documents_db = DocumentsDB(client) + +result: DocumentList = documents_db.delete_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md new file mode 100644 index 00000000..da51459d --- /dev/null +++ b/docs/examples/documentsdb/delete-index.md @@ -0,0 +1,17 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB + +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 + +documents_db = DocumentsDB(client) + +result = documents_db.delete_index( + database_id = '', + collection_id = '', + key = '' +) +``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md new file mode 100644 index 00000000..009bf807 --- /dev/null +++ b/docs/examples/documentsdb/delete-transaction.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB + +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 + +documents_db = DocumentsDB(client) + +result = documents_db.delete_transaction( + transaction_id = '' +) +``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md new file mode 100644 index 00000000..64845091 --- /dev/null +++ b/docs/examples/documentsdb/delete.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB + +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 + +documents_db = DocumentsDB(client) + +result = documents_db.delete( + database_id = '' +) +``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md new file mode 100644 index 00000000..5ec739b8 --- /dev/null +++ b/docs/examples/documentsdb/get-collection.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Collection + +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 + +documents_db = DocumentsDB(client) + +result: Collection = documents_db.get_collection( + database_id = '', + collection_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md new file mode 100644 index 00000000..3f0006e7 --- /dev/null +++ b/docs/examples/documentsdb/get-document.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.get_document( + database_id = '', + collection_id = '', + document_id = '', + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md new file mode 100644 index 00000000..f3887506 --- /dev/null +++ b/docs/examples/documentsdb/get-index.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Index + +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 + +documents_db = DocumentsDB(client) + +result: Index = documents_db.get_index( + database_id = '', + collection_id = '', + key = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md new file mode 100644 index 00000000..27d88ee7 --- /dev/null +++ b/docs/examples/documentsdb/get-transaction.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Transaction + +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 + +documents_db = DocumentsDB(client) + +result: Transaction = documents_db.get_transaction( + transaction_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md new file mode 100644 index 00000000..fc2ffb9b --- /dev/null +++ b/docs/examples/documentsdb/get.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Database + +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 + +documents_db = DocumentsDB(client) + +result: Database = documents_db.get( + database_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md new file mode 100644 index 00000000..c235865a --- /dev/null +++ b/docs/examples/documentsdb/increment-document-attribute.md @@ -0,0 +1,24 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.increment_document_attribute( + database_id = '', + collection_id = '', + document_id = '', + attribute = '', + value = None, # optional + max = None, # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md new file mode 100644 index 00000000..0d72a376 --- /dev/null +++ b/docs/examples/documentsdb/list-collections.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import CollectionList + +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 + +documents_db = DocumentsDB(client) + +result: CollectionList = documents_db.list_collections( + database_id = '', + queries = [], # optional + search = '', # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md new file mode 100644 index 00000000..c1b2a360 --- /dev/null +++ b/docs/examples/documentsdb/list-documents.md @@ -0,0 +1,23 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DocumentList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: DocumentList = documents_db.list_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md new file mode 100644 index 00000000..26655d72 --- /dev/null +++ b/docs/examples/documentsdb/list-indexes.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import IndexList + +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 + +documents_db = DocumentsDB(client) + +result: IndexList = documents_db.list_indexes( + database_id = '', + collection_id = '', + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md new file mode 100644 index 00000000..6dc7aae2 --- /dev/null +++ b/docs/examples/documentsdb/list-transactions.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import TransactionList + +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 + +documents_db = DocumentsDB(client) + +result: TransactionList = documents_db.list_transactions( + queries = [] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md new file mode 100644 index 00000000..5fbe9484 --- /dev/null +++ b/docs/examples/documentsdb/list.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DatabaseList + +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 + +documents_db = DocumentsDB(client) + +result: DatabaseList = documents_db.list( + queries = [], # optional + search = '', # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md new file mode 100644 index 00000000..2a5101dd --- /dev/null +++ b/docs/examples/documentsdb/update-collection.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Collection +from appwrite.permission import Permission +from appwrite.role import Role + +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 + +documents_db = DocumentsDB(client) + +result: Collection = documents_db.update_collection( + database_id = '', + collection_id = '', + name = '', + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md new file mode 100644 index 00000000..cf0bfcc9 --- /dev/null +++ b/docs/examples/documentsdb/update-document.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.update_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md new file mode 100644 index 00000000..2c183e55 --- /dev/null +++ b/docs/examples/documentsdb/update-documents.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DocumentList + +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 + +documents_db = DocumentsDB(client) + +result: DocumentList = documents_db.update_documents( + database_id = '', + collection_id = '', + data = {}, # optional + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md new file mode 100644 index 00000000..fff946cb --- /dev/null +++ b/docs/examples/documentsdb/update-transaction.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Transaction + +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 + +documents_db = DocumentsDB(client) + +result: Transaction = documents_db.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md new file mode 100644 index 00000000..1e0c0692 --- /dev/null +++ b/docs/examples/documentsdb/update.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Database + +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 + +documents_db = DocumentsDB(client) + +result: Database = documents_db.update( + database_id = '', + name = '', + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md new file mode 100644 index 00000000..07086f4a --- /dev/null +++ b/docs/examples/documentsdb/upsert-document.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +documents_db = DocumentsDB(client) + +result: Document = documents_db.upsert_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md new file mode 100644 index 00000000..d98b227c --- /dev/null +++ b/docs/examples/documentsdb/upsert-documents.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.documents_db import DocumentsDB +from appwrite.models import DocumentList + +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 + +documents_db = DocumentsDB(client) + +result: DocumentList = documents_db.upsert_documents( + database_id = '', + collection_id = '', + documents = [], + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 3ff4e121..235df705 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -30,7 +30,9 @@ result: Function = functions.create( provider_branch = '', # optional provider_silent_mode = False, # optional provider_root_directory = '', # optional - specification = '' # optional + build_specification = '', # optional + runtime_specification = '', # optional + deployment_retention = 0 # optional ) print(result.model_dump()) diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index a34dfc12..181626c4 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -30,7 +30,9 @@ result: Function = functions.update( provider_branch = '', # optional provider_silent_mode = False, # optional provider_root_directory = '', # optional - specification = '' # optional + build_specification = '', # optional + runtime_specification = '', # optional + deployment_retention = 0 # optional ) print(result.model_dump()) diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md new file mode 100644 index 00000000..668e3548 --- /dev/null +++ b/docs/examples/project/create-variable.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Variable + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: Variable = project.create_variable( + variable_id = '', + key = '', + value = '', + secret = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md new file mode 100644 index 00000000..89b16d21 --- /dev/null +++ b/docs/examples/project/delete-variable.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result = project.delete_variable( + variable_id = '' +) +``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md new file mode 100644 index 00000000..9771151a --- /dev/null +++ b/docs/examples/project/get-variable.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Variable + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: Variable = project.get_variable( + variable_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md new file mode 100644 index 00000000..4316f7c3 --- /dev/null +++ b/docs/examples/project/list-variables.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import VariableList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: VariableList = project.list_variables( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md new file mode 100644 index 00000000..3f4dac0f --- /dev/null +++ b/docs/examples/project/update-variable.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.project import Project +from appwrite.models import Variable + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_key('') # Your secret API key + +project = Project(client) + +result: Variable = project.update_variable( + variable_id = '', + key = '', # optional + value = '', # optional + secret = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 67eb46c0..9fa508a1 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -23,6 +23,7 @@ result: Site = sites.create( timeout = 1, # optional install_command = '', # optional build_command = '', # optional + start_command = '', # optional output_directory = '', # optional adapter = Adapter.STATIC, # optional installation_id = '', # optional @@ -31,7 +32,9 @@ result: Site = sites.create( provider_branch = '', # optional provider_silent_mode = False, # optional provider_root_directory = '', # optional - specification = '' # optional + build_specification = '', # optional + runtime_specification = '', # optional + deployment_retention = 0 # optional ) print(result.model_dump()) diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index bdfe2b14..3ce49756 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -22,6 +22,7 @@ result: Site = sites.update( timeout = 1, # optional install_command = '', # optional build_command = '', # optional + start_command = '', # optional output_directory = '', # optional build_runtime = BuildRuntime.NODE_14_5, # optional adapter = Adapter.STATIC, # optional @@ -31,7 +32,9 @@ result: Site = sites.update( provider_branch = '', # optional provider_silent_mode = False, # optional provider_root_directory = '', # optional - specification = '' # optional + build_specification = '', # optional + runtime_specification = '', # optional + deployment_retention = 0 # optional ) print(result.model_dump()) diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index acf0792c..54b23a25 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -2,7 +2,7 @@ from appwrite.client import Client from appwrite.services.tables_db import TablesDB from appwrite.models import ColumnIndex -from appwrite.enums import IndexType +from appwrite.enums import TablesDBIndexType from appwrite.enums import OrderBy client = Client() @@ -16,7 +16,7 @@ result: ColumnIndex = tables_db.create_index( database_id = '', table_id = '', key = '', - type = IndexType.KEY, + type = TablesDBIndexType.KEY, columns = [], orders = [OrderBy.ASC], # optional lengths = [] # optional diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 00000000..38fae13c --- /dev/null +++ b/docs/examples/users/update-impersonator.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.users import Users +from appwrite.models import User + +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 + +users = Users(client) + +result: User = users.update_impersonator( + user_id = '', + impersonator = False +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md new file mode 100644 index 00000000..793aa3f5 --- /dev/null +++ b/docs/examples/vectorsdb/create-collection.md @@ -0,0 +1,26 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import VectorsdbCollection +from appwrite.permission import Permission +from appwrite.role import Role + +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 + +vectors_db = VectorsDB(client) + +result: VectorsdbCollection = vectors_db.create_collection( + database_id = '', + collection_id = '', + name = '', + dimension = 1, + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md new file mode 100644 index 00000000..d032a991 --- /dev/null +++ b/docs/examples/vectorsdb/create-document.md @@ -0,0 +1,34 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result: Document = vectors_db.create_document( + database_id = '', + collection_id = '', + document_id = '', + data = { + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "key": "value" + } + }, + permissions = [Permission.read(Role.any())] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md new file mode 100644 index 00000000..431aec82 --- /dev/null +++ b/docs/examples/vectorsdb/create-documents.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DocumentList + +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 + +vectors_db = VectorsDB(client) + +result: DocumentList = vectors_db.create_documents( + database_id = '', + collection_id = '', + documents = [] +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md new file mode 100644 index 00000000..e0656bce --- /dev/null +++ b/docs/examples/vectorsdb/create-index.md @@ -0,0 +1,26 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Index +from appwrite.enums import VectorsDBIndexType +from appwrite.enums import OrderBy + +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 + +vectors_db = VectorsDB(client) + +result: Index = vectors_db.create_index( + database_id = '', + collection_id = '', + key = '', + type = VectorsDBIndexType.HNSW_EUCLIDEAN, + attributes = [], + orders = [OrderBy.ASC], # optional + lengths = [] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md new file mode 100644 index 00000000..e19a8936 --- /dev/null +++ b/docs/examples/vectorsdb/create-operations.md @@ -0,0 +1,29 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Transaction + +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 + +vectors_db = VectorsDB(client) + +result: Transaction = vectors_db.create_operations( + transaction_id = '', + operations = [ + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/vectorsdb/create-text-embeddings.md new file mode 100644 index 00000000..d4780931 --- /dev/null +++ b/docs/examples/vectorsdb/create-text-embeddings.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import EmbeddingList +from appwrite.enums import Model + +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 + +vectors_db = VectorsDB(client) + +result: EmbeddingList = vectors_db.create_text_embeddings( + texts = [], + model = Model.EMBEDDINGGEMMA # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md new file mode 100644 index 00000000..6b6cd631 --- /dev/null +++ b/docs/examples/vectorsdb/create-transaction.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Transaction + +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 + +vectors_db = VectorsDB(client) + +result: Transaction = vectors_db.create_transaction( + ttl = 60 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md new file mode 100644 index 00000000..2fe4347f --- /dev/null +++ b/docs/examples/vectorsdb/create.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Database + +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 + +vectors_db = VectorsDB(client) + +result: Database = vectors_db.create( + database_id = '', + name = '', + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md new file mode 100644 index 00000000..b96a628b --- /dev/null +++ b/docs/examples/vectorsdb/delete-collection.md @@ -0,0 +1,16 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB + +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 + +vectors_db = VectorsDB(client) + +result = vectors_db.delete_collection( + database_id = '', + collection_id = '' +) +``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md new file mode 100644 index 00000000..3915b937 --- /dev/null +++ b/docs/examples/vectorsdb/delete-document.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result = vectors_db.delete_document( + database_id = '', + collection_id = '', + document_id = '', + transaction_id = '' # optional +) +``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md new file mode 100644 index 00000000..f1bee6ee --- /dev/null +++ b/docs/examples/vectorsdb/delete-documents.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DocumentList + +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 + +vectors_db = VectorsDB(client) + +result: DocumentList = vectors_db.delete_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md new file mode 100644 index 00000000..7dc89739 --- /dev/null +++ b/docs/examples/vectorsdb/delete-index.md @@ -0,0 +1,17 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB + +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 + +vectors_db = VectorsDB(client) + +result = vectors_db.delete_index( + database_id = '', + collection_id = '', + key = '' +) +``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md new file mode 100644 index 00000000..58a367f7 --- /dev/null +++ b/docs/examples/vectorsdb/delete-transaction.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB + +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 + +vectors_db = VectorsDB(client) + +result = vectors_db.delete_transaction( + transaction_id = '' +) +``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md new file mode 100644 index 00000000..da1c5a49 --- /dev/null +++ b/docs/examples/vectorsdb/delete.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB + +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 + +vectors_db = VectorsDB(client) + +result = vectors_db.delete( + database_id = '' +) +``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md new file mode 100644 index 00000000..2616d72a --- /dev/null +++ b/docs/examples/vectorsdb/get-collection.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import VectorsdbCollection + +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 + +vectors_db = VectorsDB(client) + +result: VectorsdbCollection = vectors_db.get_collection( + database_id = '', + collection_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md new file mode 100644 index 00000000..a484c5dd --- /dev/null +++ b/docs/examples/vectorsdb/get-document.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Document + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result: Document = vectors_db.get_document( + database_id = '', + collection_id = '', + document_id = '', + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md new file mode 100644 index 00000000..31f91044 --- /dev/null +++ b/docs/examples/vectorsdb/get-index.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Index + +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 + +vectors_db = VectorsDB(client) + +result: Index = vectors_db.get_index( + database_id = '', + collection_id = '', + key = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md new file mode 100644 index 00000000..601ed0b0 --- /dev/null +++ b/docs/examples/vectorsdb/get-transaction.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Transaction + +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 + +vectors_db = VectorsDB(client) + +result: Transaction = vectors_db.get_transaction( + transaction_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md new file mode 100644 index 00000000..b251b427 --- /dev/null +++ b/docs/examples/vectorsdb/get.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Database + +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 + +vectors_db = VectorsDB(client) + +result: Database = vectors_db.get( + database_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md new file mode 100644 index 00000000..184c3c3f --- /dev/null +++ b/docs/examples/vectorsdb/list-collections.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import VectorsdbCollectionList + +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 + +vectors_db = VectorsDB(client) + +result: VectorsdbCollectionList = vectors_db.list_collections( + database_id = '', + queries = [], # optional + search = '', # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md new file mode 100644 index 00000000..5ac3ab2f --- /dev/null +++ b/docs/examples/vectorsdb/list-documents.md @@ -0,0 +1,23 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DocumentList + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result: DocumentList = vectors_db.list_documents( + database_id = '', + collection_id = '', + queries = [], # optional + transaction_id = '', # optional + total = False, # optional + ttl = 0 # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md new file mode 100644 index 00000000..c72e9800 --- /dev/null +++ b/docs/examples/vectorsdb/list-indexes.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import IndexList + +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 + +vectors_db = VectorsDB(client) + +result: IndexList = vectors_db.list_indexes( + database_id = '', + collection_id = '', + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md new file mode 100644 index 00000000..d21db012 --- /dev/null +++ b/docs/examples/vectorsdb/list-transactions.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import TransactionList + +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 + +vectors_db = VectorsDB(client) + +result: TransactionList = vectors_db.list_transactions( + queries = [] # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md new file mode 100644 index 00000000..ac87bca3 --- /dev/null +++ b/docs/examples/vectorsdb/list.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DatabaseList + +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 + +vectors_db = VectorsDB(client) + +result: DatabaseList = vectors_db.list( + queries = [], # optional + search = '', # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md new file mode 100644 index 00000000..3dcf8903 --- /dev/null +++ b/docs/examples/vectorsdb/update-collection.md @@ -0,0 +1,26 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import VectorsdbCollection +from appwrite.permission import Permission +from appwrite.role import Role + +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 + +vectors_db = VectorsDB(client) + +result: VectorsdbCollection = vectors_db.update_collection( + database_id = '', + collection_id = '', + name = '', + dimension = 1, # optional + permissions = [Permission.read(Role.any())], # optional + document_security = False, # optional + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md new file mode 100644 index 00000000..c70c2bc1 --- /dev/null +++ b/docs/examples/vectorsdb/update-document.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result: Document = vectors_db.update_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md new file mode 100644 index 00000000..5c947cd1 --- /dev/null +++ b/docs/examples/vectorsdb/update-documents.md @@ -0,0 +1,22 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DocumentList + +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 + +vectors_db = VectorsDB(client) + +result: DocumentList = vectors_db.update_documents( + database_id = '', + collection_id = '', + data = {}, # optional + queries = [], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md new file mode 100644 index 00000000..276c25c8 --- /dev/null +++ b/docs/examples/vectorsdb/update-transaction.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Transaction + +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 + +vectors_db = VectorsDB(client) + +result: Transaction = vectors_db.update_transaction( + transaction_id = '', + commit = False, # optional + rollback = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md new file mode 100644 index 00000000..c2bcb3dc --- /dev/null +++ b/docs/examples/vectorsdb/update.md @@ -0,0 +1,20 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Database + +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 + +vectors_db = VectorsDB(client) + +result: Database = vectors_db.update( + database_id = '', + name = '', + enabled = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md new file mode 100644 index 00000000..95f916d3 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-document.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import Document +from appwrite.permission import Permission +from appwrite.role import Role + +client = Client() +client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('') # Your project ID +client.set_session('') # The user session to authenticate with + +vectors_db = VectorsDB(client) + +result: Document = vectors_db.upsert_document( + database_id = '', + collection_id = '', + document_id = '', + data = {}, # optional + permissions = [Permission.read(Role.any())], # optional + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md new file mode 100644 index 00000000..5eb3d2d1 --- /dev/null +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -0,0 +1,21 @@ +```python +from appwrite.client import Client +from appwrite.services.vectors_db import VectorsDB +from appwrite.models import DocumentList + +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 + +vectors_db = VectorsDB(client) + +result: DocumentList = vectors_db.upsert_documents( + database_id = '', + collection_id = '', + documents = [], + transaction_id = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md new file mode 100644 index 00000000..11b15986 --- /dev/null +++ b/docs/examples/webhooks/create.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks +from appwrite.models import Webhook + +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 + +webhooks = Webhooks(client) + +result: Webhook = webhooks.create( + webhook_id = '', + url = '', + name = '', + events = [], + enabled = False, # optional + security = False, # optional + http_user = '', # optional + http_pass = '' # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md new file mode 100644 index 00000000..1b6cbdb3 --- /dev/null +++ b/docs/examples/webhooks/delete.md @@ -0,0 +1,15 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks + +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 + +webhooks = Webhooks(client) + +result = webhooks.delete( + webhook_id = '' +) +``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md new file mode 100644 index 00000000..e24808ce --- /dev/null +++ b/docs/examples/webhooks/get.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks +from appwrite.models import Webhook + +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 + +webhooks = Webhooks(client) + +result: Webhook = webhooks.get( + webhook_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md new file mode 100644 index 00000000..0bb23204 --- /dev/null +++ b/docs/examples/webhooks/list.md @@ -0,0 +1,19 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks +from appwrite.models import WebhookList + +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 + +webhooks = Webhooks(client) + +result: WebhookList = webhooks.list( + queries = [], # optional + total = False # optional +) + +print(result.model_dump()) +``` diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-signature.md new file mode 100644 index 00000000..94f739e8 --- /dev/null +++ b/docs/examples/webhooks/update-signature.md @@ -0,0 +1,18 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks +from appwrite.models import Webhook + +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 + +webhooks = Webhooks(client) + +result: Webhook = webhooks.update_signature( + webhook_id = '' +) + +print(result.model_dump()) +``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md new file mode 100644 index 00000000..e13b0558 --- /dev/null +++ b/docs/examples/webhooks/update.md @@ -0,0 +1,25 @@ +```python +from appwrite.client import Client +from appwrite.services.webhooks import Webhooks +from appwrite.models import Webhook + +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 + +webhooks = Webhooks(client) + +result: Webhook = webhooks.update( + webhook_id = '', + name = '', + url = '', + events = [], + enabled = False, # optional + security = False, # optional + http_user = '', # optional + http_pass = '' # optional +) + +print(result.model_dump()) +``` From 44a53f565989da22b4fe8731960ae6ba389fd6f2 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 04:25:31 +0000 Subject: [PATCH 2/9] chore: update Python SDK to 17.0.0 --- CHANGELOG.md | 4 ++++ README.md | 2 +- appwrite/client.py | 4 ++-- pyproject.toml | 2 +- setup.py | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ec77e9..e929f256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 17.0.0 + +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents + ## 16.0.0 * Breaking change: All service methods now return typed Pydantic models instead of `Dict[str, Any]` diff --git a/README.md b/README.md index 85039c66..093450fa 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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).** +**This SDK is compatible with Appwrite server version 1.9.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 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) diff --git a/appwrite/client.py b/appwrite/client.py index 426706e5..f0aacda8 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/16.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/17.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': '16.0.0', + 'x-sdk-version': '17.0.0', 'X-Appwrite-Response-Format' : '1.9.0', } diff --git a/pyproject.toml b/pyproject.toml index 032beff8..858602a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "appwrite" -version = "16.0.0" +version = "17.0.0" description = "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API" readme = "README.md" requires-python = ">=3.9" diff --git a/setup.py b/setup.py index 6c707574..5985828a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '16.0.0', + version = '17.0.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API', long_description = long_description, @@ -18,7 +18,7 @@ maintainer = 'Appwrite Team', maintainer_email = 'team@appwrite.io', url = 'https://appwrite.io/support', - download_url='https://github.com/appwrite/sdk-for-python/archive/16.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/17.0.0.tar.gz', install_requires=[ 'requests', 'pydantic>=2,<3', From ac234201d09cdfa6c45895940d05685e142c31ed Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 05:27:25 +0000 Subject: [PATCH 3/9] chore: update Python SDK to 17.0.0 --- appwrite/services/documents_db.py | 1796 ----------------- appwrite/services/vectors_db.py | 1685 ---------------- .../examples/documentsdb/create-collection.md | 27 - docs/examples/documentsdb/create-document.md | 30 - docs/examples/documentsdb/create-documents.md | 20 - docs/examples/documentsdb/create-index.md | 26 - .../examples/documentsdb/create-operations.md | 29 - .../documentsdb/create-transaction.md | 18 - docs/examples/documentsdb/create.md | 20 - .../decrement-document-attribute.md | 24 - .../examples/documentsdb/delete-collection.md | 16 - docs/examples/documentsdb/delete-document.md | 18 - docs/examples/documentsdb/delete-documents.md | 21 - docs/examples/documentsdb/delete-index.md | 17 - .../documentsdb/delete-transaction.md | 15 - docs/examples/documentsdb/delete.md | 15 - docs/examples/documentsdb/get-collection.md | 19 - docs/examples/documentsdb/get-document.md | 22 - docs/examples/documentsdb/get-index.md | 20 - docs/examples/documentsdb/get-transaction.md | 18 - docs/examples/documentsdb/get.md | 18 - .../increment-document-attribute.md | 24 - docs/examples/documentsdb/list-collections.md | 21 - docs/examples/documentsdb/list-documents.md | 23 - docs/examples/documentsdb/list-indexes.md | 21 - .../examples/documentsdb/list-transactions.md | 18 - docs/examples/documentsdb/list.md | 20 - .../examples/documentsdb/update-collection.md | 25 - docs/examples/documentsdb/update-document.md | 25 - docs/examples/documentsdb/update-documents.md | 22 - .../documentsdb/update-transaction.md | 20 - docs/examples/documentsdb/update.md | 20 - docs/examples/documentsdb/upsert-document.md | 25 - docs/examples/documentsdb/upsert-documents.md | 21 - docs/examples/vectorsdb/create-collection.md | 26 - docs/examples/vectorsdb/create-document.md | 34 - docs/examples/vectorsdb/create-documents.md | 20 - docs/examples/vectorsdb/create-index.md | 26 - docs/examples/vectorsdb/create-operations.md | 29 - .../vectorsdb/create-text-embeddings.md | 20 - docs/examples/vectorsdb/create-transaction.md | 18 - docs/examples/vectorsdb/create.md | 20 - docs/examples/vectorsdb/delete-collection.md | 16 - docs/examples/vectorsdb/delete-document.md | 18 - docs/examples/vectorsdb/delete-documents.md | 21 - docs/examples/vectorsdb/delete-index.md | 17 - docs/examples/vectorsdb/delete-transaction.md | 15 - docs/examples/vectorsdb/delete.md | 15 - docs/examples/vectorsdb/get-collection.md | 19 - docs/examples/vectorsdb/get-document.md | 22 - docs/examples/vectorsdb/get-index.md | 20 - docs/examples/vectorsdb/get-transaction.md | 18 - docs/examples/vectorsdb/get.md | 18 - docs/examples/vectorsdb/list-collections.md | 21 - docs/examples/vectorsdb/list-documents.md | 23 - docs/examples/vectorsdb/list-indexes.md | 21 - docs/examples/vectorsdb/list-transactions.md | 18 - docs/examples/vectorsdb/list.md | 20 - docs/examples/vectorsdb/update-collection.md | 26 - docs/examples/vectorsdb/update-document.md | 25 - docs/examples/vectorsdb/update-documents.md | 22 - docs/examples/vectorsdb/update-transaction.md | 20 - docs/examples/vectorsdb/update.md | 20 - docs/examples/vectorsdb/upsert-document.md | 25 - docs/examples/vectorsdb/upsert-documents.md | 21 - 65 files changed, 4813 deletions(-) delete mode 100644 appwrite/services/documents_db.py delete mode 100644 appwrite/services/vectors_db.py delete mode 100644 docs/examples/documentsdb/create-collection.md delete mode 100644 docs/examples/documentsdb/create-document.md delete mode 100644 docs/examples/documentsdb/create-documents.md delete mode 100644 docs/examples/documentsdb/create-index.md delete mode 100644 docs/examples/documentsdb/create-operations.md delete mode 100644 docs/examples/documentsdb/create-transaction.md delete mode 100644 docs/examples/documentsdb/create.md delete mode 100644 docs/examples/documentsdb/decrement-document-attribute.md delete mode 100644 docs/examples/documentsdb/delete-collection.md delete mode 100644 docs/examples/documentsdb/delete-document.md delete mode 100644 docs/examples/documentsdb/delete-documents.md delete mode 100644 docs/examples/documentsdb/delete-index.md delete mode 100644 docs/examples/documentsdb/delete-transaction.md delete mode 100644 docs/examples/documentsdb/delete.md delete mode 100644 docs/examples/documentsdb/get-collection.md delete mode 100644 docs/examples/documentsdb/get-document.md delete mode 100644 docs/examples/documentsdb/get-index.md delete mode 100644 docs/examples/documentsdb/get-transaction.md delete mode 100644 docs/examples/documentsdb/get.md delete mode 100644 docs/examples/documentsdb/increment-document-attribute.md delete mode 100644 docs/examples/documentsdb/list-collections.md delete mode 100644 docs/examples/documentsdb/list-documents.md delete mode 100644 docs/examples/documentsdb/list-indexes.md delete mode 100644 docs/examples/documentsdb/list-transactions.md delete mode 100644 docs/examples/documentsdb/list.md delete mode 100644 docs/examples/documentsdb/update-collection.md delete mode 100644 docs/examples/documentsdb/update-document.md delete mode 100644 docs/examples/documentsdb/update-documents.md delete mode 100644 docs/examples/documentsdb/update-transaction.md delete mode 100644 docs/examples/documentsdb/update.md delete mode 100644 docs/examples/documentsdb/upsert-document.md delete mode 100644 docs/examples/documentsdb/upsert-documents.md delete mode 100644 docs/examples/vectorsdb/create-collection.md delete mode 100644 docs/examples/vectorsdb/create-document.md delete mode 100644 docs/examples/vectorsdb/create-documents.md delete mode 100644 docs/examples/vectorsdb/create-index.md delete mode 100644 docs/examples/vectorsdb/create-operations.md delete mode 100644 docs/examples/vectorsdb/create-text-embeddings.md delete mode 100644 docs/examples/vectorsdb/create-transaction.md delete mode 100644 docs/examples/vectorsdb/create.md delete mode 100644 docs/examples/vectorsdb/delete-collection.md delete mode 100644 docs/examples/vectorsdb/delete-document.md delete mode 100644 docs/examples/vectorsdb/delete-documents.md delete mode 100644 docs/examples/vectorsdb/delete-index.md delete mode 100644 docs/examples/vectorsdb/delete-transaction.md delete mode 100644 docs/examples/vectorsdb/delete.md delete mode 100644 docs/examples/vectorsdb/get-collection.md delete mode 100644 docs/examples/vectorsdb/get-document.md delete mode 100644 docs/examples/vectorsdb/get-index.md delete mode 100644 docs/examples/vectorsdb/get-transaction.md delete mode 100644 docs/examples/vectorsdb/get.md delete mode 100644 docs/examples/vectorsdb/list-collections.md delete mode 100644 docs/examples/vectorsdb/list-documents.md delete mode 100644 docs/examples/vectorsdb/list-indexes.md delete mode 100644 docs/examples/vectorsdb/list-transactions.md delete mode 100644 docs/examples/vectorsdb/list.md delete mode 100644 docs/examples/vectorsdb/update-collection.md delete mode 100644 docs/examples/vectorsdb/update-document.md delete mode 100644 docs/examples/vectorsdb/update-documents.md delete mode 100644 docs/examples/vectorsdb/update-transaction.md delete mode 100644 docs/examples/vectorsdb/update.md delete mode 100644 docs/examples/vectorsdb/upsert-document.md delete mode 100644 docs/examples/vectorsdb/upsert-documents.md diff --git a/appwrite/services/documents_db.py b/appwrite/services/documents_db.py deleted file mode 100644 index 99ec7277..00000000 --- a/appwrite/services/documents_db.py +++ /dev/null @@ -1,1796 +0,0 @@ -from ..service import Service -from typing import Any, Dict, List, Optional, Union, Type, TypeVar -from ..exception import AppwriteException -from appwrite.utils.deprecated import deprecated -from ..models.database_list import DatabaseList; -from ..models.database import Database; -from ..models.transaction_list import TransactionList; -from ..models.transaction import Transaction; -from ..models.collection_list import CollectionList; -from ..models.collection import Collection; -from ..models.document_list import DocumentList; -from ..models.document import Document; -from ..models.index_list import IndexList; -from ..enums.documents_db_index_type import DocumentsDBIndexType; -from ..enums.order_by import OrderBy; -from ..models.index import Index; - -T = TypeVar('T') - -class DocumentsDB(Service): - - def __init__(self, client) -> None: - super(DocumentsDB, self).__init__(client) - - def list( - self, - queries: Optional[List[str]] = None, - search: Optional[str] = None, - total: Optional[bool] = None - ) -> DatabaseList: - """ - Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. - - Parameters - ---------- - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - search : Optional[str] - Search term to filter your list results. Max length: 256 chars. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - DatabaseList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb' - api_params = {} - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if search is not None: - api_params['search'] = self._normalize_value(search) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=DatabaseList) - - - def create( - self, - database_id: str, - name: str, - enabled: Optional[bool] = None - ) -> Database: - """ - Create a new Database. - - - Parameters - ---------- - database_id : str - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - name : str - Database name. Max length: 128 chars. - enabled : Optional[bool] - Is the 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. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - - api_params['databaseId'] = self._normalize_value(database_id) - api_params['name'] = self._normalize_value(name) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Database) - - - def list_transactions( - self, - queries: Optional[List[str]] = None - ) -> TransactionList: - """ - - - Parameters - ---------- - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - - Returns - ------- - TransactionList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions' - api_params = {} - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=TransactionList) - - - def create_transaction( - self, - ttl: Optional[float] = None - ) -> Transaction: - """ - - - Parameters - ---------- - ttl : Optional[float] - Seconds before the transaction expires. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions' - api_params = {} - - if ttl is not None: - api_params['ttl'] = self._normalize_value(ttl) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def get_transaction( - self, - transaction_id: str - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def update_transaction( - self, - transaction_id: str, - commit: Optional[bool] = None, - rollback: Optional[bool] = None - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - commit : Optional[bool] - Commit transaction? - rollback : Optional[bool] - Rollback transaction? - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - if commit is not None: - api_params['commit'] = self._normalize_value(commit) - if rollback is not None: - api_params['rollback'] = self._normalize_value(rollback) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def delete_transaction( - self, - transaction_id: str - ) -> Dict[str, Any]: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def create_operations( - self, - transaction_id: str, - operations: Optional[List[Dict[str, Any]]] = None - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - operations : Optional[List[Dict[str, Any]]] - Array of staged operations. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/transactions/{transactionId}/operations' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - if operations is not None: - api_params['operations'] = self._normalize_value(operations) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def get( - self, - database_id: str - ) -> Database: - """ - Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. - - Parameters - ---------- - database_id : str - Database ID. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Database) - - - def update( - self, - database_id: str, - name: str, - enabled: Optional[bool] = None - ) -> Database: - """ - Update a database by its unique ID. - - Parameters - ---------- - database_id : str - Database ID. - name : 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. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}' - api_params = {} - 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}', str(self._normalize_value(database_id))) - - api_params['name'] = self._normalize_value(name) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Database) - - - def delete( - self, - database_id: str - ) -> Dict[str, Any]: - """ - Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. - - Parameters - ---------- - database_id : str - Database ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def list_collections( - self, - database_id: str, - queries: Optional[List[str]] = None, - search: Optional[str] = None, - total: Optional[bool] = None - ) -> CollectionList: - """ - Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. - - Parameters - ---------- - database_id : str - Database ID. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - search : Optional[str] - Search term to filter your list results. Max length: 256 chars. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - CollectionList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if search is not None: - api_params['search'] = self._normalize_value(search) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=CollectionList) - - - def create_collection( - self, - database_id: str, - collection_id: str, - name: str, - permissions: Optional[List[str]] = None, - document_security: Optional[bool] = None, - enabled: Optional[bool] = None, - attributes: Optional[List[Dict[str, Any]]] = None, - indexes: Optional[List[Dict[str, Any]]] = None - ) -> Collection: - """ - Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - name : str - Collection name. Max length: 128 chars. - permissions : Optional[List[str]] - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - document_security : Optional[bool] - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - enabled : Optional[bool] - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - attributes : Optional[List[Dict[str, Any]]] - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - indexes : Optional[List[Dict[str, Any]]] - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). - - Returns - ------- - Collection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections' - 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 name is None: - raise AppwriteException('Missing required parameter: "name"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - api_params['collectionId'] = self._normalize_value(collection_id) - api_params['name'] = self._normalize_value(name) - api_params['permissions'] = self._normalize_value(permissions) - if document_security is not None: - api_params['documentSecurity'] = self._normalize_value(document_security) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - if attributes is not None: - api_params['attributes'] = self._normalize_value(attributes) - if indexes is not None: - api_params['indexes'] = self._normalize_value(indexes) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Collection) - - - def get_collection( - self, - database_id: str, - collection_id: str - ) -> Collection: - """ - Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - - Returns - ------- - Collection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Collection) - - - 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 - ) -> Collection: - """ - Update a collection by its unique ID. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - name : 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). - document_security : Optional[bool] - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - enabled : Optional[bool] - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - - Returns - ------- - Collection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - 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 name is None: - raise AppwriteException('Missing required parameter: "name"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['name'] = self._normalize_value(name) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if document_security is not None: - api_params['documentSecurity'] = self._normalize_value(document_security) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Collection) - - - def delete_collection( - self, - database_id: str, - collection_id: str - ) -> Dict[str, Any]: - """ - Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def list_documents( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - total: Optional[bool] = None, - ttl: Optional[float] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - Get a list of all the user's documents in a given collection. You can use the query params to filter your results. - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID to read uncommitted changes within the transaction. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - ttl : Optional[float] - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - if total is not None: - api_params['total'] = self._normalize_value(total) - if ttl is not None: - api_params['ttl'] = self._normalize_value(ttl) - - response = self.client.call('get', api_path, { - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def create_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Dict[str, Any], - permissions: Optional[List[str]] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - - 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). Make sure to define attributes before creating documents. - document_id : str - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - data : Dict[str, Any] - Document data as JSON object. - permissions : Optional[List[str]] - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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 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}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documentId'] = self._normalize_value(document_id) - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def create_documents( - self, - database_id: str, - collection_id: str, - documents: List[Dict[str, Any]], - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - - 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). Make sure to define attributes before creating documents. - documents : List[Dict[str, Any]] - Array of documents data as JSON objects. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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 documents is None: - raise AppwriteException('Missing required parameter: "documents"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documents'] = self._normalize_value(documents) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def upsert_documents( - self, - database_id: str, - collection_id: str, - documents: List[Dict[str, Any]], - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#documentsDBCreateCollection) API or directly from your database console. - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - documents : List[Dict[str, Any]] - Array of document data as JSON objects. May contain partial documents. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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 documents is None: - raise AppwriteException('Missing required parameter: "documents"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documents'] = self._normalize_value(documents) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def update_documents( - self, - database_id: str, - collection_id: str, - data: Optional[Dict[str, Any]] = None, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include only attribute and value pairs to be updated. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def delete_documents( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - Bulk delete documents using queries, if no queries are passed then all documents are deleted. - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def get_document( - self, - database_id: str, - collection_id: str, - document_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - Get a document by its unique ID. This endpoint response returns a JSON object with the document data. - - 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). - document_id : str - Document ID. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID to read uncommitted changes within the transaction. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('get', api_path, { - }, api_params) - - return Document.with_data(response, model_type) - - - def upsert_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Optional[Dict[str, Any]] = None, - permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - 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#documentsDBCreateCollection) API or directly from your database console. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include all required fields 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). - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def update_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Optional[Dict[str, Any]] = None, - permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include only fields and value pairs to be 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). - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def delete_document( - self, - database_id: str, - collection_id: str, - document_id: str, - transaction_id: Optional[str] = None - ) -> Dict[str, Any]: - """ - Delete a document by its unique ID. - - 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). - document_id : str - Document ID. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def decrement_document_attribute( - self, - database_id: str, - collection_id: str, - document_id: str, - attribute: str, - value: Optional[float] = None, - min: Optional[float] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - Decrement a specific column of a row by a given value. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - attribute : str - Attribute key. - value : Optional[float] - Value to decrement the attribute by. The value must be a number. - min : Optional[float] - Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - if attribute is None: - raise AppwriteException('Missing required parameter: "attribute"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) - - if value is not None: - api_params['value'] = self._normalize_value(value) - if min is not None: - api_params['min'] = self._normalize_value(min) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def increment_document_attribute( - self, - database_id: str, - collection_id: str, - document_id: str, - attribute: str, - value: Optional[float] = None, - max: Optional[float] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - Increment a specific column of a row by a given value. - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - attribute : str - Attribute key. - value : Optional[float] - Value to increment the attribute by. The value must be a number. - max : Optional[float] - Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - if attribute is None: - raise AppwriteException('Missing required parameter: "attribute"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - api_path = api_path.replace('{attribute}', str(self._normalize_value(attribute))) - - if value is not None: - api_params['value'] = self._normalize_value(value) - if max is not None: - api_params['max'] = self._normalize_value(max) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def list_indexes( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - total: Optional[bool] = None - ) -> IndexList: - """ - List indexes in the collection. - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - IndexList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=IndexList) - - - def create_index( - self, - database_id: str, - collection_id: str, - key: str, - type: DocumentsDBIndexType, - attributes: List[str], - orders: Optional[List[OrderBy]] = None, - lengths: Optional[List[float]] = None - ) -> Index: - """ - 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`. - - 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 - Index Key. - type : DocumentsDBIndexType - Index type. - attributes : List[str] - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - orders : Optional[List[OrderBy]] - Array of index orders. Maximum of 100 orders are allowed. - lengths : Optional[List[float]] - Length of index. Maximum of 100 - - Returns - ------- - Index - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - 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 type is None: - raise AppwriteException('Missing required parameter: "type"') - - if attributes is None: - raise AppwriteException('Missing required parameter: "attributes"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['key'] = self._normalize_value(key) - api_params['type'] = self._normalize_value(type) - api_params['attributes'] = self._normalize_value(attributes) - if orders is not None: - api_params['orders'] = self._normalize_value(orders) - if lengths is not None: - api_params['lengths'] = self._normalize_value(lengths) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Index) - - - def get_index( - self, - database_id: str, - collection_id: str, - key: str - ) -> Index: - """ - Get index by ID. - - 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 - Index Key. - - Returns - ------- - Index - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{key}', str(self._normalize_value(key))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Index) - - - def delete_index( - self, - database_id: str, - collection_id: str, - key: str - ) -> Dict[str, Any]: - """ - Delete an index. - - 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 - Index Key. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{key}', str(self._normalize_value(key))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - diff --git a/appwrite/services/vectors_db.py b/appwrite/services/vectors_db.py deleted file mode 100644 index f402e342..00000000 --- a/appwrite/services/vectors_db.py +++ /dev/null @@ -1,1685 +0,0 @@ -from ..service import Service -from typing import Any, Dict, List, Optional, Union, Type, TypeVar -from ..exception import AppwriteException -from appwrite.utils.deprecated import deprecated -from ..models.database_list import DatabaseList; -from ..models.database import Database; -from ..enums.model import Model; -from ..models.embedding_list import EmbeddingList; -from ..models.transaction_list import TransactionList; -from ..models.transaction import Transaction; -from ..models.vectorsdb_collection_list import VectorsdbCollectionList; -from ..models.vectorsdb_collection import VectorsdbCollection; -from ..models.document_list import DocumentList; -from ..models.document import Document; -from ..models.index_list import IndexList; -from ..enums.vectors_db_index_type import VectorsDBIndexType; -from ..enums.order_by import OrderBy; -from ..models.index import Index; - -T = TypeVar('T') - -class VectorsDB(Service): - - def __init__(self, client) -> None: - super(VectorsDB, self).__init__(client) - - def list( - self, - queries: Optional[List[str]] = None, - search: Optional[str] = None, - total: Optional[bool] = None - ) -> DatabaseList: - """ - - - Parameters - ---------- - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name - search : Optional[str] - Search term to filter your list results. Max length: 256 chars. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - DatabaseList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb' - api_params = {} - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if search is not None: - api_params['search'] = self._normalize_value(search) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=DatabaseList) - - - def create( - self, - database_id: str, - name: str, - enabled: Optional[bool] = None - ) -> Database: - """ - - - Parameters - ---------- - database_id : str - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - name : str - Database name. Max length: 128 chars. - enabled : Optional[bool] - Is the 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. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - if name is None: - raise AppwriteException('Missing required parameter: "name"') - - - api_params['databaseId'] = self._normalize_value(database_id) - api_params['name'] = self._normalize_value(name) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Database) - - - def create_text_embeddings( - self, - texts: List[str], - model: Optional[Model] = None - ) -> EmbeddingList: - """ - - - Parameters - ---------- - texts : List[str] - Array of text to generate embeddings. - model : Optional[Model] - The embedding model to use for generating vector embeddings. - - Returns - ------- - EmbeddingList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/embeddings/text' - api_params = {} - if texts is None: - raise AppwriteException('Missing required parameter: "texts"') - - - api_params['texts'] = self._normalize_value(texts) - if model is not None: - api_params['model'] = self._normalize_value(model) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=EmbeddingList) - - - def list_transactions( - self, - queries: Optional[List[str]] = None - ) -> TransactionList: - """ - - - Parameters - ---------- - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). - - Returns - ------- - TransactionList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions' - api_params = {} - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=TransactionList) - - - def create_transaction( - self, - ttl: Optional[float] = None - ) -> Transaction: - """ - - - Parameters - ---------- - ttl : Optional[float] - Seconds before the transaction expires. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions' - api_params = {} - - if ttl is not None: - api_params['ttl'] = self._normalize_value(ttl) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def get_transaction( - self, - transaction_id: str - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def update_transaction( - self, - transaction_id: str, - commit: Optional[bool] = None, - rollback: Optional[bool] = None - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - commit : Optional[bool] - Commit transaction? - rollback : Optional[bool] - Rollback transaction? - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - if commit is not None: - api_params['commit'] = self._normalize_value(commit) - if rollback is not None: - api_params['rollback'] = self._normalize_value(rollback) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def delete_transaction( - self, - transaction_id: str - ) -> Dict[str, Any]: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions/{transactionId}' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def create_operations( - self, - transaction_id: str, - operations: Optional[List[Dict[str, Any]]] = None - ) -> Transaction: - """ - - - Parameters - ---------- - transaction_id : str - Transaction ID. - operations : Optional[List[Dict[str, Any]]] - Array of staged operations. - - Returns - ------- - Transaction - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/transactions/{transactionId}/operations' - api_params = {} - if transaction_id is None: - raise AppwriteException('Missing required parameter: "transaction_id"') - - api_path = api_path.replace('{transactionId}', str(self._normalize_value(transaction_id))) - - if operations is not None: - api_params['operations'] = self._normalize_value(operations) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Transaction) - - - def get( - self, - database_id: str - ) -> Database: - """ - - - Parameters - ---------- - database_id : str - Database ID. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Database) - - - def update( - self, - database_id: str, - name: str, - enabled: Optional[bool] = None - ) -> Database: - """ - - - Parameters - ---------- - database_id : str - Database ID. - name : 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. - - Returns - ------- - Database - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}' - api_params = {} - 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}', str(self._normalize_value(database_id))) - - api_params['name'] = self._normalize_value(name) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Database) - - - def delete( - self, - database_id: str - ) -> Dict[str, Any]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def list_collections( - self, - database_id: str, - queries: Optional[List[str]] = None, - search: Optional[str] = None, - total: Optional[bool] = None - ) -> VectorsdbCollectionList: - """ - - - Parameters - ---------- - database_id : str - Database ID. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity - search : Optional[str] - Search term to filter your list results. Max length: 256 chars. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - VectorsdbCollectionList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections' - api_params = {} - if database_id is None: - raise AppwriteException('Missing required parameter: "database_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if search is not None: - api_params['search'] = self._normalize_value(search) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=VectorsdbCollectionList) - - - def create_collection( - self, - database_id: str, - collection_id: str, - name: str, - dimension: float, - permissions: Optional[List[str]] = None, - document_security: Optional[bool] = None, - enabled: Optional[bool] = None - ) -> VectorsdbCollection: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - name : str - Collection name. Max length: 128 chars. - dimension : float - Embedding dimension. - permissions : Optional[List[str]] - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - document_security : Optional[bool] - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - enabled : Optional[bool] - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - - Returns - ------- - VectorsdbCollection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections' - 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 name is None: - raise AppwriteException('Missing required parameter: "name"') - - if dimension is None: - raise AppwriteException('Missing required parameter: "dimension"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - - api_params['collectionId'] = self._normalize_value(collection_id) - api_params['name'] = self._normalize_value(name) - api_params['dimension'] = self._normalize_value(dimension) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if document_security is not None: - api_params['documentSecurity'] = self._normalize_value(document_security) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=VectorsdbCollection) - - - def get_collection( - self, - database_id: str, - collection_id: str - ) -> VectorsdbCollection: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - - Returns - ------- - VectorsdbCollection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=VectorsdbCollection) - - - def update_collection( - self, - database_id: str, - collection_id: str, - name: str, - dimension: Optional[float] = None, - permissions: Optional[List[str]] = None, - document_security: Optional[bool] = None, - enabled: Optional[bool] = None - ) -> VectorsdbCollection: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - name : str - Collection name. Max length: 128 chars. - dimension : Optional[float] - Embedding dimensions. - 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). - document_security : Optional[bool] - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). - enabled : Optional[bool] - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - - Returns - ------- - VectorsdbCollection - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - 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 name is None: - raise AppwriteException('Missing required parameter: "name"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['name'] = self._normalize_value(name) - if dimension is not None: - api_params['dimension'] = self._normalize_value(dimension) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if document_security is not None: - api_params['documentSecurity'] = self._normalize_value(document_security) - if enabled is not None: - api_params['enabled'] = self._normalize_value(enabled) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=VectorsdbCollection) - - - def delete_collection( - self, - database_id: str, - collection_id: str - ) -> Dict[str, Any]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def list_documents( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - total: Optional[bool] = None, - ttl: Optional[float] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID to read uncommitted changes within the transaction. - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - ttl : Optional[float] - TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - if total is not None: - api_params['total'] = self._normalize_value(total) - if ttl is not None: - api_params['ttl'] = self._normalize_value(ttl) - - response = self.client.call('get', api_path, { - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def create_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Dict[str, Any], - permissions: Optional[List[str]] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - - - 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). Make sure to define attributes before creating documents. - document_id : str - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - data : Dict[str, Any] - Document data as JSON object. - permissions : Optional[List[str]] - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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 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}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documentId'] = self._normalize_value(document_id) - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def create_documents( - self, - database_id: str, - collection_id: str, - documents: List[Dict[str, Any]], - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - - - 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). Make sure to define attributes before creating documents. - documents : List[Dict[str, Any]] - Array of documents data as JSON objects. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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 documents is None: - raise AppwriteException('Missing required parameter: "documents"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documents'] = self._normalize_value(documents) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def upsert_documents( - self, - database_id: str, - collection_id: str, - documents: List[Dict[str, Any]], - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - documents : List[Dict[str, Any]] - Array of document data as JSON objects. May contain partial documents. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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 documents is None: - raise AppwriteException('Missing required parameter: "documents"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['documents'] = self._normalize_value(documents) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def update_documents( - self, - database_id: str, - collection_id: str, - data: Optional[Dict[str, Any]] = None, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include only attribute and value pairs to be updated. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def delete_documents( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> DocumentList[T]: - """ - - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - DocumentList[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return DocumentList.with_data(response, model_type) - - - def get_document( - self, - database_id: str, - collection_id: str, - document_id: str, - queries: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - - - 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). - document_id : str - Document ID. - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - transaction_id : Optional[str] - Transaction ID to read uncommitted changes within the transaction. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('get', api_path, { - }, api_params) - - return Document.with_data(response, model_type) - - - def upsert_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Optional[Dict[str, Any]] = None, - permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include all required fields 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). - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('put', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def update_document( - self, - database_id: str, - collection_id: str, - document_id: str, - data: Optional[Dict[str, Any]] = None, - permissions: Optional[List[str]] = None, - transaction_id: Optional[str] = None, - model_type: Type[T] = dict - ) -> Document[T]: - """ - - - Parameters - ---------- - database_id : str - Database ID. - collection_id : str - Collection ID. - document_id : str - Document ID. - data : Optional[Dict[str, Any]] - Document data as JSON object. Include only fields and value pairs to be 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). - transaction_id : Optional[str] - Transaction ID for staging the operation. - - model_type : Type[T], optional - Pydantic model class for the user-defined data. Defaults to dict for backward compatibility. - - Returns - ------- - Document[T] - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if data is not None: - api_params['data'] = self._normalize_value(data) - if permissions is not None: - api_params['permissions'] = self._normalize_value(permissions) - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('patch', api_path, { - 'content-type': 'application/json', - }, api_params) - - return Document.with_data(response, model_type) - - - def delete_document( - self, - database_id: str, - collection_id: str, - document_id: str, - transaction_id: Optional[str] = None - ) -> Dict[str, Any]: - """ - - - 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). - document_id : str - Document ID. - transaction_id : Optional[str] - Transaction ID for staging the operation. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - 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 document_id is None: - raise AppwriteException('Missing required parameter: "document_id"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{documentId}', str(self._normalize_value(document_id))) - - if transaction_id is not None: - api_params['transactionId'] = self._normalize_value(transaction_id) - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - - - def list_indexes( - self, - database_id: str, - collection_id: str, - queries: Optional[List[str]] = None, - total: Optional[bool] = None - ) -> IndexList: - """ - - - 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). - queries : Optional[List[str]] - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error - total : Optional[bool] - When set to false, the total count returned will be 0 and will not be calculated. - - Returns - ------- - IndexList - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - 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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - if queries is not None: - api_params['queries'] = self._normalize_value(queries) - if total is not None: - api_params['total'] = self._normalize_value(total) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=IndexList) - - - def create_index( - self, - database_id: str, - collection_id: str, - key: str, - type: VectorsDBIndexType, - attributes: List[str], - orders: Optional[List[OrderBy]] = None, - lengths: Optional[List[float]] = None - ) -> Index: - """ - - - 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 - Index Key. - type : VectorsDBIndexType - Index type. - attributes : List[str] - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. - orders : Optional[List[OrderBy]] - Array of index orders. Maximum of 100 orders are allowed. - lengths : Optional[List[float]] - Length of index. Maximum of 100 - - Returns - ------- - Index - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - 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 type is None: - raise AppwriteException('Missing required parameter: "type"') - - if attributes is None: - raise AppwriteException('Missing required parameter: "attributes"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - - api_params['key'] = self._normalize_value(key) - api_params['type'] = self._normalize_value(type) - api_params['attributes'] = self._normalize_value(attributes) - if orders is not None: - api_params['orders'] = self._normalize_value(orders) - if lengths is not None: - api_params['lengths'] = self._normalize_value(lengths) - - response = self.client.call('post', api_path, { - 'content-type': 'application/json', - }, api_params) - - return self._parse_response(response, model=Index) - - - def get_index( - self, - database_id: str, - collection_id: str, - key: str - ) -> Index: - """ - - - 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 - Index Key. - - Returns - ------- - Index - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{key}', str(self._normalize_value(key))) - - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=Index) - - - def delete_index( - self, - database_id: str, - collection_id: str, - key: str - ) -> Dict[str, Any]: - """ - - - 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 - Index Key. - - Returns - ------- - Dict[str, Any] - API response as a dictionary - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{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"') - - api_path = api_path.replace('{databaseId}', str(self._normalize_value(database_id))) - api_path = api_path.replace('{collectionId}', str(self._normalize_value(collection_id))) - api_path = api_path.replace('{key}', str(self._normalize_value(key))) - - - response = self.client.call('delete', api_path, { - 'content-type': 'application/json', - }, api_params) - - return response - diff --git a/docs/examples/documentsdb/create-collection.md b/docs/examples/documentsdb/create-collection.md deleted file mode 100644 index b717460f..00000000 --- a/docs/examples/documentsdb/create-collection.md +++ /dev/null @@ -1,27 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Collection -from appwrite.permission import Permission -from appwrite.role import Role - -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 - -documents_db = DocumentsDB(client) - -result: Collection = documents_db.create_collection( - database_id = '', - collection_id = '', - name = '', - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False, # optional - attributes = [], # optional - indexes = [] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md deleted file mode 100644 index 1fa38033..00000000 --- a/docs/examples/documentsdb/create-document.md +++ /dev/null @@ -1,30 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.create_document( - database_id = '', - collection_id = '', - document_id = '', - data = { - "username": "walter.obrien", - "email": "walter.obrien@example.com", - "fullName": "Walter O'Brien", - "age": 30, - "isAdmin": False - }, - permissions = [Permission.read(Role.any())] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md deleted file mode 100644 index 661c32dd..00000000 --- a/docs/examples/documentsdb/create-documents.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DocumentList - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: DocumentList = documents_db.create_documents( - database_id = '', - collection_id = '', - documents = [] -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md deleted file mode 100644 index 3f2fcf0b..00000000 --- a/docs/examples/documentsdb/create-index.md +++ /dev/null @@ -1,26 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Index -from appwrite.enums import DocumentsDBIndexType -from appwrite.enums import OrderBy - -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 - -documents_db = DocumentsDB(client) - -result: Index = documents_db.create_index( - database_id = '', - collection_id = '', - key = '', - type = DocumentsDBIndexType.KEY, - attributes = [], - orders = [OrderBy.ASC], # optional - lengths = [] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md deleted file mode 100644 index 23128e81..00000000 --- a/docs/examples/documentsdb/create-operations.md +++ /dev/null @@ -1,29 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Transaction - -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 - -documents_db = DocumentsDB(client) - -result: Transaction = documents_db.create_operations( - transaction_id = '', - operations = [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create-transaction.md b/docs/examples/documentsdb/create-transaction.md deleted file mode 100644 index d34b358e..00000000 --- a/docs/examples/documentsdb/create-transaction.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Transaction - -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 - -documents_db = DocumentsDB(client) - -result: Transaction = documents_db.create_transaction( - ttl = 60 # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/create.md b/docs/examples/documentsdb/create.md deleted file mode 100644 index 753759be..00000000 --- a/docs/examples/documentsdb/create.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Database - -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 - -documents_db = DocumentsDB(client) - -result: Database = documents_db.create( - database_id = '', - name = '', - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/decrement-document-attribute.md b/docs/examples/documentsdb/decrement-document-attribute.md deleted file mode 100644 index d10b6f2b..00000000 --- a/docs/examples/documentsdb/decrement-document-attribute.md +++ /dev/null @@ -1,24 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.decrement_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = None, # optional - min = None, # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/delete-collection.md b/docs/examples/documentsdb/delete-collection.md deleted file mode 100644 index 1652ab2b..00000000 --- a/docs/examples/documentsdb/delete-collection.md +++ /dev/null @@ -1,16 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB - -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 - -documents_db = DocumentsDB(client) - -result = documents_db.delete_collection( - database_id = '', - collection_id = '' -) -``` diff --git a/docs/examples/documentsdb/delete-document.md b/docs/examples/documentsdb/delete-document.md deleted file mode 100644 index e588088e..00000000 --- a/docs/examples/documentsdb/delete-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result = documents_db.delete_document( - database_id = '', - collection_id = '', - document_id = '', - transaction_id = '' # optional -) -``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md deleted file mode 100644 index 8bc343de..00000000 --- a/docs/examples/documentsdb/delete-documents.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DocumentList - -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 - -documents_db = DocumentsDB(client) - -result: DocumentList = documents_db.delete_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/delete-index.md b/docs/examples/documentsdb/delete-index.md deleted file mode 100644 index da51459d..00000000 --- a/docs/examples/documentsdb/delete-index.md +++ /dev/null @@ -1,17 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB - -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 - -documents_db = DocumentsDB(client) - -result = documents_db.delete_index( - database_id = '', - collection_id = '', - key = '' -) -``` diff --git a/docs/examples/documentsdb/delete-transaction.md b/docs/examples/documentsdb/delete-transaction.md deleted file mode 100644 index 009bf807..00000000 --- a/docs/examples/documentsdb/delete-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB - -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 - -documents_db = DocumentsDB(client) - -result = documents_db.delete_transaction( - transaction_id = '' -) -``` diff --git a/docs/examples/documentsdb/delete.md b/docs/examples/documentsdb/delete.md deleted file mode 100644 index 64845091..00000000 --- a/docs/examples/documentsdb/delete.md +++ /dev/null @@ -1,15 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB - -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 - -documents_db = DocumentsDB(client) - -result = documents_db.delete( - database_id = '' -) -``` diff --git a/docs/examples/documentsdb/get-collection.md b/docs/examples/documentsdb/get-collection.md deleted file mode 100644 index 5ec739b8..00000000 --- a/docs/examples/documentsdb/get-collection.md +++ /dev/null @@ -1,19 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Collection - -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 - -documents_db = DocumentsDB(client) - -result: Collection = documents_db.get_collection( - database_id = '', - collection_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/get-document.md b/docs/examples/documentsdb/get-document.md deleted file mode 100644 index 3f0006e7..00000000 --- a/docs/examples/documentsdb/get-document.md +++ /dev/null @@ -1,22 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.get_document( - database_id = '', - collection_id = '', - document_id = '', - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/get-index.md b/docs/examples/documentsdb/get-index.md deleted file mode 100644 index f3887506..00000000 --- a/docs/examples/documentsdb/get-index.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Index - -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 - -documents_db = DocumentsDB(client) - -result: Index = documents_db.get_index( - database_id = '', - collection_id = '', - key = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/get-transaction.md b/docs/examples/documentsdb/get-transaction.md deleted file mode 100644 index 27d88ee7..00000000 --- a/docs/examples/documentsdb/get-transaction.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Transaction - -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 - -documents_db = DocumentsDB(client) - -result: Transaction = documents_db.get_transaction( - transaction_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/get.md b/docs/examples/documentsdb/get.md deleted file mode 100644 index fc2ffb9b..00000000 --- a/docs/examples/documentsdb/get.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Database - -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 - -documents_db = DocumentsDB(client) - -result: Database = documents_db.get( - database_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/increment-document-attribute.md b/docs/examples/documentsdb/increment-document-attribute.md deleted file mode 100644 index c235865a..00000000 --- a/docs/examples/documentsdb/increment-document-attribute.md +++ /dev/null @@ -1,24 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.increment_document_attribute( - database_id = '', - collection_id = '', - document_id = '', - attribute = '', - value = None, # optional - max = None, # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/list-collections.md b/docs/examples/documentsdb/list-collections.md deleted file mode 100644 index 0d72a376..00000000 --- a/docs/examples/documentsdb/list-collections.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import CollectionList - -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 - -documents_db = DocumentsDB(client) - -result: CollectionList = documents_db.list_collections( - database_id = '', - queries = [], # optional - search = '', # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/list-documents.md b/docs/examples/documentsdb/list-documents.md deleted file mode 100644 index c1b2a360..00000000 --- a/docs/examples/documentsdb/list-documents.md +++ /dev/null @@ -1,23 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DocumentList - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: DocumentList = documents_db.list_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/list-indexes.md b/docs/examples/documentsdb/list-indexes.md deleted file mode 100644 index 26655d72..00000000 --- a/docs/examples/documentsdb/list-indexes.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import IndexList - -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 - -documents_db = DocumentsDB(client) - -result: IndexList = documents_db.list_indexes( - database_id = '', - collection_id = '', - queries = [], # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md deleted file mode 100644 index 6dc7aae2..00000000 --- a/docs/examples/documentsdb/list-transactions.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import TransactionList - -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 - -documents_db = DocumentsDB(client) - -result: TransactionList = documents_db.list_transactions( - queries = [] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/list.md b/docs/examples/documentsdb/list.md deleted file mode 100644 index 5fbe9484..00000000 --- a/docs/examples/documentsdb/list.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DatabaseList - -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 - -documents_db = DocumentsDB(client) - -result: DatabaseList = documents_db.list( - queries = [], # optional - search = '', # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/update-collection.md b/docs/examples/documentsdb/update-collection.md deleted file mode 100644 index 2a5101dd..00000000 --- a/docs/examples/documentsdb/update-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Collection -from appwrite.permission import Permission -from appwrite.role import Role - -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 - -documents_db = DocumentsDB(client) - -result: Collection = documents_db.update_collection( - database_id = '', - collection_id = '', - name = '', - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/update-document.md b/docs/examples/documentsdb/update-document.md deleted file mode 100644 index cf0bfcc9..00000000 --- a/docs/examples/documentsdb/update-document.md +++ /dev/null @@ -1,25 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.update_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/update-documents.md b/docs/examples/documentsdb/update-documents.md deleted file mode 100644 index 2c183e55..00000000 --- a/docs/examples/documentsdb/update-documents.md +++ /dev/null @@ -1,22 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DocumentList - -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 - -documents_db = DocumentsDB(client) - -result: DocumentList = documents_db.update_documents( - database_id = '', - collection_id = '', - data = {}, # optional - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/update-transaction.md b/docs/examples/documentsdb/update-transaction.md deleted file mode 100644 index fff946cb..00000000 --- a/docs/examples/documentsdb/update-transaction.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Transaction - -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 - -documents_db = DocumentsDB(client) - -result: Transaction = documents_db.update_transaction( - transaction_id = '', - commit = False, # optional - rollback = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/update.md b/docs/examples/documentsdb/update.md deleted file mode 100644 index 1e0c0692..00000000 --- a/docs/examples/documentsdb/update.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Database - -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 - -documents_db = DocumentsDB(client) - -result: Database = documents_db.update( - database_id = '', - name = '', - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/upsert-document.md b/docs/examples/documentsdb/upsert-document.md deleted file mode 100644 index 07086f4a..00000000 --- a/docs/examples/documentsdb/upsert-document.md +++ /dev/null @@ -1,25 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -documents_db = DocumentsDB(client) - -result: Document = documents_db.upsert_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md deleted file mode 100644 index d98b227c..00000000 --- a/docs/examples/documentsdb/upsert-documents.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.documents_db import DocumentsDB -from appwrite.models import DocumentList - -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 - -documents_db = DocumentsDB(client) - -result: DocumentList = documents_db.upsert_documents( - database_id = '', - collection_id = '', - documents = [], - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md deleted file mode 100644 index 793aa3f5..00000000 --- a/docs/examples/vectorsdb/create-collection.md +++ /dev/null @@ -1,26 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import VectorsdbCollection -from appwrite.permission import Permission -from appwrite.role import Role - -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollection = vectors_db.create_collection( - database_id = '', - collection_id = '', - name = '', - dimension = 1, - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md deleted file mode 100644 index d032a991..00000000 --- a/docs/examples/vectorsdb/create-document.md +++ /dev/null @@ -1,34 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result: Document = vectors_db.create_document( - database_id = '', - collection_id = '', - document_id = '', - data = { - "embeddings": [ - 0.12, - -0.55, - 0.88, - 1.02 - ], - "metadata": { - "key": "value" - } - }, - permissions = [Permission.read(Role.any())] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md deleted file mode 100644 index 431aec82..00000000 --- a/docs/examples/vectorsdb/create-documents.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DocumentList - -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 - -vectors_db = VectorsDB(client) - -result: DocumentList = vectors_db.create_documents( - database_id = '', - collection_id = '', - documents = [] -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md deleted file mode 100644 index e0656bce..00000000 --- a/docs/examples/vectorsdb/create-index.md +++ /dev/null @@ -1,26 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Index -from appwrite.enums import VectorsDBIndexType -from appwrite.enums import OrderBy - -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 - -vectors_db = VectorsDB(client) - -result: Index = vectors_db.create_index( - database_id = '', - collection_id = '', - key = '', - type = VectorsDBIndexType.HNSW_EUCLIDEAN, - attributes = [], - orders = [OrderBy.ASC], # optional - lengths = [] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md deleted file mode 100644 index e19a8936..00000000 --- a/docs/examples/vectorsdb/create-operations.md +++ /dev/null @@ -1,29 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Transaction - -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 - -vectors_db = VectorsDB(client) - -result: Transaction = vectors_db.create_operations( - transaction_id = '', - operations = [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-text-embeddings.md b/docs/examples/vectorsdb/create-text-embeddings.md deleted file mode 100644 index d4780931..00000000 --- a/docs/examples/vectorsdb/create-text-embeddings.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import EmbeddingList -from appwrite.enums import Model - -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 - -vectors_db = VectorsDB(client) - -result: EmbeddingList = vectors_db.create_text_embeddings( - texts = [], - model = Model.EMBEDDINGGEMMA # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create-transaction.md b/docs/examples/vectorsdb/create-transaction.md deleted file mode 100644 index 6b6cd631..00000000 --- a/docs/examples/vectorsdb/create-transaction.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Transaction - -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 - -vectors_db = VectorsDB(client) - -result: Transaction = vectors_db.create_transaction( - ttl = 60 # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/create.md b/docs/examples/vectorsdb/create.md deleted file mode 100644 index 2fe4347f..00000000 --- a/docs/examples/vectorsdb/create.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Database - -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 - -vectors_db = VectorsDB(client) - -result: Database = vectors_db.create( - database_id = '', - name = '', - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/delete-collection.md b/docs/examples/vectorsdb/delete-collection.md deleted file mode 100644 index b96a628b..00000000 --- a/docs/examples/vectorsdb/delete-collection.md +++ /dev/null @@ -1,16 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB - -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 - -vectors_db = VectorsDB(client) - -result = vectors_db.delete_collection( - database_id = '', - collection_id = '' -) -``` diff --git a/docs/examples/vectorsdb/delete-document.md b/docs/examples/vectorsdb/delete-document.md deleted file mode 100644 index 3915b937..00000000 --- a/docs/examples/vectorsdb/delete-document.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result = vectors_db.delete_document( - database_id = '', - collection_id = '', - document_id = '', - transaction_id = '' # optional -) -``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md deleted file mode 100644 index f1bee6ee..00000000 --- a/docs/examples/vectorsdb/delete-documents.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DocumentList - -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 - -vectors_db = VectorsDB(client) - -result: DocumentList = vectors_db.delete_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/delete-index.md b/docs/examples/vectorsdb/delete-index.md deleted file mode 100644 index 7dc89739..00000000 --- a/docs/examples/vectorsdb/delete-index.md +++ /dev/null @@ -1,17 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB - -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 - -vectors_db = VectorsDB(client) - -result = vectors_db.delete_index( - database_id = '', - collection_id = '', - key = '' -) -``` diff --git a/docs/examples/vectorsdb/delete-transaction.md b/docs/examples/vectorsdb/delete-transaction.md deleted file mode 100644 index 58a367f7..00000000 --- a/docs/examples/vectorsdb/delete-transaction.md +++ /dev/null @@ -1,15 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB - -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 - -vectors_db = VectorsDB(client) - -result = vectors_db.delete_transaction( - transaction_id = '' -) -``` diff --git a/docs/examples/vectorsdb/delete.md b/docs/examples/vectorsdb/delete.md deleted file mode 100644 index da1c5a49..00000000 --- a/docs/examples/vectorsdb/delete.md +++ /dev/null @@ -1,15 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB - -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 - -vectors_db = VectorsDB(client) - -result = vectors_db.delete( - database_id = '' -) -``` diff --git a/docs/examples/vectorsdb/get-collection.md b/docs/examples/vectorsdb/get-collection.md deleted file mode 100644 index 2616d72a..00000000 --- a/docs/examples/vectorsdb/get-collection.md +++ /dev/null @@ -1,19 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import VectorsdbCollection - -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollection = vectors_db.get_collection( - database_id = '', - collection_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/get-document.md b/docs/examples/vectorsdb/get-document.md deleted file mode 100644 index a484c5dd..00000000 --- a/docs/examples/vectorsdb/get-document.md +++ /dev/null @@ -1,22 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Document - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result: Document = vectors_db.get_document( - database_id = '', - collection_id = '', - document_id = '', - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/get-index.md b/docs/examples/vectorsdb/get-index.md deleted file mode 100644 index 31f91044..00000000 --- a/docs/examples/vectorsdb/get-index.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Index - -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 - -vectors_db = VectorsDB(client) - -result: Index = vectors_db.get_index( - database_id = '', - collection_id = '', - key = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/get-transaction.md b/docs/examples/vectorsdb/get-transaction.md deleted file mode 100644 index 601ed0b0..00000000 --- a/docs/examples/vectorsdb/get-transaction.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Transaction - -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 - -vectors_db = VectorsDB(client) - -result: Transaction = vectors_db.get_transaction( - transaction_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/get.md b/docs/examples/vectorsdb/get.md deleted file mode 100644 index b251b427..00000000 --- a/docs/examples/vectorsdb/get.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Database - -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 - -vectors_db = VectorsDB(client) - -result: Database = vectors_db.get( - database_id = '' -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/list-collections.md b/docs/examples/vectorsdb/list-collections.md deleted file mode 100644 index 184c3c3f..00000000 --- a/docs/examples/vectorsdb/list-collections.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import VectorsdbCollectionList - -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollectionList = vectors_db.list_collections( - database_id = '', - queries = [], # optional - search = '', # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/list-documents.md b/docs/examples/vectorsdb/list-documents.md deleted file mode 100644 index 5ac3ab2f..00000000 --- a/docs/examples/vectorsdb/list-documents.md +++ /dev/null @@ -1,23 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DocumentList - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result: DocumentList = vectors_db.list_documents( - database_id = '', - collection_id = '', - queries = [], # optional - transaction_id = '', # optional - total = False, # optional - ttl = 0 # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/list-indexes.md b/docs/examples/vectorsdb/list-indexes.md deleted file mode 100644 index c72e9800..00000000 --- a/docs/examples/vectorsdb/list-indexes.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import IndexList - -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 - -vectors_db = VectorsDB(client) - -result: IndexList = vectors_db.list_indexes( - database_id = '', - collection_id = '', - queries = [], # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md deleted file mode 100644 index d21db012..00000000 --- a/docs/examples/vectorsdb/list-transactions.md +++ /dev/null @@ -1,18 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import TransactionList - -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 - -vectors_db = VectorsDB(client) - -result: TransactionList = vectors_db.list_transactions( - queries = [] # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/list.md b/docs/examples/vectorsdb/list.md deleted file mode 100644 index ac87bca3..00000000 --- a/docs/examples/vectorsdb/list.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DatabaseList - -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 - -vectors_db = VectorsDB(client) - -result: DatabaseList = vectors_db.list( - queries = [], # optional - search = '', # optional - total = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md deleted file mode 100644 index 3dcf8903..00000000 --- a/docs/examples/vectorsdb/update-collection.md +++ /dev/null @@ -1,26 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import VectorsdbCollection -from appwrite.permission import Permission -from appwrite.role import Role - -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 - -vectors_db = VectorsDB(client) - -result: VectorsdbCollection = vectors_db.update_collection( - database_id = '', - collection_id = '', - name = '', - dimension = 1, # optional - permissions = [Permission.read(Role.any())], # optional - document_security = False, # optional - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/update-document.md b/docs/examples/vectorsdb/update-document.md deleted file mode 100644 index c70c2bc1..00000000 --- a/docs/examples/vectorsdb/update-document.md +++ /dev/null @@ -1,25 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result: Document = vectors_db.update_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/update-documents.md b/docs/examples/vectorsdb/update-documents.md deleted file mode 100644 index 5c947cd1..00000000 --- a/docs/examples/vectorsdb/update-documents.md +++ /dev/null @@ -1,22 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DocumentList - -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 - -vectors_db = VectorsDB(client) - -result: DocumentList = vectors_db.update_documents( - database_id = '', - collection_id = '', - data = {}, # optional - queries = [], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/update-transaction.md b/docs/examples/vectorsdb/update-transaction.md deleted file mode 100644 index 276c25c8..00000000 --- a/docs/examples/vectorsdb/update-transaction.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Transaction - -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 - -vectors_db = VectorsDB(client) - -result: Transaction = vectors_db.update_transaction( - transaction_id = '', - commit = False, # optional - rollback = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/update.md b/docs/examples/vectorsdb/update.md deleted file mode 100644 index c2bcb3dc..00000000 --- a/docs/examples/vectorsdb/update.md +++ /dev/null @@ -1,20 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Database - -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 - -vectors_db = VectorsDB(client) - -result: Database = vectors_db.update( - database_id = '', - name = '', - enabled = False # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/upsert-document.md b/docs/examples/vectorsdb/upsert-document.md deleted file mode 100644 index 95f916d3..00000000 --- a/docs/examples/vectorsdb/upsert-document.md +++ /dev/null @@ -1,25 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import Document -from appwrite.permission import Permission -from appwrite.role import Role - -client = Client() -client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint -client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with - -vectors_db = VectorsDB(client) - -result: Document = vectors_db.upsert_document( - database_id = '', - collection_id = '', - document_id = '', - data = {}, # optional - permissions = [Permission.read(Role.any())], # optional - transaction_id = '' # optional -) - -print(result.model_dump()) -``` diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md deleted file mode 100644 index 5eb3d2d1..00000000 --- a/docs/examples/vectorsdb/upsert-documents.md +++ /dev/null @@ -1,21 +0,0 @@ -```python -from appwrite.client import Client -from appwrite.services.vectors_db import VectorsDB -from appwrite.models import DocumentList - -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 - -vectors_db = VectorsDB(client) - -result: DocumentList = vectors_db.upsert_documents( - database_id = '', - collection_id = '', - documents = [], - transaction_id = '' # optional -) - -print(result.model_dump()) -``` From 1f4817787bb56efad36cdddea4e46f45fdbef08b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 06:43:25 +0000 Subject: [PATCH 4/9] chore: update Python SDK to 17.0.0 --- appwrite/encoders/value_class_encoder.py | 26 +- appwrite/enums/documents_db_index_type.py | 7 - appwrite/enums/model.py | 4 - appwrite/enums/template_reference_type.py | 2 +- appwrite/enums/vcs_reference_type.py | 1 - appwrite/enums/vectors_db_index_type.py | 9 - appwrite/models/__init__.py | 460 +++++++++---------- appwrite/models/attribute_object.py | 37 -- appwrite/models/attribute_vector.py | 40 -- appwrite/models/embedding.py | 24 - appwrite/models/embedding_list.py | 19 - appwrite/models/vectorsdb_collection.py | 54 --- appwrite/models/vectorsdb_collection_list.py | 19 - appwrite/services/health.py | 175 ------- 14 files changed, 232 insertions(+), 645 deletions(-) delete mode 100644 appwrite/enums/documents_db_index_type.py delete mode 100644 appwrite/enums/model.py delete mode 100644 appwrite/enums/vectors_db_index_type.py delete mode 100644 appwrite/models/attribute_object.py delete mode 100644 appwrite/models/attribute_vector.py delete mode 100644 appwrite/models/embedding.py delete mode 100644 appwrite/models/embedding_list.py delete mode 100644 appwrite/models/vectorsdb_collection.py delete mode 100644 appwrite/models/vectorsdb_collection_list.py diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index 0c420123..aba85579 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -15,7 +15,6 @@ from ..enums.relation_mutate import RelationMutate from ..enums.databases_index_type import DatabasesIndexType from ..enums.order_by import OrderBy -from ..enums.documents_db_index_type import DocumentsDBIndexType from ..enums.runtime import Runtime from ..enums.scopes import Scopes from ..enums.template_reference_type import TemplateReferenceType @@ -33,18 +32,16 @@ from ..enums.tables_db_index_type import TablesDBIndexType from ..enums.password_hash import PasswordHash from ..enums.messaging_provider_type import MessagingProviderType -from ..enums.model import Model -from ..enums.vectors_db_index_type import VectorsDBIndexType from ..enums.database_type import DatabaseType from ..enums.attribute_status import AttributeStatus -from ..enums.column_status import ColumnStatus from ..enums.index_status import IndexStatus from ..enums.deployment_status import DeploymentStatus from ..enums.execution_trigger import ExecutionTrigger from ..enums.execution_status import ExecutionStatus -from ..enums.health_antivirus_status import HealthAntivirusStatus from ..enums.health_check_status import HealthCheckStatus +from ..enums.health_antivirus_status import HealthAntivirusStatus from ..enums.message_status import MessageStatus +from ..enums.column_status import ColumnStatus class ValueClassEncoder(json.JSONEncoder): def default(self, o): @@ -96,9 +93,6 @@ def default(self, o): if isinstance(o, OrderBy): return o.value - if isinstance(o, DocumentsDBIndexType): - return o.value - if isinstance(o, Runtime): return o.value @@ -150,21 +144,12 @@ def default(self, o): if isinstance(o, MessagingProviderType): return o.value - if isinstance(o, Model): - return o.value - - if isinstance(o, VectorsDBIndexType): - return o.value - if isinstance(o, DatabaseType): return o.value if isinstance(o, AttributeStatus): return o.value - if isinstance(o, ColumnStatus): - return o.value - if isinstance(o, IndexStatus): return o.value @@ -177,13 +162,16 @@ def default(self, o): if isinstance(o, ExecutionStatus): return o.value - if isinstance(o, HealthAntivirusStatus): + if isinstance(o, HealthCheckStatus): return o.value - if isinstance(o, HealthCheckStatus): + if isinstance(o, HealthAntivirusStatus): return o.value if isinstance(o, MessageStatus): return o.value + if isinstance(o, ColumnStatus): + return o.value + return super().default(o) diff --git a/appwrite/enums/documents_db_index_type.py b/appwrite/enums/documents_db_index_type.py deleted file mode 100644 index 30cb9e7c..00000000 --- a/appwrite/enums/documents_db_index_type.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import Enum - -class DocumentsDBIndexType(Enum): - KEY = "key" - FULLTEXT = "fulltext" - UNIQUE = "unique" - SPATIAL = "spatial" diff --git a/appwrite/enums/model.py b/appwrite/enums/model.py deleted file mode 100644 index 88068045..00000000 --- a/appwrite/enums/model.py +++ /dev/null @@ -1,4 +0,0 @@ -from enum import Enum - -class Model(Enum): - EMBEDDINGGEMMA = "embeddinggemma" diff --git a/appwrite/enums/template_reference_type.py b/appwrite/enums/template_reference_type.py index 9b0e50e9..b523991a 100644 --- a/appwrite/enums/template_reference_type.py +++ b/appwrite/enums/template_reference_type.py @@ -1,6 +1,6 @@ from enum import Enum class TemplateReferenceType(Enum): - BRANCH = "branch" COMMIT = "commit" + BRANCH = "branch" TAG = "tag" diff --git a/appwrite/enums/vcs_reference_type.py b/appwrite/enums/vcs_reference_type.py index e172e638..4a6d7ebb 100644 --- a/appwrite/enums/vcs_reference_type.py +++ b/appwrite/enums/vcs_reference_type.py @@ -3,4 +3,3 @@ class VCSReferenceType(Enum): BRANCH = "branch" COMMIT = "commit" - TAG = "tag" diff --git a/appwrite/enums/vectors_db_index_type.py b/appwrite/enums/vectors_db_index_type.py deleted file mode 100644 index 651be5d3..00000000 --- a/appwrite/enums/vectors_db_index_type.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - -class VectorsDBIndexType(Enum): - HNSW_EUCLIDEAN = "hnsw_euclidean" - HNSW_DOT = "hnsw_dot" - HNSW_COSINE = "hnsw_cosine" - OBJECT = "object" - KEY = "key" - UNIQUE = "unique" diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index 9282f487..519dabc8 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -1,299 +1,287 @@ from .base_model import AppwriteModel -from .row_list import RowList -from .document_list import DocumentList -from .table_list import TableList -from .collection_list import CollectionList -from .database_list import DatabaseList -from .index_list import IndexList -from .column_index_list import ColumnIndexList -from .user_list import UserList -from .session_list import SessionList +from .user import User from .identity_list import IdentityList +from .jwt import Jwt from .log_list import LogList -from .file_list import FileList -from .bucket_list import BucketList -from .resource_token_list import ResourceTokenList -from .team_list import TeamList -from .membership_list import MembershipList -from .site_list import SiteList -from .function_list import FunctionList -from .framework_list import FrameworkList -from .runtime_list import RuntimeList -from .deployment_list import DeploymentList -from .execution_list import ExecutionList -from .webhook_list import WebhookList -from .country_list import CountryList -from .continent_list import ContinentList -from .language_list import LanguageList -from .currency_list import CurrencyList -from .phone_list import PhoneList -from .variable_list import VariableList -from .health_status_list import HealthStatusList -from .locale_code_list import LocaleCodeList -from .provider_list import ProviderList -from .message_list import MessageList -from .topic_list import TopicList -from .subscriber_list import SubscriberList -from .target_list import TargetList -from .transaction_list import TransactionList -from .specification_list import SpecificationList -from .vectorsdb_collection_list import VectorsdbCollectionList -from .embedding_list import EmbeddingList +from .mfa_type import MfaType +from .mfa_challenge import MfaChallenge +from .session import Session +from .mfa_factors import MfaFactors +from .mfa_recovery_codes import MfaRecoveryCodes +from .preferences import Preferences +from .token import Token +from .session_list import SessionList +from .activity_event_list import ActivityEventList +from .activity_event import ActivityEvent +from .backup_archive_list import BackupArchiveList +from .backup_archive import BackupArchive +from .backup_policy_list import BackupPolicyList +from .backup_policy import BackupPolicy +from .backup_restoration import BackupRestoration +from .backup_restoration_list import BackupRestorationList +from .database_list import DatabaseList from .database import Database -from .embedding import Embedding +from .transaction_list import TransactionList +from .transaction import Transaction +from .collection_list import CollectionList from .collection import Collection from .attribute_list import AttributeList -from .attribute_string import AttributeString -from .attribute_integer import AttributeInteger -from .attribute_float import AttributeFloat from .attribute_boolean import AttributeBoolean +from .attribute_datetime import AttributeDatetime from .attribute_email import AttributeEmail from .attribute_enum import AttributeEnum +from .attribute_float import AttributeFloat +from .attribute_integer import AttributeInteger from .attribute_ip import AttributeIp -from .attribute_url import AttributeUrl -from .attribute_datetime import AttributeDatetime -from .attribute_relationship import AttributeRelationship -from .attribute_point import AttributePoint from .attribute_line import AttributeLine +from .attribute_longtext import AttributeLongtext +from .attribute_mediumtext import AttributeMediumtext +from .attribute_point import AttributePoint from .attribute_polygon import AttributePolygon -from .attribute_varchar import AttributeVarchar +from .attribute_relationship import AttributeRelationship +from .attribute_string import AttributeString from .attribute_text import AttributeText -from .attribute_mediumtext import AttributeMediumtext -from .attribute_longtext import AttributeLongtext -from .vectorsdb_collection import VectorsdbCollection -from .attribute_object import AttributeObject -from .attribute_vector import AttributeVector +from .attribute_url import AttributeUrl +from .attribute_varchar import AttributeVarchar +from .document_list import DocumentList +from .document import Document +from .index_list import IndexList +from .index import Index +from .function_list import FunctionList +from .function import Function +from .runtime_list import RuntimeList +from .specification_list import SpecificationList +from .deployment_list import DeploymentList +from .deployment import Deployment +from .execution_list import ExecutionList +from .execution import Execution +from .variable_list import VariableList +from .variable import Variable +from .health_status import HealthStatus +from .health_antivirus import HealthAntivirus +from .health_status_list import HealthStatusList +from .health_certificate import HealthCertificate +from .health_queue import HealthQueue +from .health_time import HealthTime +from .locale import Locale +from .locale_code_list import LocaleCodeList +from .continent_list import ContinentList +from .country_list import CountryList +from .phone_list import PhoneList +from .currency_list import CurrencyList +from .language_list import LanguageList +from .message_list import MessageList +from .message import Message +from .target_list import TargetList +from .provider_list import ProviderList +from .provider import Provider +from .topic_list import TopicList +from .topic import Topic +from .subscriber_list import SubscriberList +from .subscriber import Subscriber +from .site_list import SiteList +from .site import Site +from .framework_list import FrameworkList +from .bucket_list import BucketList +from .bucket import Bucket +from .file_list import FileList +from .file import File +from .table_list import TableList from .table import Table from .column_list import ColumnList -from .column_string import ColumnString -from .column_integer import ColumnInteger -from .column_float import ColumnFloat from .column_boolean import ColumnBoolean +from .column_datetime import ColumnDatetime from .column_email import ColumnEmail from .column_enum import ColumnEnum +from .column_float import ColumnFloat +from .column_integer import ColumnInteger from .column_ip import ColumnIp -from .column_url import ColumnUrl -from .column_datetime import ColumnDatetime -from .column_relationship import ColumnRelationship -from .column_point import ColumnPoint from .column_line import ColumnLine +from .column_longtext import ColumnLongtext +from .column_mediumtext import ColumnMediumtext +from .column_point import ColumnPoint from .column_polygon import ColumnPolygon -from .column_varchar import ColumnVarchar +from .column_relationship import ColumnRelationship +from .column_string import ColumnString from .column_text import ColumnText -from .column_mediumtext import ColumnMediumtext -from .column_longtext import ColumnLongtext -from .index import Index +from .column_url import ColumnUrl +from .column_varchar import ColumnVarchar +from .column_index_list import ColumnIndexList from .column_index import ColumnIndex +from .row_list import RowList from .row import Row -from .document import Document -from .log import Log -from .user import User -from .algo_md5 import AlgoMd5 -from .algo_sha import AlgoSha -from .algo_phpass import AlgoPhpass -from .algo_bcrypt import AlgoBcrypt +from .team_list import TeamList +from .team import Team +from .membership_list import MembershipList +from .membership import Membership +from .resource_token_list import ResourceTokenList +from .resource_token import ResourceToken +from .user_list import UserList +from .target import Target +from .webhook_list import WebhookList +from .webhook import Webhook +from .algo_argon2 import AlgoArgon2 from .algo_scrypt import AlgoScrypt from .algo_scrypt_modified import AlgoScryptModified -from .algo_argon2 import AlgoArgon2 -from .preferences import Preferences -from .session import Session +from .algo_bcrypt import AlgoBcrypt +from .algo_phpass import AlgoPhpass +from .algo_sha import AlgoSha +from .algo_md5 import AlgoMd5 from .identity import Identity -from .token import Token -from .jwt import Jwt -from .locale import Locale -from .locale_code import LocaleCode -from .file import File -from .bucket import Bucket -from .resource_token import ResourceToken -from .team import Team -from .membership import Membership -from .site import Site -from .function import Function +from .log import Log from .runtime import Runtime -from .framework import Framework -from .framework_adapter import FrameworkAdapter -from .deployment import Deployment -from .execution import Execution -from .webhook import Webhook -from .variable import Variable -from .country import Country +from .specification import Specification +from .headers import Headers +from .locale_code import LocaleCode from .continent import Continent -from .language import Language -from .currency import Currency +from .country import Country from .phone import Phone -from .health_antivirus import HealthAntivirus -from .health_queue import HealthQueue -from .health_status import HealthStatus -from .health_certificate import HealthCertificate -from .health_time import HealthTime -from .headers import Headers -from .specification import Specification -from .mfa_challenge import MfaChallenge -from .mfa_recovery_codes import MfaRecoveryCodes -from .mfa_type import MfaType -from .mfa_factors import MfaFactors -from .provider import Provider -from .message import Message -from .topic import Topic -from .transaction import Transaction -from .subscriber import Subscriber -from .target import Target -from .activity_event import ActivityEvent -from .backup_archive import BackupArchive -from .backup_policy import BackupPolicy -from .backup_restoration import BackupRestoration -from .activity_event_list import ActivityEventList -from .backup_archive_list import BackupArchiveList -from .backup_policy_list import BackupPolicyList -from .backup_restoration_list import BackupRestorationList +from .currency import Currency +from .language import Language +from .framework import Framework +from .framework_adapter import FrameworkAdapter __all__ = [ 'AppwriteModel', - 'RowList', - 'DocumentList', - 'TableList', - 'CollectionList', - 'DatabaseList', - 'IndexList', - 'ColumnIndexList', - 'UserList', - 'SessionList', + 'User', 'IdentityList', + 'Jwt', 'LogList', - 'FileList', - 'BucketList', - 'ResourceTokenList', - 'TeamList', - 'MembershipList', - 'SiteList', - 'FunctionList', - 'FrameworkList', - 'RuntimeList', - 'DeploymentList', - 'ExecutionList', - 'WebhookList', - 'CountryList', - 'ContinentList', - 'LanguageList', - 'CurrencyList', - 'PhoneList', - 'VariableList', - 'HealthStatusList', - 'LocaleCodeList', - 'ProviderList', - 'MessageList', - 'TopicList', - 'SubscriberList', - 'TargetList', - 'TransactionList', - 'SpecificationList', - 'VectorsdbCollectionList', - 'EmbeddingList', + 'MfaType', + 'MfaChallenge', + 'Session', + 'MfaFactors', + 'MfaRecoveryCodes', + 'Preferences', + 'Token', + 'SessionList', + 'ActivityEventList', + 'ActivityEvent', + 'BackupArchiveList', + 'BackupArchive', + 'BackupPolicyList', + 'BackupPolicy', + 'BackupRestoration', + 'BackupRestorationList', + 'DatabaseList', 'Database', - 'Embedding', + 'TransactionList', + 'Transaction', + 'CollectionList', 'Collection', 'AttributeList', - 'AttributeString', - 'AttributeInteger', - 'AttributeFloat', 'AttributeBoolean', + 'AttributeDatetime', 'AttributeEmail', 'AttributeEnum', + 'AttributeFloat', + 'AttributeInteger', 'AttributeIp', - 'AttributeUrl', - 'AttributeDatetime', - 'AttributeRelationship', - 'AttributePoint', 'AttributeLine', + 'AttributeLongtext', + 'AttributeMediumtext', + 'AttributePoint', 'AttributePolygon', - 'AttributeVarchar', + 'AttributeRelationship', + 'AttributeString', 'AttributeText', - 'AttributeMediumtext', - 'AttributeLongtext', - 'VectorsdbCollection', - 'AttributeObject', - 'AttributeVector', + 'AttributeUrl', + 'AttributeVarchar', + 'DocumentList', + 'Document', + 'IndexList', + 'Index', + 'FunctionList', + 'Function', + 'RuntimeList', + 'SpecificationList', + 'DeploymentList', + 'Deployment', + 'ExecutionList', + 'Execution', + 'VariableList', + 'Variable', + 'HealthStatus', + 'HealthAntivirus', + 'HealthStatusList', + 'HealthCertificate', + 'HealthQueue', + 'HealthTime', + 'Locale', + 'LocaleCodeList', + 'ContinentList', + 'CountryList', + 'PhoneList', + 'CurrencyList', + 'LanguageList', + 'MessageList', + 'Message', + 'TargetList', + 'ProviderList', + 'Provider', + 'TopicList', + 'Topic', + 'SubscriberList', + 'Subscriber', + 'SiteList', + 'Site', + 'FrameworkList', + 'BucketList', + 'Bucket', + 'FileList', + 'File', + 'TableList', 'Table', 'ColumnList', - 'ColumnString', - 'ColumnInteger', - 'ColumnFloat', 'ColumnBoolean', + 'ColumnDatetime', 'ColumnEmail', 'ColumnEnum', + 'ColumnFloat', + 'ColumnInteger', 'ColumnIp', - 'ColumnUrl', - 'ColumnDatetime', - 'ColumnRelationship', - 'ColumnPoint', 'ColumnLine', + 'ColumnLongtext', + 'ColumnMediumtext', + 'ColumnPoint', 'ColumnPolygon', - 'ColumnVarchar', + 'ColumnRelationship', + 'ColumnString', 'ColumnText', - 'ColumnMediumtext', - 'ColumnLongtext', - 'Index', + 'ColumnUrl', + 'ColumnVarchar', + 'ColumnIndexList', 'ColumnIndex', + 'RowList', 'Row', - 'Document', - 'Log', - 'User', - 'AlgoMd5', - 'AlgoSha', - 'AlgoPhpass', - 'AlgoBcrypt', + 'TeamList', + 'Team', + 'MembershipList', + 'Membership', + 'ResourceTokenList', + 'ResourceToken', + 'UserList', + 'Target', + 'WebhookList', + 'Webhook', + 'AlgoArgon2', 'AlgoScrypt', 'AlgoScryptModified', - 'AlgoArgon2', - 'Preferences', - 'Session', + 'AlgoBcrypt', + 'AlgoPhpass', + 'AlgoSha', + 'AlgoMd5', 'Identity', - 'Token', - 'Jwt', - 'Locale', - 'LocaleCode', - 'File', - 'Bucket', - 'ResourceToken', - 'Team', - 'Membership', - 'Site', - 'Function', + 'Log', 'Runtime', - 'Framework', - 'FrameworkAdapter', - 'Deployment', - 'Execution', - 'Webhook', - 'Variable', - 'Country', + 'Specification', + 'Headers', + 'LocaleCode', 'Continent', - 'Language', - 'Currency', + 'Country', 'Phone', - 'HealthAntivirus', - 'HealthQueue', - 'HealthStatus', - 'HealthCertificate', - 'HealthTime', - 'Headers', - 'Specification', - 'MfaChallenge', - 'MfaRecoveryCodes', - 'MfaType', - 'MfaFactors', - 'Provider', - 'Message', - 'Topic', - 'Transaction', - 'Subscriber', - 'Target', - 'ActivityEvent', - 'BackupArchive', - 'BackupPolicy', - 'BackupRestoration', - 'ActivityEventList', - 'BackupArchiveList', - 'BackupPolicyList', - 'BackupRestorationList', + 'Currency', + 'Language', + 'Framework', + 'FrameworkAdapter', ] diff --git a/appwrite/models/attribute_object.py b/appwrite/models/attribute_object.py deleted file mode 100644 index 20438c7b..00000000 --- a/appwrite/models/attribute_object.py +++ /dev/null @@ -1,37 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel -from ..enums.attribute_status import AttributeStatus - -class AttributeObject(AppwriteModel): - """ - AttributeObject - - Attributes - ---------- - key : str - Attribute Key. - type : str - Attribute type. - status : AttributeStatus - Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - error : str - Error message. Displays error generated on failure of creating or deleting an attribute. - required : bool - Is attribute required? - array : Optional[bool] - Is attribute an array? - createdat : str - Attribute creation date in ISO 8601 format. - updatedat : str - Attribute update date in ISO 8601 format. - """ - key: str = Field(..., alias='key') - type: str = Field(..., alias='type') - status: AttributeStatus = Field(..., alias='status') - error: str = Field(..., alias='error') - required: bool = Field(..., alias='required') - array: Optional[bool] = Field(default=None, alias='array') - createdat: str = Field(..., alias='$createdAt') - updatedat: str = Field(..., alias='$updatedAt') diff --git a/appwrite/models/attribute_vector.py b/appwrite/models/attribute_vector.py deleted file mode 100644 index 1b5f9909..00000000 --- a/appwrite/models/attribute_vector.py +++ /dev/null @@ -1,40 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel -from ..enums.attribute_status import AttributeStatus - -class AttributeVector(AppwriteModel): - """ - AttributeVector - - Attributes - ---------- - key : str - Attribute Key. - type : str - Attribute type. - status : AttributeStatus - Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - error : str - Error message. Displays error generated on failure of creating or deleting an attribute. - required : bool - Is attribute required? - array : Optional[bool] - Is attribute an array? - createdat : str - Attribute creation date in ISO 8601 format. - updatedat : str - Attribute update date in ISO 8601 format. - size : float - Vector dimensions. - """ - key: str = Field(..., alias='key') - type: str = Field(..., alias='type') - status: AttributeStatus = Field(..., alias='status') - error: str = Field(..., alias='error') - required: bool = Field(..., alias='required') - array: Optional[bool] = Field(default=None, alias='array') - createdat: str = Field(..., alias='$createdAt') - updatedat: str = Field(..., alias='$updatedAt') - size: float = Field(..., alias='size') diff --git a/appwrite/models/embedding.py b/appwrite/models/embedding.py deleted file mode 100644 index 9da9bab5..00000000 --- a/appwrite/models/embedding.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel - -class Embedding(AppwriteModel): - """ - Embedding - - Attributes - ---------- - model : str - Embedding model used to generate embeddings. - dimension : float - Number of dimensions for each embedding vector. - embedding : List[Any] - Embedding vector values. If an error occurs, this will be an empty array. - error : str - Error message if embedding generation fails. Empty string if no error. - """ - model: str = Field(..., alias='model') - dimension: float = Field(..., alias='dimension') - embedding: List[Any] = Field(..., alias='embedding') - error: str = Field(..., alias='error') diff --git a/appwrite/models/embedding_list.py b/appwrite/models/embedding_list.py deleted file mode 100644 index d8f437e7..00000000 --- a/appwrite/models/embedding_list.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel -from .embedding import Embedding - -class EmbeddingList(AppwriteModel): - """ - Embedding list - - Attributes - ---------- - total : float - Total number of embeddings that matched your query. - embeddings : List[Embedding] - List of embeddings. - """ - total: float = Field(..., alias='total') - embeddings: List[Embedding] = Field(..., alias='embeddings') diff --git a/appwrite/models/vectorsdb_collection.py b/appwrite/models/vectorsdb_collection.py deleted file mode 100644 index ed0ed0e2..00000000 --- a/appwrite/models/vectorsdb_collection.py +++ /dev/null @@ -1,54 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel -from .attribute_object import AttributeObject -from .attribute_vector import AttributeVector -from .index import Index - -class VectorsdbCollection(AppwriteModel): - """ - VectorsDB Collection - - Attributes - ---------- - id : str - Collection ID. - createdat : str - Collection creation date in ISO 8601 format. - updatedat : str - Collection update date in ISO 8601 format. - permissions : List[Any] - Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - databaseid : str - Database ID. - name : str - Collection name. - enabled : bool - Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. - documentsecurity : bool - Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). - attributes : List[Union[AttributeObject, AttributeVector]] - Collection attributes. - indexes : List[Index] - Collection indexes. - bytesmax : float - Maximum document size in bytes. Returns 0 when no limit applies. - bytesused : float - Currently used document size in bytes based on defined attributes. - dimension : float - Embedding dimension. - """ - id: str = Field(..., alias='$id') - createdat: str = Field(..., alias='$createdAt') - updatedat: str = Field(..., alias='$updatedAt') - permissions: List[Any] = Field(..., alias='$permissions') - databaseid: str = Field(..., alias='databaseId') - name: str = Field(..., alias='name') - enabled: bool = Field(..., alias='enabled') - documentsecurity: bool = Field(..., alias='documentSecurity') - attributes: List[Union[AttributeObject, AttributeVector]] = Field(..., alias='attributes') - indexes: List[Index] = Field(..., alias='indexes') - bytesmax: float = Field(..., alias='bytesMax') - bytesused: float = Field(..., alias='bytesUsed') - dimension: float = Field(..., alias='dimension') diff --git a/appwrite/models/vectorsdb_collection_list.py b/appwrite/models/vectorsdb_collection_list.py deleted file mode 100644 index 2ed72af5..00000000 --- a/appwrite/models/vectorsdb_collection_list.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Any, Dict, List, Optional, Union, cast -from pydantic import Field, PrivateAttr - -from .base_model import AppwriteModel -from .vectorsdb_collection import VectorsdbCollection - -class VectorsdbCollectionList(AppwriteModel): - """ - VectorsDB Collections List - - Attributes - ---------- - total : float - Total number of collections that matched your query. - collections : List[VectorsdbCollection] - List of collections. - """ - total: float = Field(..., alias='total') - collections: List[VectorsdbCollection] = Field(..., alias='collections') diff --git a/appwrite/services/health.py b/appwrite/services/health.py index 35c5366a..1aafa0b0 100644 --- a/appwrite/services/health.py +++ b/appwrite/services/health.py @@ -256,76 +256,6 @@ def get_queue_audits( return self._parse_response(response, model=HealthQueue) - def get_queue_billing_project_aggregation( - self, - threshold: Optional[float] = None - ) -> HealthQueue: - """ - Get billing project aggregation queue. - - Parameters - ---------- - threshold : Optional[float] - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - - Returns - ------- - HealthQueue - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/health/queue/billing-project-aggregation' - api_params = {} - - if threshold is not None: - api_params['threshold'] = self._normalize_value(threshold) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=HealthQueue) - - - def get_queue_billing_team_aggregation( - self, - threshold: Optional[float] = None - ) -> HealthQueue: - """ - Get billing team aggregation queue. - - Parameters - ---------- - threshold : Optional[float] - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - - Returns - ------- - HealthQueue - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/health/queue/billing-team-aggregation' - api_params = {} - - if threshold is not None: - api_params['threshold'] = self._normalize_value(threshold) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=HealthQueue) - - def get_queue_builds( self, threshold: Optional[float] = None @@ -361,41 +291,6 @@ def get_queue_builds( return self._parse_response(response, model=HealthQueue) - def get_queue_priority_builds( - self, - threshold: Optional[float] = None - ) -> HealthQueue: - """ - Get the priority builds queue size. - - Parameters - ---------- - threshold : Optional[float] - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. - - Returns - ------- - HealthQueue - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/health/queue/builds-priority' - api_params = {} - - if threshold is not None: - api_params['threshold'] = self._normalize_value(threshold) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=HealthQueue) - - def get_queue_certificates( self, threshold: Optional[float] = None @@ -724,41 +619,6 @@ def get_queue_migrations( return self._parse_response(response, model=HealthQueue) - def get_queue_region_manager( - self, - threshold: Optional[float] = None - ) -> HealthQueue: - """ - Get region manager queue. - - Parameters - ---------- - threshold : Optional[float] - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - - Returns - ------- - HealthQueue - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/health/queue/region-manager' - api_params = {} - - if threshold is not None: - api_params['threshold'] = self._normalize_value(threshold) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=HealthQueue) - - def get_queue_stats_resources( self, threshold: Optional[float] = None @@ -829,41 +689,6 @@ def get_queue_usage( return self._parse_response(response, model=HealthQueue) - def get_queue_threats( - self, - threshold: Optional[float] = None - ) -> HealthQueue: - """ - Get threats queue. - - Parameters - ---------- - threshold : Optional[float] - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - - Returns - ------- - HealthQueue - API response as a typed Pydantic model - - Raises - ------ - AppwriteException - If API request fails - """ - - api_path = '/health/queue/threats' - api_params = {} - - if threshold is not None: - api_params['threshold'] = self._normalize_value(threshold) - - response = self.client.call('get', api_path, { - }, api_params) - - return self._parse_response(response, model=HealthQueue) - - def get_queue_webhooks( self, threshold: Optional[float] = None From 8c17c2f6dcaf38b968825278bd7995626ef8ad32 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 07:03:57 +0000 Subject: [PATCH 5/9] chore: update Python SDK to 17.0.0 --- appwrite/encoders/value_class_encoder.py | 14 +- appwrite/models/__init__.py | 448 +++++++++++------------ 2 files changed, 231 insertions(+), 231 deletions(-) diff --git a/appwrite/encoders/value_class_encoder.py b/appwrite/encoders/value_class_encoder.py index aba85579..19c4fb48 100644 --- a/appwrite/encoders/value_class_encoder.py +++ b/appwrite/encoders/value_class_encoder.py @@ -34,14 +34,14 @@ from ..enums.messaging_provider_type import MessagingProviderType from ..enums.database_type import DatabaseType from ..enums.attribute_status import AttributeStatus +from ..enums.column_status import ColumnStatus from ..enums.index_status import IndexStatus from ..enums.deployment_status import DeploymentStatus from ..enums.execution_trigger import ExecutionTrigger from ..enums.execution_status import ExecutionStatus -from ..enums.health_check_status import HealthCheckStatus from ..enums.health_antivirus_status import HealthAntivirusStatus +from ..enums.health_check_status import HealthCheckStatus from ..enums.message_status import MessageStatus -from ..enums.column_status import ColumnStatus class ValueClassEncoder(json.JSONEncoder): def default(self, o): @@ -150,6 +150,9 @@ def default(self, o): if isinstance(o, AttributeStatus): return o.value + if isinstance(o, ColumnStatus): + return o.value + if isinstance(o, IndexStatus): return o.value @@ -162,16 +165,13 @@ def default(self, o): if isinstance(o, ExecutionStatus): return o.value - if isinstance(o, HealthCheckStatus): - return o.value - if isinstance(o, HealthAntivirusStatus): return o.value - if isinstance(o, MessageStatus): + if isinstance(o, HealthCheckStatus): return o.value - if isinstance(o, ColumnStatus): + if isinstance(o, MessageStatus): return o.value return super().default(o) diff --git a/appwrite/models/__init__.py b/appwrite/models/__init__.py index 519dabc8..5bf96835 100644 --- a/appwrite/models/__init__.py +++ b/appwrite/models/__init__.py @@ -1,287 +1,287 @@ from .base_model import AppwriteModel -from .user import User -from .identity_list import IdentityList -from .jwt import Jwt -from .log_list import LogList -from .mfa_type import MfaType -from .mfa_challenge import MfaChallenge -from .session import Session -from .mfa_factors import MfaFactors -from .mfa_recovery_codes import MfaRecoveryCodes -from .preferences import Preferences -from .token import Token -from .session_list import SessionList -from .activity_event_list import ActivityEventList -from .activity_event import ActivityEvent -from .backup_archive_list import BackupArchiveList -from .backup_archive import BackupArchive -from .backup_policy_list import BackupPolicyList -from .backup_policy import BackupPolicy -from .backup_restoration import BackupRestoration -from .backup_restoration_list import BackupRestorationList -from .database_list import DatabaseList -from .database import Database -from .transaction_list import TransactionList -from .transaction import Transaction -from .collection_list import CollectionList -from .collection import Collection -from .attribute_list import AttributeList -from .attribute_boolean import AttributeBoolean -from .attribute_datetime import AttributeDatetime -from .attribute_email import AttributeEmail -from .attribute_enum import AttributeEnum -from .attribute_float import AttributeFloat -from .attribute_integer import AttributeInteger -from .attribute_ip import AttributeIp -from .attribute_line import AttributeLine -from .attribute_longtext import AttributeLongtext -from .attribute_mediumtext import AttributeMediumtext -from .attribute_point import AttributePoint -from .attribute_polygon import AttributePolygon -from .attribute_relationship import AttributeRelationship -from .attribute_string import AttributeString -from .attribute_text import AttributeText -from .attribute_url import AttributeUrl -from .attribute_varchar import AttributeVarchar +from .row_list import RowList from .document_list import DocumentList -from .document import Document +from .table_list import TableList +from .collection_list import CollectionList +from .database_list import DatabaseList from .index_list import IndexList -from .index import Index +from .column_index_list import ColumnIndexList +from .user_list import UserList +from .session_list import SessionList +from .identity_list import IdentityList +from .log_list import LogList +from .file_list import FileList +from .bucket_list import BucketList +from .resource_token_list import ResourceTokenList +from .team_list import TeamList +from .membership_list import MembershipList +from .site_list import SiteList from .function_list import FunctionList -from .function import Function +from .framework_list import FrameworkList from .runtime_list import RuntimeList -from .specification_list import SpecificationList from .deployment_list import DeploymentList -from .deployment import Deployment from .execution_list import ExecutionList -from .execution import Execution +from .webhook_list import WebhookList +from .country_list import CountryList +from .continent_list import ContinentList +from .language_list import LanguageList +from .currency_list import CurrencyList +from .phone_list import PhoneList from .variable_list import VariableList -from .variable import Variable -from .health_status import HealthStatus -from .health_antivirus import HealthAntivirus from .health_status_list import HealthStatusList -from .health_certificate import HealthCertificate -from .health_queue import HealthQueue -from .health_time import HealthTime -from .locale import Locale from .locale_code_list import LocaleCodeList -from .continent_list import ContinentList -from .country_list import CountryList -from .phone_list import PhoneList -from .currency_list import CurrencyList -from .language_list import LanguageList -from .message_list import MessageList -from .message import Message -from .target_list import TargetList from .provider_list import ProviderList -from .provider import Provider +from .message_list import MessageList from .topic_list import TopicList -from .topic import Topic from .subscriber_list import SubscriberList -from .subscriber import Subscriber -from .site_list import SiteList -from .site import Site -from .framework_list import FrameworkList -from .bucket_list import BucketList -from .bucket import Bucket -from .file_list import FileList -from .file import File -from .table_list import TableList +from .target_list import TargetList +from .transaction_list import TransactionList +from .specification_list import SpecificationList +from .database import Database +from .collection import Collection +from .attribute_list import AttributeList +from .attribute_string import AttributeString +from .attribute_integer import AttributeInteger +from .attribute_float import AttributeFloat +from .attribute_boolean import AttributeBoolean +from .attribute_email import AttributeEmail +from .attribute_enum import AttributeEnum +from .attribute_ip import AttributeIp +from .attribute_url import AttributeUrl +from .attribute_datetime import AttributeDatetime +from .attribute_relationship import AttributeRelationship +from .attribute_point import AttributePoint +from .attribute_line import AttributeLine +from .attribute_polygon import AttributePolygon +from .attribute_varchar import AttributeVarchar +from .attribute_text import AttributeText +from .attribute_mediumtext import AttributeMediumtext +from .attribute_longtext import AttributeLongtext from .table import Table from .column_list import ColumnList +from .column_string import ColumnString +from .column_integer import ColumnInteger +from .column_float import ColumnFloat from .column_boolean import ColumnBoolean -from .column_datetime import ColumnDatetime from .column_email import ColumnEmail from .column_enum import ColumnEnum -from .column_float import ColumnFloat -from .column_integer import ColumnInteger from .column_ip import ColumnIp -from .column_line import ColumnLine -from .column_longtext import ColumnLongtext -from .column_mediumtext import ColumnMediumtext +from .column_url import ColumnUrl +from .column_datetime import ColumnDatetime +from .column_relationship import ColumnRelationship from .column_point import ColumnPoint +from .column_line import ColumnLine from .column_polygon import ColumnPolygon -from .column_relationship import ColumnRelationship -from .column_string import ColumnString -from .column_text import ColumnText -from .column_url import ColumnUrl from .column_varchar import ColumnVarchar -from .column_index_list import ColumnIndexList +from .column_text import ColumnText +from .column_mediumtext import ColumnMediumtext +from .column_longtext import ColumnLongtext +from .index import Index from .column_index import ColumnIndex -from .row_list import RowList from .row import Row -from .team_list import TeamList -from .team import Team -from .membership_list import MembershipList -from .membership import Membership -from .resource_token_list import ResourceTokenList -from .resource_token import ResourceToken -from .user_list import UserList -from .target import Target -from .webhook_list import WebhookList -from .webhook import Webhook -from .algo_argon2 import AlgoArgon2 +from .document import Document +from .log import Log +from .user import User +from .algo_md5 import AlgoMd5 +from .algo_sha import AlgoSha +from .algo_phpass import AlgoPhpass +from .algo_bcrypt import AlgoBcrypt from .algo_scrypt import AlgoScrypt from .algo_scrypt_modified import AlgoScryptModified -from .algo_bcrypt import AlgoBcrypt -from .algo_phpass import AlgoPhpass -from .algo_sha import AlgoSha -from .algo_md5 import AlgoMd5 +from .algo_argon2 import AlgoArgon2 +from .preferences import Preferences +from .session import Session from .identity import Identity -from .log import Log -from .runtime import Runtime -from .specification import Specification -from .headers import Headers +from .token import Token +from .jwt import Jwt +from .locale import Locale from .locale_code import LocaleCode -from .continent import Continent -from .country import Country -from .phone import Phone -from .currency import Currency -from .language import Language +from .file import File +from .bucket import Bucket +from .resource_token import ResourceToken +from .team import Team +from .membership import Membership +from .site import Site +from .function import Function +from .runtime import Runtime from .framework import Framework from .framework_adapter import FrameworkAdapter +from .deployment import Deployment +from .execution import Execution +from .webhook import Webhook +from .variable import Variable +from .country import Country +from .continent import Continent +from .language import Language +from .currency import Currency +from .phone import Phone +from .health_antivirus import HealthAntivirus +from .health_queue import HealthQueue +from .health_status import HealthStatus +from .health_certificate import HealthCertificate +from .health_time import HealthTime +from .headers import Headers +from .specification import Specification +from .mfa_challenge import MfaChallenge +from .mfa_recovery_codes import MfaRecoveryCodes +from .mfa_type import MfaType +from .mfa_factors import MfaFactors +from .provider import Provider +from .message import Message +from .topic import Topic +from .transaction import Transaction +from .subscriber import Subscriber +from .target import Target +from .activity_event import ActivityEvent +from .backup_archive import BackupArchive +from .backup_policy import BackupPolicy +from .backup_restoration import BackupRestoration +from .activity_event_list import ActivityEventList +from .backup_archive_list import BackupArchiveList +from .backup_policy_list import BackupPolicyList +from .backup_restoration_list import BackupRestorationList __all__ = [ 'AppwriteModel', - 'User', - 'IdentityList', - 'Jwt', - 'LogList', - 'MfaType', - 'MfaChallenge', - 'Session', - 'MfaFactors', - 'MfaRecoveryCodes', - 'Preferences', - 'Token', - 'SessionList', - 'ActivityEventList', - 'ActivityEvent', - 'BackupArchiveList', - 'BackupArchive', - 'BackupPolicyList', - 'BackupPolicy', - 'BackupRestoration', - 'BackupRestorationList', - 'DatabaseList', - 'Database', - 'TransactionList', - 'Transaction', - 'CollectionList', - 'Collection', - 'AttributeList', - 'AttributeBoolean', - 'AttributeDatetime', - 'AttributeEmail', - 'AttributeEnum', - 'AttributeFloat', - 'AttributeInteger', - 'AttributeIp', - 'AttributeLine', - 'AttributeLongtext', - 'AttributeMediumtext', - 'AttributePoint', - 'AttributePolygon', - 'AttributeRelationship', - 'AttributeString', - 'AttributeText', - 'AttributeUrl', - 'AttributeVarchar', + 'RowList', 'DocumentList', - 'Document', + 'TableList', + 'CollectionList', + 'DatabaseList', 'IndexList', - 'Index', + 'ColumnIndexList', + 'UserList', + 'SessionList', + 'IdentityList', + 'LogList', + 'FileList', + 'BucketList', + 'ResourceTokenList', + 'TeamList', + 'MembershipList', + 'SiteList', 'FunctionList', - 'Function', + 'FrameworkList', 'RuntimeList', - 'SpecificationList', 'DeploymentList', - 'Deployment', 'ExecutionList', - 'Execution', + 'WebhookList', + 'CountryList', + 'ContinentList', + 'LanguageList', + 'CurrencyList', + 'PhoneList', 'VariableList', - 'Variable', - 'HealthStatus', - 'HealthAntivirus', 'HealthStatusList', - 'HealthCertificate', - 'HealthQueue', - 'HealthTime', - 'Locale', 'LocaleCodeList', - 'ContinentList', - 'CountryList', - 'PhoneList', - 'CurrencyList', - 'LanguageList', - 'MessageList', - 'Message', - 'TargetList', 'ProviderList', - 'Provider', + 'MessageList', 'TopicList', - 'Topic', 'SubscriberList', - 'Subscriber', - 'SiteList', - 'Site', - 'FrameworkList', - 'BucketList', - 'Bucket', - 'FileList', - 'File', - 'TableList', + 'TargetList', + 'TransactionList', + 'SpecificationList', + 'Database', + 'Collection', + 'AttributeList', + 'AttributeString', + 'AttributeInteger', + 'AttributeFloat', + 'AttributeBoolean', + 'AttributeEmail', + 'AttributeEnum', + 'AttributeIp', + 'AttributeUrl', + 'AttributeDatetime', + 'AttributeRelationship', + 'AttributePoint', + 'AttributeLine', + 'AttributePolygon', + 'AttributeVarchar', + 'AttributeText', + 'AttributeMediumtext', + 'AttributeLongtext', 'Table', 'ColumnList', + 'ColumnString', + 'ColumnInteger', + 'ColumnFloat', 'ColumnBoolean', - 'ColumnDatetime', 'ColumnEmail', 'ColumnEnum', - 'ColumnFloat', - 'ColumnInteger', 'ColumnIp', - 'ColumnLine', - 'ColumnLongtext', - 'ColumnMediumtext', + 'ColumnUrl', + 'ColumnDatetime', + 'ColumnRelationship', 'ColumnPoint', + 'ColumnLine', 'ColumnPolygon', - 'ColumnRelationship', - 'ColumnString', - 'ColumnText', - 'ColumnUrl', 'ColumnVarchar', - 'ColumnIndexList', + 'ColumnText', + 'ColumnMediumtext', + 'ColumnLongtext', + 'Index', 'ColumnIndex', - 'RowList', 'Row', - 'TeamList', - 'Team', - 'MembershipList', - 'Membership', - 'ResourceTokenList', - 'ResourceToken', - 'UserList', - 'Target', - 'WebhookList', - 'Webhook', - 'AlgoArgon2', + 'Document', + 'Log', + 'User', + 'AlgoMd5', + 'AlgoSha', + 'AlgoPhpass', + 'AlgoBcrypt', 'AlgoScrypt', 'AlgoScryptModified', - 'AlgoBcrypt', - 'AlgoPhpass', - 'AlgoSha', - 'AlgoMd5', + 'AlgoArgon2', + 'Preferences', + 'Session', 'Identity', - 'Log', - 'Runtime', - 'Specification', - 'Headers', + 'Token', + 'Jwt', + 'Locale', 'LocaleCode', - 'Continent', - 'Country', - 'Phone', - 'Currency', - 'Language', + 'File', + 'Bucket', + 'ResourceToken', + 'Team', + 'Membership', + 'Site', + 'Function', + 'Runtime', 'Framework', 'FrameworkAdapter', + 'Deployment', + 'Execution', + 'Webhook', + 'Variable', + 'Country', + 'Continent', + 'Language', + 'Currency', + 'Phone', + 'HealthAntivirus', + 'HealthQueue', + 'HealthStatus', + 'HealthCertificate', + 'HealthTime', + 'Headers', + 'Specification', + 'MfaChallenge', + 'MfaRecoveryCodes', + 'MfaType', + 'MfaFactors', + 'Provider', + 'Message', + 'Topic', + 'Transaction', + 'Subscriber', + 'Target', + 'ActivityEvent', + 'BackupArchive', + 'BackupPolicy', + 'BackupRestoration', + 'ActivityEventList', + 'BackupArchiveList', + 'BackupPolicyList', + 'BackupRestorationList', ] From fd0267c71cd2841f74a17cf84daf9f2f44f616e1 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2026 07:19:45 +0000 Subject: [PATCH 6/9] chore: update Python SDK to 17.0.0 --- appwrite/enums/vcs_reference_type.py | 1 + 1 file changed, 1 insertion(+) diff --git a/appwrite/enums/vcs_reference_type.py b/appwrite/enums/vcs_reference_type.py index 4a6d7ebb..e172e638 100644 --- a/appwrite/enums/vcs_reference_type.py +++ b/appwrite/enums/vcs_reference_type.py @@ -3,3 +3,4 @@ class VCSReferenceType(Enum): BRANCH = "branch" COMMIT = "commit" + TAG = "tag" From dbacd569cb01f130bec380b9a94385b81517c414 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 04:22:16 +0000 Subject: [PATCH 7/9] chore: update Python SDK to 17.0.0 --- appwrite/enums/build_runtime.py | 86 --------------------------------- appwrite/enums/runtime.py | 86 --------------------------------- 2 files changed, 172 deletions(-) diff --git a/appwrite/enums/build_runtime.py b/appwrite/enums/build_runtime.py index a6c3fb88..8fe21cbc 100644 --- a/appwrite/enums/build_runtime.py +++ b/appwrite/enums/build_runtime.py @@ -87,89 +87,3 @@ class BuildRuntime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" - NODE_14_5_RC = "node-14.5-rc" - NODE_16_0_RC = "node-16.0-rc" - NODE_18_0_RC = "node-18.0-rc" - NODE_19_0_RC = "node-19.0-rc" - NODE_20_0_RC = "node-20.0-rc" - NODE_21_0_RC = "node-21.0-rc" - NODE_22_RC = "node-22-rc" - NODE_23_RC = "node-23-rc" - NODE_24_RC = "node-24-rc" - NODE_25_RC = "node-25-rc" - PHP_8_0_RC = "php-8.0-rc" - PHP_8_1_RC = "php-8.1-rc" - PHP_8_2_RC = "php-8.2-rc" - PHP_8_3_RC = "php-8.3-rc" - PHP_8_4_RC = "php-8.4-rc" - RUBY_3_0_RC = "ruby-3.0-rc" - RUBY_3_1_RC = "ruby-3.1-rc" - RUBY_3_2_RC = "ruby-3.2-rc" - RUBY_3_3_RC = "ruby-3.3-rc" - RUBY_3_4_RC = "ruby-3.4-rc" - RUBY_4_0_RC = "ruby-4.0-rc" - PYTHON_3_8_RC = "python-3.8-rc" - PYTHON_3_9_RC = "python-3.9-rc" - PYTHON_3_10_RC = "python-3.10-rc" - PYTHON_3_11_RC = "python-3.11-rc" - PYTHON_3_12_RC = "python-3.12-rc" - PYTHON_3_13_RC = "python-3.13-rc" - PYTHON_3_14_RC = "python-3.14-rc" - PYTHON_ML_3_11_RC = "python-ml-3.11-rc" - PYTHON_ML_3_12_RC = "python-ml-3.12-rc" - PYTHON_ML_3_13_RC = "python-ml-3.13-rc" - DENO_1_40_RC = "deno-1.40-rc" - DENO_1_46_RC = "deno-1.46-rc" - DENO_2_0_RC = "deno-2.0-rc" - DENO_2_5_RC = "deno-2.5-rc" - DENO_2_6_RC = "deno-2.6-rc" - DART_2_15_RC = "dart-2.15-rc" - DART_2_16_RC = "dart-2.16-rc" - DART_2_17_RC = "dart-2.17-rc" - DART_2_18_RC = "dart-2.18-rc" - DART_2_19_RC = "dart-2.19-rc" - DART_3_0_RC = "dart-3.0-rc" - DART_3_1_RC = "dart-3.1-rc" - DART_3_3_RC = "dart-3.3-rc" - DART_3_5_RC = "dart-3.5-rc" - DART_3_8_RC = "dart-3.8-rc" - DART_3_9_RC = "dart-3.9-rc" - DART_3_10_RC = "dart-3.10-rc" - DOTNET_6_0_RC = "dotnet-6.0-rc" - DOTNET_7_0_RC = "dotnet-7.0-rc" - DOTNET_8_0_RC = "dotnet-8.0-rc" - DOTNET_10_RC = "dotnet-10-rc" - JAVA_8_0_RC = "java-8.0-rc" - JAVA_11_0_RC = "java-11.0-rc" - JAVA_17_0_RC = "java-17.0-rc" - JAVA_18_0_RC = "java-18.0-rc" - JAVA_21_0_RC = "java-21.0-rc" - JAVA_22_RC = "java-22-rc" - JAVA_25_RC = "java-25-rc" - SWIFT_5_5_RC = "swift-5.5-rc" - SWIFT_5_8_RC = "swift-5.8-rc" - SWIFT_5_9_RC = "swift-5.9-rc" - SWIFT_5_10_RC = "swift-5.10-rc" - SWIFT_6_2_RC = "swift-6.2-rc" - KOTLIN_1_6_RC = "kotlin-1.6-rc" - KOTLIN_1_8_RC = "kotlin-1.8-rc" - KOTLIN_1_9_RC = "kotlin-1.9-rc" - KOTLIN_2_0_RC = "kotlin-2.0-rc" - KOTLIN_2_3_RC = "kotlin-2.3-rc" - CPP_17_RC = "cpp-17-rc" - CPP_20_RC = "cpp-20-rc" - BUN_1_0_RC = "bun-1.0-rc" - BUN_1_1_RC = "bun-1.1-rc" - BUN_1_2_RC = "bun-1.2-rc" - BUN_1_3_RC = "bun-1.3-rc" - GO_1_23_RC = "go-1.23-rc" - GO_1_24_RC = "go-1.24-rc" - GO_1_25_RC = "go-1.25-rc" - GO_1_26_RC = "go-1.26-rc" - STATIC_1_RC = "static-1-rc" - FLUTTER_3_24_RC = "flutter-3.24-rc" - FLUTTER_3_27_RC = "flutter-3.27-rc" - FLUTTER_3_29_RC = "flutter-3.29-rc" - FLUTTER_3_32_RC = "flutter-3.32-rc" - FLUTTER_3_35_RC = "flutter-3.35-rc" - FLUTTER_3_38_RC = "flutter-3.38-rc" diff --git a/appwrite/enums/runtime.py b/appwrite/enums/runtime.py index 89003e70..171dbd95 100644 --- a/appwrite/enums/runtime.py +++ b/appwrite/enums/runtime.py @@ -87,89 +87,3 @@ class Runtime(Enum): FLUTTER_3_32 = "flutter-3.32" FLUTTER_3_35 = "flutter-3.35" FLUTTER_3_38 = "flutter-3.38" - NODE_14_5_RC = "node-14.5-rc" - NODE_16_0_RC = "node-16.0-rc" - NODE_18_0_RC = "node-18.0-rc" - NODE_19_0_RC = "node-19.0-rc" - NODE_20_0_RC = "node-20.0-rc" - NODE_21_0_RC = "node-21.0-rc" - NODE_22_RC = "node-22-rc" - NODE_23_RC = "node-23-rc" - NODE_24_RC = "node-24-rc" - NODE_25_RC = "node-25-rc" - PHP_8_0_RC = "php-8.0-rc" - PHP_8_1_RC = "php-8.1-rc" - PHP_8_2_RC = "php-8.2-rc" - PHP_8_3_RC = "php-8.3-rc" - PHP_8_4_RC = "php-8.4-rc" - RUBY_3_0_RC = "ruby-3.0-rc" - RUBY_3_1_RC = "ruby-3.1-rc" - RUBY_3_2_RC = "ruby-3.2-rc" - RUBY_3_3_RC = "ruby-3.3-rc" - RUBY_3_4_RC = "ruby-3.4-rc" - RUBY_4_0_RC = "ruby-4.0-rc" - PYTHON_3_8_RC = "python-3.8-rc" - PYTHON_3_9_RC = "python-3.9-rc" - PYTHON_3_10_RC = "python-3.10-rc" - PYTHON_3_11_RC = "python-3.11-rc" - PYTHON_3_12_RC = "python-3.12-rc" - PYTHON_3_13_RC = "python-3.13-rc" - PYTHON_3_14_RC = "python-3.14-rc" - PYTHON_ML_3_11_RC = "python-ml-3.11-rc" - PYTHON_ML_3_12_RC = "python-ml-3.12-rc" - PYTHON_ML_3_13_RC = "python-ml-3.13-rc" - DENO_1_40_RC = "deno-1.40-rc" - DENO_1_46_RC = "deno-1.46-rc" - DENO_2_0_RC = "deno-2.0-rc" - DENO_2_5_RC = "deno-2.5-rc" - DENO_2_6_RC = "deno-2.6-rc" - DART_2_15_RC = "dart-2.15-rc" - DART_2_16_RC = "dart-2.16-rc" - DART_2_17_RC = "dart-2.17-rc" - DART_2_18_RC = "dart-2.18-rc" - DART_2_19_RC = "dart-2.19-rc" - DART_3_0_RC = "dart-3.0-rc" - DART_3_1_RC = "dart-3.1-rc" - DART_3_3_RC = "dart-3.3-rc" - DART_3_5_RC = "dart-3.5-rc" - DART_3_8_RC = "dart-3.8-rc" - DART_3_9_RC = "dart-3.9-rc" - DART_3_10_RC = "dart-3.10-rc" - DOTNET_6_0_RC = "dotnet-6.0-rc" - DOTNET_7_0_RC = "dotnet-7.0-rc" - DOTNET_8_0_RC = "dotnet-8.0-rc" - DOTNET_10_RC = "dotnet-10-rc" - JAVA_8_0_RC = "java-8.0-rc" - JAVA_11_0_RC = "java-11.0-rc" - JAVA_17_0_RC = "java-17.0-rc" - JAVA_18_0_RC = "java-18.0-rc" - JAVA_21_0_RC = "java-21.0-rc" - JAVA_22_RC = "java-22-rc" - JAVA_25_RC = "java-25-rc" - SWIFT_5_5_RC = "swift-5.5-rc" - SWIFT_5_8_RC = "swift-5.8-rc" - SWIFT_5_9_RC = "swift-5.9-rc" - SWIFT_5_10_RC = "swift-5.10-rc" - SWIFT_6_2_RC = "swift-6.2-rc" - KOTLIN_1_6_RC = "kotlin-1.6-rc" - KOTLIN_1_8_RC = "kotlin-1.8-rc" - KOTLIN_1_9_RC = "kotlin-1.9-rc" - KOTLIN_2_0_RC = "kotlin-2.0-rc" - KOTLIN_2_3_RC = "kotlin-2.3-rc" - CPP_17_RC = "cpp-17-rc" - CPP_20_RC = "cpp-20-rc" - BUN_1_0_RC = "bun-1.0-rc" - BUN_1_1_RC = "bun-1.1-rc" - BUN_1_2_RC = "bun-1.2-rc" - BUN_1_3_RC = "bun-1.3-rc" - GO_1_23_RC = "go-1.23-rc" - GO_1_24_RC = "go-1.24-rc" - GO_1_25_RC = "go-1.25-rc" - GO_1_26_RC = "go-1.26-rc" - STATIC_1_RC = "static-1-rc" - FLUTTER_3_24_RC = "flutter-3.24-rc" - FLUTTER_3_27_RC = "flutter-3.27-rc" - FLUTTER_3_29_RC = "flutter-3.29-rc" - FLUTTER_3_32_RC = "flutter-3.32-rc" - FLUTTER_3_35_RC = "flutter-3.35-rc" - FLUTTER_3_38_RC = "flutter-3.38-rc" From d1830da8353d5e51d9551c5032637c7d6ad5007e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 05:06:32 +0000 Subject: [PATCH 8/9] chore: update Python SDK to 17.0.0 --- docs/examples/databases/upsert-documents.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 50b78fc1..5039ccb0 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -6,7 +6,7 @@ from appwrite.models import DocumentList client = Client() client.set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint client.set_project('') # Your project ID -client.set_session('') # The user session to authenticate with +client.set_key('') # Your secret API key databases = Databases(client) From d72b7aa50a7f22fe282224552fd8fe69f5f57e4f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Mar 2026 05:18:22 +0000 Subject: [PATCH 9/9] chore: update Python SDK to 17.0.0 --- CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e929f256..bae4c145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,22 @@ ## 17.0.0 -* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents +* [BREAKING] Changed `$sequence` type from `float` to `str` for `Row` and `Document` models +* [BREAKING] Renamed `IndexType` enum: split into `DatabasesIndexType` (with new `SPATIAL` value) and `TablesDBIndexType` +* [BREAKING] Replaced `specification` parameter with `build_specification` and `runtime_specification` in `functions.create()`, `functions.update()`, `sites.create()`, `sites.update()` +* Added new `Project` service with full CRUD for project-level environment variables +* Added new `Webhooks` service with full CRUD for project webhooks (including `update_signature`) +* Added `Webhook` and `WebhookList` models +* Added `users.update_impersonator()` method for enabling/disabling user impersonation +* Added impersonation support: `set_impersonate_user_id()`, `set_impersonate_user_email()`, `set_impersonate_user_phone()` on `Client` +* Added `impersonator` and `impersonatoruserid` optional fields to `User` model +* Added `deployment_retention` parameter to Functions and Sites create/update +* Added `start_command` parameter to Sites create/update +* Added `Documentsdb`, `Vectorsdb` values to `BackupServices` and `DatabaseType` enums +* Added `WebhooksRead`, `WebhooksWrite`, `ProjectRead`, `ProjectWrite` scopes +* Removed `get_queue_billing_project_aggregation`, `get_queue_billing_team_aggregation`, `get_queue_priority_builds`, `get_queue_region_manager`, `get_queue_threats` from `Health` service +* Updated `Log` model field descriptions to clarify impersonation behavior +* Updated `X-Appwrite-Response-Format` header to `1.9.0` ## 16.0.0