Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
4 changes: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

Expand Down
10 changes: 9 additions & 1 deletion appwrite/services/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
-------
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 9 additions & 1 deletion appwrite/services/tables_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
-------
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-anonymous-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-email-password-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-email-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-magic-url-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-mfa-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from appwrite.enums import AuthenticationFactor
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-o-auth-2-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from appwrite.enums import OAuthProvider
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-phone-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-magic-url-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
1 change: 1 addition & 0 deletions docs/examples/account/update-phone-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ from appwrite.services.account import Account
client = Client()
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
client.set_session('') # The user session to authenticate with

account = Account(client)

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/databases/create-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ result = databases.create_collection(
name = '<NAME>',
permissions = [Permission.read(Role.any())], # optional
document_security = False, # optional
enabled = False # optional
enabled = False, # optional
attributes = [], # optional
indexes = [] # optional
)
4 changes: 3 additions & 1 deletion docs/examples/tablesdb/create-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ result = tables_db.create_table(
name = '<NAME>',
permissions = [Permission.read(Role.any())], # optional
row_security = False, # optional
enabled = False # optional
enabled = False, # optional
columns = [], # optional
indexes = [] # optional
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
],
Expand Down