diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2ac85..160d5aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 14.1.0 + +* Added ability to create columns and indexes synchronously while creating a table + ## 14.0.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` diff --git a/appwrite/client.py b/appwrite/client.py index cd05569..c6ae723 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/appwrite/services/databases.py b/appwrite/services/databases.py index e99a00a..b2f96d5 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), 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 dcef276..a99e684 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 c3b7a87..d98ccea 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 e831821..c69b50a 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 7ff4f6b..0e4f1b6 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 172f45f..9b5fd90 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 14e76ed..439f2e7 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 abd746c..85dcd7a 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 2dc171b..4d4c068 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 06c2b20..3b63669 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 1048dfe..a05d4f2 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 7eda5a3..a0c09f1 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 0146083..60baca8 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 52e7723..5fbba21 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 66dc667..196a9d5 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 91a15df..649a4e8 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 ) diff --git a/setup.py b/setup.py index 01a503e..3c922e7 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', ],