appwrite 4.1.0 → 7.0.0.pre.RC1

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