appwrite 4.0.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,194 @@
1
1
  #frozen_string_literal: true
2
2
 
3
3
  module Appwrite
4
- class Database < Service
4
+ class Databases < Service
5
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).
6
+ @database_id
7
+ def initialize(client, database_id:)
8
+ @client = client
9
+ @database_id = database_id
10
+ end
11
+
12
+ #
10
13
  #
11
14
  # @param [string] search Search term to filter your list results. Max length: 256 chars.
12
15
  # @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
16
  # @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
17
  # @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.
18
+ # @param [string] cursor_direction Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
19
+ # @param [string] order_type Order result by ASC or DESC order.
20
+ #
21
+ # @return [DatabaseList]
22
+ def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
23
+ path = '/databases'
24
+
25
+ params = {
26
+ search: search,
27
+ limit: limit,
28
+ offset: offset,
29
+ cursor: cursor,
30
+ cursorDirection: cursor_direction,
31
+ orderType: order_type,
32
+ }
33
+
34
+ headers = {
35
+ "content-type": 'application/json',
36
+ }
37
+
38
+ @client.call(
39
+ method: 'GET',
40
+ path: path,
41
+ headers: headers,
42
+ params: params,
43
+ response_type: Models::DatabaseList
44
+ )
45
+ end
46
+
47
+ #
48
+ #
49
+ # @param [string] database_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.
50
+ # @param [string] name Collection name. Max length: 128 chars.
51
+ #
52
+ # @return [Database]
53
+ def create(name:)
54
+ if @database_id.nil?
55
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
56
+ end
57
+
58
+ if name.nil?
59
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
60
+ end
61
+
62
+ path = '/databases'
63
+
64
+ params = {
65
+ databaseId: @database_id,
66
+ name: name,
67
+ }
68
+
69
+ headers = {
70
+ "content-type": 'application/json',
71
+ }
72
+
73
+ @client.call(
74
+ method: 'POST',
75
+ path: path,
76
+ headers: headers,
77
+ params: params,
78
+ response_type: Models::Database
79
+ )
80
+ end
81
+
82
+ #
83
+ #
84
+ # @param [string] database_id Database ID.
85
+ #
86
+ # @return [Collection]
87
+ def get()
88
+ if @database_id.nil?
89
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
90
+ end
91
+
92
+ path = '/databases/{databaseId}'
93
+ .gsub('{databaseId}', @database_id)
94
+
95
+ params = {
96
+ }
97
+
98
+ headers = {
99
+ "content-type": 'application/json',
100
+ }
101
+
102
+ @client.call(
103
+ method: 'GET',
104
+ path: path,
105
+ headers: headers,
106
+ params: params,
107
+ response_type: Models::Collection
108
+ )
109
+ end
110
+
111
+ #
112
+ #
113
+ # @param [string] database_id Database ID.
114
+ # @param [string] name Collection name. Max length: 128 chars.
115
+ #
116
+ # @return [Collection]
117
+ def update(name:)
118
+ if @database_id.nil?
119
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
120
+ end
121
+
122
+ if name.nil?
123
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
124
+ end
125
+
126
+ path = '/databases/{databaseId}'
127
+ .gsub('{databaseId}', @database_id)
128
+
129
+ params = {
130
+ name: name,
131
+ }
132
+
133
+ headers = {
134
+ "content-type": 'application/json',
135
+ }
136
+
137
+ @client.call(
138
+ method: 'PUT',
139
+ path: path,
140
+ headers: headers,
141
+ params: params,
142
+ response_type: Models::Collection
143
+ )
144
+ end
145
+
146
+ #
147
+ #
148
+ # @param [string] database_id Database ID.
149
+ #
150
+ # @return []
151
+ def delete()
152
+ if @database_id.nil?
153
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
154
+ end
155
+
156
+ path = '/databases/{databaseId}'
157
+ .gsub('{databaseId}', @database_id)
158
+
159
+ params = {
160
+ }
161
+
162
+ headers = {
163
+ "content-type": 'application/json',
164
+ }
165
+
166
+ @client.call(
167
+ method: 'DELETE',
168
+ path: path,
169
+ headers: headers,
170
+ params: params,
171
+ )
172
+ end
173
+
174
+ #
175
+ #
176
+ # @param [string] database_id Database ID.
177
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
178
+ # @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.
179
+ # @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)
180
+ # @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.
181
+ # @param [string] cursor_direction Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
16
182
  # @param [string] order_type Order result by ASC or DESC order.
