From 6447f20c096330f51b3acc0316d2f44489dbddfb Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 17 Dec 2025 18:54:47 +1300 Subject: [PATCH 1/4] Add full schema collection create --- appwrite/services/databases.py | 10 +++++++++- appwrite/services/tables_db.py | 10 +++++++++- docs/examples/account/create-anonymous-session.md | 1 + docs/examples/account/create-email-password-session.md | 1 + docs/examples/account/create-email-token.md | 1 + docs/examples/account/create-jwt.md | 1 + docs/examples/account/create-magic-url-token.md | 1 + docs/examples/account/create-mfa-challenge.md | 1 + docs/examples/account/create-o-auth-2-token.md | 1 + docs/examples/account/create-phone-token.md | 1 + docs/examples/account/create-session.md | 1 + docs/examples/account/create.md | 1 + docs/examples/account/update-magic-url-session.md | 1 + docs/examples/account/update-phone-session.md | 1 + docs/examples/databases/create-collection.md | 4 +++- docs/examples/tablesdb/create-table.md | 4 +++- 16 files changed, 36 insertions(+), 4 deletions(-) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index e99a00aa..40c24cc7 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -456,7 +456,7 @@ def list_collections(self, database_id: str, queries: Optional[List[str]] = None }, api_params) @deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_table` instead.") - 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) -> Dict[str, Any]: + 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]] = None, indexes: Optional[List[dict]] = None) -> Dict[str, Any]: """ 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#databasesCreateCollection) API or directly from your database console. @@ -476,6 +476,10 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per 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]] + 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]] + 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 ------- @@ -508,6 +512,10 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per api_params['documentSecurity'] = document_security if enabled is not None: api_params['enabled'] = enabled + if attributes is not None: + api_params['attributes'] = attributes + if indexes is not None: + api_params['indexes'] = indexes return self.client.call('post', api_path, { 'content-type': 'application/json', diff --git a/appwrite/services/tables_db.py b/appwrite/services/tables_db.py index dcef2764..a99e6846 100644 --- a/appwrite/services/tables_db.py +++ b/appwrite/services/tables_db.py @@ -437,7 +437,7 @@ def list_tables(self, database_id: str, queries: Optional[List[str]] = None, sea return self.client.call('get', api_path, { }, api_params) - def create_table(self, database_id: str, table_id: str, name: str, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None) -> Dict[str, Any]: + def create_table(self, database_id: str, table_id: str, name: str, permissions: Optional[List[str]] = None, row_security: Optional[bool] = None, enabled: Optional[bool] = None, columns: Optional[List[dict]] = None, indexes: Optional[List[dict]] = None) -> Dict[str, Any]: """ Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. @@ -455,6 +455,10 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions: Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). enabled : Optional[bool] Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + columns : Optional[List[dict]] + Array of column definitions to create. Each column 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]] + Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). Returns ------- @@ -487,6 +491,10 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions: api_params['rowSecurity'] = row_security if enabled is not None: api_params['enabled'] = enabled + if columns is not None: + api_params['columns'] = columns + if indexes is not None: + api_params['indexes'] = indexes return self.client.call('post', api_path, { 'content-type': 'application/json', diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index c3b7a87d..d98cceaf 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index e831821a..c69b50ad 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index 7ff4f6b8..0e4f1b6a 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 172f45f9..9b5fd905 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-magic-url-token.md b/docs/examples/account/create-magic-url-token.md index 14e76ed4..439f2e74 100644 --- a/docs/examples/account/create-magic-url-token.md +++ b/docs/examples/account/create-magic-url-token.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index abd746c6..85dcd7a9 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -5,6 +5,7 @@ from appwrite.enums import AuthenticationFactor 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 account = Account(client) diff --git a/docs/examples/account/create-o-auth-2-token.md b/docs/examples/account/create-o-auth-2-token.md index 2dc171bb..4d4c0680 100644 --- a/docs/examples/account/create-o-auth-2-token.md +++ b/docs/examples/account/create-o-auth-2-token.md @@ -5,6 +5,7 @@ from appwrite.enums import OAuthProvider 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 account = Account(client) diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index 06c2b204..3b636697 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index 1048dfed..a05d4f24 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index 7eda5a37..a0c09f10 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/update-magic-url-session.md b/docs/examples/account/update-magic-url-session.md index 01460830..60baca81 100644 --- a/docs/examples/account/update-magic-url-session.md +++ b/docs/examples/account/update-magic-url-session.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 52e77233..5fbba213 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -4,6 +4,7 @@ from appwrite.services.account import Account 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 account = Account(client) diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 66dc6676..196a9d55 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -16,5 +16,7 @@ result = databases.create_collection( name = '', permissions = [Permission.read(Role.any())], # optional document_security = False, # optional - enabled = False # optional + enabled = False, # optional + attributes = [], # optional + indexes = [] # optional ) diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md index 91a15df4..649a4e8a 100644 --- a/docs/examples/tablesdb/create-table.md +++ b/docs/examples/tablesdb/create-table.md @@ -16,5 +16,7 @@ result = tables_db.create_table( name = '', permissions = [Permission.read(Role.any())], # optional row_security = False, # optional - enabled = False # optional + enabled = False, # optional + columns = [], # optional + indexes = [] # optional ) From da25d979ebebc439420c49da1ca60bc737fc849d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 17 Dec 2025 19:21:34 +1300 Subject: [PATCH 2/4] Update version --- CHANGELOG.md | 4 ++++ appwrite/client.py | 4 ++-- setup.py | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2ac853..aaf6fd89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 14.1.0 + +* Added ability to create attributes and indexes synchronously while creating a collection + ## 14.0.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` diff --git a/appwrite/client.py b/appwrite/client.py index cd05569a..c6ae7238 100644 --- a/appwrite/client.py +++ b/appwrite/client.py @@ -15,11 +15,11 @@ def __init__(self): self._endpoint = 'https://cloud.appwrite.io/v1' self._global_headers = { 'content-type': '', - 'user-agent' : f'AppwritePythonSDK/14.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', + 'user-agent' : f'AppwritePythonSDK/14.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})', 'x-sdk-name': 'Python', 'x-sdk-platform': 'server', 'x-sdk-language': 'python', - 'x-sdk-version': '14.0.0', + 'x-sdk-version': '14.1.0', 'X-Appwrite-Response-Format' : '1.8.0', } diff --git a/setup.py b/setup.py index 01a503e2..3c922e7c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name = 'appwrite', packages = setuptools.find_packages(), - version = '14.0.0', + version = '14.1.0', license='BSD-3-Clause', description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API', 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/14.0.0.tar.gz', + download_url='https://github.com/appwrite/sdk-for-python/archive/14.1.0.tar.gz', install_requires=[ 'requests', ], From 2878d81070519eebaa2a650aa12a0584db452c6d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 18 Dec 2025 20:31:17 +1300 Subject: [PATCH 3/4] Remove invalid type --- appwrite/services/databases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appwrite/services/databases.py b/appwrite/services/databases.py index 40c24cc7..b2f96d52 100644 --- a/appwrite/services/databases.py +++ b/appwrite/services/databases.py @@ -477,7 +477,7 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per 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]] - 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. + Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. indexes : Optional[List[dict]] 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). From 72b9a49fbce995ed9a5071eb90287b5ba34dfc61 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 18 Dec 2025 20:34:48 +1300 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf6fd89..160d5aa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 14.1.0 -* Added ability to create attributes and indexes synchronously while creating a collection +* Added ability to create columns and indexes synchronously while creating a table ## 14.0.0