appwrite 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +134 -57
- data/lib/appwrite/exception.rb +5 -7
- data/lib/appwrite/file.rb +5 -13
- data/lib/appwrite/models/attribute_boolean.rb +52 -0
- data/lib/appwrite/models/attribute_email.rb +57 -0
- data/lib/appwrite/models/attribute_enum.rb +62 -0
- data/lib/appwrite/models/attribute_float.rb +62 -0
- data/lib/appwrite/models/attribute_integer.rb +62 -0
- data/lib/appwrite/models/attribute_ip.rb +57 -0
- data/lib/appwrite/models/attribute_list.rb +32 -0
- data/lib/appwrite/models/attribute_string.rb +57 -0
- data/lib/appwrite/models/attribute_url.rb +57 -0
- data/lib/appwrite/models/collection.rb +62 -0
- data/lib/appwrite/models/collection_list.rb +32 -0
- data/lib/appwrite/models/continent.rb +32 -0
- data/lib/appwrite/models/continent_list.rb +32 -0
- data/lib/appwrite/models/country.rb +32 -0
- data/lib/appwrite/models/country_list.rb +32 -0
- data/lib/appwrite/models/currency.rb +57 -0
- data/lib/appwrite/models/currency_list.rb +32 -0
- data/lib/appwrite/models/document.rb +50 -0
- data/lib/appwrite/models/document_list.rb +36 -0
- data/lib/appwrite/models/execution.rb +72 -0
- data/lib/appwrite/models/execution_list.rb +32 -0
- data/lib/appwrite/models/file.rb +62 -0
- data/lib/appwrite/models/file_list.rb +32 -0
- data/lib/appwrite/models/function.rb +92 -0
- data/lib/appwrite/models/function_list.rb +32 -0
- data/lib/appwrite/models/health_antivirus.rb +32 -0
- data/lib/appwrite/models/health_queue.rb +27 -0
- data/lib/appwrite/models/health_status.rb +32 -0
- data/lib/appwrite/models/health_time.rb +37 -0
- data/lib/appwrite/models/index.rb +47 -0
- data/lib/appwrite/models/index_list.rb +32 -0
- data/lib/appwrite/models/language.rb +37 -0
- data/lib/appwrite/models/language_list.rb +32 -0
- data/lib/appwrite/models/locale.rb +57 -0
- data/lib/appwrite/models/log.rb +127 -0
- data/lib/appwrite/models/log_list.rb +32 -0
- data/lib/appwrite/models/membership.rb +67 -0
- data/lib/appwrite/models/membership_list.rb +32 -0
- data/lib/appwrite/models/phone.rb +37 -0
- data/lib/appwrite/models/phone_list.rb +32 -0
- data/lib/appwrite/models/preferences.rb +30 -0
- data/lib/appwrite/models/runtime.rb +57 -0
- data/lib/appwrite/models/runtime_list.rb +32 -0
- data/lib/appwrite/models/session.rb +132 -0
- data/lib/appwrite/models/session_list.rb +32 -0
- data/lib/appwrite/models/tag.rb +47 -0
- data/lib/appwrite/models/tag_list.rb +32 -0
- data/lib/appwrite/models/team.rb +42 -0
- data/lib/appwrite/models/team_list.rb +32 -0
- data/lib/appwrite/models/token.rb +42 -0
- data/lib/appwrite/models/user.rb +62 -0
- data/lib/appwrite/models/user_list.rb +32 -0
- data/lib/appwrite/query.rb +42 -0
- data/lib/appwrite/service.rb +0 -5
- data/lib/appwrite/services/account.rb +380 -133
- data/lib/appwrite/services/avatars.rb +189 -125
- data/lib/appwrite/services/database.rb +876 -130
- data/lib/appwrite/services/functions.rb +366 -184
- data/lib/appwrite/services/health.rb +202 -58
- data/lib/appwrite/services/locale.rb +134 -32
- data/lib/appwrite/services/storage.rb +211 -118
- data/lib/appwrite/services/teams.rb +299 -118
- data/lib/appwrite/services/users.rb +372 -85
- data/lib/appwrite.rb +55 -0
- metadata +72 -103
- data/.travis.yml +0 -16
- data/CHANGELOG.md +0 -1
- data/Gemfile +0 -4
- data/LICENSE +0 -12
- data/README.md +0 -97
- data/appwrite.gemspec +0 -11
- data/docs/examples/account/create-recovery.md +0 -15
- data/docs/examples/account/create-verification.md +0 -15
- data/docs/examples/account/delete-session.md +0 -15
- data/docs/examples/account/delete-sessions.md +0 -15
- data/docs/examples/account/delete.md +0 -15
- data/docs/examples/account/get-logs.md +0 -15
- data/docs/examples/account/get-prefs.md +0 -15
- data/docs/examples/account/get-sessions.md +0 -15
- data/docs/examples/account/get.md +0 -15
- data/docs/examples/account/update-email.md +0 -15
- data/docs/examples/account/update-name.md +0 -15
- data/docs/examples/account/update-password.md +0 -15
- data/docs/examples/account/update-prefs.md +0 -15
- data/docs/examples/account/update-recovery.md +0 -15
- data/docs/examples/account/update-verification.md +0 -15
- data/docs/examples/avatars/get-browser.md +0 -15
- data/docs/examples/avatars/get-credit-card.md +0 -15
- data/docs/examples/avatars/get-favicon.md +0 -15
- data/docs/examples/avatars/get-flag.md +0 -15
- data/docs/examples/avatars/get-image.md +0 -15
- data/docs/examples/avatars/get-initials.md +0 -15
- data/docs/examples/avatars/get-q-r.md +0 -15
- data/docs/examples/database/create-collection.md +0 -15
- data/docs/examples/database/create-document.md +0 -15
- data/docs/examples/database/delete-collection.md +0 -15
- data/docs/examples/database/delete-document.md +0 -15
- data/docs/examples/database/get-collection.md +0 -15
- data/docs/examples/database/get-document.md +0 -15
- data/docs/examples/database/list-collections.md +0 -15
- data/docs/examples/database/list-documents.md +0 -15
- data/docs/examples/database/update-collection.md +0 -15
- data/docs/examples/database/update-document.md +0 -15
- data/docs/examples/functions/create-execution.md +0 -15
- data/docs/examples/functions/create-tag.md +0 -15
- data/docs/examples/functions/create.md +0 -15
- data/docs/examples/functions/delete-tag.md +0 -15
- data/docs/examples/functions/delete.md +0 -15
- data/docs/examples/functions/get-execution.md +0 -15
- data/docs/examples/functions/get-tag.md +0 -15
- data/docs/examples/functions/get.md +0 -15
- data/docs/examples/functions/list-executions.md +0 -15
- data/docs/examples/functions/list-tags.md +0 -15
- data/docs/examples/functions/list.md +0 -15
- data/docs/examples/functions/update-tag.md +0 -15
- data/docs/examples/functions/update.md +0 -15
- data/docs/examples/health/get-anti-virus.md +0 -15
- data/docs/examples/health/get-cache.md +0 -15
- data/docs/examples/health/get-d-b.md +0 -15
- data/docs/examples/health/get-queue-certificates.md +0 -15
- data/docs/examples/health/get-queue-functions.md +0 -15
- data/docs/examples/health/get-queue-logs.md +0 -15
- data/docs/examples/health/get-queue-tasks.md +0 -15
- data/docs/examples/health/get-queue-usage.md +0 -15
- data/docs/examples/health/get-queue-webhooks.md +0 -15
- data/docs/examples/health/get-storage-local.md +0 -15
- data/docs/examples/health/get-time.md +0 -15
- data/docs/examples/health/get.md +0 -15
- data/docs/examples/locale/get-continents.md +0 -15
- data/docs/examples/locale/get-countries-e-u.md +0 -15
- data/docs/examples/locale/get-countries-phones.md +0 -15
- data/docs/examples/locale/get-countries.md +0 -15
- data/docs/examples/locale/get-currencies.md +0 -15
- data/docs/examples/locale/get-languages.md +0 -15
- data/docs/examples/locale/get.md +0 -15
- data/docs/examples/storage/create-file.md +0 -15
- data/docs/examples/storage/delete-file.md +0 -15
- data/docs/examples/storage/get-file-download.md +0 -15
- data/docs/examples/storage/get-file-preview.md +0 -15
- data/docs/examples/storage/get-file-view.md +0 -15
- data/docs/examples/storage/get-file.md +0 -15
- data/docs/examples/storage/list-files.md +0 -15
- data/docs/examples/storage/update-file.md +0 -15
- data/docs/examples/teams/create-membership.md +0 -15
- data/docs/examples/teams/create.md +0 -15
- data/docs/examples/teams/delete-membership.md +0 -15
- data/docs/examples/teams/delete.md +0 -15
- data/docs/examples/teams/get-memberships.md +0 -15
- data/docs/examples/teams/get.md +0 -15
- data/docs/examples/teams/list.md +0 -15
- data/docs/examples/teams/update-membership-roles.md +0 -15
- data/docs/examples/teams/update-membership-status.md +0 -15
- data/docs/examples/teams/update.md +0 -15
- data/docs/examples/users/create.md +0 -15
- data/docs/examples/users/delete-session.md +0 -15
- data/docs/examples/users/delete-sessions.md +0 -15
- data/docs/examples/users/delete.md +0 -15
- data/docs/examples/users/get-logs.md +0 -15
- data/docs/examples/users/get-prefs.md +0 -15
- data/docs/examples/users/get-sessions.md +0 -15
- data/docs/examples/users/get.md +0 -15
- data/docs/examples/users/list.md +0 -15
- data/docs/examples/users/update-prefs.md +0 -15
- data/docs/examples/users/update-status.md +0 -15
|
@@ -1,37 +1,69 @@
|
|
|
1
|
+
#frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Appwrite
|
|
2
4
|
class Database < Service
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
include Models
|
|
7
|
+
# Get a list of all the user collections. You can use the query params to
|
|
8
|
+
# filter your results. On admin mode, this endpoint will return a list of all
|
|
9
|
+
# of the project's collections. [Learn more about different API
|
|
10
|
+
# modes](/docs/admin).
|
|
11
|
+
#
|
|
12
|
+
# @param [string] search Search term to filter your list results. Max length: 256 chars.
|
|
13
|
+
# @param [number] limit Maximum number of collection to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
|
14
|
+
# @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
|
|
15
|
+
# @param [string] cursor ID of the collection used as the starting point for the query, excluding the collection itself. Should be used for efficient pagination when working with large sets of data.
|
|
16
|
+
# @param [string] cursor_direction Direction of the cursor.
|
|
17
|
+
# @param [string] order_type Order result by ASC or DESC order.
|
|
18
|
+
#
|
|
19
|
+
# @return [CollectionList]
|
|
20
|
+
def list_collections(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
|
|
5
21
|
path = '/database/collections'
|
|
6
22
|
|
|
7
|
-
params = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
params = {
|
|
24
|
+
search: search,
|
|
25
|
+
limit: limit,
|
|
26
|
+
offset: offset,
|
|
27
|
+
cursor: cursor,
|
|
28
|
+
cursorDirection: cursor_direction,
|
|
29
|
+
orderType: order_type,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
headers = {
|
|
33
|
+
"content-type": 'application/json',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@client.call(
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: path,
|
|
39
|
+
params: params,
|
|
40
|
+
headers: headers,
|
|
41
|
+
response_type: CollectionList
|
|
42
|
+
)
|
|
43
|
+
end
|
|
20
44
|
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
# Create a new Collection.
|
|
46
|
+
#
|
|
47
|
+
# @param [string] collection_id Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
48
|
+
# @param [string] name Collection name. Max length: 128 chars.
|
|
49
|
+
# @param [string] permission Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
50
|
+
# @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
51
|
+
# @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
52
|
+
#
|
|
53
|
+
# @return [Collection]
|
|
54
|
+
def create_collection(collection_id:, name:, permission:, read:, write:)
|
|
55
|
+
if collection_id.nil?
|
|
56
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
23
57
|
end
|
|
24
58
|
|
|
25
|
-
return @client.call('get', path, {
|
|
26
|
-
'content-type' => 'application/json',
|
|
27
|
-
}, params);
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def create_collection(name:, read:, write:, rules:)
|
|
31
59
|
if name.nil?
|
|
32
60
|
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
|
33
61
|
end
|
|
34
62
|
|
|
63
|
+
if permission.nil?
|
|
64
|
+
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
|
65
|
+
end
|
|
66
|
+
|
|
35
67
|
if read.nil?
|
|
36
68
|
raise Appwrite::Exception.new('Missing required parameter: "read"')
|
|
37
69
|
end
|
|
@@ -40,36 +72,113 @@ module Appwrite
|
|
|
40
72
|
raise Appwrite::Exception.new('Missing required parameter: "write"')
|
|
41
73
|
end
|
|
42
74
|
|
|
43
|
-
if rules.nil?
|
|
44
|
-
raise Appwrite::Exception.new('Missing required parameter: "rules"')
|
|
45
|
-
end
|
|
46
|
-
|
|
47
75
|
path = '/database/collections'
|
|
48
76
|
|
|
49
|
-
params = {
|
|
77
|
+
params = {
|
|
78
|
+
collectionId: collection_id,
|
|
79
|
+
name: name,
|
|
80
|
+
permission: permission,
|
|
81
|
+
read: read,
|
|
82
|
+
write: write,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
headers = {
|
|
86
|
+
"content-type": 'application/json',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@client.call(
|
|
90
|
+
method: 'POST',
|
|
91
|
+
path: path,
|
|
92
|
+
params: params,
|
|
93
|
+
headers: headers,
|
|
94
|
+
response_type: Collection
|
|
95
|
+
)
|
|
96
|
+
end
|
|
50
97
|
|
|
51
|
-
|
|
52
|
-
|
|
98
|
+
# Get a collection by its unique ID. This endpoint response returns a JSON
|
|
99
|
+
# object with the collection metadata.
|
|
100
|
+
#
|
|
101
|
+
# @param [string] collection_id Collection ID.
|
|
102
|
+
#
|
|
103
|
+
# @return [Collection]
|
|
104
|
+
def get_collection(collection_id:)
|
|
105
|
+
if collection_id.nil?
|
|
106
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
53
107
|
end
|
|
54
108
|
|
|
55
|
-
|
|
56
|
-
|
|
109
|
+
path = '/database/collections/{collectionId}'
|
|
110
|
+
.gsub('{collectionId}', collection_id)
|
|
111
|
+
|
|
112
|
+
params = {
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
headers = {
|
|
116
|
+
"content-type": 'application/json',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@client.call(
|
|
120
|
+
method: 'GET',
|
|
121
|
+
path: path,
|
|
122
|
+
params: params,
|
|
123
|
+
headers: headers,
|
|
124
|
+
response_type: Collection
|
|
125
|
+
)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Update a collection by its unique ID.
|
|
129
|
+
#
|
|
130
|
+
# @param [string] collection_id Collection ID.
|
|
131
|
+
# @param [string] name Collection name. Max length: 128 chars.
|
|
132
|
+
# @param [string] permission Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the `read` and `write` params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
133
|
+
# @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
134
|
+
# @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
135
|
+
# @param [boolean] enabled Is collection enabled?
|
|
136
|
+
#
|
|
137
|
+
# @return [Collection]
|
|
138
|
+
def update_collection(collection_id:, name:, permission:, read: nil, write: nil, enabled: nil)
|
|
139
|
+
if collection_id.nil?
|
|
140
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
57
141
|
end
|
|
58
142
|
|
|
59
|
-
if
|
|
60
|
-
|
|
143
|
+
if name.nil?
|
|
144
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
|
61
145
|
end
|
|
62
146
|
|
|
63
|
-
if
|
|
64
|
-
|
|
147
|
+
if permission.nil?
|
|
148
|
+
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
|
65
149
|
end
|
|
66
150
|
|
|
67
|
-
|
|
68
|
-
'
|
|
69
|
-
|
|
151
|
+
path = '/database/collections/{collectionId}'
|
|
152
|
+
.gsub('{collectionId}', collection_id)
|
|
153
|
+
|
|
154
|
+
params = {
|
|
155
|
+
name: name,
|
|
156
|
+
permission: permission,
|
|
157
|
+
read: read,
|
|
158
|
+
write: write,
|
|
159
|
+
enabled: enabled,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
headers = {
|
|
163
|
+
"content-type": 'application/json',
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@client.call(
|
|
167
|
+
method: 'PUT',
|
|
168
|
+
path: path,
|
|
169
|
+
params: params,
|
|
170
|
+
headers: headers,
|
|
171
|
+
response_type: Collection
|
|
172
|
+
)
|
|
70
173
|
end
|
|
71
174
|
|
|
72
|
-
|
|
175
|
+
# Delete a collection by its unique ID. Only users with write permissions
|
|
176
|
+
# have access to delete this resource.
|
|
177
|
+
#
|
|
178
|
+
# @param [string] collection_id Collection ID.
|
|
179
|
+
#
|
|
180
|
+
# @return []
|
|
181
|
+
def delete_collection(collection_id:)
|
|
73
182
|
if collection_id.nil?
|
|
74
183
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
75
184
|
end
|
|
@@ -77,149 +186,608 @@ module Appwrite
|
|
|
77
186
|
path = '/database/collections/{collectionId}'
|
|
78
187
|
.gsub('{collectionId}', collection_id)
|
|
79
188
|
|
|
80
|
-
params = {
|
|
189
|
+
params = {
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
headers = {
|
|
193
|
+
"content-type": 'application/json',
|
|
194
|
+
}
|
|
81
195
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
196
|
+
@client.call(
|
|
197
|
+
method: 'DELETE',
|
|
198
|
+
path: path,
|
|
199
|
+
params: params,
|
|
200
|
+
headers: headers,
|
|
201
|
+
)
|
|
85
202
|
end
|
|
86
203
|
|
|
87
|
-
|
|
204
|
+
#
|
|
205
|
+
#
|
|
206
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
207
|
+
#
|
|
208
|
+
# @return [AttributeList]
|
|
209
|
+
def list_attributes(collection_id:)
|
|
88
210
|
if collection_id.nil?
|
|
89
211
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
90
212
|
end
|
|
91
213
|
|
|
92
|
-
|
|
93
|
-
|
|
214
|
+
path = '/database/collections/{collectionId}/attributes'
|
|
215
|
+
.gsub('{collectionId}', collection_id)
|
|
216
|
+
|
|
217
|
+
params = {
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
headers = {
|
|
221
|
+
"content-type": 'application/json',
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@client.call(
|
|
225
|
+
method: 'GET',
|
|
226
|
+
path: path,
|
|
227
|
+
params: params,
|
|
228
|
+
headers: headers,
|
|
229
|
+
response_type: AttributeList
|
|
230
|
+
)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Create a boolean attribute.
|
|
234
|
+
#
|
|
235
|
+
#
|
|
236
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
237
|
+
# @param [string] key Attribute Key.
|
|
238
|
+
# @param [boolean] required Is attribute required?
|
|
239
|
+
# @param [boolean] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
240
|
+
# @param [boolean] array Is attribute an array?
|
|
241
|
+
#
|
|
242
|
+
# @return [AttributeBoolean]
|
|
243
|
+
def create_boolean_attribute(collection_id:, key:, required:, default: nil, array: nil)
|
|
244
|
+
if collection_id.nil?
|
|
245
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
94
246
|
end
|
|
95
247
|
|
|
96
|
-
|
|
248
|
+
if key.nil?
|
|
249
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
if required.nil?
|
|
253
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
path = '/database/collections/{collectionId}/attributes/boolean'
|
|
97
257
|
.gsub('{collectionId}', collection_id)
|
|
98
258
|
|
|
99
|
-
params = {
|
|
259
|
+
params = {
|
|
260
|
+
key: key,
|
|
261
|
+
required: required,
|
|
262
|
+
default: default,
|
|
263
|
+
array: array,
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
headers = {
|
|
267
|
+
"content-type": 'application/json',
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@client.call(
|
|
271
|
+
method: 'POST',
|
|
272
|
+
path: path,
|
|
273
|
+
params: params,
|
|
274
|
+
headers: headers,
|
|
275
|
+
response_type: AttributeBoolean
|
|
276
|
+
)
|
|
277
|
+
end
|
|
100
278
|
|
|
101
|
-
|
|
102
|
-
|
|
279
|
+
# Create an email attribute.
|
|
280
|
+
#
|
|
281
|
+
#
|
|
282
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
283
|
+
# @param [string] key Attribute Key.
|
|
284
|
+
# @param [boolean] required Is attribute required?
|
|
285
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
286
|
+
# @param [boolean] array Is attribute an array?
|
|
287
|
+
#
|
|
288
|
+
# @return [AttributeEmail]
|
|
289
|
+
def create_email_attribute(collection_id:, key:, required:, default: nil, array: nil)
|
|
290
|
+
if collection_id.nil?
|
|
291
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
103
292
|
end
|
|
104
293
|
|
|
105
|
-
if
|
|
106
|
-
|
|
294
|
+
if key.nil?
|
|
295
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
107
296
|
end
|
|
108
297
|
|
|
109
|
-
if
|
|
110
|
-
|
|
298
|
+
if required.nil?
|
|
299
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
111
300
|
end
|
|
112
301
|
|
|
113
|
-
|
|
114
|
-
|
|
302
|
+
path = '/database/collections/{collectionId}/attributes/email'
|
|
303
|
+
.gsub('{collectionId}', collection_id)
|
|
304
|
+
|
|
305
|
+
params = {
|
|
306
|
+
key: key,
|
|
307
|
+
required: required,
|
|
308
|
+
default: default,
|
|
309
|
+
array: array,
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
headers = {
|
|
313
|
+
"content-type": 'application/json',
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@client.call(
|
|
317
|
+
method: 'POST',
|
|
318
|
+
path: path,
|
|
319
|
+
params: params,
|
|
320
|
+
headers: headers,
|
|
321
|
+
response_type: AttributeEmail
|
|
322
|
+
)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
#
|
|
326
|
+
#
|
|
327
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
328
|
+
# @param [string] key Attribute Key.
|
|
329
|
+
# @param [array] elements Array of elements in enumerated type. Uses length of longest element to determine size.
|
|
330
|
+
# @param [boolean] required Is attribute required?
|
|
331
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
332
|
+
# @param [boolean] array Is attribute an array?
|
|
333
|
+
#
|
|
334
|
+
# @return [AttributeEnum]
|
|
335
|
+
def create_enum_attribute(collection_id:, key:, elements:, required:, default: nil, array: nil)
|
|
336
|
+
if collection_id.nil?
|
|
337
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
if key.nil?
|
|
341
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
115
342
|
end
|
|
116
343
|
|
|
117
|
-
|
|
118
|
-
'
|
|
119
|
-
|
|
344
|
+
if elements.nil?
|
|
345
|
+
raise Appwrite::Exception.new('Missing required parameter: "elements"')
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
if required.nil?
|
|
349
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
path = '/database/collections/{collectionId}/attributes/enum'
|
|
353
|
+
.gsub('{collectionId}', collection_id)
|
|
354
|
+
|
|
355
|
+
params = {
|
|
356
|
+
key: key,
|
|
357
|
+
elements: elements,
|
|
358
|
+
required: required,
|
|
359
|
+
default: default,
|
|
360
|
+
array: array,
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
headers = {
|
|
364
|
+
"content-type": 'application/json',
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@client.call(
|
|
368
|
+
method: 'POST',
|
|
369
|
+
path: path,
|
|
370
|
+
params: params,
|
|
371
|
+
headers: headers,
|
|
372
|
+
response_type: AttributeEnum
|
|
373
|
+
)
|
|
120
374
|
end
|
|
121
375
|
|
|
122
|
-
|
|
376
|
+
# Create a float attribute. Optionally, minimum and maximum values can be
|
|
377
|
+
# provided.
|
|
378
|
+
#
|
|
379
|
+
#
|
|
380
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
381
|
+
# @param [string] key Attribute Key.
|
|
382
|
+
# @param [boolean] required Is attribute required?
|
|
383
|
+
# @param [string] min Minimum value to enforce on new documents
|
|
384
|
+
# @param [string] max Maximum value to enforce on new documents
|
|
385
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
386
|
+
# @param [boolean] array Is attribute an array?
|
|
387
|
+
#
|
|
388
|
+
# @return [AttributeFloat]
|
|
389
|
+
def create_float_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
|
|
123
390
|
if collection_id.nil?
|
|
124
391
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
125
392
|
end
|
|
126
393
|
|
|
127
|
-
|
|
394
|
+
if key.nil?
|
|
395
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
if required.nil?
|
|
399
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
path = '/database/collections/{collectionId}/attributes/float'
|
|
128
403
|
.gsub('{collectionId}', collection_id)
|
|
129
404
|
|
|
130
|
-
params = {
|
|
405
|
+
params = {
|
|
406
|
+
key: key,
|
|
407
|
+
required: required,
|
|
408
|
+
min: min,
|
|
409
|
+
max: max,
|
|
410
|
+
default: default,
|
|
411
|
+
array: array,
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
headers = {
|
|
415
|
+
"content-type": 'application/json',
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
@client.call(
|
|
419
|
+
method: 'POST',
|
|
420
|
+
path: path,
|
|
421
|
+
params: params,
|
|
422
|
+
headers: headers,
|
|
423
|
+
response_type: AttributeFloat
|
|
424
|
+
)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
# Create an integer attribute. Optionally, minimum and maximum values can be
|
|
428
|
+
# provided.
|
|
429
|
+
#
|
|
430
|
+
#
|
|
431
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
432
|
+
# @param [string] key Attribute Key.
|
|
433
|
+
# @param [boolean] required Is attribute required?
|
|
434
|
+
# @param [number] min Minimum value to enforce on new documents
|
|
435
|
+
# @param [number] max Maximum value to enforce on new documents
|
|
436
|
+
# @param [number] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
437
|
+
# @param [boolean] array Is attribute an array?
|
|
438
|
+
#
|
|
439
|
+
# @return [AttributeInteger]
|
|
440
|
+
def create_integer_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
|
|
441
|
+
if collection_id.nil?
|
|
442
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
if key.nil?
|
|
446
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
if required.nil?
|
|
450
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
451
|
+
end
|
|
131
452
|
|
|
132
|
-
|
|
133
|
-
'
|
|
134
|
-
|
|
453
|
+
path = '/database/collections/{collectionId}/attributes/integer'
|
|
454
|
+
.gsub('{collectionId}', collection_id)
|
|
455
|
+
|
|
456
|
+
params = {
|
|
457
|
+
key: key,
|
|
458
|
+
required: required,
|
|
459
|
+
min: min,
|
|
460
|
+
max: max,
|
|
461
|
+
default: default,
|
|
462
|
+
array: array,
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
headers = {
|
|
466
|
+
"content-type": 'application/json',
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
@client.call(
|
|
470
|
+
method: 'POST',
|
|
471
|
+
path: path,
|
|
472
|
+
params: params,
|
|
473
|
+
headers: headers,
|
|
474
|
+
response_type: AttributeInteger
|
|
475
|
+
)
|
|
135
476
|
end
|
|
136
477
|
|
|
137
|
-
|
|
478
|
+
# Create IP address attribute.
|
|
479
|
+
#
|
|
480
|
+
#
|
|
481
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
482
|
+
# @param [string] key Attribute Key.
|
|
483
|
+
# @param [boolean] required Is attribute required?
|
|
484
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
485
|
+
# @param [boolean] array Is attribute an array?
|
|
486
|
+
#
|
|
487
|
+
# @return [AttributeIp]
|
|
488
|
+
def create_ip_attribute(collection_id:, key:, required:, default: nil, array: nil)
|
|
138
489
|
if collection_id.nil?
|
|
139
490
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
140
491
|
end
|
|
141
492
|
|
|
142
|
-
|
|
493
|
+
if key.nil?
|
|
494
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
if required.nil?
|
|
498
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
path = '/database/collections/{collectionId}/attributes/ip'
|
|
143
502
|
.gsub('{collectionId}', collection_id)
|
|
144
503
|
|
|
145
|
-
params = {
|
|
504
|
+
params = {
|
|
505
|
+
key: key,
|
|
506
|
+
required: required,
|
|
507
|
+
default: default,
|
|
508
|
+
array: array,
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
headers = {
|
|
512
|
+
"content-type": 'application/json',
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
@client.call(
|
|
516
|
+
method: 'POST',
|
|
517
|
+
path: path,
|
|
518
|
+
params: params,
|
|
519
|
+
headers: headers,
|
|
520
|
+
response_type: AttributeIp
|
|
521
|
+
)
|
|
522
|
+
end
|
|
146
523
|
|
|
147
|
-
|
|
148
|
-
|
|
524
|
+
# Create a string attribute.
|
|
525
|
+
#
|
|
526
|
+
#
|
|
527
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
528
|
+
# @param [string] key Attribute Key.
|
|
529
|
+
# @param [number] size Attribute size for text attributes, in number of characters.
|
|
530
|
+
# @param [boolean] required Is attribute required?
|
|
531
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
532
|
+
# @param [boolean] array Is attribute an array?
|
|
533
|
+
#
|
|
534
|
+
# @return [AttributeString]
|
|
535
|
+
def create_string_attribute(collection_id:, key:, size:, required:, default: nil, array: nil)
|
|
536
|
+
if collection_id.nil?
|
|
537
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
149
538
|
end
|
|
150
539
|
|
|
151
|
-
if
|
|
152
|
-
|
|
540
|
+
if key.nil?
|
|
541
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
153
542
|
end
|
|
154
543
|
|
|
155
|
-
if
|
|
156
|
-
|
|
544
|
+
if size.nil?
|
|
545
|
+
raise Appwrite::Exception.new('Missing required parameter: "size"')
|
|
157
546
|
end
|
|
158
547
|
|
|
159
|
-
if
|
|
160
|
-
|
|
548
|
+
if required.nil?
|
|
549
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
161
550
|
end
|
|
162
551
|
|
|
163
|
-
|
|
164
|
-
|
|
552
|
+
path = '/database/collections/{collectionId}/attributes/string'
|
|
553
|
+
.gsub('{collectionId}', collection_id)
|
|
554
|
+
|
|
555
|
+
params = {
|
|
556
|
+
key: key,
|
|
557
|
+
size: size,
|
|
558
|
+
required: required,
|
|
559
|
+
default: default,
|
|
560
|
+
array: array,
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
headers = {
|
|
564
|
+
"content-type": 'application/json',
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
@client.call(
|
|
568
|
+
method: 'POST',
|
|
569
|
+
path: path,
|
|
570
|
+
params: params,
|
|
571
|
+
headers: headers,
|
|
572
|
+
response_type: AttributeString
|
|
573
|
+
)
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
# Create a URL attribute.
|
|
577
|
+
#
|
|
578
|
+
#
|
|
579
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
580
|
+
# @param [string] key Attribute Key.
|
|
581
|
+
# @param [boolean] required Is attribute required?
|
|
582
|
+
# @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
|
583
|
+
# @param [boolean] array Is attribute an array?
|
|
584
|
+
#
|
|
585
|
+
# @return [AttributeUrl]
|
|
586
|
+
def create_url_attribute(collection_id:, key:, required:, default: nil, array: nil)
|
|
587
|
+
if collection_id.nil?
|
|
588
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
165
589
|
end
|
|
166
590
|
|
|
167
|
-
if
|
|
168
|
-
|
|
591
|
+
if key.nil?
|
|
592
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
169
593
|
end
|
|
170
594
|
|
|
171
|
-
if
|
|
172
|
-
|
|
595
|
+
if required.nil?
|
|
596
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
|
173
597
|
end
|
|
174
598
|
|
|
175
|
-
|
|
176
|
-
'
|
|
177
|
-
|
|
599
|
+
path = '/database/collections/{collectionId}/attributes/url'
|
|
600
|
+
.gsub('{collectionId}', collection_id)
|
|
601
|
+
|
|
602
|
+
params = {
|
|
603
|
+
key: key,
|
|
604
|
+
required: required,
|
|
605
|
+
default: default,
|
|
606
|
+
array: array,
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
headers = {
|
|
610
|
+
"content-type": 'application/json',
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
@client.call(
|
|
614
|
+
method: 'POST',
|
|
615
|
+
path: path,
|
|
616
|
+
params: params,
|
|
617
|
+
headers: headers,
|
|
618
|
+
response_type: AttributeUrl
|
|
619
|
+
)
|
|
178
620
|
end
|
|
179
621
|
|
|
180
|
-
|
|
622
|
+
#
|
|
623
|
+
#
|
|
624
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
625
|
+
# @param [string] key Attribute Key.
|
|
626
|
+
#
|
|
627
|
+
# @return []
|
|
628
|
+
def get_attribute(collection_id:, key:)
|
|
181
629
|
if collection_id.nil?
|
|
182
630
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
183
631
|
end
|
|
184
632
|
|
|
185
|
-
if
|
|
186
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
|
633
|
+
if key.nil?
|
|
634
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
187
635
|
end
|
|
188
636
|
|
|
189
|
-
path = '/database/collections/{collectionId}/
|
|
637
|
+
path = '/database/collections/{collectionId}/attributes/{key}'
|
|
190
638
|
.gsub('{collectionId}', collection_id)
|
|
639
|
+
.gsub('{key}', key)
|
|
191
640
|
|
|
192
|
-
params = {
|
|
641
|
+
params = {
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
headers = {
|
|
645
|
+
"content-type": 'application/json',
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
@client.call(
|
|
649
|
+
method: 'GET',
|
|
650
|
+
path: path,
|
|
651
|
+
params: params,
|
|
652
|
+
headers: headers,
|
|
653
|
+
)
|
|
654
|
+
end
|
|
193
655
|
|
|
194
|
-
|
|
195
|
-
|
|
656
|
+
#
|
|
657
|
+
#
|
|
658
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
659
|
+
# @param [string] key Attribute Key.
|
|
660
|
+
#
|
|
661
|
+
# @return []
|
|
662
|
+
def delete_attribute(collection_id:, key:)
|
|
663
|
+
if collection_id.nil?
|
|
664
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
196
665
|
end
|
|
197
666
|
|
|
198
|
-
if
|
|
199
|
-
|
|
667
|
+
if key.nil?
|
|
668
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
200
669
|
end
|
|
201
670
|
|
|
202
|
-
|
|
203
|
-
|
|
671
|
+
path = '/database/collections/{collectionId}/attributes/{key}'
|
|
672
|
+
.gsub('{collectionId}', collection_id)
|
|
673
|
+
.gsub('{key}', key)
|
|
674
|
+
|
|
675
|
+
params = {
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
headers = {
|
|
679
|
+
"content-type": 'application/json',
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
@client.call(
|
|
683
|
+
method: 'DELETE',
|
|
684
|
+
path: path,
|
|
685
|
+
params: params,
|
|
686
|
+
headers: headers,
|
|
687
|
+
)
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
# Get a list of all the user documents. You can use the query params to
|
|
691
|
+
# filter your results. On admin mode, this endpoint will return a list of all
|
|
692
|
+
# of the project's documents. [Learn more about different API
|
|
693
|
+
# modes](/docs/admin).
|
|
694
|
+
#
|
|
695
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
696
|
+
# @param [array] queries Array of query strings.
|
|
697
|
+
# @param [number] limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
|
698
|
+
# @param [number] offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
|
|
699
|
+
# @param [string] cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
|
|
700
|
+
# @param [string] cursor_direction Direction of the cursor.
|
|
701
|
+
# @param [array] order_attributes Array of attributes used to sort results.
|
|
702
|
+
# @param [array] order_types Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.
|
|
703
|
+
#
|
|
704
|
+
# @return [DocumentList]
|
|
705
|
+
def list_documents(collection_id:, queries: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_attributes: nil, order_types: nil)
|
|
706
|
+
if collection_id.nil?
|
|
707
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
204
708
|
end
|
|
205
709
|
|
|
206
|
-
|
|
207
|
-
|
|
710
|
+
path = '/database/collections/{collectionId}/documents'
|
|
711
|
+
.gsub('{collectionId}', collection_id)
|
|
712
|
+
|
|
713
|
+
params = {
|
|
714
|
+
queries: queries,
|
|
715
|
+
limit: limit,
|
|
716
|
+
offset: offset,
|
|
717
|
+
cursor: cursor,
|
|
718
|
+
cursorDirection: cursor_direction,
|
|
719
|
+
orderAttributes: order_attributes,
|
|
720
|
+
orderTypes: order_types,
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
headers = {
|
|
724
|
+
"content-type": 'application/json',
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
@client.call(
|
|
728
|
+
method: 'GET',
|
|
729
|
+
path: path,
|
|
730
|
+
params: params,
|
|
731
|
+
headers: headers,
|
|
732
|
+
response_type: DocumentList
|
|
733
|
+
)
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
# Create a new Document. Before using this route, you should create a new
|
|
737
|
+
# collection resource using either a [server
|
|
738
|
+
# integration](/docs/server/database#databaseCreateCollection) API or
|
|
739
|
+
# directly from your database console.
|
|
740
|
+
#
|
|
741
|
+
# @param [string] collection_id Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
742
|
+
# @param [string] document_id Document ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
743
|
+
# @param [object] data Document data as JSON object.
|
|
744
|
+
# @param [array] read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
745
|
+
# @param [array] write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
746
|
+
#
|
|
747
|
+
# @return [Document]
|
|
748
|
+
def create_document(collection_id:, document_id:, data:, read: nil, write: nil)
|
|
749
|
+
if collection_id.nil?
|
|
750
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
208
751
|
end
|
|
209
752
|
|
|
210
|
-
if
|
|
211
|
-
|
|
753
|
+
if document_id.nil?
|
|
754
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
|
212
755
|
end
|
|
213
756
|
|
|
214
|
-
if
|
|
215
|
-
|
|
757
|
+
if data.nil?
|
|
758
|
+
raise Appwrite::Exception.new('Missing required parameter: "data"')
|
|
216
759
|
end
|
|
217
760
|
|
|
218
|
-
|
|
219
|
-
'
|
|
220
|
-
|
|
761
|
+
path = '/database/collections/{collectionId}/documents'
|
|
762
|
+
.gsub('{collectionId}', collection_id)
|
|
763
|
+
|
|
764
|
+
params = {
|
|
765
|
+
documentId: document_id,
|
|
766
|
+
data: data,
|
|
767
|
+
read: read,
|
|
768
|
+
write: write,
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
headers = {
|
|
772
|
+
"content-type": 'application/json',
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
@client.call(
|
|
776
|
+
method: 'POST',
|
|
777
|
+
path: path,
|
|
778
|
+
params: params,
|
|
779
|
+
headers: headers,
|
|
780
|
+
response_type: Document
|
|
781
|
+
)
|
|
221
782
|
end
|
|
222
783
|
|
|
784
|
+
# Get a document by its unique ID. This endpoint response returns a JSON
|
|
785
|
+
# object with the document data.
|
|
786
|
+
#
|
|
787
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
788
|
+
# @param [string] document_id Document ID.
|
|
789
|
+
#
|
|
790
|
+
# @return [Document]
|
|
223
791
|
def get_document(collection_id:, document_id:)
|
|
224
792
|
if collection_id.nil?
|
|
225
793
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
@@ -233,13 +801,32 @@ module Appwrite
|
|
|
233
801
|
.gsub('{collectionId}', collection_id)
|
|
234
802
|
.gsub('{documentId}', document_id)
|
|
235
803
|
|
|
236
|
-
params = {
|
|
804
|
+
params = {
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
headers = {
|
|
808
|
+
"content-type": 'application/json',
|
|
809
|
+
}
|
|
237
810
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
811
|
+
@client.call(
|
|
812
|
+
method: 'GET',
|
|
813
|
+
path: path,
|
|
814
|
+
params: params,
|
|
815
|
+
headers: headers,
|
|
816
|
+
response_type: Document
|
|
817
|
+
)
|
|
241
818
|
end
|
|
242
819
|
|
|
820
|
+
# Update a document by its unique ID. Using the patch method you can pass
|
|
821
|
+
# only specific fields that will get updated.
|
|
822
|
+
#
|
|
823
|
+
# @param [string] collection_id Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
824
|
+
# @param [string] document_id Document ID.
|
|
825
|
+
# @param [object] data Document data as JSON object.
|
|
826
|
+
# @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
827
|
+
# @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
828
|
+
#
|
|
829
|
+
# @return [Document]
|
|
243
830
|
def update_document(collection_id:, document_id:, data:, read: nil, write: nil)
|
|
244
831
|
if collection_id.nil?
|
|
245
832
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
@@ -257,48 +844,207 @@ module Appwrite
|
|
|
257
844
|
.gsub('{collectionId}', collection_id)
|
|
258
845
|
.gsub('{documentId}', document_id)
|
|
259
846
|
|
|
260
|
-
params = {
|
|
847
|
+
params = {
|
|
848
|
+
data: data,
|
|
849
|
+
read: read,
|
|
850
|
+
write: write,
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
headers = {
|
|
854
|
+
"content-type": 'application/json',
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
@client.call(
|
|
858
|
+
method: 'PATCH',
|
|
859
|
+
path: path,
|
|
860
|
+
params: params,
|
|
861
|
+
headers: headers,
|
|
862
|
+
response_type: Document
|
|
863
|
+
)
|
|
864
|
+
end
|
|
261
865
|
|
|
262
|
-
|
|
263
|
-
|
|
866
|
+
# Delete a document by its unique ID. This endpoint deletes only the parent
|
|
867
|
+
# documents, its attributes and relations to other documents. Child documents
|
|
868
|
+
# **will not** be deleted.
|
|
869
|
+
#
|
|
870
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
871
|
+
# @param [string] document_id Document ID.
|
|
872
|
+
#
|
|
873
|
+
# @return []
|
|
874
|
+
def delete_document(collection_id:, document_id:)
|
|
875
|
+
if collection_id.nil?
|
|
876
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
264
877
|
end
|
|
265
878
|
|
|
266
|
-
if
|
|
267
|
-
|
|
879
|
+
if document_id.nil?
|
|
880
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
|
268
881
|
end
|
|
269
882
|
|
|
270
|
-
|
|
271
|
-
|
|
883
|
+
path = '/database/collections/{collectionId}/documents/{documentId}'
|
|
884
|
+
.gsub('{collectionId}', collection_id)
|
|
885
|
+
.gsub('{documentId}', document_id)
|
|
886
|
+
|
|
887
|
+
params = {
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
headers = {
|
|
891
|
+
"content-type": 'application/json',
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
@client.call(
|
|
895
|
+
method: 'DELETE',
|
|
896
|
+
path: path,
|
|
897
|
+
params: params,
|
|
898
|
+
headers: headers,
|
|
899
|
+
)
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
#
|
|
903
|
+
#
|
|
904
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
905
|
+
#
|
|
906
|
+
# @return [IndexList]
|
|
907
|
+
def list_indexes(collection_id:)
|
|
908
|
+
if collection_id.nil?
|
|
909
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
272
910
|
end
|
|
273
911
|
|
|
274
|
-
|
|
275
|
-
'
|
|
276
|
-
|
|
912
|
+
path = '/database/collections/{collectionId}/indexes'
|
|
913
|
+
.gsub('{collectionId}', collection_id)
|
|
914
|
+
|
|
915
|
+
params = {
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
headers = {
|
|
919
|
+
"content-type": 'application/json',
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
@client.call(
|
|
923
|
+
method: 'GET',
|
|
924
|
+
path: path,
|
|
925
|
+
params: params,
|
|
926
|
+
headers: headers,
|
|
927
|
+
response_type: IndexList
|
|
928
|
+
)
|
|
277
929
|
end
|
|
278
930
|
|
|
279
|
-
|
|
931
|
+
#
|
|
932
|
+
#
|
|
933
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
934
|
+
# @param [string] key Index Key.
|
|
935
|
+
# @param [string] type Index type.
|
|
936
|
+
# @param [array] attributes Array of attributes to index.
|
|
937
|
+
# @param [array] orders Array of index orders.
|
|
938
|
+
#
|
|
939
|
+
# @return [Index]
|
|
940
|
+
def create_index(collection_id:, key:, type:, attributes:, orders: nil)
|
|
280
941
|
if collection_id.nil?
|
|
281
942
|
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
282
943
|
end
|
|
283
944
|
|
|
284
|
-
if
|
|
285
|
-
raise Appwrite::Exception.new('Missing required parameter: "
|
|
945
|
+
if key.nil?
|
|
946
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
286
947
|
end
|
|
287
948
|
|
|
288
|
-
|
|
949
|
+
if type.nil?
|
|
950
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
|
951
|
+
end
|
|
952
|
+
|
|
953
|
+
if attributes.nil?
|
|
954
|
+
raise Appwrite::Exception.new('Missing required parameter: "attributes"')
|
|
955
|
+
end
|
|
956
|
+
|
|
957
|
+
path = '/database/collections/{collectionId}/indexes'
|
|
289
958
|
.gsub('{collectionId}', collection_id)
|
|
290
|
-
.gsub('{documentId}', document_id)
|
|
291
959
|
|
|
292
|
-
params = {
|
|
960
|
+
params = {
|
|
961
|
+
key: key,
|
|
962
|
+
type: type,
|
|
963
|
+
attributes: attributes,
|
|
964
|
+
orders: orders,
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
headers = {
|
|
968
|
+
"content-type": 'application/json',
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
@client.call(
|
|
972
|
+
method: 'POST',
|
|
973
|
+
path: path,
|
|
974
|
+
params: params,
|
|
975
|
+
headers: headers,
|
|
976
|
+
response_type: Index
|
|
977
|
+
)
|
|
978
|
+
end
|
|
979
|
+
|
|
980
|
+
#
|
|
981
|
+
#
|
|
982
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
983
|
+
# @param [string] key Index Key.
|
|
984
|
+
#
|
|
985
|
+
# @return [Index]
|
|
986
|
+
def get_index(collection_id:, key:)
|
|
987
|
+
if collection_id.nil?
|
|
988
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
989
|
+
end
|
|
990
|
+
|
|
991
|
+
if key.nil?
|
|
992
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
993
|
+
end
|
|
293
994
|
|
|
294
|
-
|
|
295
|
-
'
|
|
296
|
-
|
|
995
|
+
path = '/database/collections/{collectionId}/indexes/{key}'
|
|
996
|
+
.gsub('{collectionId}', collection_id)
|
|
997
|
+
.gsub('{key}', key)
|
|
998
|
+
|
|
999
|
+
params = {
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
headers = {
|
|
1003
|
+
"content-type": 'application/json',
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
@client.call(
|
|
1007
|
+
method: 'GET',
|
|
1008
|
+
path: path,
|
|
1009
|
+
params: params,
|
|
1010
|
+
headers: headers,
|
|
1011
|
+
response_type: Index
|
|
1012
|
+
)
|
|
297
1013
|
end
|
|
298
1014
|
|
|
1015
|
+
#
|
|
1016
|
+
#
|
|
1017
|
+
# @param [string] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
|
|
1018
|
+
# @param [string] key Index Key.
|
|
1019
|
+
#
|
|
1020
|
+
# @return []
|
|
1021
|
+
def delete_index(collection_id:, key:)
|
|
1022
|
+
if collection_id.nil?
|
|
1023
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
|
1024
|
+
end
|
|
1025
|
+
|
|
1026
|
+
if key.nil?
|
|
1027
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
|
1028
|
+
end
|
|
299
1029
|
|
|
300
|
-
|
|
1030
|
+
path = '/database/collections/{collectionId}/indexes/{key}'
|
|
1031
|
+
.gsub('{collectionId}', collection_id)
|
|
1032
|
+
.gsub('{key}', key)
|
|
1033
|
+
|
|
1034
|
+
params = {
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
headers = {
|
|
1038
|
+
"content-type": 'application/json',
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
@client.call(
|
|
1042
|
+
method: 'DELETE',
|
|
1043
|
+
path: path,
|
|
1044
|
+
params: params,
|
|
1045
|
+
headers: headers,
|
|
1046
|
+
)
|
|
1047
|
+
end
|
|
301
1048
|
|
|
302
|
-
private
|
|
303
1049
|
end
|
|
304
1050
|
end
|