17
183
  #
18
184
  # @return [CollectionList]
19
185
  def list_collections(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
20
- path = '/database/collections'
186
+ if @database_id.nil?
187
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
188
+ end
189
+
190
+ path = '/databases/{databaseId}/collections'
191
+ .gsub('{databaseId}', @database_id)
21
192
 
22
193
  params = {
23
194
  search: search,
@@ -41,16 +212,21 @@ module Appwrite
41
212
  )
42
213
  end
43
214
 
44
- # Create a new Collection.
215
+ #
45
216
  #
217
+ # @param [string] database_id Database ID.
46
218
  # @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
219
  # @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.
220
+ # @param [string] permission Specifies the permissions model used in this collection, which accepts either &#039;collection&#039; or &#039;document&#039;. For &#039;collection&#039; level permission, the permissions specified in read and write params are applied to all documents in the collection. For &#039;document&#039; level permissions, read and write permissions are specified in each document. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
49
221
  # @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
222
  # @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
223
  #
52
224
  # @return [Collection]
53
225
  def create_collection(collection_id:, name:, permission:, read:, write:)
226
+ if @database_id.nil?
227
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
228
+ end
229
+
54
230
  if collection_id.nil?
55
231
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
56
232
  end
@@ -71,7 +247,8 @@ module Appwrite
71
247
  raise Appwrite::Exception.new('Missing required parameter: "write"')
72
248
  end
73
249
 
74
- path = '/database/collections'
250
+ path = '/databases/{databaseId}/collections'
251
+ .gsub('{databaseId}', @database_id)
75
252
 
76
253
  params = {
77
254
  collectionId: collection_id,
@@ -94,18 +271,23 @@ module Appwrite
94
271
  )
95
272
  end
96
273
 
97
- # Get a collection by its unique ID. This endpoint response returns a JSON
98
- # object with the collection metadata.
274
+ #
99
275
  #
276
+ # @param [string] database_id Database ID.
100
277
  # @param [string] collection_id Collection ID.
101
278
  #
102
279
  # @return [Collection]
103
280
  def get_collection(collection_id:)
281
+ if @database_id.nil?
282
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
283
+ end
284
+
104
285
  if collection_id.nil?
105
286
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
106
287
  end
107
288
 
108
- path = '/database/collections/{collectionId}'
289
+ path = '/databases/{databaseId}/collections/{collectionId}'
290
+ .gsub('{databaseId}', @database_id)
109
291
  .gsub('{collectionId}', collection_id)
110
292
 
111
293
  params = {
@@ -124,8 +306,9 @@ module Appwrite
124
306
  )
125
307
  end
126
308
 
127
- # Update a collection by its unique ID.
309
+ #
128
310
  #
311
+ # @param [string] database_id Database ID.
129
312
  # @param [string] collection_id Collection ID.
130
313
  # @param [string] name Collection name. Max length: 128 chars.
131
314
  # @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.
@@ -135,6 +318,10 @@ module Appwrite
135
318
  #
136
319
  # @return [Collection]
137
320
  def update_collection(collection_id:, name:, permission:, read: nil, write: nil, enabled: nil)
321
+ if @database_id.nil?
322
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
323
+ end
324
+
138
325
  if collection_id.nil?
139
326
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
140
327
  end
@@ -147,7 +334,8 @@ module Appwrite
147
334
  raise Appwrite::Exception.new('Missing required parameter: "permission"')
148
335
  end
149
336
 
150
- path = '/database/collections/{collectionId}'
337
+ path = '/databases/{databaseId}/collections/{collectionId}'
338
+ .gsub('{databaseId}', @database_id)
151
339
  .gsub('{collectionId}', collection_id)
152
340
 
153
341
  params = {
@@ -171,18 +359,23 @@ module Appwrite
171
359
  )
172
360
  end
173
361
 
174
- # Delete a collection by its unique ID. Only users with write permissions
175
- # have access to delete this resource.
362
+ #
176
363
  #
364
+ # @param [string] database_id Database ID.
177
365
  # @param [string] collection_id Collection ID.
178
366
  #
179
367
  # @return []
180
368
  def delete_collection(collection_id:)
369
+ if @database_id.nil?
370
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
371
+ end
372
+
181
373
  if collection_id.nil?
182
374
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
183
375
  end
184
376
 
185
- path = '/database/collections/{collectionId}'
377
+ path = '/databases/{databaseId}/collections/{collectionId}'
378
+ .gsub('{databaseId}', @database_id)
186
379
  .gsub('{collectionId}', collection_id)
187
380
 
188
381
  params = {
@@ -202,15 +395,21 @@ module Appwrite
202
395
 
203
396
  #
204
397
  #
398
+ # @param [string] database_id Database ID.
205
399
  # @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
400
  #
207
401
  # @return [AttributeList]
208
402
  def list_attributes(collection_id:)
403
+ if @database_id.nil?
404
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
405
+ end
406
+
209
407
  if collection_id.nil?
210
408
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
211
409
  end
212
410
 
213
- path = '/database/collections/{collectionId}/attributes'
411
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes'
412
+ .gsub('{databaseId}', @database_id)
214
413
  .gsub('{collectionId}', collection_id)
215
414
 
216
415
  params = {
@@ -229,9 +428,9 @@ module Appwrite
229
428
  )
230
429
  end
231
430
 
232
- # Create a boolean attribute.
233
431
  #
234
432
  #
433
+ # @param [string] database_id Database ID.
235
434
  # @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
435
  # @param [string] key Attribute Key.
237
436
  # @param [boolean] required Is attribute required?
@@ -240,6 +439,10 @@ module Appwrite
240
439
  #
241
440
  # @return [AttributeBoolean]
242
441
  def create_boolean_attribute(collection_id:, key:, required:, default: nil, array: nil)
442
+ if @database_id.nil?
443
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
444
+ end
445
+
243
446
  if collection_id.nil?
244
447
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
245
448
  end
@@ -252,7 +455,8 @@ module Appwrite
252
455
  raise Appwrite::Exception.new('Missing required parameter: "required"')
253
456
  end
254
457
 
255
- path = '/database/collections/{collectionId}/attributes/boolean'
458
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'
459
+ .gsub('{databaseId}', @database_id)
256
460
  .gsub('{collectionId}', collection_id)
257
461
 
258
462
  params = {
@@ -275,9 +479,9 @@ module Appwrite
275
479
  )
276
480
  end
277
481
 
278
- # Create an email attribute.
279
482
  #
280
483
  #
484
+ # @param [string] database_id Database ID.
281
485
  # @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
486
  # @param [string] key Attribute Key.
283
487
  # @param [boolean] required Is attribute required?
@@ -286,6 +490,10 @@ module Appwrite
286
490
  #
287
491
  # @return [AttributeEmail]
288
492
  def create_email_attribute(collection_id:, key:, required:, default: nil, array: nil)
493
+ if @database_id.nil?
494
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
495
+ end
496
+
289
497
  if collection_id.nil?
290
498
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
291
499
  end
@@ -298,7 +506,8 @@ module Appwrite
298
506
  raise Appwrite::Exception.new('Missing required parameter: "required"')
299
507
  end
300
508
 
301
- path = '/database/collections/{collectionId}/attributes/email'
509
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'
510
+ .gsub('{databaseId}', @database_id)
302
511
  .gsub('{collectionId}', collection_id)
303
512
 
304
513
  params = {
@@ -323,15 +532,20 @@ module Appwrite
323
532
 
324
533
  #
325
534
  #
535
+ # @param [string] database_id Database ID.
326
536
  # @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
537
  # @param [string] key Attribute Key.
328
- # @param [array] elements Array of elements in enumerated type. Uses length of longest element to determine size.
538
+ # @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.
329
539
  # @param [boolean] required Is attribute required?
330
540
  # @param [string] default Default value for attribute when not provided. Cannot be set when attribute is required.
331
541
  # @param [boolean] array Is attribute an array?
332
542
  #
333
543
  # @return [AttributeEnum]
334
544
  def create_enum_attribute(collection_id:, key:, elements:, required:, default: nil, array: nil)
545
+ if @database_id.nil?
546
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
547
+ end
548
+
335
549
  if collection_id.nil?
336
550
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
337
551
  end
@@ -348,7 +562,8 @@ module Appwrite
348
562
  raise Appwrite::Exception.new('Missing required parameter: "required"')
349
563
  end
350
564
 
351
- path = '/database/collections/{collectionId}/attributes/enum'
565
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'
566
+ .gsub('{databaseId}', @database_id)
352
567
  .gsub('{collectionId}', collection_id)
353
568
 
354
569
  params = {
@@ -372,10 +587,9 @@ module Appwrite
372
587
  )
373
588
  end
374
589
 
375
- # Create a float attribute. Optionally, minimum and maximum values can be
376
- # provided.
377
590
  #
378
591
  #
592
+ # @param [string] database_id Database ID.
379
593
  # @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
594
  # @param [string] key Attribute Key.
381
595
  # @param [boolean] required Is attribute required?
@@ -386,6 +600,10 @@ module Appwrite
386
600
  #
387
601
  # @return [AttributeFloat]
388
602
  def create_float_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
603
+ if @database_id.nil?
604
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
605
+ end
606
+
389
607
  if collection_id.nil?
390
608
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
391
609
  end
@@ -398,7 +616,8 @@ module Appwrite
398
616
  raise Appwrite::Exception.new('Missing required parameter: "required"')
399
617
  end
400
618
 
401
- path = '/database/collections/{collectionId}/attributes/float'
619
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'
620
+ .gsub('{databaseId}', @database_id)
402
621
  .gsub('{collectionId}', collection_id)
403
622
 
404
623
  params = {
@@ -423,10 +642,9 @@ module Appwrite
423
642
  )
424
643
  end
425
644
 
426
- # Create an integer attribute. Optionally, minimum and maximum values can be
427
- # provided.
428
645
  #
429
646
  #
647
+ # @param [string] database_id Database ID.
430
648
  # @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
649
  # @param [string] key Attribute Key.
432
650
  # @param [boolean] required Is attribute required?
@@ -437,6 +655,10 @@ module Appwrite
437
655
  #
438
656
  # @return [AttributeInteger]
439
657
  def create_integer_attribute(collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
658
+ if @database_id.nil?
659
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
660
+ end
661
+
440
662
  if collection_id.nil?
441
663
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
442
664
  end
@@ -449,7 +671,8 @@ module Appwrite
449
671
  raise Appwrite::Exception.new('Missing required parameter: "required"')
450
672
  end
451
673
 
452
- path = '/database/collections/{collectionId}/attributes/integer'
674
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'
675
+ .gsub('{databaseId}', @database_id)
453
676
  .gsub('{collectionId}', collection_id)
454
677
 
455
678
  params = {
@@ -474,9 +697,9 @@ module Appwrite
474
697
  )
475
698
  end
476
699
 
477
- # Create IP address attribute.
478
700
  #
479
701
  #
702
+ # @param [string] database_id Database ID.
480
703
  # @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
704
  # @param [string] key Attribute Key.
482
705
  # @param [boolean] required Is attribute required?
@@ -485,6 +708,10 @@ module Appwrite
485
708
  #
486
709
  # @return [AttributeIp]
487
710
  def create_ip_attribute(collection_id:, key:, required:, default: nil, array: nil)
711
+ if @database_id.nil?
712
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
713
+ end
714
+
488
715
  if collection_id.nil?
489
716
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
490
717
  end
@@ -497,7 +724,8 @@ module Appwrite
497
724
  raise Appwrite::Exception.new('Missing required parameter: "required"')
498
725
  end
499
726
 
500
- path = '/database/collections/{collectionId}/attributes/ip'
727
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'
728
+ .gsub('{databaseId}', @database_id)
501
729
  .gsub('{collectionId}', collection_id)
502
730
 
503
731
  params = {
@@ -520,9 +748,9 @@ module Appwrite
520
748
  )
521
749
  end
522
750
 
523
- # Create a string attribute.
524
751
  #
525
752
  #
753
+ # @param [string] database_id Database ID.
526
754
  # @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
755
  # @param [string] key Attribute Key.
528
756
  # @param [number] size Attribute size for text attributes, in number of characters.
@@ -532,6 +760,10 @@ module Appwrite
532
760
  #
533
761
  # @return [AttributeString]
534
762
  def create_string_attribute(collection_id:, key:, size:, required:, default: nil, array: nil)
763
+ if @database_id.nil?
764
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
765
+ end
766
+
535
767
  if collection_id.nil?
536
768
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
537
769
  end
@@ -548,7 +780,8 @@ module Appwrite
548
780
  raise Appwrite::Exception.new('Missing required parameter: "required"')
549
781
  end
550
782
 
551
- path = '/database/collections/{collectionId}/attributes/string'
783
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'
784
+ .gsub('{databaseId}', @database_id)
552
785
  .gsub('{collectionId}', collection_id)
553
786
 
554
787
  params = {
@@ -572,9 +805,9 @@ module Appwrite
572
805
  )
573
806
  end
574
807
 
575
- # Create a URL attribute.
576
808
  #
577
809
  #
810
+ # @param [string] database_id Database ID.
578
811
  # @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
812
  # @param [string] key Attribute Key.
580
813
  # @param [boolean] required Is attribute required?
@@ -583,6 +816,10 @@ module Appwrite
583
816
  #
584
817
  # @return [AttributeUrl]
585
818
  def create_url_attribute(collection_id:, key:, required:, default: nil, array: nil)
819
+ if @database_id.nil?
820
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
821
+ end
822
+
586
823
  if collection_id.nil?
587
824
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
588
825
  end
@@ -595,7 +832,8 @@ module Appwrite
595
832
  raise Appwrite::Exception.new('Missing required parameter: "required"')
596
833
  end
597
834
 
598
- path = '/database/collections/{collectionId}/attributes/url'
835
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'
836
+ .gsub('{databaseId}', @database_id)
599
837
  .gsub('{collectionId}', collection_id)
600
838
 
601
839
  params = {
@@ -620,11 +858,16 @@ module Appwrite
620
858
 
621
859
  #
622
860
  #
861
+ # @param [string] database_id Database ID.
623
862
  # @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
863
  # @param [string] key Attribute Key.
625
864
  #
626
865
  # @return []
627
866
  def get_attribute(collection_id:, key:)
867
+ if @database_id.nil?
868
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
869
+ end
870
+
628
871
  if collection_id.nil?
629
872
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
630
873
  end
@@ -633,7 +876,8 @@ module Appwrite
633
876
  raise Appwrite::Exception.new('Missing required parameter: "key"')
634
877
  end
635
878
 
636
- path = '/database/collections/{collectionId}/attributes/{key}'
879
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
880
+ .gsub('{databaseId}', @database_id)
637
881
  .gsub('{collectionId}', collection_id)
638
882
  .gsub('{key}', key)
639
883
 
@@ -654,11 +898,16 @@ module Appwrite
654
898
 
655
899
  #
656
900
  #
901
+ # @param [string] database_id Database ID.
657
902
  # @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
903
  # @param [string] key Attribute Key.
659
904
  #
660
905
  # @return []
661
906
  def delete_attribute(collection_id:, key:)
907
+ if @database_id.nil?
908
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
909
+ end
910
+
662
911
  if collection_id.nil?
663
912
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
664
913
  end
@@ -667,7 +916,8 @@ module Appwrite
667
916
  raise Appwrite::Exception.new('Missing required parameter: "key"')
668
917
  end
669
918
 
670
- path = '/database/collections/{collectionId}/attributes/{key}'
919
+ path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'
920
+ .gsub('{databaseId}', @database_id)
671
921
  .gsub('{collectionId}', collection_id)
672
922
  .gsub('{key}', key)
673
923
 
@@ -686,27 +936,30 @@ module Appwrite
686
936
  )
687
937
  end
688
938
 
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).
939
+ #
693
940
  #
941
+ # @param [string] database_id Database ID.
694
942
  # @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.
943
+ # @param [array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.
696
944
  # @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
945
  # @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
946
  # @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.
947
+ # @param [string] cursor_direction Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
948
+ # @param [array] order_attributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long.
949
+ # @param [array] order_types Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed.
702
950
  #
703
951
  # @return [DocumentList]
704
952
  def list_documents(collection_id:, queries: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_attributes: nil, order_types: nil)
953
+ if @database_id.nil?
954
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
955
+ end
956
+
705
957
  if collection_id.nil?
706
958
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
707
959
  end
708
960
 
709
- path = '/database/collections/{collectionId}/documents'
961
+ path = '/databases/{databaseId}/collections/{collectionId}/documents'
962
+ .gsub('{databaseId}', @database_id)
710
963
  .gsub('{collectionId}', collection_id)
711
964
 
712
965
  params = {
@@ -732,11 +985,9 @@ module Appwrite
732
985
  )
733
986
  end
734
987
 
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.
988
+ #
739
989
  #
990
+ # @param [string] database_id Database ID.
740
991
  # @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
992
  # @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
993
  # @param [object] data Document data as JSON object.
@@ -745,6 +996,10 @@ module Appwrite
745
996
  #
746
997
  # @return [Document]
747
998
  def create_document(collection_id:, document_id:, data:, read: nil, write: nil)
999
+ if @database_id.nil?
1000
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1001
+ end
1002
+
748
1003
  if collection_id.nil?
749
1004
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
750
1005
  end
@@ -757,7 +1012,8 @@ module Appwrite
757
1012
  raise Appwrite::Exception.new('Missing required parameter: "data"')
758
1013
  end
759
1014
 
760
- path = '/database/collections/{collectionId}/documents'
1015
+ path = '/databases/{databaseId}/collections/{collectionId}/documents'
1016
+ .gsub('{databaseId}', @database_id)
761
1017
  .gsub('{collectionId}', collection_id)
762
1018
 
763
1019
  params = {
@@ -780,14 +1036,18 @@ module Appwrite
780
1036
  )
781
1037
  end
782
1038
 
783
- # Get a document by its unique ID. This endpoint response returns a JSON
784
- # object with the document data.
1039
+ #
785
1040
  #
1041
+ # @param [string] database_id Database ID.
786
1042
  # @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
1043
  # @param [string] document_id Document ID.
788
1044
  #
789
1045
  # @return [Document]
790
1046
  def get_document(collection_id:, document_id:)
1047
+ if @database_id.nil?
1048
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1049
+ end
1050
+
791
1051
  if collection_id.nil?
792
1052
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
793
1053
  end
@@ -796,7 +1056,8 @@ module Appwrite
796
1056
  raise Appwrite::Exception.new('Missing required parameter: "documentId"')
797
1057
  end
798
1058
 
799
- path = '/database/collections/{collectionId}/documents/{documentId}'
1059
+ path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
1060
+ .gsub('{databaseId}', @database_id)
800
1061
  .gsub('{collectionId}', collection_id)
801
1062
  .gsub('{documentId}', document_id)
802
1063
 
@@ -816,17 +1077,21 @@ module Appwrite
816
1077
  )
817
1078
  end
818
1079
 
819
- # Update a document by its unique ID. Using the patch method you can pass
820
- # only specific fields that will get updated.
1080
+ #
821
1081
  #
1082
+ # @param [string] database_id Database ID.
822
1083
  # @param [string] collection_id Collection ID.
823
1084
  # @param [string] document_id Document ID.
824
- # @param [object] data Document data as JSON object.
1085
+ # @param [object] data Document data as JSON object. Include only attribute and value pairs to be updated.
825
1086
  # @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
1087
  # @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
1088
  #
828
1089
  # @return [Document]
829
- def update_document(collection_id:, document_id:, data:, read: nil, write: nil)
1090
+ def update_document(collection_id:, document_id:, data: nil, read: nil, write: nil)
1091
+ if @database_id.nil?
1092
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1093
+ end
1094
+
830
1095
  if collection_id.nil?
831
1096
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
832
1097
  end
@@ -835,11 +1100,8 @@ module Appwrite
835
1100
  raise Appwrite::Exception.new('Missing required parameter: "documentId"')
836
1101
  end
837
1102
 
838
- if data.nil?
839
- raise Appwrite::Exception.new('Missing required parameter: "data"')
840
- end
841
-
842
- path = '/database/collections/{collectionId}/documents/{documentId}'
1103
+ path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
1104
+ .gsub('{databaseId}', @database_id)
843
1105
  .gsub('{collectionId}', collection_id)
844
1106
  .gsub('{documentId}', document_id)
845
1107
 
@@ -862,15 +1124,18 @@ module Appwrite
862
1124
  )
863
1125
  end
864
1126
 
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.
1127
+ #
868
1128
  #
1129
+ # @param [string] database_id Database ID.
869
1130
  # @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
1131
  # @param [string] document_id Document ID.
871
1132
  #
872
1133
  # @return []
873
1134
  def delete_document(collection_id:, document_id:)
1135
+ if @database_id.nil?
1136
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1137
+ end
1138
+
874
1139
  if collection_id.nil?
875
1140
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
876
1141
  end
@@ -879,7 +1144,8 @@ module Appwrite
879
1144
  raise Appwrite::Exception.new('Missing required parameter: "documentId"')
880
1145
  end
881
1146
 
882
- path = '/database/collections/{collectionId}/documents/{documentId}'
1147
+ path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'
1148
+ .gsub('{databaseId}', @database_id)
883
1149
  .gsub('{collectionId}', collection_id)
884
1150
  .gsub('{documentId}', document_id)
885
1151
 
@@ -900,15 +1166,21 @@ module Appwrite
900
1166
 
901
1167
  #
902
1168
  #
1169
+ # @param [string] database_id Database ID.
903
1170
  # @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
1171
  #
905
1172
  # @return [IndexList]
906
1173
  def list_indexes(collection_id:)
1174
+ if @database_id.nil?
1175
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1176
+ end
1177
+
907
1178
  if collection_id.nil?
908
1179
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
909
1180
  end
910
1181
 
911
- path = '/database/collections/{collectionId}/indexes'
1182
+ path = '/databases/{databaseId}/collections/{collectionId}/indexes'
1183
+ .gsub('{databaseId}', @database_id)
912
1184
  .gsub('{collectionId}', collection_id)
913
1185
 
914
1186
  params = {
@@ -929,14 +1201,19 @@ module Appwrite
929
1201
 
930
1202
  #
931
1203
  #
1204
+ # @param [string] database_id Database ID.
932
1205
  # @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
1206
  # @param [string] key Index Key.
934
1207
  # @param [string] type Index type.
935
- # @param [array] attributes Array of attributes to index.
936
- # @param [array] orders Array of index orders.
1208
+ # @param [array] attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
1209
+ # @param [array] orders Array of index orders. Maximum of 100 orders are allowed.
937
1210
  #
938
1211
  # @return [Index]
939
1212
  def create_index(collection_id:, key:, type:, attributes:, orders: nil)
1213
+ if @database_id.nil?
1214
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1215
+ end
1216
+
940
1217
  if collection_id.nil?
941
1218
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
942
1219
  end
@@ -953,7 +1230,8 @@ module Appwrite
953
1230
  raise Appwrite::Exception.new('Missing required parameter: "attributes"')
954
1231
  end
955
1232
 
956
- path = '/database/collections/{collectionId}/indexes'
1233
+ path = '/databases/{databaseId}/collections/{collectionId}/indexes'
1234
+ .gsub('{databaseId}', @database_id)
957
1235
  .gsub('{collectionId}', collection_id)
958
1236
 
959
1237
  params = {
@@ -978,11 +1256,16 @@ module Appwrite
978
1256
 
979
1257
  #
980
1258
  #
1259
+ # @param [string] database_id Database ID.
981
1260
  # @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
1261
  # @param [string] key Index Key.
983
1262
  #
984
1263
  # @return [Index]
985
1264
  def get_index(collection_id:, key:)
1265
+ if @database_id.nil?
1266
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1267
+ end
1268
+
986
1269
  if collection_id.nil?
987
1270
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
988
1271
  end
@@ -991,7 +1274,8 @@ module Appwrite
991
1274
  raise Appwrite::Exception.new('Missing required parameter: "key"')
992
1275
  end
993
1276
 
994
- path = '/database/collections/{collectionId}/indexes/{key}'
1277
+ path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
1278
+ .gsub('{databaseId}', @database_id)
995
1279
  .gsub('{collectionId}', collection_id)
996
1280
  .gsub('{key}', key)
997
1281
 
@@ -1013,11 +1297,16 @@ module Appwrite
1013
1297
 
1014
1298
  #
1015
1299
  #
1300
+ # @param [string] database_id Database ID.
1016
1301
  # @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
1302
  # @param [string] key Index Key.
1018
1303
  #
1019
1304
  # @return []
1020
1305
  def delete_index(collection_id:, key:)
1306
+ if @database_id.nil?
1307
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1308
+ end
1309
+
1021
1310
  if collection_id.nil?
1022
1311
  raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1023
1312
  end
@@ -1026,7 +1315,8 @@ module Appwrite
1026
1315
  raise Appwrite::Exception.new('Missing required parameter: "key"')
1027
1316
  end
1028
1317
 
1029
- path = '/database/collections/{collectionId}/indexes/{key}'
1318
+ path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'
1319
+ .gsub('{databaseId}', @database_id)
1030
1320
  .gsub('{collectionId}', collection_id)
1031
1321
  .gsub('{key}', key)
1032
1322