appwrite 16.1.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +2 -2
  3. data/lib/appwrite/models/column_boolean.rb +67 -0
  4. data/lib/appwrite/models/column_datetime.rb +72 -0
  5. data/lib/appwrite/models/column_email.rb +72 -0
  6. data/lib/appwrite/models/column_enum.rb +77 -0
  7. data/lib/appwrite/models/column_float.rb +77 -0
  8. data/lib/appwrite/models/column_index.rb +72 -0
  9. data/lib/appwrite/models/column_index_list.rb +32 -0
  10. data/lib/appwrite/models/column_integer.rb +77 -0
  11. data/lib/appwrite/models/column_ip.rb +72 -0
  12. data/lib/appwrite/models/column_list.rb +32 -0
  13. data/lib/appwrite/models/column_relationship.rb +92 -0
  14. data/lib/appwrite/models/column_string.rb +77 -0
  15. data/lib/appwrite/models/column_url.rb +72 -0
  16. data/lib/appwrite/models/database.rb +8 -3
  17. data/lib/appwrite/models/execution.rb +5 -0
  18. data/lib/appwrite/models/index.rb +18 -13
  19. data/lib/appwrite/models/row.rb +66 -0
  20. data/lib/appwrite/models/row_list.rb +36 -0
  21. data/lib/appwrite/models/table.rb +72 -0
  22. data/lib/appwrite/models/table_list.rb +32 -0
  23. data/lib/appwrite/query.rb +36 -0
  24. data/lib/appwrite/services/account.rb +15 -48
  25. data/lib/appwrite/services/avatars.rb +0 -7
  26. data/lib/appwrite/services/databases.rb +198 -120
  27. data/lib/appwrite/services/functions.rb +0 -26
  28. data/lib/appwrite/services/graphql.rb +0 -2
  29. data/lib/appwrite/services/health.rb +0 -22
  30. data/lib/appwrite/services/locale.rb +0 -8
  31. data/lib/appwrite/services/messaging.rb +0 -46
  32. data/lib/appwrite/services/sites.rb +0 -25
  33. data/lib/appwrite/services/storage.rb +0 -13
  34. data/lib/appwrite/services/tables_db.rb +2318 -0
  35. data/lib/appwrite/services/teams.rb +0 -13
  36. data/lib/appwrite/services/tokens.rb +0 -5
  37. data/lib/appwrite/services/users.rb +0 -42
  38. data/lib/appwrite.rb +18 -0
  39. metadata +20 -2
