appwrite 4.1.0 → 7.0.0.pre.RC1
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 +32 -11
- data/lib/appwrite/id.rb +11 -0
- data/lib/appwrite/input_file.rb +33 -0
- data/lib/appwrite/models/account.rb +82 -0
- data/lib/appwrite/models/algo_argon2.rb +37 -0
- data/lib/appwrite/models/algo_bcrypt.rb +22 -0
- data/lib/appwrite/models/algo_md5.rb +22 -0
- data/lib/appwrite/models/algo_phpass.rb +22 -0
- data/lib/appwrite/models/algo_scrypt.rb +42 -0
- data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
- data/lib/appwrite/models/algo_sha.rb +22 -0
- data/lib/appwrite/models/attribute_datetime.rb +57 -0
- data/lib/appwrite/models/bucket.rb +25 -25
- data/lib/appwrite/models/collection.rb +25 -15
- data/lib/appwrite/models/database.rb +42 -0
- data/lib/appwrite/models/database_list.rb +32 -0
- data/lib/appwrite/models/deployment.rb +10 -5
- data/lib/appwrite/models/document.rb +15 -10
- data/lib/appwrite/models/execution.rb +20 -10
- data/lib/appwrite/models/file.rb +15 -15
- data/lib/appwrite/models/function.rb +12 -12
- data/lib/appwrite/models/index.rb +1 -1
- data/lib/appwrite/models/membership.rb +25 -10
- data/lib/appwrite/models/session.rb +5 -0
- data/lib/appwrite/models/team.rb +10 -5
- data/lib/appwrite/models/token.rb +5 -0
- data/lib/appwrite/models/user.rb +35 -0
- data/lib/appwrite/models/variable.rb +52 -0
- data/lib/appwrite/models/variable_list.rb +32 -0
- data/lib/appwrite/permission.rb +21 -0
- data/lib/appwrite/query.rb +43 -14
- data/lib/appwrite/role.rb +31 -0
- data/lib/appwrite/services/account.rb +274 -126
- data/lib/appwrite/services/avatars.rb +106 -59
- data/lib/appwrite/services/databases.rb +1425 -0
- data/lib/appwrite/services/functions.rb +381 -176
- data/lib/appwrite/services/health.rb +34 -34
- data/lib/appwrite/services/locale.rb +25 -7
- data/lib/appwrite/services/storage.rb +195 -193
- data/lib/appwrite/services/teams.rb +138 -128
- data/lib/appwrite/services/users.rb +637 -123
- data/lib/appwrite.rb +19 -2
- metadata +22 -6
- data/lib/appwrite/file.rb +0 -17
- data/lib/appwrite/services/database.rb +0 -1049
@@ -0,0 +1,1425 @@
|
|
1
|
+
#frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appwrite
|
4
|
+
class Databases < Service
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
# Get a list of all databases from the current Appwrite project. You can use
|
11
|
+
# the search parameter to filter your results.
|
12
|
+
#
|
13
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name
|
14
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
15
|
+
#
|
16
|
+
# @return [DatabaseList]
|
17
|
+
def list(queries: nil, search: nil)
|
18
|
+
|
19
|
+
path = '/databases'
|
20
|
+
|
21
|
+
params = {
|
22
|
+
queries: queries,
|
23
|
+
search: search,
|
24
|
+
}
|
25
|
+
|
26
|
+
headers = {
|
27
|
+
"content-type": 'application/json',
|
28
|
+
}
|
29
|
+
|
30
|
+
@client.call(
|
31
|
+
method: 'GET',
|
32
|
+
path: path,
|
33
|
+
headers: headers,
|
34
|
+
params: params,
|
35
|
+
response_type: Models::DatabaseList
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# Create a new Database.
|
41
|
+
#
|
42
|
+
#
|
43
|
+
# @param [String] database_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.
|
44
|
+
# @param [String] name Collection name. Max length: 128 chars.
|
45
|
+
#
|
46
|
+
# @return [Database]
|
47
|
+
def create(database_id:, name:)
|
48
|
+
|
49
|
+
path = '/databases'
|
50
|
+
|
51
|
+
params = {
|
52
|
+
databaseId: database_id,
|
53
|
+
name: name,
|
54
|
+
}
|
55
|
+
|
56
|
+
headers = {
|
57
|
+
"content-type": 'application/json',
|
58
|
+
}
|
59
|
+
if database_id.nil?
|
60
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
61
|
+
end
|
62
|
+
|
63
|
+
if name.nil?
|
64
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
@client.call(
|
69
|
+
method: 'POST',
|
70
|
+
path: path,
|
71
|
+
headers: headers,
|
72
|
+
params: params,
|
73
|
+
response_type: Models::Database
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# Get a database by its unique ID. This endpoint response returns a JSON
|
79
|
+
# object with the database metadata.
|
80
|
+
#
|
81
|
+
# @param [String] database_id Database ID.
|
82
|
+
#
|
83
|
+
# @return [Database]
|
84
|
+
def get(database_id:)
|
85
|
+
|
86
|
+
path = '/databases/{databaseId}'
|
87
|
+
|
88
|
+
params = {
|
89
|
+
}
|
90
|
+
|
91
|
+
headers = {
|
92
|
+
"content-type": 'application/json',
|
93
|
+
}
|
94
|
+
if database_id.nil?
|
95
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
96
|
+
end
|
97
|
+
|
98
|
+
.gsub('{databaseId}', database_id)
|
99
|
+
|
100
|
+
@client.call(
|
101
|
+
method: 'GET',
|
102
|
+
path: path,
|
103
|
+
headers: headers,
|
104
|
+
params: params,
|
105
|
+
response_type: Models::Database
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
# Update a database by its unique ID.
|
111
|
+
#
|
112
|
+
# @param [String] database_id Database ID.
|
113
|
+
# @param [String] name Collection name. Max length: 128 chars.
|
114
|
+
#
|
115
|
+
# @return [Database]
|
116
|
+
def update(database_id:, name:)
|
117
|
+
|
118
|
+
path = '/databases/{databaseId}'
|
119
|
+
|
120
|
+
params = {
|
121
|
+
name: name,
|
122
|
+
}
|
123
|
+
|
124
|
+
headers = {
|
125
|
+
"content-type": 'application/json',
|
126
|
+
}
|
127
|
+
if database_id.nil?
|
128
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
129
|
+
end
|
130
|
+
|
131
|
+
if name.nil?
|
132
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
133
|
+
end
|
134
|
+
|
135
|
+
.gsub('{databaseId}', database_id)
|
136
|
+
|
137
|
+
@client.call(
|
138
|
+
method: 'PUT',
|
139
|
+
path: path,
|
140
|
+
headers: headers,
|
141
|
+
params: params,
|
142
|
+
response_type: Models::Database
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
# Delete a database by its unique ID. Only API keys with with databases.write
|
148
|
+
# scope can delete a database.
|
149
|
+
#
|
150
|
+
# @param [String] database_id Database ID.
|
151
|
+
#
|
152
|
+
# @return []
|
153
|
+
def delete(database_id:)
|
154
|
+
|
155
|
+
path = '/databases/{databaseId}'
|
156
|
+
|
157
|
+
params = {
|
158
|
+
}
|
159
|
+
|
160
|
+
headers = {
|
161
|
+
"content-type": 'application/json',
|
162
|
+
}
|
163
|
+
if database_id.nil?
|
164
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
165
|
+
end
|
166
|
+
|
167
|
+
.gsub('{databaseId}', database_id)
|
168
|
+
|
169
|
+
@client.call(
|
170
|
+
method: 'DELETE',
|
171
|
+
path: path,
|
172
|
+
headers: headers,
|
173
|
+
params: params,
|
174
|
+
)
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
# Get a list of all collections that belong to the provided databaseId. You
|
179
|
+
# can use the search parameter to filter your results.
|
180
|
+
#
|
181
|
+
# @param [String] database_id Database ID.
|
182
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity
|
183
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
184
|
+
#
|
185
|
+
# @return [CollectionList]
|
186
|
+
def list_collections(database_id:, queries: nil, search: nil)
|
187
|
+
|
188
|
+
path = '/databases/{databaseId}/collections'
|
189
|
+
|
190
|
+
params = {
|
191
|
+
queries: queries,
|
192
|
+
search: search,
|
193
|
+
}
|
194
|
+
|
195
|
+
headers = {
|
196
|
+
"content-type": 'application/json',
|
197
|
+
}
|
198
|
+
if database_id.nil?
|
199
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
200
|
+
end
|
201
|
+
|
202
|
+
.gsub('{databaseId}', database_id)
|
203
|
+
|
204
|
+
@client.call(
|
205
|
+
method: 'GET',
|
206
|
+
path: path,
|
207
|
+
headers: headers,
|
208
|
+
params: params,
|
209
|
+
response_type: Models::CollectionList
|
210
|
+
)
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
# Create a new Collection. Before using this route, you should create a new
|
215
|
+
# database resource using either a [server
|
216
|
+
# integration](/docs/server/databases#databasesCreateCollection) API or
|
217
|
+
# directly from your database console.
|
218
|
+
#
|
219
|
+
# @param [String] database_id Database ID.
|
220
|
+
# @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.
|
221
|
+
# @param [String] name Collection name. Max length: 128 chars.
|
222
|
+
# @param [Array] permissions An array of permissions strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).
|
223
|
+
# @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).
|
224
|
+
#
|
225
|
+
# @return [Collection]
|
226
|
+
def create_collection(database_id:, collection_id:, name:, permissions: nil, document_security: nil)
|
227
|
+
|
228
|
+
path = '/databases/{databaseId}/collections'
|
229
|
+
|
230
|
+
params = {
|
231
|
+
collectionId: collection_id,
|
232
|
+
name: name,
|
233
|
+
permissions: permissions,
|
234
|
+
documentSecurity: document_security,
|
235
|
+
}
|
236
|
+
|
237
|
+
headers = {
|
238
|
+
"content-type": 'application/json',
|
239
|
+
}
|
240
|
+
if database_id.nil?
|
241
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
242
|
+
end
|
243
|
+
|
244
|
+
if collection_id.nil?
|
245
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
246
|
+
end
|
247
|
+
|
248
|
+
if name.nil?
|
249
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
250
|
+
end
|
251
|
+
|
252
|
+
.gsub('{databaseId}', database_id)
|
253
|
+
|
254
|
+
@client.call(
|
255
|
+
method: 'POST',
|
256
|
+
path: path,
|
257
|
+
headers: headers,
|
258
|
+
params: params,
|
259
|
+
response_type: Models::Collection
|
260
|
+
)
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
# Get a collection by its unique ID. This endpoint response returns a JSON
|
265
|
+
# object with the collection metadata.
|
266
|
+
#
|
267
|
+
# @param [String] database_id Database ID.
|
268
|
+
# @param [String] collection_id Collection ID.
|
269
|
+
#
|
270
|
+
# @return [Collection]
|
271
|
+
def get_collection(database_id:, collection_id:)
|
272
|
+
|
273
|
+
path = '/databases/{databaseId}/collections/{collectionId}'
|
274
|
+
|
275
|
+
params = {
|
276
|
+
}
|
277
|
+
|
278
|
+
headers = {
|
279
|
+
"content-type": 'application/json',
|
280
|
+
}
|
281
|
+
if database_id.nil?
|
282
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
283
|
+
end
|
284
|
+
|
285
|
+
if collection_id.nil?
|
286
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
287
|
+
end
|
288
|
+
|
289
|
+
.gsub('{databaseId}', database_id)
|
290
|
+
.gsub('{collectionId}', collection_id)
|
291
|
+
|
292
|
+
@client.call(
|
293
|
+
method: 'GET',
|
294
|
+
path: path,
|
295
|
+
headers: headers,
|
296
|
+
params: params,
|
297
|
+
response_type: Models::Collection
|
298
|
+
)
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
# Update a collection by its unique ID.
|
303
|
+
#
|
304
|
+
# @param [String] database_id Database ID.
|
305
|
+
# @param [String] collection_id Collection ID.
|
306
|
+
# @param [String] name Collection name. Max length: 128 chars.
|
307
|
+
# @param [Array] permissions An array of permission strings. By default the current permission are inherited. [Learn more about permissions](/docs/permissions).
|
308
|
+
# @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](/docs/permissions).
|
309
|
+
# @param [] enabled Is collection enabled?
|
310
|
+
#
|
311
|
+
# @return [Collection]
|
312
|
+
def update_collection(database_id:, collection_id:, name:, permissions: nil, document_security: nil, enabled: nil)
|
313
|
+
|
314
|
+
path = '/databases/{databaseId}/collections/{collectionId}'
|
315
|
+
|
316
|
+
params = {
|
317
|
+
name: name,
|
318
|
+
permissions: permissions,
|
319
|
+
documentSecurity: document_security,
|
320
|
+
enabled: enabled,
|
321
|
+
}
|
322
|
+
|
323
|
+
headers = {
|
324
|
+
"content-type": 'application/json',
|
325
|
+
}
|
326
|
+
if database_id.nil?
|
327
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
328
|
+
end
|
329
|
+
|
330
|
+
if collection_id.nil?
|
331
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
332
|
+
end
|
333
|
+
|
334
|
+
if name.nil?
|
335
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
336
|
+
end
|
337
|
+
|
338
|
+
.gsub('{databaseId}', database_id)
|
339
|
+
.gsub('{collectionId}', collection_id)
|
340
|
+
|
341
|
+
@client.call(
|
342
|
+
method: 'PUT',
|
343
|
+
path: path,
|
344
|
+
headers: headers,
|
345
|
+
params: params,
|
346
|
+
response_type: Models::Collection
|
347
|
+
)
|
348
|
+
end
|
349
|
+
|
350
|
+
|
351
|
+
# Delete a collection by its unique ID. Only users with write permissions
|
352
|
+
# have access to delete this resource.
|
353
|
+
#
|
354
|
+
# @param [String] database_id Database ID.
|
355
|
+
# @param [String] collection_id Collection ID.
|
356
|
+
#
|
357
|
+
# @return []
|
358
|
+
def delete_collection(database_id:, collection_id:)
|
359
|
+
|
360
|
+
path = '/databases/{databaseId}/collections/{collectionId}'
|
361
|
+
|
362
|
+
params = {
|
363
|
+
}
|
364
|
+
|
365
|
+
headers = {
|
366
|
+
"content-type": 'application/json',
|
367
|
+
}
|
368
|
+
if database_id.nil?
|
369
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
370
|
+
end
|
371
|
+
|
372
|
+
if collection_id.nil?
|
373
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
374
|
+
end
|
375
|
+
|
376
|
+
.gsub('{databaseId}', database_id)
|
377
|
+
.gsub('{collectionId}', collection_id)
|
378
|
+
|
379
|
+
@client.call(
|
380
|
+
method: 'DELETE',
|
381
|
+
path: path,
|
382
|
+
headers: headers,
|
383
|
+
params: params,
|
384
|
+
)
|
385
|
+
end
|
386
|
+
|
387
|
+
|
388
|
+
#
|
389
|
+
#
|
390
|
+
# @param [String] database_id Database ID.
|
391
|
+
# @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).
|
392
|
+
#
|
393
|
+
# @return [AttributeList]
|
394
|
+
def list_attributes(database_id:, collection_id:)
|
395
|
+
|
396
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes'
|
397
|
+
|
398
|
+
params = {
|
399
|
+
}
|
400
|
+
|
401
|
+
headers = {
|
402
|
+
"content-type": 'application/json',
|
403
|
+
}
|
404
|
+
if database_id.nil?
|
405
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
406
|
+
end
|
407
|
+
|
408
|
+
if collection_id.nil?
|
409
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
410
|
+
end
|
411
|
+
|
412
|
+
.gsub('{databaseId}', database_id)
|
413
|
+
.gsub('{collectionId}', collection_id)
|
414
|
+
|
415
|
+
@client.call(
|
416
|
+
method: 'GET',
|
417
|
+
path: path,
|
418
|
+
headers: headers,
|
419
|
+
params: params,
|
420
|
+
response_type: Models::AttributeList
|
421
|
+
)
|
422
|
+
end
|
423
|
+
|
424
|
+
|
425
|
+
# Create a boolean attribute.
|
426
|
+
#
|
427
|
+
#
|
428
|
+
# @param [String] database_id Database ID.
|
429
|
+
# @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).
|
430
|
+
# @param [String] key Attribute Key.
|
431
|
+
# @param [] required Is attribute required?
|
432
|
+
# @param [] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
433
|
+
# @param [] array Is attribute an array?
|
434
|
+
#
|
435
|
+
# @return [AttributeBoolean]
|
436
|
+
def create_boolean_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)
|
437
|
+
|
438
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'
|
439
|
+
|
440
|
+
params = {
|
441
|
+
key: key,
|
442
|
+
required: required,
|
443
|
+
default: default,
|
444
|
+
array: array,
|
445
|
+
}
|
446
|
+
|
447
|
+
headers = {
|
448
|
+
"content-type": 'application/json',
|
449
|
+
}
|
450
|
+
if database_id.nil?
|
451
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
452
|
+
end
|
453
|
+
|
454
|
+
if collection_id.nil?
|
455
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
456
|
+
end
|
457
|
+
|
458
|
+
if key.nil?
|
459
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
460
|
+
end
|
461
|
+
|
462
|
+
if required.nil?
|
463
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
464
|
+
end
|
465
|
+
|
466
|
+
.gsub('{databaseId}', database_id)
|
467
|
+
.gsub('{collectionId}', collection_id)
|
468
|
+
|
469
|
+
@client.call(
|
470
|
+
method: 'POST',
|
471
|
+
path: path,
|
472
|
+
headers: headers,
|
473
|
+
params: params,
|
474
|
+
response_type: Models::AttributeBoolean
|
475
|
+
)
|
476
|
+
end
|
477
|
+
|
478
|
+
|
479
|
+
#
|
480
|
+
#
|
481
|
+
# @param [String] database_id Database ID.
|
482
|
+
# @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).
|
483
|
+
# @param [String] key Attribute Key.
|
484
|
+
# @param [] required Is attribute required?
|
485
|
+
# @param [String] default Default value for the attribute in ISO 8601 format. Cannot be set when attribute is required.
|
486
|
+
# @param [] array Is attribute an array?
|
487
|
+
#
|
488
|
+
# @return [AttributeDatetime]
|
489
|
+
def create_datetime_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)
|
490
|
+
|
491
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'
|
492
|
+
|
493
|
+
params = {
|
494
|
+
key: key,
|
495
|
+
required: required,
|
496
|
+
default: default,
|
497
|
+
array: array,
|
498
|
+
}
|
499
|
+
|
500
|
+
headers = {
|
501
|
+
"content-type": 'application/json',
|
502
|
+
}
|
503
|
+
if database_id.nil?
|
504
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
505
|
+
end
|
506
|
+
|
507
|
+
if collection_id.nil?
|
508
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
509
|
+
end
|
510
|
+
|
511
|
+
if key.nil?
|
512
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
513
|
+
end
|
514
|
+
|
515
|
+
if required.nil?
|
516
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
517
|
+
end
|
518
|
+
|
519
|
+
.gsub('{databaseId}', database_id)
|
520
|
+
.gsub('{collectionId}', collection_id)
|
521
|
+
|
522
|
+
@client.call(
|
523
|
+
method: 'POST',
|
524
|
+
path: path,
|
525
|
+
headers: headers,
|
526
|
+
params: params,
|
527
|
+
response_type: Models::AttributeDatetime
|
528
|
+
)
|
529
|
+
end
|
530
|
+
|
531
|
+
|
532
|
+
# Create an email attribute.
|
533
|
+
#
|
534
|
+
#
|
535
|
+
# @param [String] database_id Database ID.
|
536
|
+
# @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).
|
537
|
+
# @param [String] key Attribute Key.
|
538
|
+
# @param [] required Is attribute required?
|
539
|
+
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
540
|
+
# @param [] array Is attribute an array?
|
541
|
+
#
|
542
|
+
# @return [AttributeEmail]
|
543
|
+
def create_email_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)
|
544
|
+
|
545
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'
|
546
|
+
|
547
|
+
params = {
|
548
|
+
key: key,
|
549
|
+
required: required,
|
550
|
+
default: default,
|
551
|
+
array: array,
|
552
|
+
}
|
553
|
+
|
554
|
+
headers = {
|
555
|
+
"content-type": 'application/json',
|
556
|
+
}
|
557
|
+
if database_id.nil?
|
558
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
559
|
+
end
|
560
|
+
|
561
|
+
if collection_id.nil?
|
562
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
563
|
+
end
|
564
|
+
|
565
|
+
if key.nil?
|
566
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
567
|
+
end
|
568
|
+
|
569
|
+
if required.nil?
|
570
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
571
|
+
end
|
572
|
+
|
573
|
+
.gsub('{databaseId}', database_id)
|
574
|
+
.gsub('{collectionId}', collection_id)
|
575
|
+
|
576
|
+
@client.call(
|
577
|
+
method: 'POST',
|
578
|
+
path: path,
|
579
|
+
headers: headers,
|
580
|
+
params: params,
|
581
|
+
response_type: Models::AttributeEmail
|
582
|
+
)
|
583
|
+
end
|
584
|
+
|
585
|
+
|
586
|
+
#
|
587
|
+
#
|
588
|
+
# @param [String] database_id Database ID.
|
589
|
+
# @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).
|
590
|
+
# @param [String] key Attribute Key.
|
591
|
+
# @param [Array] elements Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 4096 characters long.
|
592
|
+
# @param [] required Is attribute required?
|
593
|
+
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
594
|
+
# @param [] array Is attribute an array?
|
595
|
+
#
|
596
|
+
# @return [AttributeEnum]
|
597
|
+
def create_enum_attribute(database_id:, collection_id:, key:, elements:, required:, default: nil, array: nil)
|
598
|
+
|
599
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'
|
600
|
+
|
601
|
+
params = {
|
602
|
+
key: key,
|
603
|
+
elements: elements,
|
604
|
+
required: required,
|
605
|
+
default: default,
|
606
|
+
array: array,
|
607
|
+
}
|
608
|
+
|
609
|
+
headers = {
|
610
|
+
"content-type": 'application/json',
|
611
|
+
}
|
612
|
+
if database_id.nil?
|
613
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
614
|
+
end
|
615
|
+
|
616
|
+
if collection_id.nil?
|
617
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
618
|
+
end
|
619
|
+
|
620
|
+
if key.nil?
|
621
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
622
|
+
end
|
623
|
+
|
624
|
+
if elements.nil?
|
625
|
+
raise Appwrite::Exception.new('Missing required parameter: "elements"')
|
626
|
+
end
|
627
|
+
|
628
|
+
if required.nil?
|
629
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
630
|
+
end
|
631
|
+
|
632
|
+
.gsub('{databaseId}', database_id)
|
633
|
+
.gsub('{collectionId}', collection_id)
|
634
|
+
|
635
|
+
@client.call(
|
636
|
+
method: 'POST',
|
637
|
+
path: path,
|
638
|
+
headers: headers,
|
639
|
+
params: params,
|
640
|
+
response_type: Models::AttributeEnum
|
641
|
+
)
|
642
|
+
end
|
643
|
+
|
644
|
+
|
645
|
+
# Create a float attribute. Optionally, minimum and maximum values can be
|
646
|
+
# provided.
|
647
|
+
#
|
648
|
+
#
|
649
|
+
# @param [String] database_id Database ID.
|
650
|
+
# @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).
|
651
|
+
# @param [String] key Attribute Key.
|
652
|
+
# @param [] required Is attribute required?
|
653
|
+
# @param [Float] min Minimum value to enforce on new documents
|
654
|
+
# @param [Float] max Maximum value to enforce on new documents
|
655
|
+
# @param [Float] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
656
|
+
# @param [] array Is attribute an array?
|
657
|
+
#
|
658
|
+
# @return [AttributeFloat]
|
659
|
+
def create_float_attribute(database_id:, collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
|
660
|
+
|
661
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'
|
662
|
+
|
663
|
+
params = {
|
664
|
+
key: key,
|
665
|
+
required: required,
|
666
|
+
min: min,
|
667
|
+
max: max,
|
668
|
+
default: default,
|
669
|
+
array: array,
|
670
|
+
}
|
671
|
+
|
672
|
+
headers = {
|
673
|
+
"content-type": 'application/json',
|
674
|
+
}
|
675
|
+
if database_id.nil?
|
676
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
677
|
+
end
|
678
|
+
|
679
|
+
if collection_id.nil?
|
680
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
681
|
+
end
|
682
|
+
|
683
|
+
if key.nil?
|
684
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
685
|
+
end
|
686
|
+
|
687
|
+
if required.nil?
|
688
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
689
|
+
end
|
690
|
+
|
691
|
+
.gsub('{databaseId}', database_id)
|
692
|
+
.gsub('{collectionId}', collection_id)
|
693
|
+
|
694
|
+
@client.call(
|
695
|
+
method: 'POST',
|
696
|
+
path: path,
|
697
|
+
headers: headers,
|
698
|
+
params: params,
|
699
|
+
response_type: Models::AttributeFloat
|
700
|
+
)
|
701
|
+
end
|
702
|
+
|
703
|
+
|
704
|
+
# Create an integer attribute. Optionally, minimum and maximum values can be
|
705
|
+
# provided.
|
706
|
+
#
|
707
|
+
#
|
708
|
+
# @param [String] database_id Database ID.
|
709
|
+
# @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).
|
710
|
+
# @param [String] key Attribute Key.
|
711
|
+
# @param [] required Is attribute required?
|
712
|
+
# @param [Integer] min Minimum value to enforce on new documents
|
713
|
+
# @param [Integer] max Maximum value to enforce on new documents
|
714
|
+
# @param [Integer] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
715
|
+
# @param [] array Is attribute an array?
|
716
|
+
#
|
717
|
+
# @return [AttributeInteger]
|
718
|
+
def create_integer_attribute(database_id:, collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
|
719
|
+
|
720
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'
|
721
|
+
|
722
|
+
params = {
|
723
|
+
key: key,
|
724
|
+
required: required,
|
725
|
+
min: min,
|
726
|
+
max: max,
|
727
|
+
default: default,
|
728
|
+
array: array,
|
729
|
+
}
|
730
|
+
|
731
|
+
headers = {
|
732
|
+
"content-type": 'application/json',
|
733
|
+
}
|
734
|
+
if database_id.nil?
|
735
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
736
|
+
end
|
737
|
+
|
738
|
+
if collection_id.nil?
|
739
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
740
|
+
end
|
741
|
+
|
742
|
+
if key.nil?
|
743
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
744
|
+
end
|
745
|
+
|
746
|
+
if required.nil?
|
747
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
748
|
+
end
|
749
|
+
|
750
|
+
.gsub('{databaseId}', database_id)
|
751
|
+
.gsub('{collectionId}', collection_id)
|
752
|
+
|
753
|
+
@client.call(
|
754
|
+
method: 'POST',
|
755
|
+
path: path,
|
756
|
+
headers: headers,
|
757
|
+
params: params,
|
758
|
+
response_type: Models::AttributeInteger
|
759
|
+
)
|
760
|
+
end
|
761
|
+
|
762
|
+
|
763
|
+
# Create IP address attribute.
|
764
|
+
#
|
765
|
+
#
|
766
|
+
# @param [String] database_id Database ID.
|
767
|
+
# @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).
|
768
|
+
# @param [String] key Attribute Key.
|
769
|
+
# @param [] required Is attribute required?
|
770
|
+
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
771
|
+
# @param [] array Is attribute an array?
|
772
|
+
#
|
773
|
+
# @return [AttributeIp]
|
774
|
+
def create_ip_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)
|
775
|
+
|
776
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'
|
777
|
+
|
778
|
+
params = {
|
779
|
+
key: key,
|
780
|
+
required: required,
|
781
|
+
default: default,
|
782
|
+
array: array,
|
783
|
+
}
|
784
|
+
|
785
|
+
headers = {
|
786
|
+
"content-type": 'application/json',
|
787
|
+
}
|
788
|
+
if database_id.nil?
|
789
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
790
|
+
end
|
791
|
+
|
792
|
+
if collection_id.nil?
|
793
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
794
|
+
end
|
795
|
+
|
796
|
+
if key.nil?
|
797
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
798
|
+
end
|
799
|
+
|
800
|
+
if required.nil?
|
801
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
802
|
+
end
|
803
|
+
|
804
|
+
.gsub('{databaseId}', database_id)
|
805
|
+
.gsub('{collectionId}', collection_id)
|
806
|
+
|
807
|
+
@client.call(
|
808
|
+
method: 'POST',
|
809
|
+
path: path,
|
810
|
+
headers: headers,
|
811
|
+
params: params,
|
812
|
+
response_type: Models::AttributeIp
|
813
|
+
)
|
814
|
+
end
|
815
|
+
|
816
|
+
|
817
|
+
# Create a string attribute.
|
818
|
+
#
|
819
|
+
#
|
820
|
+
# @param [String] database_id Database ID.
|
821
|
+
# @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).
|
822
|
+
# @param [String] key Attribute Key.
|
823
|
+
# @param [Integer] size Attribute size for text attributes, in number of characters.
|
824
|
+
# @param [] required Is attribute required?
|
825
|
+
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
826
|
+
# @param [] array Is attribute an array?
|
827
|
+
#
|
828
|
+
# @return [AttributeString]
|
829
|
+
def create_string_attribute(database_id:, collection_id:, key:, size:, required:, default: nil, array: nil)
|
830
|
+
|
831
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'
|
832
|
+
|
833
|
+
params = {
|
834
|
+
key: key,
|
835
|
+
size: size,
|
836
|
+
required: required,
|
837
|
+
default: default,
|
838
|
+
array: array,
|
839
|
+
}
|
840
|
+
|
841
|
+
headers = {
|
842
|
+
"content-type": 'application/json',
|
843
|
+
}
|
844
|
+
if database_id.nil?
|
845
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
846
|
+
end
|
847
|
+
|
848
|
+
if collection_id.nil?
|
849
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
850
|
+
end
|
851
|
+
|
852
|
+
if key.nil?
|
853
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
854
|
+
end
|
855
|
+
|
856
|
+
if size.nil?
|
857
|
+
raise Appwrite::Exception.new('Missing required parameter: "size"')
|
858
|
+
end
|
859
|
+
|
860
|
+
if required.nil?
|
861
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
862
|
+
end
|
863
|
+
|
864
|
+
.gsub('{databaseId}', database_id)
|
865
|
+
.gsub('{collectionId}', collection_id)
|
866
|
+
|
867
|
+
@client.call(
|
868
|
+
method: 'POST',
|
869
|
+
path: path,
|
870
|
+
headers: headers,
|
871
|
+
params: params,
|
872
|
+
response_type: Models::AttributeString
|
873
|
+
)
|
874
|
+
end
|
875
|
+
|
876
|
+
|
877
|
+
# Create a URL attribute.
|
878
|
+
#
|
879
|
+
#
|
880
|
+
# @param [String] database_id Database ID.
|
881
|
+
# @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).
|
882
|
+
# @param [String] key Attribute Key.
|
883
|
+
# @param [] required Is attribute required?
|
884
|
+
# @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required.
|
885
|
+
# @param [] array Is attribute an array?
|
886
|
+
#
|
887
|
+
# @return [AttributeUrl]
|
888
|
+
def create_url_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil)
|
889
|
+
|
890
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'
|
891
|
+
|
892
|
+
params = {
|
893
|
+
key: key,
|
894
|
+
required: required,
|
895
|
+
default: default,
|
896
|
+
array: array,
|
897
|
+
}
|
898
|
+
|
899
|
+
headers = {
|
900
|
+
"content-type": 'application/json',
|
901
|
+
}
|
902
|
+
if database_id.nil?
|
903
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
904
|
+
end
|
905
|
+
|
906
|
+
if collection_id.nil?
|
907
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
908
|
+
end
|
909
|
+
|
910
|
+
if key.nil?
|
911
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
912
|
+
end
|
913
|
+
|
914
|
+
if required.nil?
|
915
|
+
raise Appwrite::Exception.new('Missing required parameter: "required"')
|
916
|
+
end
|
917
|
+
|
918
|
+
.gsub('{databaseId}', database_id)
|
919
|
+
.gsub('{collectionId}', collection_id)
|
920
|
+
|
921
|
+
@client.call(
|
922
|
+
method: 'POST',
|
923
|
+
path: path,
|
924
|
+
headers: headers,
|
925
|
+
params: params,
|
926
|
+
response_type: Models::AttributeUrl
|
927
|
+
)
|
928
|
+
end
|
929
|
+
|
930
|
+
|
931
|
+
#
|
932
|
+
#
|
933
|
+
# @param [String] database_id Database ID.
|
934
|
+
# @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).
|
935
|
+
# @param [String] key Attribute Key.
|
936
|
+
#
|
937
|
+
# @return []
|
938
|
+
def get_attribute(database_id:, collection_id:, key:)
|
939
|
+
|
940
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
|
941
|
+
|
942
|
+
params = {
|
943
|
+
}
|
944
|
+
|
945
|
+
headers = {
|
946
|
+
"content-type": 'application/json',
|
947
|
+
}
|
948
|
+
if database_id.nil?
|
949
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
950
|
+
end
|
951
|
+
|
952
|
+
if collection_id.nil?
|
953
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
954
|
+
end
|
955
|
+
|
956
|
+
if key.nil?
|
957
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
958
|
+
end
|
959
|
+
|
960
|
+
.gsub('{databaseId}', database_id)
|
961
|
+
.gsub('{collectionId}', collection_id)
|
962
|
+
.gsub('{key}', key)
|
963
|
+
|
964
|
+
@client.call(
|
965
|
+
method: 'GET',
|
966
|
+
path: path,
|
967
|
+
headers: headers,
|
968
|
+
params: params,
|
969
|
+
)
|
970
|
+
end
|
971
|
+
|
972
|
+
|
973
|
+
#
|
974
|
+
#
|
975
|
+
# @param [String] database_id Database ID.
|
976
|
+
# @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).
|
977
|
+
# @param [String] key Attribute Key.
|
978
|
+
#
|
979
|
+
# @return []
|
980
|
+
def delete_attribute(database_id:, collection_id:, key:)
|
981
|
+
|
982
|
+
path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
|
983
|
+
|
984
|
+
params = {
|
985
|
+
}
|
986
|
+
|
987
|
+
headers = {
|
988
|
+
"content-type": 'application/json',
|
989
|
+
}
|
990
|
+
if database_id.nil?
|
991
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
992
|
+
end
|
993
|
+
|
994
|
+
if collection_id.nil?
|
995
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
996
|
+
end
|
997
|
+
|
998
|
+
if key.nil?
|
999
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
1000
|
+
end
|
1001
|
+
|
1002
|
+
.gsub('{databaseId}', database_id)
|
1003
|
+
.gsub('{collectionId}', collection_id)
|
1004
|
+
.gsub('{key}', key)
|
1005
|
+
|
1006
|
+
@client.call(
|
1007
|
+
method: 'DELETE',
|
1008
|
+
path: path,
|
1009
|
+
headers: headers,
|
1010
|
+
params: params,
|
1011
|
+
)
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
|
1015
|
+
# Get a list of all the user's documents in a given collection. You can use
|
1016
|
+
# the query params to filter your results. On admin mode, this endpoint will
|
1017
|
+
# return a list of all of documents belonging to the provided collectionId.
|
1018
|
+
# [Learn more about different API modes](/docs/admin).
|
1019
|
+
#
|
1020
|
+
# @param [String] database_id Database ID.
|
1021
|
+
# @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).
|
1022
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.
|
1023
|
+
#
|
1024
|
+
# @return [DocumentList]
|
1025
|
+
def list_documents(database_id:, collection_id:, queries: nil)
|
1026
|
+
|
1027
|
+
path = '/databases/{databaseId}/collections/{collectionId}/documents'
|
1028
|
+
|
1029
|
+
params = {
|
1030
|
+
queries: queries,
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
headers = {
|
1034
|
+
"content-type": 'application/json',
|
1035
|
+
}
|
1036
|
+
if database_id.nil?
|
1037
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
if collection_id.nil?
|
1041
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
.gsub('{databaseId}', database_id)
|
1045
|
+
.gsub('{collectionId}', collection_id)
|
1046
|
+
|
1047
|
+
@client.call(
|
1048
|
+
method: 'GET',
|
1049
|
+
path: path,
|
1050
|
+
headers: headers,
|
1051
|
+
params: params,
|
1052
|
+
response_type: Models::DocumentList
|
1053
|
+
)
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
|
1057
|
+
# Create a new Document. Before using this route, you should create a new
|
1058
|
+
# collection resource using either a [server
|
1059
|
+
# integration](/docs/server/databases#databasesCreateCollection) API or
|
1060
|
+
# directly from your database console.
|
1061
|
+
#
|
1062
|
+
# @param [String] database_id Database ID.
|
1063
|
+
# @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). Make sure to define attributes before creating documents.
|
1064
|
+
# @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.
|
1065
|
+
# @param [Hash] data Document data as JSON object.
|
1066
|
+
# @param [Array] permissions An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).
|
1067
|
+
#
|
1068
|
+
# @return [Document]
|
1069
|
+
def create_document(database_id:, collection_id:, document_id:, data:, permissions: nil)
|
1070
|
+
|
1071
|
+
path = '/databases/{databaseId}/collections/{collectionId}/documents'
|
1072
|
+
|
1073
|
+
params = {
|
1074
|
+
documentId: document_id,
|
1075
|
+
data: data,
|
1076
|
+
permissions: permissions,
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
headers = {
|
1080
|
+
"content-type": 'application/json',
|
1081
|
+
}
|
1082
|
+
if database_id.nil?
|
1083
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
if collection_id.nil?
|
1087
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
if document_id.nil?
|
1091
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
if data.nil?
|
1095
|
+
raise Appwrite::Exception.new('Missing required parameter: "data"')
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
.gsub('{databaseId}', database_id)
|
1099
|
+
.gsub('{collectionId}', collection_id)
|
1100
|
+
|
1101
|
+
@client.call(
|
1102
|
+
method: 'POST',
|
1103
|
+
path: path,
|
1104
|
+
headers: headers,
|
1105
|
+
params: params,
|
1106
|
+
response_type: Models::Document
|
1107
|
+
)
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
|
1111
|
+
# Get a document by its unique ID. This endpoint response returns a JSON
|
1112
|
+
# object with the document data.
|
1113
|
+
#
|
1114
|
+
# @param [String] database_id Database ID.
|
1115
|
+
# @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).
|
1116
|
+
# @param [String] document_id Document ID.
|
1117
|
+
#
|
1118
|
+
# @return [Document]
|
1119
|
+
def get_document(database_id:, collection_id:, document_id:)
|
1120
|
+
|
1121
|
+
path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
|
1122
|
+
|
1123
|
+
params = {
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
headers = {
|
1127
|
+
"content-type": 'application/json',
|
1128
|
+
}
|
1129
|
+
if database_id.nil?
|
1130
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
if collection_id.nil?
|
1134
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
if document_id.nil?
|
1138
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
.gsub('{databaseId}', database_id)
|
1142
|
+
.gsub('{collectionId}', collection_id)
|
1143
|
+
.gsub('{documentId}', document_id)
|
1144
|
+
|
1145
|
+
@client.call(
|
1146
|
+
method: 'GET',
|
1147
|
+
path: path,
|
1148
|
+
headers: headers,
|
1149
|
+
params: params,
|
1150
|
+
response_type: Models::Document
|
1151
|
+
)
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
|
1155
|
+
# Update a document by its unique ID. Using the patch method you can pass
|
1156
|
+
# only specific fields that will get updated.
|
1157
|
+
#
|
1158
|
+
# @param [String] database_id Database ID.
|
1159
|
+
# @param [String] collection_id Collection ID.
|
1160
|
+
# @param [String] document_id Document ID.
|
1161
|
+
# @param [Hash] data Document data as JSON object. Include only attribute and value pairs to be updated.
|
1162
|
+
# @param [Array] permissions An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
|
1163
|
+
#
|
1164
|
+
# @return [Document]
|
1165
|
+
def update_document(database_id:, collection_id:, document_id:, data: nil, permissions: nil)
|
1166
|
+
|
1167
|
+
path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
|
1168
|
+
|
1169
|
+
params = {
|
1170
|
+
data: data,
|
1171
|
+
permissions: permissions,
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
headers = {
|
1175
|
+
"content-type": 'application/json',
|
1176
|
+
}
|
1177
|
+
if database_id.nil?
|
1178
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
if collection_id.nil?
|
1182
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
if document_id.nil?
|
1186
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
.gsub('{databaseId}', database_id)
|
1190
|
+
.gsub('{collectionId}', collection_id)
|
1191
|
+
.gsub('{documentId}', document_id)
|
1192
|
+
|
1193
|
+
@client.call(
|
1194
|
+
method: 'PATCH',
|
1195
|
+
path: path,
|
1196
|
+
headers: headers,
|
1197
|
+
params: params,
|
1198
|
+
response_type: Models::Document
|
1199
|
+
)
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
|
1203
|
+
# Delete a document by its unique ID.
|
1204
|
+
#
|
1205
|
+
# @param [String] database_id Database ID.
|
1206
|
+
# @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).
|
1207
|
+
# @param [String] document_id Document ID.
|
1208
|
+
#
|
1209
|
+
# @return []
|
1210
|
+
def delete_document(database_id:, collection_id:, document_id:)
|
1211
|
+
|
1212
|
+
path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
|
1213
|
+
|
1214
|
+
params = {
|
1215
|
+
}
|
1216
|
+
|
1217
|
+
headers = {
|
1218
|
+
"content-type": 'application/json',
|
1219
|
+
}
|
1220
|
+
if database_id.nil?
|
1221
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
if collection_id.nil?
|
1225
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1226
|
+
end
|
1227
|
+
|
1228
|
+
if document_id.nil?
|
1229
|
+
raise Appwrite::Exception.new('Missing required parameter: "documentId"')
|
1230
|
+
end
|
1231
|
+
|
1232
|
+
.gsub('{databaseId}', database_id)
|
1233
|
+
.gsub('{collectionId}', collection_id)
|
1234
|
+
.gsub('{documentId}', document_id)
|
1235
|
+
|
1236
|
+
@client.call(
|
1237
|
+
method: 'DELETE',
|
1238
|
+
path: path,
|
1239
|
+
headers: headers,
|
1240
|
+
params: params,
|
1241
|
+
)
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
|
1245
|
+
#
|
1246
|
+
#
|
1247
|
+
# @param [String] database_id Database ID.
|
1248
|
+
# @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).
|
1249
|
+
#
|
1250
|
+
# @return [IndexList]
|
1251
|
+
def list_indexes(database_id:, collection_id:)
|
1252
|
+
|
1253
|
+
path = '/databases/{databaseId}/collections/{collectionId}/indexes'
|
1254
|
+
|
1255
|
+
params = {
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
headers = {
|
1259
|
+
"content-type": 'application/json',
|
1260
|
+
}
|
1261
|
+
if database_id.nil?
|
1262
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
if collection_id.nil?
|
1266
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
.gsub('{databaseId}', database_id)
|
1270
|
+
.gsub('{collectionId}', collection_id)
|
1271
|
+
|
1272
|
+
@client.call(
|
1273
|
+
method: 'GET',
|
1274
|
+
path: path,
|
1275
|
+
headers: headers,
|
1276
|
+
params: params,
|
1277
|
+
response_type: Models::IndexList
|
1278
|
+
)
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
|
1282
|
+
#
|
1283
|
+
#
|
1284
|
+
# @param [String] database_id Database ID.
|
1285
|
+
# @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).
|
1286
|
+
# @param [String] key Index Key.
|
1287
|
+
# @param [String] type Index type.
|
1288
|
+
# @param [Array] attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
|
1289
|
+
# @param [Array] orders Array of index orders. Maximum of 100 orders are allowed.
|
1290
|
+
#
|
1291
|
+
# @return [Index]
|
1292
|
+
def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: nil)
|
1293
|
+
|
1294
|
+
path = '/databases/{databaseId}/collections/{collectionId}/indexes'
|
1295
|
+
|
1296
|
+
params = {
|
1297
|
+
key: key,
|
1298
|
+
type: type,
|
1299
|
+
attributes: attributes,
|
1300
|
+
orders: orders,
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
headers = {
|
1304
|
+
"content-type": 'application/json',
|
1305
|
+
}
|
1306
|
+
if database_id.nil?
|
1307
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
if collection_id.nil?
|
1311
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1312
|
+
end
|
1313
|
+
|
1314
|
+
if key.nil?
|
1315
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
if type.nil?
|
1319
|
+
raise Appwrite::Exception.new('Missing required parameter: "type"')
|
1320
|
+
end
|
1321
|
+
|
1322
|
+
if attributes.nil?
|
1323
|
+
raise Appwrite::Exception.new('Missing required parameter: "attributes"')
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
.gsub('{databaseId}', database_id)
|
1327
|
+
.gsub('{collectionId}', collection_id)
|
1328
|
+
|
1329
|
+
@client.call(
|
1330
|
+
method: 'POST',
|
1331
|
+
path: path,
|
1332
|
+
headers: headers,
|
1333
|
+
params: params,
|
1334
|
+
response_type: Models::Index
|
1335
|
+
)
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
|
1339
|
+
#
|
1340
|
+
#
|
1341
|
+
# @param [String] database_id Database ID.
|
1342
|
+
# @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).
|
1343
|
+
# @param [String] key Index Key.
|
1344
|
+
#
|
1345
|
+
# @return [Index]
|
1346
|
+
def get_index(database_id:, collection_id:, key:)
|
1347
|
+
|
1348
|
+
path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
|
1349
|
+
|
1350
|
+
params = {
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
headers = {
|
1354
|
+
"content-type": 'application/json',
|
1355
|
+
}
|
1356
|
+
if database_id.nil?
|
1357
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1358
|
+
end
|
1359
|
+
|
1360
|
+
if collection_id.nil?
|
1361
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
if key.nil?
|
1365
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
.gsub('{databaseId}', database_id)
|
1369
|
+
.gsub('{collectionId}', collection_id)
|
1370
|
+
.gsub('{key}', key)
|
1371
|
+
|
1372
|
+
@client.call(
|
1373
|
+
method: 'GET',
|
1374
|
+
path: path,
|
1375
|
+
headers: headers,
|
1376
|
+
params: params,
|
1377
|
+
response_type: Models::Index
|
1378
|
+
)
|
1379
|
+
end
|
1380
|
+
|
1381
|
+
|
1382
|
+
#
|
1383
|
+
#
|
1384
|
+
# @param [String] database_id Database ID.
|
1385
|
+
# @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).
|
1386
|
+
# @param [String] key Index Key.
|
1387
|
+
#
|
1388
|
+
# @return []
|
1389
|
+
def delete_index(database_id:, collection_id:, key:)
|
1390
|
+
|
1391
|
+
path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
|
1392
|
+
|
1393
|
+
params = {
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
headers = {
|
1397
|
+
"content-type": 'application/json',
|
1398
|
+
}
|
1399
|
+
if database_id.nil?
|
1400
|
+
raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
|
1401
|
+
end
|
1402
|
+
|
1403
|
+
if collection_id.nil?
|
1404
|
+
raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
if key.nil?
|
1408
|
+
raise Appwrite::Exception.new('Missing required parameter: "key"')
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
.gsub('{databaseId}', database_id)
|
1412
|
+
.gsub('{collectionId}', collection_id)
|
1413
|
+
.gsub('{key}', key)
|
1414
|
+
|
1415
|
+
@client.call(
|
1416
|
+
method: 'DELETE',
|
1417
|
+
path: path,
|
1418
|
+
headers: headers,
|
1419
|
+
params: params,
|
1420
|
+
)
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
|
1424
|
+
end
|
1425
|
+
end
|