Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update attributes #93

Merged
merged 3 commits into from
Sep 10, 2024
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: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : 'AppwritePythonSDK/6.0.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'user-agent' : 'AppwritePythonSDK/6.1.0 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '6.0.0',
'x-sdk-version': '6.1.0',
'X-Appwrite-Response-Format' : '1.6.0',
}

Expand Down
31 changes: 21 additions & 10 deletions appwrite/services/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def create_boolean_attribute(self, database_id, collection_id, key, required, de
'content-type': 'application/json',
}, api_params)

def update_boolean_attribute(self, database_id, collection_id, key, required, default):
def update_boolean_attribute(self, database_id, collection_id, key, required, default, new_key = None):
"""Update boolean attribute"""


Expand All @@ -281,6 +281,7 @@ def update_boolean_attribute(self, database_id, collection_id, key, required, de

api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -316,7 +317,7 @@ def create_datetime_attribute(self, database_id, collection_id, key, required, d
'content-type': 'application/json',
}, api_params)

def update_datetime_attribute(self, database_id, collection_id, key, required, default):
def update_datetime_attribute(self, database_id, collection_id, key, required, default, new_key = None):
"""Update dateTime attribute"""


Expand All @@ -340,6 +341,7 @@ def update_datetime_attribute(self, database_id, collection_id, key, required, d

api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -375,7 +377,7 @@ def create_email_attribute(self, database_id, collection_id, key, required, defa
'content-type': 'application/json',
}, api_params)

def update_email_attribute(self, database_id, collection_id, key, required, default):
def update_email_attribute(self, database_id, collection_id, key, required, default, new_key = None):
"""Update email attribute"""


Expand All @@ -399,6 +401,7 @@ def update_email_attribute(self, database_id, collection_id, key, required, defa

api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -438,7 +441,7 @@ def create_enum_attribute(self, database_id, collection_id, key, elements, requi
'content-type': 'application/json',
}, api_params)

def update_enum_attribute(self, database_id, collection_id, key, elements, required, default):
def update_enum_attribute(self, database_id, collection_id, key, elements, required, default, new_key = None):
"""Update enum attribute"""


Expand Down Expand Up @@ -466,6 +469,7 @@ def update_enum_attribute(self, database_id, collection_id, key, elements, requi
api_params['elements'] = elements
api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -503,7 +507,7 @@ def create_float_attribute(self, database_id, collection_id, key, required, min
'content-type': 'application/json',
}, api_params)

def update_float_attribute(self, database_id, collection_id, key, required, min, max, default):
def update_float_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None):
"""Update float attribute"""


Expand Down Expand Up @@ -535,6 +539,7 @@ def update_float_attribute(self, database_id, collection_id, key, required, min,
api_params['min'] = min
api_params['max'] = max
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -572,7 +577,7 @@ def create_integer_attribute(self, database_id, collection_id, key, required, mi
'content-type': 'application/json',
}, api_params)

def update_integer_attribute(self, database_id, collection_id, key, required, min, max, default):
def update_integer_attribute(self, database_id, collection_id, key, required, min, max, default, new_key = None):
"""Update integer attribute"""


Expand Down Expand Up @@ -604,6 +609,7 @@ def update_integer_attribute(self, database_id, collection_id, key, required, mi
api_params['min'] = min
api_params['max'] = max
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -639,7 +645,7 @@ def create_ip_attribute(self, database_id, collection_id, key, required, default
'content-type': 'application/json',
}, api_params)

def update_ip_attribute(self, database_id, collection_id, key, required, default):
def update_ip_attribute(self, database_id, collection_id, key, required, default, new_key = None):
"""Update IP address attribute"""


Expand All @@ -663,6 +669,7 @@ def update_ip_attribute(self, database_id, collection_id, key, required, default

api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -735,7 +742,7 @@ def create_string_attribute(self, database_id, collection_id, key, size, require
'content-type': 'application/json',
}, api_params)

def update_string_attribute(self, database_id, collection_id, key, required, default):
def update_string_attribute(self, database_id, collection_id, key, required, default, size = None, new_key = None):
"""Update string attribute"""


Expand All @@ -759,6 +766,8 @@ def update_string_attribute(self, database_id, collection_id, key, required, def

api_params['required'] = required
api_params['default'] = default
api_params['size'] = size
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -794,7 +803,7 @@ def create_url_attribute(self, database_id, collection_id, key, required, defaul
'content-type': 'application/json',
}, api_params)

def update_url_attribute(self, database_id, collection_id, key, required, default):
def update_url_attribute(self, database_id, collection_id, key, required, default, new_key = None):
"""Update URL attribute"""


Expand All @@ -818,6 +827,7 @@ def update_url_attribute(self, database_id, collection_id, key, required, defaul

api_params['required'] = required
api_params['default'] = default
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down Expand Up @@ -871,7 +881,7 @@ def delete_attribute(self, database_id, collection_id, key):
'content-type': 'application/json',
}, api_params)

def update_relationship_attribute(self, database_id, collection_id, key, on_delete = None):
def update_relationship_attribute(self, database_id, collection_id, key, on_delete = None, new_key = None):
"""Update relationship attribute"""


Expand All @@ -891,6 +901,7 @@ def update_relationship_attribute(self, database_id, collection_id, key, on_dele
api_path = api_path.replace('{key}', key)

api_params['onDelete'] = on_delete
api_params['newKey'] = new_key

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/databases/update-boolean-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ result = databases.update_boolean_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = False
default = False,
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-datetime-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ result = databases.update_datetime_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = ''
default = '',
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-email-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ result = databases.update_email_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = '[email protected]'
default = '[email protected]',
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-enum-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ result = databases.update_enum_attribute(
key = '',
elements = [],
required = False,
default = '<DEFAULT>'
default = '<DEFAULT>',
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-float-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ result = databases.update_float_attribute(
required = False,
min = None,
max = None,
default = None
default = None,
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-integer-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ result = databases.update_integer_attribute(
required = False,
min = None,
max = None,
default = None
default = None,
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-ip-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ result = databases.update_ip_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = ''
default = '',
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-relationship-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ result = databases.update_relationship_attribute(
database_id = '<DATABASE_ID>',
collection_id = '<COLLECTION_ID>',
key = '',
on_delete = RelationMutate.CASCADE # optional
on_delete = RelationMutate.CASCADE, # optional
new_key = '' # optional
)
4 changes: 3 additions & 1 deletion docs/examples/databases/update-string-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ result = databases.update_string_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = '<DEFAULT>'
default = '<DEFAULT>',
size = None, # optional
new_key = '' # optional
)
3 changes: 2 additions & 1 deletion docs/examples/databases/update-url-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ result = databases.update_url_attribute(
collection_id = '<COLLECTION_ID>',
key = '',
required = False,
default = 'https://example.com'
default = 'https://example.com',
new_key = '' # optional
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'appwrite/encoders',
'appwrite/enums',
],
version = '6.0.0',
version = '6.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 @@ -23,7 +23,7 @@
maintainer = 'Appwrite Team',
maintainer_email = '[email protected]',
url = 'https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/6.0.0.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/6.1.0.tar.gz',
install_requires=[
'requests',
],
Expand Down