Skip to content

Commit

Permalink
Merge pull request #29 from appwrite/dev
Browse files Browse the repository at this point in the history
Update attributes
  • Loading branch information
abnegate authored Sep 10, 2024
2 parents c3777a7 + ac440e6 commit 37d2188
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|

spec.name = 'appwrite'
spec.version = '12.0.0'
spec.version = '12.1.0'
spec.license = 'BSD-3-Clause'
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
spec.author = 'Appwrite Team'
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 @@ -14,5 +14,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 @@ -14,5 +14,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 @@ -14,5 +14,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 @@ -15,5 +15,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 @@ -16,5 +16,6 @@ result = databases.update_float_attribute(
required: false,
min: null,
max: null,
default: null
default: null,
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 @@ -16,5 +16,6 @@ result = databases.update_integer_attribute(
required: false,
min: null,
max: null,
default: null
default: null,
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 @@ -14,5 +14,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 @@ -13,5 +13,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 @@ -14,5 +14,7 @@ result = databases.update_string_attribute(
collection_id: '<COLLECTION_ID>',
key: '',
required: false,
default: '<DEFAULT>'
default: '<DEFAULT>',
size: null, # 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 @@ -14,5 +14,6 @@ result = databases.update_url_attribute(
collection_id: '<COLLECTION_ID>',
key: '',
required: false,
default: 'https://example.com'
default: 'https://example.com',
new_key: '' # optional
)
2 changes: 1 addition & 1 deletion lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize
'x-sdk-name'=> 'Ruby',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'ruby',
'x-sdk-version'=> '12.0.0',
'x-sdk-version'=> '12.1.0',
'X-Appwrite-Response-Format' => '1.6.0'
}
@endpoint = 'https://cloud.appwrite.io/v1'
Expand Down
42 changes: 32 additions & 10 deletions lib/appwrite/services/databases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,10 @@ def create_boolean_attribute(database_id:, collection_id:, key:, required:, defa
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeBoolean]
def update_boolean_attribute(database_id:, collection_id:, key:, required:, default:)
def update_boolean_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -511,6 +512,7 @@ def update_boolean_attribute(database_id:, collection_id:, key:, required:, defa
api_params = {
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -587,9 +589,10 @@ def create_datetime_attribute(database_id:, collection_id:, key:, required:, def
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeDatetime]
def update_datetime_attribute(database_id:, collection_id:, key:, required:, default:)
def update_datetime_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -618,6 +621,7 @@ def update_datetime_attribute(database_id:, collection_id:, key:, required:, def
api_params = {
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -696,9 +700,10 @@ def create_email_attribute(database_id:, collection_id:, key:, required:, defaul
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeEmail]
def update_email_attribute(database_id:, collection_id:, key:, required:, default:)
def update_email_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -727,6 +732,7 @@ def update_email_attribute(database_id:, collection_id:, key:, required:, defaul
api_params = {
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -813,9 +819,10 @@ def create_enum_attribute(database_id:, collection_id:, key:, elements:, require
# @param [Array] elements Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeEnum]
def update_enum_attribute(database_id:, collection_id:, key:, elements:, required:, default:)
def update_enum_attribute(database_id:, collection_id:, key:, elements:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -849,6 +856,7 @@ def update_enum_attribute(database_id:, collection_id:, key:, elements:, require
elements: elements,
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -934,9 +942,10 @@ def create_float_attribute(database_id:, collection_id:, key:, required:, min: n
# @param [Float] min Minimum value to enforce on new documents
# @param [Float] max Maximum value to enforce on new documents
# @param [Float] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeFloat]
def update_float_attribute(database_id:, collection_id:, key:, required:, min:, max:, default:)
def update_float_attribute(database_id:, collection_id:, key:, required:, min:, max:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -975,6 +984,7 @@ def update_float_attribute(database_id:, collection_id:, key:, required:, min:,
min: min,
max: max,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -1060,9 +1070,10 @@ def create_integer_attribute(database_id:, collection_id:, key:, required:, min:
# @param [Integer] min Minimum value to enforce on new documents
# @param [Integer] max Maximum value to enforce on new documents
# @param [Integer] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeInteger]
def update_integer_attribute(database_id:, collection_id:, key:, required:, min:, max:, default:)
def update_integer_attribute(database_id:, collection_id:, key:, required:, min:, max:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -1101,6 +1112,7 @@ def update_integer_attribute(database_id:, collection_id:, key:, required:, min:
min: min,
max: max,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -1179,9 +1191,10 @@ def create_ip_attribute(database_id:, collection_id:, key:, required:, default:
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeIp]
def update_ip_attribute(database_id:, collection_id:, key:, required:, default:)
def update_ip_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -1210,6 +1223,7 @@ def update_ip_attribute(database_id:, collection_id:, key:, required:, default:)
api_params = {
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -1354,9 +1368,11 @@ def create_string_attribute(database_id:, collection_id:, key:, size:, required:
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [Integer] size Maximum size of the string attribute.
# @param [String] new_key New attribute key.
#
# @return [AttributeString]
def update_string_attribute(database_id:, collection_id:, key:, required:, default:)
def update_string_attribute(database_id:, collection_id:, key:, required:, default:, size: nil, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -1385,6 +1401,8 @@ def update_string_attribute(database_id:, collection_id:, key:, required:, defau
api_params = {
required: required,
default: default,
size: size,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -1463,9 +1481,10 @@ def create_url_attribute(database_id:, collection_id:, key:, required:, default:
# @param [String] key Attribute Key.
# @param [] required Is attribute required?
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
# @param [String] new_key New attribute key.
#
# @return [AttributeUrl]
def update_url_attribute(database_id:, collection_id:, key:, required:, default:)
def update_url_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand Down Expand Up @@ -1494,6 +1513,7 @@ def update_url_attribute(database_id:, collection_id:, key:, required:, default:
api_params = {
required: required,
default: default,
newKey: new_key,
}

api_headers = {
Expand Down Expand Up @@ -1600,9 +1620,10 @@ def delete_attribute(database_id:, collection_id:, key:)
# @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
# @param [String] key Attribute Key.
# @param [RelationMutate] on_delete Constraints option
# @param [String] new_key New attribute key.
#
# @return [AttributeRelationship]
def update_relationship_attribute(database_id:, collection_id:, key:, on_delete: nil)
def update_relationship_attribute(database_id:, collection_id:, key:, on_delete: nil, new_key: nil)
api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'
.gsub('{databaseId}', database_id)
.gsub('{collectionId}', collection_id)
Expand All @@ -1622,6 +1643,7 @@ def update_relationship_attribute(database_id:, collection_id:, key:, on_delete:

api_params = {
onDelete: on_delete,
newKey: new_key,
}

api_headers = {
Expand Down

0 comments on commit 37d2188

Please sign in to comment.