Skip to content

Commit dd6ff57

Browse files
authored
Merge pull request #127 from appwrite/dev
feat: Python SDK update for version 14.0.0
2 parents 8b010e4 + 72b9a49 commit dd6ff57

19 files changed

+44
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 14.1.0
4+
5+
* Added ability to create columns and indexes synchronously while creating a table
6+
37
## 14.0.0
48

59
* Rename `VCSDeploymentType` enum to `VCSReferenceType`

appwrite/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def __init__(self):
1515
self._endpoint = 'https://cloud.appwrite.io/v1'
1616
self._global_headers = {
1717
'content-type': '',
18-
'user-agent' : f'AppwritePythonSDK/14.0.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
18+
'user-agent' : f'AppwritePythonSDK/14.1.0 ({platform.uname().system}; {platform.uname().version}; {platform.uname().machine})',
1919
'x-sdk-name': 'Python',
2020
'x-sdk-platform': 'server',
2121
'x-sdk-language': 'python',
22-
'x-sdk-version': '14.0.0',
22+
'x-sdk-version': '14.1.0',
2323
'X-Appwrite-Response-Format' : '1.8.0',
2424
}
2525

appwrite/services/databases.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def list_collections(self, database_id: str, queries: Optional[List[str]] = None
456456
}, api_params)
457457

458458
@deprecated("This API has been deprecated since 1.8.0. Please use `tablesDB.create_table` instead.")
459-
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]:
459+
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]:
460460
"""
461461
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.
462462
@@ -476,6 +476,10 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per
476476
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).
477477
enabled : Optional[bool]
478478
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.
479+
attributes : Optional[List[dict]]
480+
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.
481+
indexes : Optional[List[dict]]
482+
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).
479483
480484
Returns
481485
-------
@@ -508,6 +512,10 @@ def create_collection(self, database_id: str, collection_id: str, name: str, per
508512
api_params['documentSecurity'] = document_security
509513
if enabled is not None:
510514
api_params['enabled'] = enabled
515+
if attributes is not None:
516+
api_params['attributes'] = attributes
517+
if indexes is not None:
518+
api_params['indexes'] = indexes
511519

512520
return self.client.call('post', api_path, {
513521
'content-type': 'application/json',

appwrite/services/tables_db.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def list_tables(self, database_id: str, queries: Optional[List[str]] = None, sea
437437
return self.client.call('get', api_path, {
438438
}, api_params)
439439

440-
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]:
440+
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]:
441441
"""
442442
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.
443443
@@ -455,6 +455,10 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions:
455455
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).
456456
enabled : Optional[bool]
457457
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.
458+
columns : Optional[List[dict]]
459+
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.
460+
indexes : Optional[List[dict]]
461+
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).
458462
459463
Returns
460464
-------
@@ -487,6 +491,10 @@ def create_table(self, database_id: str, table_id: str, name: str, permissions:
487491
api_params['rowSecurity'] = row_security
488492
if enabled is not None:
489493
api_params['enabled'] = enabled
494+
if columns is not None:
495+
api_params['columns'] = columns
496+
if indexes is not None:
497+
api_params['indexes'] = indexes
490498

491499
return self.client.call('post', api_path, {
492500
'content-type': 'application/json',

docs/examples/account/create-anonymous-session.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from appwrite.services.account import Account
44
client = Client()
55
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
66
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
7+
client.set_session('') # The user session to authenticate with
78

89
account = Account(client)
910

docs/examples/account/create-email-password-session.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from appwrite.services.account import Account
44
client = Client()
55
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
66
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
7+
client.set_session('') # The user session to authenticate with
78

89
account = Account(client)
910

docs/examples/account/create-email-token.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from appwrite.services.account import Account
44
client = Client()
55
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
66
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
7+
client.set_session('') # The user session to authenticate with
78

89
account = Account(client)
910

docs/examples/account/create-jwt.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from appwrite.services.account import Account
44
client = Client()
55
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
66
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
7+
client.set_session('') # The user session to authenticate with
78

89
account = Account(client)
910

docs/examples/account/create-magic-url-token.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from appwrite.services.account import Account
44
client = Client()
55
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
66
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
7+
client.set_session('') # The user session to authenticate with
78

89
account = Account(client)
910

docs/examples/account/create-mfa-challenge.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from appwrite.enums import AuthenticationFactor
55
client = Client()
66
client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint
77
client.set_project('<YOUR_PROJECT_ID>') # Your project ID
8+
client.set_session('') # The user session to authenticate with
89

910
account = Account(client)
1011

0 commit comments

Comments
 (0)