@@ -0,0 +1,2318 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class TablesDB < 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: 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
+ api_path = '/tablesdb'
19
+
20
+ api_params = {
21
+ queries: queries,
22
+ search: search,
23
+ }
24
+
25
+ api_headers = {
26
+ }
27
+
28
+ @client.call(
29
+ method: 'GET',
30
+ path: api_path,
31
+ headers: api_headers,
32
+ params: api_params,
33
+ response_type: Models::DatabaseList
34
+ )
35
+ end
36
+
37
+ # Create a new Database.
38
+ #
39
+ #
40
+ # @param [String] database_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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.
41
+ # @param [String] name Database name. Max length: 128 chars.
42
+ # @param [] enabled Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
43
+ #
44
+ # @return [Database]
45
+ def create(database_id:, name:, enabled: nil)
46
+ api_path = '/tablesdb'
47
+
48
+ if database_id.nil?
49
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
50
+ end
51
+
52
+ if name.nil?
53
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
54
+ end
55
+
56
+ api_params = {
57
+ databaseId: database_id,
58
+ name: name,
59
+ enabled: enabled,
60
+ }
61
+
62
+ api_headers = {
63
+ "content-type": 'application/json',
64
+ }
65
+
66
+ @client.call(
67
+ method: 'POST',
68
+ path: api_path,
69
+ headers: api_headers,
70
+ params: api_params,
71
+ response_type: Models::Database
72
+ )
73
+ end
74
+
75
+ # Get a database by its unique ID. This endpoint response returns a JSON
76
+ # object with the database metadata.
77
+ #
78
+ # @param [String] database_id Database ID.
79
+ #
80
+ # @return [Database]
81
+ def get(database_id:)
82
+ api_path = '/tablesdb/{databaseId}'
83
+ .gsub('{databaseId}', database_id)
84
+
85
+ if database_id.nil?
86
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
87
+ end
88
+
89
+ api_params = {
90
+ }
91
+
92
+ api_headers = {
93
+ }
94
+
95
+ @client.call(
96
+ method: 'GET',
97
+ path: api_path,
98
+ headers: api_headers,
99
+ params: api_params,
100
+ response_type: Models::Database
101
+ )
102
+ end
103
+
104
+ # Update a database by its unique ID.
105
+ #
106
+ # @param [String] database_id Database ID.
107
+ # @param [String] name Database name. Max length: 128 chars.
108
+ # @param [] enabled Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.
109
+ #
110
+ # @return [Database]
111
+ def update(database_id:, name:, enabled: nil)
112
+ api_path = '/tablesdb/{databaseId}'
113
+ .gsub('{databaseId}', database_id)
114
+
115
+ if database_id.nil?
116
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
117
+ end
118
+
119
+ if name.nil?
120
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
121
+ end
122
+
123
+ api_params = {
124
+ name: name,
125
+ enabled: enabled,
126
+ }
127
+
128
+ api_headers = {
129
+ "content-type": 'application/json',
130
+ }
131
+
132
+ @client.call(
133
+ method: 'PUT',
134
+ path: api_path,
135
+ headers: api_headers,
136
+ params: api_params,
137
+ response_type: Models::Database
138
+ )
139
+ end
140
+
141
+ # Delete a database by its unique ID. Only API keys with with databases.write
142
+ # scope can delete a database.
143
+ #
144
+ # @param [String] database_id Database ID.
145
+ #
146
+ # @return []
147
+ def delete(database_id:)
148
+ api_path = '/tablesdb/{databaseId}'
149
+ .gsub('{databaseId}', database_id)
150
+
151
+ if database_id.nil?
152
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
153
+ end
154
+
155
+ api_params = {
156
+ }
157
+
158
+ api_headers = {
159
+ "content-type": 'application/json',
160
+ }
161
+
162
+ @client.call(
163
+ method: 'DELETE',
164
+ path: api_path,
165
+ headers: api_headers,
166
+ params: api_params,
167
+ )
168
+ end
169
+
170
+ # Get a list of all tables that belong to the provided databaseId. You can
171
+ # use the search parameter to filter your results.
172
+ #
173
+ # @param [String] database_id Database ID.
174
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name, enabled, rowSecurity
175
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
176
+ #
177
+ # @return [TableList]
178
+ def list_tables(database_id:, queries: nil, search: nil)
179
+ api_path = '/tablesdb/{databaseId}/tables'
180
+ .gsub('{databaseId}', database_id)
181
+
182
+ if database_id.nil?
183
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
184
+ end
185
+
186
+ api_params = {
187
+ queries: queries,
188
+ search: search,
189
+ }
190
+
191
+ api_headers = {
192
+ }
193
+
194
+ @client.call(
195
+ method: 'GET',
196
+ path: api_path,
197
+ headers: api_headers,
198
+ params: api_params,
199
+ response_type: Models::TableList
200
+ )
201
+ end
202
+
203
+ # Create a new Table. Before using this route, you should create a new
204
+ # database resource using either a [server
205
+ # integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
206
+ # API or directly from your database console.
207
+ #
208
+ # @param [String] database_id Database ID.
209
+ # @param [String] table_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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.
210
+ # @param [String] name Table name. Max length: 128 chars.
211
+ # @param [Array] permissions An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
212
+ # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions).
213
+ # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.
214
+ #
215
+ # @return [Table]
216
+ def create_table(database_id:, table_id:, name:, permissions: nil, row_security: nil, enabled: nil)
217
+ api_path = '/tablesdb/{databaseId}/tables'
218
+ .gsub('{databaseId}', database_id)
219
+
220
+ if database_id.nil?
221
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
222
+ end
223
+
224
+ if table_id.nil?
225
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
226
+ end
227
+
228
+ if name.nil?
229
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
230
+ end
231
+
232
+ api_params = {
233
+ tableId: table_id,
234
+ name: name,
235
+ permissions: permissions,
236
+ rowSecurity: row_security,
237
+ enabled: enabled,
238
+ }
239
+
240
+ api_headers = {
241
+ "content-type": 'application/json',
242
+ }
243
+
244
+ @client.call(
245
+ method: 'POST',
246
+ path: api_path,
247
+ headers: api_headers,
248
+ params: api_params,
249
+ response_type: Models::Table
250
+ )
251
+ end
252
+
253
+ # Get a table by its unique ID. This endpoint response returns a JSON object
254
+ # with the table metadata.
255
+ #
256
+ # @param [String] database_id Database ID.
257
+ # @param [String] table_id Table ID.
258
+ #
259
+ # @return [Table]
260
+ def get_table(database_id:, table_id:)
261
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}'
262
+ .gsub('{databaseId}', database_id)
263
+ .gsub('{tableId}', table_id)
264
+
265
+ if database_id.nil?
266
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
267
+ end
268
+
269
+ if table_id.nil?
270
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
271
+ end
272
+
273
+ api_params = {
274
+ }
275
+
276
+ api_headers = {
277
+ }
278
+
279
+ @client.call(
280
+ method: 'GET',
281
+ path: api_path,
282
+ headers: api_headers,
283
+ params: api_params,
284
+ response_type: Models::Table
285
+ )
286
+ end
287
+
288
+ # Update a table by its unique ID.
289
+ #
290
+ # @param [String] database_id Database ID.
291
+ # @param [String] table_id Table ID.
292
+ # @param [String] name Table name. Max length: 128 chars.
293
+ # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
294
+ # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).
295
+ # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.
296
+ #
297
+ # @return [Table]
298
+ def update_table(database_id:, table_id:, name:, permissions: nil, row_security: nil, enabled: nil)
299
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}'
300
+ .gsub('{databaseId}', database_id)
301
+ .gsub('{tableId}', table_id)
302
+
303
+ if database_id.nil?
304
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
305
+ end
306
+
307
+ if table_id.nil?
308
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
309
+ end
310
+
311
+ if name.nil?
312
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
313
+ end
314
+
315
+ api_params = {
316
+ name: name,
317
+ permissions: permissions,
318
+ rowSecurity: row_security,
319
+ enabled: enabled,
320
+ }
321
+
322
+ api_headers = {
323
+ "content-type": 'application/json',
324
+ }
325
+
326
+ @client.call(
327
+ method: 'PUT',
328
+ path: api_path,
329
+ headers: api_headers,
330
+ params: api_params,
331
+ response_type: Models::Table
332
+ )
333
+ end
334
+
335
+ # Delete a table by its unique ID. Only users with write permissions have
336
+ # access to delete this resource.
337
+ #
338
+ # @param [String] database_id Database ID.
339
+ # @param [String] table_id Table ID.
340
+ #
341
+ # @return []
342
+ def delete_table(database_id:, table_id:)
343
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}'
344
+ .gsub('{databaseId}', database_id)
345
+ .gsub('{tableId}', table_id)
346
+
347
+ if database_id.nil?
348
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
349
+ end
350
+
351
+ if table_id.nil?
352
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
353
+ end
354
+
355
+ api_params = {
356
+ }
357
+
358
+ api_headers = {
359
+ "content-type": 'application/json',
360
+ }
361
+
362
+ @client.call(
363
+ method: 'DELETE',
364
+ path: api_path,
365
+ headers: api_headers,
366
+ params: api_params,
367
+ )
368
+ end
369
+
370
+ # List columns in the table.
371
+ #
372
+ # @param [String] database_id Database ID.
373
+ # @param [String] table_id Table ID.
374
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, size, required, array, status, error
375
+ #
376
+ # @return [ColumnList]
377
+ def list_columns(database_id:, table_id:, queries: nil)
378
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns'
379
+ .gsub('{databaseId}', database_id)
380
+ .gsub('{tableId}', table_id)
381
+
382
+ if database_id.nil?
383
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
384
+ end
385
+
386
+ if table_id.nil?
387
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
388
+ end
389
+
390
+ api_params = {
391
+ queries: queries,
392
+ }
393
+
394
+ api_headers = {
395
+ }
396
+
397
+ @client.call(
398
+ method: 'GET',
399
+ path: api_path,
400
+ headers: api_headers,
401
+ params: api_params,
402
+ response_type: Models::ColumnList
403
+ )
404
+ end
405
+
406
+ # Create a boolean column.
407
+ #
408
+ #
409
+ # @param [String] database_id Database ID.
410
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
411
+ # @param [String] key Column Key.
412
+ # @param [] required Is column required?
413
+ # @param [] default Default value for column when not provided. Cannot be set when column is required.
414
+ # @param [] array Is column an array?
415
+ #
416
+ # @return [ColumnBoolean]
417
+ def create_boolean_column(database_id:, table_id:, key:, required:, default: nil, array: nil)
418
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean'
419
+ .gsub('{databaseId}', database_id)
420
+ .gsub('{tableId}', table_id)
421
+
422
+ if database_id.nil?
423
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
424
+ end
425
+
426
+ if table_id.nil?
427
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
428
+ end
429
+
430
+ if key.nil?
431
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
432
+ end
433
+
434
+ if required.nil?
435
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
436
+ end
437
+
438
+ api_params = {
439
+ key: key,
440
+ required: required,
441
+ default: default,
442
+ array: array,
443
+ }
444
+
445
+ api_headers = {
446
+ "content-type": 'application/json',
447
+ }
448
+
449
+ @client.call(
450
+ method: 'POST',
451
+ path: api_path,
452
+ headers: api_headers,
453
+ params: api_params,
454
+ response_type: Models::ColumnBoolean
455
+ )
456
+ end
457
+
458
+ # Update a boolean column. Changing the `default` value will not update
459
+ # already existing rows.
460
+ #
461
+ # @param [String] database_id Database ID.
462
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
463
+ # @param [String] key Column Key.
464
+ # @param [] required Is column required?
465
+ # @param [] default Default value for column when not provided. Cannot be set when column is required.
466
+ # @param [String] new_key New Column Key.
467
+ #
468
+ # @return [ColumnBoolean]
469
+ def update_boolean_column(database_id:, table_id:, key:, required:, default:, new_key: nil)
470
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}'
471
+ .gsub('{databaseId}', database_id)
472
+ .gsub('{tableId}', table_id)
473
+ .gsub('{key}', key)
474
+
475
+ if database_id.nil?
476
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
477
+ end
478
+
479
+ if table_id.nil?
480
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
481
+ end
482
+
483
+ if key.nil?
484
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
485
+ end
486
+
487
+ if required.nil?
488
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
489
+ end
490
+
491
+ if default.nil?
492
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
493
+ end
494
+
495
+ api_params = {
496
+ required: required,
497
+ default: default,
498
+ newKey: new_key,
499
+ }
500
+
501
+ api_headers = {
502
+ "content-type": 'application/json',
503
+ }
504
+
505
+ @client.call(
506
+ method: 'PATCH',
507
+ path: api_path,
508
+ headers: api_headers,
509
+ params: api_params,
510
+ response_type: Models::ColumnBoolean
511
+ )
512
+ end
513
+
514
+ # Create a date time column according to the ISO 8601 standard.
515
+ #
516
+ # @param [String] database_id Database ID.
517
+ # @param [String] table_id Table ID.
518
+ # @param [String] key Column Key.
519
+ # @param [] required Is column required?
520
+ # @param [String] default Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required.
521
+ # @param [] array Is column an array?
522
+ #
523
+ # @return [ColumnDatetime]
524
+ def create_datetime_column(database_id:, table_id:, key:, required:, default: nil, array: nil)
525
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime'
526
+ .gsub('{databaseId}', database_id)
527
+ .gsub('{tableId}', table_id)
528
+
529
+ if database_id.nil?
530
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
531
+ end
532
+
533
+ if table_id.nil?
534
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
535
+ end
536
+
537
+ if key.nil?
538
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
539
+ end
540
+
541
+ if required.nil?
542
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
543
+ end
544
+
545
+ api_params = {
546
+ key: key,
547
+ required: required,
548
+ default: default,
549
+ array: array,
550
+ }
551
+
552
+ api_headers = {
553
+ "content-type": 'application/json',
554
+ }
555
+
556
+ @client.call(
557
+ method: 'POST',
558
+ path: api_path,
559
+ headers: api_headers,
560
+ params: api_params,
561
+ response_type: Models::ColumnDatetime
562
+ )
563
+ end
564
+
565
+ # Update a date time column. Changing the `default` value will not update
566
+ # already existing rows.
567
+ #
568
+ # @param [String] database_id Database ID.
569
+ # @param [String] table_id Table ID.
570
+ # @param [String] key Column Key.
571
+ # @param [] required Is column required?
572
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
573
+ # @param [String] new_key New Column Key.
574
+ #
575
+ # @return [ColumnDatetime]
576
+ def update_datetime_column(database_id:, table_id:, key:, required:, default:, new_key: nil)
577
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}'
578
+ .gsub('{databaseId}', database_id)
579
+ .gsub('{tableId}', table_id)
580
+ .gsub('{key}', key)
581
+
582
+ if database_id.nil?
583
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
584
+ end
585
+
586
+ if table_id.nil?
587
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
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
+ if default.nil?
599
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
600
+ end
601
+
602
+ api_params = {
603
+ required: required,
604
+ default: default,
605
+ newKey: new_key,
606
+ }
607
+
608
+ api_headers = {
609
+ "content-type": 'application/json',
610
+ }
611
+
612
+ @client.call(
613
+ method: 'PATCH',
614
+ path: api_path,
615
+ headers: api_headers,
616
+ params: api_params,
617
+ response_type: Models::ColumnDatetime
618
+ )
619
+ end
620
+
621
+ # Create an email column.
622
+ #
623
+ #
624
+ # @param [String] database_id Database ID.
625
+ # @param [String] table_id Table ID.
626
+ # @param [String] key Column Key.
627
+ # @param [] required Is column required?
628
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
629
+ # @param [] array Is column an array?
630
+ #
631
+ # @return [ColumnEmail]
632
+ def create_email_column(database_id:, table_id:, key:, required:, default: nil, array: nil)
633
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email'
634
+ .gsub('{databaseId}', database_id)
635
+ .gsub('{tableId}', table_id)
636
+
637
+ if database_id.nil?
638
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
639
+ end
640
+
641
+ if table_id.nil?
642
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
643
+ end
644
+
645
+ if key.nil?
646
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
647
+ end
648
+
649
+ if required.nil?
650
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
651
+ end
652
+
653
+ api_params = {
654
+ key: key,
655
+ required: required,
656
+ default: default,
657
+ array: array,
658
+ }
659
+
660
+ api_headers = {
661
+ "content-type": 'application/json',
662
+ }
663
+
664
+ @client.call(
665
+ method: 'POST',
666
+ path: api_path,
667
+ headers: api_headers,
668
+ params: api_params,
669
+ response_type: Models::ColumnEmail
670
+ )
671
+ end
672
+
673
+ # Update an email column. Changing the `default` value will not update
674
+ # already existing rows.
675
+ #
676
+ #
677
+ # @param [String] database_id Database ID.
678
+ # @param [String] table_id Table ID.
679
+ # @param [String] key Column Key.
680
+ # @param [] required Is column required?
681
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
682
+ # @param [String] new_key New Column Key.
683
+ #
684
+ # @return [ColumnEmail]
685
+ def update_email_column(database_id:, table_id:, key:, required:, default:, new_key: nil)
686
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}'
687
+ .gsub('{databaseId}', database_id)
688
+ .gsub('{tableId}', table_id)
689
+ .gsub('{key}', key)
690
+
691
+ if database_id.nil?
692
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
693
+ end
694
+
695
+ if table_id.nil?
696
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
697
+ end
698
+
699
+ if key.nil?
700
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
701
+ end
702
+
703
+ if required.nil?
704
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
705
+ end
706
+
707
+ if default.nil?
708
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
709
+ end
710
+
711
+ api_params = {
712
+ required: required,
713
+ default: default,
714
+ newKey: new_key,
715
+ }
716
+
717
+ api_headers = {
718
+ "content-type": 'application/json',
719
+ }
720
+
721
+ @client.call(
722
+ method: 'PATCH',
723
+ path: api_path,
724
+ headers: api_headers,
725
+ params: api_params,
726
+ response_type: Models::ColumnEmail
727
+ )
728
+ end
729
+
730
+ # Create an enumeration column. The `elements` param acts as a white-list of
731
+ # accepted values for this column.
732
+ #
733
+ # @param [String] database_id Database ID.
734
+ # @param [String] table_id Table ID.
735
+ # @param [String] key Column Key.
736
+ # @param [Array] elements Array of enum values.
737
+ # @param [] required Is column required?
738
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
739
+ # @param [] array Is column an array?
740
+ #
741
+ # @return [ColumnEnum]
742
+ def create_enum_column(database_id:, table_id:, key:, elements:, required:, default: nil, array: nil)
743
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum'
744
+ .gsub('{databaseId}', database_id)
745
+ .gsub('{tableId}', table_id)
746
+
747
+ if database_id.nil?
748
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
749
+ end
750
+
751
+ if table_id.nil?
752
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
753
+ end
754
+
755
+ if key.nil?
756
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
757
+ end
758
+
759
+ if elements.nil?
760
+ raise Appwrite::Exception.new('Missing required parameter: "elements"')
761
+ end
762
+
763
+ if required.nil?
764
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
765
+ end
766
+
767
+ api_params = {
768
+ key: key,
769
+ elements: elements,
770
+ required: required,
771
+ default: default,
772
+ array: array,
773
+ }
774
+
775
+ api_headers = {
776
+ "content-type": 'application/json',
777
+ }
778
+
779
+ @client.call(
780
+ method: 'POST',
781
+ path: api_path,
782
+ headers: api_headers,
783
+ params: api_params,
784
+ response_type: Models::ColumnEnum
785
+ )
786
+ end
787
+
788
+ # Update an enum column. Changing the `default` value will not update already
789
+ # existing rows.
790
+ #
791
+ #
792
+ # @param [String] database_id Database ID.
793
+ # @param [String] table_id Table ID.
794
+ # @param [String] key Column Key.
795
+ # @param [Array] elements Updated list of enum values.
796
+ # @param [] required Is column required?
797
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
798
+ # @param [String] new_key New Column Key.
799
+ #
800
+ # @return [ColumnEnum]
801
+ def update_enum_column(database_id:, table_id:, key:, elements:, required:, default:, new_key: nil)
802
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}'
803
+ .gsub('{databaseId}', database_id)
804
+ .gsub('{tableId}', table_id)
805
+ .gsub('{key}', key)
806
+
807
+ if database_id.nil?
808
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
809
+ end
810
+
811
+ if table_id.nil?
812
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
813
+ end
814
+
815
+ if key.nil?
816
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
817
+ end
818
+
819
+ if elements.nil?
820
+ raise Appwrite::Exception.new('Missing required parameter: "elements"')
821
+ end
822
+
823
+ if required.nil?
824
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
825
+ end
826
+
827
+ if default.nil?
828
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
829
+ end
830
+
831
+ api_params = {
832
+ elements: elements,
833
+ required: required,
834
+ default: default,
835
+ newKey: new_key,
836
+ }
837
+
838
+ api_headers = {
839
+ "content-type": 'application/json',
840
+ }
841
+
842
+ @client.call(
843
+ method: 'PATCH',
844
+ path: api_path,
845
+ headers: api_headers,
846
+ params: api_params,
847
+ response_type: Models::ColumnEnum
848
+ )
849
+ end
850
+
851
+ # Create a float column. Optionally, minimum and maximum values can be
852
+ # provided.
853
+ #
854
+ #
855
+ # @param [String] database_id Database ID.
856
+ # @param [String] table_id Table ID.
857
+ # @param [String] key Column Key.
858
+ # @param [] required Is column required?
859
+ # @param [Float] min Minimum value
860
+ # @param [Float] max Maximum value
861
+ # @param [Float] default Default value. Cannot be set when required.
862
+ # @param [] array Is column an array?
863
+ #
864
+ # @return [ColumnFloat]
865
+ def create_float_column(database_id:, table_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
866
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float'
867
+ .gsub('{databaseId}', database_id)
868
+ .gsub('{tableId}', table_id)
869
+
870
+ if database_id.nil?
871
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
872
+ end
873
+
874
+ if table_id.nil?
875
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
876
+ end
877
+
878
+ if key.nil?
879
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
880
+ end
881
+
882
+ if required.nil?
883
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
884
+ end
885
+
886
+ api_params = {
887
+ key: key,
888
+ required: required,
889
+ min: min,
890
+ max: max,
891
+ default: default,
892
+ array: array,
893
+ }
894
+
895
+ api_headers = {
896
+ "content-type": 'application/json',
897
+ }
898
+
899
+ @client.call(
900
+ method: 'POST',
901
+ path: api_path,
902
+ headers: api_headers,
903
+ params: api_params,
904
+ response_type: Models::ColumnFloat
905
+ )
906
+ end
907
+
908
+ # Update a float column. Changing the `default` value will not update already
909
+ # existing rows.
910
+ #
911
+ #
912
+ # @param [String] database_id Database ID.
913
+ # @param [String] table_id Table ID.
914
+ # @param [String] key Column Key.
915
+ # @param [] required Is column required?
916
+ # @param [Float] default Default value. Cannot be set when required.
917
+ # @param [Float] min Minimum value
918
+ # @param [Float] max Maximum value
919
+ # @param [String] new_key New Column Key.
920
+ #
921
+ # @return [ColumnFloat]
922
+ def update_float_column(database_id:, table_id:, key:, required:, default:, min: nil, max: nil, new_key: nil)
923
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}'
924
+ .gsub('{databaseId}', database_id)
925
+ .gsub('{tableId}', table_id)
926
+ .gsub('{key}', key)
927
+
928
+ if database_id.nil?
929
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
930
+ end
931
+
932
+ if table_id.nil?
933
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
934
+ end
935
+
936
+ if key.nil?
937
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
938
+ end
939
+
940
+ if required.nil?
941
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
942
+ end
943
+
944
+ if default.nil?
945
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
946
+ end
947
+
948
+ api_params = {
949
+ required: required,
950
+ min: min,
951
+ max: max,
952
+ default: default,
953
+ newKey: new_key,
954
+ }
955
+
956
+ api_headers = {
957
+ "content-type": 'application/json',
958
+ }
959
+
960
+ @client.call(
961
+ method: 'PATCH',
962
+ path: api_path,
963
+ headers: api_headers,
964
+ params: api_params,
965
+ response_type: Models::ColumnFloat
966
+ )
967
+ end
968
+
969
+ # Create an integer column. Optionally, minimum and maximum values can be
970
+ # provided.
971
+ #
972
+ #
973
+ # @param [String] database_id Database ID.
974
+ # @param [String] table_id Table ID.
975
+ # @param [String] key Column Key.
976
+ # @param [] required Is column required?
977
+ # @param [Integer] min Minimum value
978
+ # @param [Integer] max Maximum value
979
+ # @param [Integer] default Default value. Cannot be set when column is required.
980
+ # @param [] array Is column an array?
981
+ #
982
+ # @return [ColumnInteger]
983
+ def create_integer_column(database_id:, table_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
984
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer'
985
+ .gsub('{databaseId}', database_id)
986
+ .gsub('{tableId}', table_id)
987
+
988
+ if database_id.nil?
989
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
990
+ end
991
+
992
+ if table_id.nil?
993
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
994
+ end
995
+
996
+ if key.nil?
997
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
998
+ end
999
+
1000
+ if required.nil?
1001
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1002
+ end
1003
+
1004
+ api_params = {
1005
+ key: key,
1006
+ required: required,
1007
+ min: min,
1008
+ max: max,
1009
+ default: default,
1010
+ array: array,
1011
+ }
1012
+
1013
+ api_headers = {
1014
+ "content-type": 'application/json',
1015
+ }
1016
+
1017
+ @client.call(
1018
+ method: 'POST',
1019
+ path: api_path,
1020
+ headers: api_headers,
1021
+ params: api_params,
1022
+ response_type: Models::ColumnInteger
1023
+ )
1024
+ end
1025
+
1026
+ # Update an integer column. Changing the `default` value will not update
1027
+ # already existing rows.
1028
+ #
1029
+ #
1030
+ # @param [String] database_id Database ID.
1031
+ # @param [String] table_id Table ID.
1032
+ # @param [String] key Column Key.
1033
+ # @param [] required Is column required?
1034
+ # @param [Integer] default Default value. Cannot be set when column is required.
1035
+ # @param [Integer] min Minimum value
1036
+ # @param [Integer] max Maximum value
1037
+ # @param [String] new_key New Column Key.
1038
+ #
1039
+ # @return [ColumnInteger]
1040
+ def update_integer_column(database_id:, table_id:, key:, required:, default:, min: nil, max: nil, new_key: nil)
1041
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}'
1042
+ .gsub('{databaseId}', database_id)
1043
+ .gsub('{tableId}', table_id)
1044
+ .gsub('{key}', key)
1045
+
1046
+ if database_id.nil?
1047
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1048
+ end
1049
+
1050
+ if table_id.nil?
1051
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1052
+ end
1053
+
1054
+ if key.nil?
1055
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1056
+ end
1057
+
1058
+ if required.nil?
1059
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1060
+ end
1061
+
1062
+ if default.nil?
1063
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
1064
+ end
1065
+
1066
+ api_params = {
1067
+ required: required,
1068
+ min: min,
1069
+ max: max,
1070
+ default: default,
1071
+ newKey: new_key,
1072
+ }
1073
+
1074
+ api_headers = {
1075
+ "content-type": 'application/json',
1076
+ }
1077
+
1078
+ @client.call(
1079
+ method: 'PATCH',
1080
+ path: api_path,
1081
+ headers: api_headers,
1082
+ params: api_params,
1083
+ response_type: Models::ColumnInteger
1084
+ )
1085
+ end
1086
+
1087
+ # Create IP address column.
1088
+ #
1089
+ #
1090
+ # @param [String] database_id Database ID.
1091
+ # @param [String] table_id Table ID.
1092
+ # @param [String] key Column Key.
1093
+ # @param [] required Is column required?
1094
+ # @param [String] default Default value. Cannot be set when column is required.
1095
+ # @param [] array Is column an array?
1096
+ #
1097
+ # @return [ColumnIp]
1098
+ def create_ip_column(database_id:, table_id:, key:, required:, default: nil, array: nil)
1099
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip'
1100
+ .gsub('{databaseId}', database_id)
1101
+ .gsub('{tableId}', table_id)
1102
+
1103
+ if database_id.nil?
1104
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1105
+ end
1106
+
1107
+ if table_id.nil?
1108
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1109
+ end
1110
+
1111
+ if key.nil?
1112
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1113
+ end
1114
+
1115
+ if required.nil?
1116
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1117
+ end
1118
+
1119
+ api_params = {
1120
+ key: key,
1121
+ required: required,
1122
+ default: default,
1123
+ array: array,
1124
+ }
1125
+
1126
+ api_headers = {
1127
+ "content-type": 'application/json',
1128
+ }
1129
+
1130
+ @client.call(
1131
+ method: 'POST',
1132
+ path: api_path,
1133
+ headers: api_headers,
1134
+ params: api_params,
1135
+ response_type: Models::ColumnIp
1136
+ )
1137
+ end
1138
+
1139
+ # Update an ip column. Changing the `default` value will not update already
1140
+ # existing rows.
1141
+ #
1142
+ #
1143
+ # @param [String] database_id Database ID.
1144
+ # @param [String] table_id Table ID.
1145
+ # @param [String] key Column Key.
1146
+ # @param [] required Is column required?
1147
+ # @param [String] default Default value. Cannot be set when column is required.
1148
+ # @param [String] new_key New Column Key.
1149
+ #
1150
+ # @return [ColumnIp]
1151
+ def update_ip_column(database_id:, table_id:, key:, required:, default:, new_key: nil)
1152
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}'
1153
+ .gsub('{databaseId}', database_id)
1154
+ .gsub('{tableId}', table_id)
1155
+ .gsub('{key}', key)
1156
+
1157
+ if database_id.nil?
1158
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1159
+ end
1160
+
1161
+ if table_id.nil?
1162
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1163
+ end
1164
+
1165
+ if key.nil?
1166
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1167
+ end
1168
+
1169
+ if required.nil?
1170
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1171
+ end
1172
+
1173
+ if default.nil?
1174
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
1175
+ end
1176
+
1177
+ api_params = {
1178
+ required: required,
1179
+ default: default,
1180
+ newKey: new_key,
1181
+ }
1182
+
1183
+ api_headers = {
1184
+ "content-type": 'application/json',
1185
+ }
1186
+
1187
+ @client.call(
1188
+ method: 'PATCH',
1189
+ path: api_path,
1190
+ headers: api_headers,
1191
+ params: api_params,
1192
+ response_type: Models::ColumnIp
1193
+ )
1194
+ end
1195
+
1196
+ # Create relationship column. [Learn more about relationship
1197
+ # columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
1198
+ #
1199
+ #
1200
+ # @param [String] database_id Database ID.
1201
+ # @param [String] table_id Table ID.
1202
+ # @param [String] related_table_id Related Table ID.
1203
+ # @param [RelationshipType] type Relation type
1204
+ # @param [] two_way Is Two Way?
1205
+ # @param [String] key Column Key.
1206
+ # @param [String] two_way_key Two Way Column Key.
1207
+ # @param [RelationMutate] on_delete Constraints option
1208
+ #
1209
+ # @return [ColumnRelationship]
1210
+ def create_relationship_column(database_id:, table_id:, related_table_id:, type:, two_way: nil, key: nil, two_way_key: nil, on_delete: nil)
1211
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship'
1212
+ .gsub('{databaseId}', database_id)
1213
+ .gsub('{tableId}', table_id)
1214
+
1215
+ if database_id.nil?
1216
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1217
+ end
1218
+
1219
+ if table_id.nil?
1220
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1221
+ end
1222
+
1223
+ if related_table_id.nil?
1224
+ raise Appwrite::Exception.new('Missing required parameter: "relatedTableId"')
1225
+ end
1226
+
1227
+ if type.nil?
1228
+ raise Appwrite::Exception.new('Missing required parameter: "type"')
1229
+ end
1230
+
1231
+ api_params = {
1232
+ relatedTableId: related_table_id,
1233
+ type: type,
1234
+ twoWay: two_way,
1235
+ key: key,
1236
+ twoWayKey: two_way_key,
1237
+ onDelete: on_delete,
1238
+ }
1239
+
1240
+ api_headers = {
1241
+ "content-type": 'application/json',
1242
+ }
1243
+
1244
+ @client.call(
1245
+ method: 'POST',
1246
+ path: api_path,
1247
+ headers: api_headers,
1248
+ params: api_params,
1249
+ response_type: Models::ColumnRelationship
1250
+ )
1251
+ end
1252
+
1253
+ # Create a string column.
1254
+ #
1255
+ #
1256
+ # @param [String] database_id Database ID.
1257
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1258
+ # @param [String] key Column Key.
1259
+ # @param [Integer] size Column size for text columns, in number of characters.
1260
+ # @param [] required Is column required?
1261
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
1262
+ # @param [] array Is column an array?
1263
+ # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried.
1264
+ #
1265
+ # @return [ColumnString]
1266
+ def create_string_column(database_id:, table_id:, key:, size:, required:, default: nil, array: nil, encrypt: nil)
1267
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string'
1268
+ .gsub('{databaseId}', database_id)
1269
+ .gsub('{tableId}', table_id)
1270
+
1271
+ if database_id.nil?
1272
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1273
+ end
1274
+
1275
+ if table_id.nil?
1276
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1277
+ end
1278
+
1279
+ if key.nil?
1280
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1281
+ end
1282
+
1283
+ if size.nil?
1284
+ raise Appwrite::Exception.new('Missing required parameter: "size"')
1285
+ end
1286
+
1287
+ if required.nil?
1288
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1289
+ end
1290
+
1291
+ api_params = {
1292
+ key: key,
1293
+ size: size,
1294
+ required: required,
1295
+ default: default,
1296
+ array: array,
1297
+ encrypt: encrypt,
1298
+ }
1299
+
1300
+ api_headers = {
1301
+ "content-type": 'application/json',
1302
+ }
1303
+
1304
+ @client.call(
1305
+ method: 'POST',
1306
+ path: api_path,
1307
+ headers: api_headers,
1308
+ params: api_params,
1309
+ response_type: Models::ColumnString
1310
+ )
1311
+ end
1312
+
1313
+ # Update a string column. Changing the `default` value will not update
1314
+ # already existing rows.
1315
+ #
1316
+ #
1317
+ # @param [String] database_id Database ID.
1318
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1319
+ # @param [String] key Column Key.
1320
+ # @param [] required Is column required?
1321
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
1322
+ # @param [Integer] size Maximum size of the string column.
1323
+ # @param [String] new_key New Column Key.
1324
+ #
1325
+ # @return [ColumnString]
1326
+ def update_string_column(database_id:, table_id:, key:, required:, default:, size: nil, new_key: nil)
1327
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}'
1328
+ .gsub('{databaseId}', database_id)
1329
+ .gsub('{tableId}', table_id)
1330
+ .gsub('{key}', key)
1331
+
1332
+ if database_id.nil?
1333
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1334
+ end
1335
+
1336
+ if table_id.nil?
1337
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1338
+ end
1339
+
1340
+ if key.nil?
1341
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1342
+ end
1343
+
1344
+ if required.nil?
1345
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1346
+ end
1347
+
1348
+ if default.nil?
1349
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
1350
+ end
1351
+
1352
+ api_params = {
1353
+ required: required,
1354
+ default: default,
1355
+ size: size,
1356
+ newKey: new_key,
1357
+ }
1358
+
1359
+ api_headers = {
1360
+ "content-type": 'application/json',
1361
+ }
1362
+
1363
+ @client.call(
1364
+ method: 'PATCH',
1365
+ path: api_path,
1366
+ headers: api_headers,
1367
+ params: api_params,
1368
+ response_type: Models::ColumnString
1369
+ )
1370
+ end
1371
+
1372
+ # Create a URL column.
1373
+ #
1374
+ #
1375
+ # @param [String] database_id Database ID.
1376
+ # @param [String] table_id Table ID.
1377
+ # @param [String] key Column Key.
1378
+ # @param [] required Is column required?
1379
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
1380
+ # @param [] array Is column an array?
1381
+ #
1382
+ # @return [ColumnUrl]
1383
+ def create_url_column(database_id:, table_id:, key:, required:, default: nil, array: nil)
1384
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url'
1385
+ .gsub('{databaseId}', database_id)
1386
+ .gsub('{tableId}', table_id)
1387
+
1388
+ if database_id.nil?
1389
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1390
+ end
1391
+
1392
+ if table_id.nil?
1393
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1394
+ end
1395
+
1396
+ if key.nil?
1397
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1398
+ end
1399
+
1400
+ if required.nil?
1401
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1402
+ end
1403
+
1404
+ api_params = {
1405
+ key: key,
1406
+ required: required,
1407
+ default: default,
1408
+ array: array,
1409
+ }
1410
+
1411
+ api_headers = {
1412
+ "content-type": 'application/json',
1413
+ }
1414
+
1415
+ @client.call(
1416
+ method: 'POST',
1417
+ path: api_path,
1418
+ headers: api_headers,
1419
+ params: api_params,
1420
+ response_type: Models::ColumnUrl
1421
+ )
1422
+ end
1423
+
1424
+ # Update an url column. Changing the `default` value will not update already
1425
+ # existing rows.
1426
+ #
1427
+ #
1428
+ # @param [String] database_id Database ID.
1429
+ # @param [String] table_id Table ID.
1430
+ # @param [String] key Column Key.
1431
+ # @param [] required Is column required?
1432
+ # @param [String] default Default value for column when not provided. Cannot be set when column is required.
1433
+ # @param [String] new_key New Column Key.
1434
+ #
1435
+ # @return [ColumnUrl]
1436
+ def update_url_column(database_id:, table_id:, key:, required:, default:, new_key: nil)
1437
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}'
1438
+ .gsub('{databaseId}', database_id)
1439
+ .gsub('{tableId}', table_id)
1440
+ .gsub('{key}', key)
1441
+
1442
+ if database_id.nil?
1443
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1444
+ end
1445
+
1446
+ if table_id.nil?
1447
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1448
+ end
1449
+
1450
+ if key.nil?
1451
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1452
+ end
1453
+
1454
+ if required.nil?
1455
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
1456
+ end
1457
+
1458
+ if default.nil?
1459
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
1460
+ end
1461
+
1462
+ api_params = {
1463
+ required: required,
1464
+ default: default,
1465
+ newKey: new_key,
1466
+ }
1467
+
1468
+ api_headers = {
1469
+ "content-type": 'application/json',
1470
+ }
1471
+
1472
+ @client.call(
1473
+ method: 'PATCH',
1474
+ path: api_path,
1475
+ headers: api_headers,
1476
+ params: api_params,
1477
+ response_type: Models::ColumnUrl
1478
+ )
1479
+ end
1480
+
1481
+ # Get column by ID.
1482
+ #
1483
+ # @param [String] database_id Database ID.
1484
+ # @param [String] table_id Table ID.
1485
+ # @param [String] key Column Key.
1486
+ #
1487
+ # @return []
1488
+ def get_column(database_id:, table_id:, key:)
1489
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'
1490
+ .gsub('{databaseId}', database_id)
1491
+ .gsub('{tableId}', table_id)
1492
+ .gsub('{key}', key)
1493
+
1494
+ if database_id.nil?
1495
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1496
+ end
1497
+
1498
+ if table_id.nil?
1499
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1500
+ end
1501
+
1502
+ if key.nil?
1503
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1504
+ end
1505
+
1506
+ api_params = {
1507
+ }
1508
+
1509
+ api_headers = {
1510
+ }
1511
+
1512
+ @client.call(
1513
+ method: 'GET',
1514
+ path: api_path,
1515
+ headers: api_headers,
1516
+ params: api_params,
1517
+ )
1518
+ end
1519
+
1520
+ # Deletes a column.
1521
+ #
1522
+ # @param [String] database_id Database ID.
1523
+ # @param [String] table_id Table ID.
1524
+ # @param [String] key Column Key.
1525
+ #
1526
+ # @return []
1527
+ def delete_column(database_id:, table_id:, key:)
1528
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'
1529
+ .gsub('{databaseId}', database_id)
1530
+ .gsub('{tableId}', table_id)
1531
+ .gsub('{key}', key)
1532
+
1533
+ if database_id.nil?
1534
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1535
+ end
1536
+
1537
+ if table_id.nil?
1538
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1539
+ end
1540
+
1541
+ if key.nil?
1542
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1543
+ end
1544
+
1545
+ api_params = {
1546
+ }
1547
+
1548
+ api_headers = {
1549
+ "content-type": 'application/json',
1550
+ }
1551
+
1552
+ @client.call(
1553
+ method: 'DELETE',
1554
+ path: api_path,
1555
+ headers: api_headers,
1556
+ params: api_params,
1557
+ )
1558
+ end
1559
+
1560
+ # Update relationship column. [Learn more about relationship
1561
+ # columns](https://appwrite.io/docs/databases-relationships#relationship-columns).
1562
+ #
1563
+ #
1564
+ # @param [String] database_id Database ID.
1565
+ # @param [String] table_id Table ID.
1566
+ # @param [String] key Column Key.
1567
+ # @param [RelationMutate] on_delete Constraints option
1568
+ # @param [String] new_key New Column Key.
1569
+ #
1570
+ # @return [ColumnRelationship]
1571
+ def update_relationship_column(database_id:, table_id:, key:, on_delete: nil, new_key: nil)
1572
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship'
1573
+ .gsub('{databaseId}', database_id)
1574
+ .gsub('{tableId}', table_id)
1575
+ .gsub('{key}', key)
1576
+
1577
+ if database_id.nil?
1578
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1579
+ end
1580
+
1581
+ if table_id.nil?
1582
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1583
+ end
1584
+
1585
+ if key.nil?
1586
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1587
+ end
1588
+
1589
+ api_params = {
1590
+ onDelete: on_delete,
1591
+ newKey: new_key,
1592
+ }
1593
+
1594
+ api_headers = {
1595
+ "content-type": 'application/json',
1596
+ }
1597
+
1598
+ @client.call(
1599
+ method: 'PATCH',
1600
+ path: api_path,
1601
+ headers: api_headers,
1602
+ params: api_params,
1603
+ response_type: Models::ColumnRelationship
1604
+ )
1605
+ end
1606
+
1607
+ # List indexes on the table.
1608
+ #
1609
+ # @param [String] database_id Database ID.
1610
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1611
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error
1612
+ #
1613
+ # @return [ColumnIndexList]
1614
+ def list_indexes(database_id:, table_id:, queries: nil)
1615
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes'
1616
+ .gsub('{databaseId}', database_id)
1617
+ .gsub('{tableId}', table_id)
1618
+
1619
+ if database_id.nil?
1620
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1621
+ end
1622
+
1623
+ if table_id.nil?
1624
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1625
+ end
1626
+
1627
+ api_params = {
1628
+ queries: queries,
1629
+ }
1630
+
1631
+ api_headers = {
1632
+ }
1633
+
1634
+ @client.call(
1635
+ method: 'GET',
1636
+ path: api_path,
1637
+ headers: api_headers,
1638
+ params: api_params,
1639
+ response_type: Models::ColumnIndexList
1640
+ )
1641
+ end
1642
+
1643
+ # Creates an index on the columns listed. Your index should include all the
1644
+ # columns you will query in a single request.
1645
+ # Type can be `key`, `fulltext`, or `unique`.
1646
+ #
1647
+ # @param [String] database_id Database ID.
1648
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1649
+ # @param [String] key Index Key.
1650
+ # @param [IndexType] type Index type.
1651
+ # @param [Array] columns Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long.
1652
+ # @param [Array] orders Array of index orders. Maximum of 100 orders are allowed.
1653
+ # @param [Array] lengths Length of index. Maximum of 100
1654
+ #
1655
+ # @return [ColumnIndex]
1656
+ def create_index(database_id:, table_id:, key:, type:, columns:, orders: nil, lengths: nil)
1657
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes'
1658
+ .gsub('{databaseId}', database_id)
1659
+ .gsub('{tableId}', table_id)
1660
+
1661
+ if database_id.nil?
1662
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1663
+ end
1664
+
1665
+ if table_id.nil?
1666
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1667
+ end
1668
+
1669
+ if key.nil?
1670
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1671
+ end
1672
+
1673
+ if type.nil?
1674
+ raise Appwrite::Exception.new('Missing required parameter: "type"')
1675
+ end
1676
+
1677
+ if columns.nil?
1678
+ raise Appwrite::Exception.new('Missing required parameter: "columns"')
1679
+ end
1680
+
1681
+ api_params = {
1682
+ key: key,
1683
+ type: type,
1684
+ columns: columns,
1685
+ orders: orders,
1686
+ lengths: lengths,
1687
+ }
1688
+
1689
+ api_headers = {
1690
+ "content-type": 'application/json',
1691
+ }
1692
+
1693
+ @client.call(
1694
+ method: 'POST',
1695
+ path: api_path,
1696
+ headers: api_headers,
1697
+ params: api_params,
1698
+ response_type: Models::ColumnIndex
1699
+ )
1700
+ end
1701
+
1702
+ # Get index by ID.
1703
+ #
1704
+ # @param [String] database_id Database ID.
1705
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1706
+ # @param [String] key Index Key.
1707
+ #
1708
+ # @return [ColumnIndex]
1709
+ def get_index(database_id:, table_id:, key:)
1710
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'
1711
+ .gsub('{databaseId}', database_id)
1712
+ .gsub('{tableId}', table_id)
1713
+ .gsub('{key}', key)
1714
+
1715
+ if database_id.nil?
1716
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1717
+ end
1718
+
1719
+ if table_id.nil?
1720
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1721
+ end
1722
+
1723
+ if key.nil?
1724
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1725
+ end
1726
+
1727
+ api_params = {
1728
+ }
1729
+
1730
+ api_headers = {
1731
+ }
1732
+
1733
+ @client.call(
1734
+ method: 'GET',
1735
+ path: api_path,
1736
+ headers: api_headers,
1737
+ params: api_params,
1738
+ response_type: Models::ColumnIndex
1739
+ )
1740
+ end
1741
+
1742
+ # Delete an index.
1743
+ #
1744
+ # @param [String] database_id Database ID.
1745
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
1746
+ # @param [String] key Index Key.
1747
+ #
1748
+ # @return []
1749
+ def delete_index(database_id:, table_id:, key:)
1750
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'
1751
+ .gsub('{databaseId}', database_id)
1752
+ .gsub('{tableId}', table_id)
1753
+ .gsub('{key}', key)
1754
+
1755
+ if database_id.nil?
1756
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1757
+ end
1758
+
1759
+ if table_id.nil?
1760
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1761
+ end
1762
+
1763
+ if key.nil?
1764
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
1765
+ end
1766
+
1767
+ api_params = {
1768
+ }
1769
+
1770
+ api_headers = {
1771
+ "content-type": 'application/json',
1772
+ }
1773
+
1774
+ @client.call(
1775
+ method: 'DELETE',
1776
+ path: api_path,
1777
+ headers: api_headers,
1778
+ params: api_params,
1779
+ )
1780
+ end
1781
+
1782
+ # Get a list of all the user's rows in a given table. You can use the query
1783
+ # params to filter your results.
1784
+ #
1785
+ # @param [String] database_id Database ID.
1786
+ # @param [String] table_id Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
1787
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
1788
+ #
1789
+ # @return [RowList]
1790
+ def list_rows(database_id:, table_id:, queries: nil)
1791
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
1792
+ .gsub('{databaseId}', database_id)
1793
+ .gsub('{tableId}', table_id)
1794
+
1795
+ if database_id.nil?
1796
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1797
+ end
1798
+
1799
+ if table_id.nil?
1800
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1801
+ end
1802
+
1803
+ api_params = {
1804
+ queries: queries,
1805
+ }
1806
+
1807
+ api_headers = {
1808
+ }
1809
+
1810
+ @client.call(
1811
+ method: 'GET',
1812
+ path: api_path,
1813
+ headers: api_headers,
1814
+ params: api_params,
1815
+ response_type: Models::RowList
1816
+ )
1817
+ end
1818
+
1819
+ # Create a new Row. Before using this route, you should create a new table
1820
+ # resource using either a [server
1821
+ # integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1822
+ # API or directly from your database console.
1823
+ #
1824
+ # @param [String] database_id Database ID.
1825
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
1826
+ # @param [String] row_id Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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.
1827
+ # @param [Hash] data Row data as JSON object.
1828
+ # @param [Array] permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
1829
+ #
1830
+ # @return [Row]
1831
+ def create_row(database_id:, table_id:, row_id:, data:, permissions: nil)
1832
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
1833
+ .gsub('{databaseId}', database_id)
1834
+ .gsub('{tableId}', table_id)
1835
+
1836
+ if database_id.nil?
1837
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1838
+ end
1839
+
1840
+ if table_id.nil?
1841
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1842
+ end
1843
+
1844
+ if row_id.nil?
1845
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
1846
+ end
1847
+
1848
+ if data.nil?
1849
+ raise Appwrite::Exception.new('Missing required parameter: "data"')
1850
+ end
1851
+
1852
+ api_params = {
1853
+ rowId: row_id,
1854
+ data: data,
1855
+ permissions: permissions,
1856
+ }
1857
+
1858
+ api_headers = {
1859
+ "content-type": 'application/json',
1860
+ }
1861
+
1862
+ @client.call(
1863
+ method: 'POST',
1864
+ path: api_path,
1865
+ headers: api_headers,
1866
+ params: api_params,
1867
+ response_type: Models::Row
1868
+ )
1869
+ end
1870
+
1871
+ # Create new Rows. Before using this route, you should create a new table
1872
+ # resource using either a [server
1873
+ # integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1874
+ # API or directly from your database console.
1875
+ #
1876
+ # @param [String] database_id Database ID.
1877
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
1878
+ # @param [Array] rows Array of documents data as JSON objects.
1879
+ #
1880
+ # @return [RowList]
1881
+ def create_rows(database_id:, table_id:, rows:)
1882
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
1883
+ .gsub('{databaseId}', database_id)
1884
+ .gsub('{tableId}', table_id)
1885
+
1886
+ if database_id.nil?
1887
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1888
+ end
1889
+
1890
+ if table_id.nil?
1891
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1892
+ end
1893
+
1894
+ if rows.nil?
1895
+ raise Appwrite::Exception.new('Missing required parameter: "rows"')
1896
+ end
1897
+
1898
+ api_params = {
1899
+ rows: rows,
1900
+ }
1901
+
1902
+ api_headers = {
1903
+ "content-type": 'application/json',
1904
+ }
1905
+
1906
+ @client.call(
1907
+ method: 'POST',
1908
+ path: api_path,
1909
+ headers: api_headers,
1910
+ params: api_params,
1911
+ response_type: Models::RowList
1912
+ )
1913
+ end
1914
+
1915
+ # Create or update Rows. Before using this route, you should create a new
1916
+ # table resource using either a [server
1917
+ # integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1918
+ # API or directly from your database console.
1919
+ #
1920
+ #
1921
+ # @param [String] database_id Database ID.
1922
+ # @param [String] table_id Table ID.
1923
+ # @param [Array] rows Array of row data as JSON objects. May contain partial rows.
1924
+ #
1925
+ # @return [RowList]
1926
+ def upsert_rows(database_id:, table_id:, rows:)
1927
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
1928
+ .gsub('{databaseId}', database_id)
1929
+ .gsub('{tableId}', table_id)
1930
+
1931
+ if database_id.nil?
1932
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1933
+ end
1934
+
1935
+ if table_id.nil?
1936
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1937
+ end
1938
+
1939
+ if rows.nil?
1940
+ raise Appwrite::Exception.new('Missing required parameter: "rows"')
1941
+ end
1942
+
1943
+ api_params = {
1944
+ rows: rows,
1945
+ }
1946
+
1947
+ api_headers = {
1948
+ "content-type": 'application/json',
1949
+ }
1950
+
1951
+ @client.call(
1952
+ method: 'PUT',
1953
+ path: api_path,
1954
+ headers: api_headers,
1955
+ params: api_params,
1956
+ response_type: Models::RowList
1957
+ )
1958
+ end
1959
+
1960
+ # Update all rows that match your queries, if no queries are submitted then
1961
+ # all rows are updated. You can pass only specific fields to be updated.
1962
+ #
1963
+ # @param [String] database_id Database ID.
1964
+ # @param [String] table_id Table ID.
1965
+ # @param [Hash] data Row data as JSON object. Include only column and value pairs to be updated.
1966
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
1967
+ #
1968
+ # @return [RowList]
1969
+ def update_rows(database_id:, table_id:, data: nil, queries: nil)
1970
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
1971
+ .gsub('{databaseId}', database_id)
1972
+ .gsub('{tableId}', table_id)
1973
+
1974
+ if database_id.nil?
1975
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1976
+ end
1977
+
1978
+ if table_id.nil?
1979
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
1980
+ end
1981
+
1982
+ api_params = {
1983
+ data: data,
1984
+ queries: queries,
1985
+ }
1986
+
1987
+ api_headers = {
1988
+ "content-type": 'application/json',
1989
+ }
1990
+
1991
+ @client.call(
1992
+ method: 'PATCH',
1993
+ path: api_path,
1994
+ headers: api_headers,
1995
+ params: api_params,
1996
+ response_type: Models::RowList
1997
+ )
1998
+ end
1999
+
2000
+ # Bulk delete rows using queries, if no queries are passed then all rows are
2001
+ # deleted.
2002
+ #
2003
+ # @param [String] database_id Database ID.
2004
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
2005
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
2006
+ #
2007
+ # @return [RowList]
2008
+ def delete_rows(database_id:, table_id:, queries: nil)
2009
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows'
2010
+ .gsub('{databaseId}', database_id)
2011
+ .gsub('{tableId}', table_id)
2012
+
2013
+ if database_id.nil?
2014
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2015
+ end
2016
+
2017
+ if table_id.nil?
2018
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2019
+ end
2020
+
2021
+ api_params = {
2022
+ queries: queries,
2023
+ }
2024
+
2025
+ api_headers = {
2026
+ "content-type": 'application/json',
2027
+ }
2028
+
2029
+ @client.call(
2030
+ method: 'DELETE',
2031
+ path: api_path,
2032
+ headers: api_headers,
2033
+ params: api_params,
2034
+ response_type: Models::RowList
2035
+ )
2036
+ end
2037
+
2038
+ # Get a row by its unique ID. This endpoint response returns a JSON object
2039
+ # with the row data.
2040
+ #
2041
+ # @param [String] database_id Database ID.
2042
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
2043
+ # @param [String] row_id Row ID.
2044
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
2045
+ #
2046
+ # @return [Row]
2047
+ def get_row(database_id:, table_id:, row_id:, queries: nil)
2048
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'
2049
+ .gsub('{databaseId}', database_id)
2050
+ .gsub('{tableId}', table_id)
2051
+ .gsub('{rowId}', row_id)
2052
+
2053
+ if database_id.nil?
2054
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2055
+ end
2056
+
2057
+ if table_id.nil?
2058
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2059
+ end
2060
+
2061
+ if row_id.nil?
2062
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2063
+ end
2064
+
2065
+ api_params = {
2066
+ queries: queries,
2067
+ }
2068
+
2069
+ api_headers = {
2070
+ }
2071
+
2072
+ @client.call(
2073
+ method: 'GET',
2074
+ path: api_path,
2075
+ headers: api_headers,
2076
+ params: api_params,
2077
+ response_type: Models::Row
2078
+ )
2079
+ end
2080
+
2081
+ # Create or update a Row. Before using this route, you should create a new
2082
+ # table resource using either a [server
2083
+ # integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
2084
+ # API or directly from your database console.
2085
+ #
2086
+ # @param [String] database_id Database ID.
2087
+ # @param [String] table_id Table ID.
2088
+ # @param [String] row_id Row ID.
2089
+ # @param [Hash] data Row data as JSON object. Include all required columns of the row to be created or updated.
2090
+ # @param [Array] permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
2091
+ #
2092
+ # @return [Row]
2093
+ def upsert_row(database_id:, table_id:, row_id:, data: nil, permissions: nil)
2094
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'
2095
+ .gsub('{databaseId}', database_id)
2096
+ .gsub('{tableId}', table_id)
2097
+ .gsub('{rowId}', row_id)
2098
+
2099
+ if database_id.nil?
2100
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2101
+ end
2102
+
2103
+ if table_id.nil?
2104
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2105
+ end
2106
+
2107
+ if row_id.nil?
2108
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2109
+ end
2110
+
2111
+ api_params = {
2112
+ data: data,
2113
+ permissions: permissions,
2114
+ }
2115
+
2116
+ api_headers = {
2117
+ "content-type": 'application/json',
2118
+ }
2119
+
2120
+ @client.call(
2121
+ method: 'PUT',
2122
+ path: api_path,
2123
+ headers: api_headers,
2124
+ params: api_params,
2125
+ response_type: Models::Row
2126
+ )
2127
+ end
2128
+
2129
+ # Update a row by its unique ID. Using the patch method you can pass only
2130
+ # specific fields that will get updated.
2131
+ #
2132
+ # @param [String] database_id Database ID.
2133
+ # @param [String] table_id Table ID.
2134
+ # @param [String] row_id Row ID.
2135
+ # @param [Hash] data Row data as JSON object. Include only columns and value pairs to be updated.
2136
+ # @param [Array] permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
2137
+ #
2138
+ # @return [Row]
2139
+ def update_row(database_id:, table_id:, row_id:, data: nil, permissions: nil)
2140
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'
2141
+ .gsub('{databaseId}', database_id)
2142
+ .gsub('{tableId}', table_id)
2143
+ .gsub('{rowId}', row_id)
2144
+
2145
+ if database_id.nil?
2146
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2147
+ end
2148
+
2149
+ if table_id.nil?
2150
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2151
+ end
2152
+
2153
+ if row_id.nil?
2154
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2155
+ end
2156
+
2157
+ api_params = {
2158
+ data: data,
2159
+ permissions: permissions,
2160
+ }
2161
+
2162
+ api_headers = {
2163
+ "content-type": 'application/json',
2164
+ }
2165
+
2166
+ @client.call(
2167
+ method: 'PATCH',
2168
+ path: api_path,
2169
+ headers: api_headers,
2170
+ params: api_params,
2171
+ response_type: Models::Row
2172
+ )
2173
+ end
2174
+
2175
+ # Delete a row by its unique ID.
2176
+ #
2177
+ # @param [String] database_id Database ID.
2178
+ # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
2179
+ # @param [String] row_id Row ID.
2180
+ #
2181
+ # @return []
2182
+ def delete_row(database_id:, table_id:, row_id:)
2183
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'
2184
+ .gsub('{databaseId}', database_id)
2185
+ .gsub('{tableId}', table_id)
2186
+ .gsub('{rowId}', row_id)
2187
+
2188
+ if database_id.nil?
2189
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2190
+ end
2191
+
2192
+ if table_id.nil?
2193
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2194
+ end
2195
+
2196
+ if row_id.nil?
2197
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2198
+ end
2199
+
2200
+ api_params = {
2201
+ }
2202
+
2203
+ api_headers = {
2204
+ "content-type": 'application/json',
2205
+ }
2206
+
2207
+ @client.call(
2208
+ method: 'DELETE',
2209
+ path: api_path,
2210
+ headers: api_headers,
2211
+ params: api_params,
2212
+ )
2213
+ end
2214
+
2215
+ # Decrement a specific column of a row by a given value.
2216
+ #
2217
+ # @param [String] database_id Database ID.
2218
+ # @param [String] table_id Table ID.
2219
+ # @param [String] row_id Row ID.
2220
+ # @param [String] column Column key.
2221
+ # @param [Float] value Value to increment the column by. The value must be a number.
2222
+ # @param [Float] min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.
2223
+ #
2224
+ # @return [Row]
2225
+ def decrement_row_column(database_id:, table_id:, row_id:, column:, value: nil, min: nil)
2226
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement'
2227
+ .gsub('{databaseId}', database_id)
2228
+ .gsub('{tableId}', table_id)
2229
+ .gsub('{rowId}', row_id)
2230
+ .gsub('{column}', column)
2231
+
2232
+ if database_id.nil?
2233
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2234
+ end
2235
+
2236
+ if table_id.nil?
2237
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2238
+ end
2239
+
2240
+ if row_id.nil?
2241
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2242
+ end
2243
+
2244
+ if column.nil?
2245
+ raise Appwrite::Exception.new('Missing required parameter: "column"')
2246
+ end
2247
+
2248
+ api_params = {
2249
+ value: value,
2250
+ min: min,
2251
+ }
2252
+
2253
+ api_headers = {
2254
+ "content-type": 'application/json',
2255
+ }
2256
+
2257
+ @client.call(
2258
+ method: 'PATCH',
2259
+ path: api_path,
2260
+ headers: api_headers,
2261
+ params: api_params,
2262
+ response_type: Models::Row
2263
+ )
2264
+ end
2265
+
2266
+ # Increment a specific column of a row by a given value.
2267
+ #
2268
+ # @param [String] database_id Database ID.
2269
+ # @param [String] table_id Table ID.
2270
+ # @param [String] row_id Row ID.
2271
+ # @param [String] column Column key.
2272
+ # @param [Float] value Value to increment the column by. The value must be a number.
2273
+ # @param [Float] max Maximum value for the column. If the current value is greater than this value, an error will be thrown.
2274
+ #
2275
+ # @return [Row]
2276
+ def increment_row_column(database_id:, table_id:, row_id:, column:, value: nil, max: nil)
2277
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment'
2278
+ .gsub('{databaseId}', database_id)
2279
+ .gsub('{tableId}', table_id)
2280
+ .gsub('{rowId}', row_id)
2281
+ .gsub('{column}', column)
2282
+
2283
+ if database_id.nil?
2284
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
2285
+ end
2286
+
2287
+ if table_id.nil?
2288
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
2289
+ end
2290
+
2291
+ if row_id.nil?
2292
+ raise Appwrite::Exception.new('Missing required parameter: "rowId"')
2293
+ end
2294
+
2295
+ if column.nil?
2296
+ raise Appwrite::Exception.new('Missing required parameter: "column"')
2297
+ end
2298
+
2299
+ api_params = {
2300
+ value: value,
2301
+ max: max,
2302
+ }
2303
+
2304
+ api_headers = {
2305
+ "content-type": 'application/json',
2306
+ }
2307
+
2308
+ @client.call(
2309
+ method: 'PATCH',
2310
+ path: api_path,
2311
+ headers: api_headers,
2312
+ params: api_params,
2313
+ response_type: Models::Row
2314
+ )
2315
+ end
2316
+
2317
+ end
2318
+ end