appwrite 3.0.0 → 4.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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +69 -5
  3. data/lib/appwrite/exception.rb +3 -1
  4. data/lib/appwrite/file.rb +4 -2
  5. data/lib/appwrite/models/attribute_list.rb +5 -5
  6. data/lib/appwrite/models/bucket.rb +82 -0
  7. data/lib/appwrite/models/bucket_list.rb +32 -0
  8. data/lib/appwrite/models/collection_list.rb +5 -5
  9. data/lib/appwrite/models/continent_list.rb +5 -5
  10. data/lib/appwrite/models/country_list.rb +5 -5
  11. data/lib/appwrite/models/currency_list.rb +5 -5
  12. data/lib/appwrite/models/deployment.rb +77 -0
  13. data/lib/appwrite/models/deployment_list.rb +32 -0
  14. data/lib/appwrite/models/document_list.rb +5 -5
  15. data/lib/appwrite/models/execution.rb +5 -5
  16. data/lib/appwrite/models/execution_list.rb +5 -5
  17. data/lib/appwrite/models/file.rb +18 -3
  18. data/lib/appwrite/models/file_list.rb +5 -5
  19. data/lib/appwrite/models/function.rb +5 -5
  20. data/lib/appwrite/models/function_list.rb +5 -5
  21. data/lib/appwrite/models/index_list.rb +5 -5
  22. data/lib/appwrite/models/language_list.rb +5 -5
  23. data/lib/appwrite/models/log_list.rb +5 -5
  24. data/lib/appwrite/models/membership_list.rb +5 -5
  25. data/lib/appwrite/models/phone_list.rb +5 -5
  26. data/lib/appwrite/models/runtime_list.rb +5 -5
  27. data/lib/appwrite/models/session.rb +15 -5
  28. data/lib/appwrite/models/session_list.rb +5 -5
  29. data/lib/appwrite/models/team.rb +5 -5
  30. data/lib/appwrite/models/team_list.rb +5 -5
  31. data/lib/appwrite/models/user_list.rb +5 -5
  32. data/lib/appwrite/services/account.rb +62 -32
  33. data/lib/appwrite/services/avatars.rb +7 -8
  34. data/lib/appwrite/services/database.rb +52 -53
  35. data/lib/appwrite/services/functions.rb +175 -125
  36. data/lib/appwrite/services/health.rb +22 -23
  37. data/lib/appwrite/services/locale.rb +14 -15
  38. data/lib/appwrite/services/storage.rb +309 -47
  39. data/lib/appwrite/services/teams.rb +25 -22
  40. data/lib/appwrite/services/users.rb +31 -31
  41. data/lib/appwrite.rb +5 -3
  42. metadata +8 -6
  43. data/lib/appwrite/models/tag.rb +0 -47
  44. data/lib/appwrite/models/tag_list.rb +0 -32
@@ -3,7 +3,6 @@
3
3
  module Appwrite
4
4
  class Functions < Service
5
5
 
6
- include Models
7
6
  # Get a list of all the project's functions. You can use the query params to
8
7
  # filter your results.
9
8
  #
@@ -34,9 +33,9 @@ module Appwrite
34
33
  @client.call(
35
34
  method: 'GET',
36
35
  path: path,
37
- params: params,
38
36
  headers: headers,
39
- response_type: FunctionList
37
+ params: params,
38
+ response_type: Models::FunctionList
40
39
  )
41
40
  end
42
41
 
@@ -44,7 +43,7 @@ module Appwrite
44
43
  # [permissions](/docs/permissions) to allow different project users or team
45
44
  # with access to execute the function using the client API.
46
45
  #
47
- # @param [string] function_id Function ID. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
46
+ # @param [string] function_id Function 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.
48
47
  # @param [string] name Function name. Max length: 128 chars.
49
48
  # @param [array] execute An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
50
49
  # @param [string] runtime Execution runtime.
@@ -91,9 +90,9 @@ module Appwrite
91
90
  @client.call(
92
91
  method: 'POST',
93
92
  path: path,
94
- params: params,
95
93
  headers: headers,
96
- response_type: Function
94
+ params: params,
95
+ response_type: Models::Function
97
96
  )
98
97
  end
99
98
 
@@ -114,9 +113,9 @@ module Appwrite
114
113
  @client.call(
115
114
  method: 'GET',
116
115
  path: path,
117
- params: params,
118
116
  headers: headers,
119
- response_type: RuntimeList
117
+ params: params,
118
+ response_type: Models::RuntimeList
120
119
  )
121
120
  end
122
121
 
@@ -143,9 +142,9 @@ module Appwrite
143
142
  @client.call(
144
143
  method: 'GET',
145
144
  path: path,
146
- params: params,
147
145
  headers: headers,
148
- response_type: Function
146
+ params: params,
147
+ response_type: Models::Function
149
148
  )
150
149
  end
151
150
 
@@ -192,9 +191,9 @@ module Appwrite
192
191
  @client.call(
193
192
  method: 'PUT',
194
193
  path: path,
195
- params: params,
196
194
  headers: headers,
197
- response_type: Function
195
+ params: params,
196
+ response_type: Models::Function
198
197
  )
199
198
  end
200
199
 
@@ -221,38 +220,38 @@ module Appwrite
221
220
  @client.call(
222
221
  method: 'DELETE',
223
222
  path: path,
224
- params: params,
225
223
  headers: headers,
224
+ params: params,
226
225
  )
227
226
  end
228
227
 
229
- # Get a list of all the current user function execution logs. You can use the
230
- # query params to filter your results. On admin mode, this endpoint will
231
- # return a list of all of the project's executions. [Learn more about
232
- # different API modes](/docs/admin).
228
+ # Get a list of all the project's code deployments. You can use the query
229
+ # params to filter your results.
233
230
  #
234
231
  # @param [string] function_id Function ID.
235
- # @param [number] limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
236
- # @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)
237
232
  # @param [string] search Search term to filter your list results. Max length: 256 chars.
238
- # @param [string] cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
233
+ # @param [number] limit Maximum number of deployments to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
234
+ # @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)
235
+ # @param [string] cursor ID of the deployment used as the starting point for the query, excluding the deployment itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
239
236
  # @param [string] cursor_direction Direction of the cursor.
237
+ # @param [string] order_type Order result by ASC or DESC order.
240
238
  #
241
- # @return [ExecutionList]
242
- def list_executions(function_id:, limit: nil, offset: nil, search: nil, cursor: nil, cursor_direction: nil)
239
+ # @return [DeploymentList]
240
+ def list_deployments(function_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
243
241
  if function_id.nil?
244
242
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
245
243
  end
246
244
 
247
- path = '/functions/{functionId}/executions'
245
+ path = '/functions/{functionId}/deployments'
248
246
  .gsub('{functionId}', function_id)
249
247
 
250
248
  params = {
249
+ search: search,
251
250
  limit: limit,
252
251
  offset: offset,
253
- search: search,
254
252
  cursor: cursor,
255
253
  cursorDirection: cursor_direction,
254
+ orderType: order_type,
256
255
  }
257
256
 
258
257
  headers = {
@@ -262,64 +261,89 @@ module Appwrite
262
261
  @client.call(
263
262
  method: 'GET',
264
263
  path: path,
265
- params: params,
266
264
  headers: headers,
267
- response_type: ExecutionList
265
+ params: params,
266
+ response_type: Models::DeploymentList
268
267
  )
269
268
  end
270
269
 
271
- # Trigger a function execution. The returned object will return you the
272
- # current execution status. You can ping the `Get Execution` endpoint to get
273
- # updates on the current execution status. Once this endpoint is called, your
274
- # function execution process will start asynchronously.
270
+ # Create a new function code deployment. Use this endpoint to upload a new
271
+ # version of your code function. To execute your newly uploaded code, you'll
272
+ # need to update the function's deployment to use your new deployment UID.
273
+ #
274
+ # This endpoint accepts a tar.gz file compressed with your code. Make sure to
275
+ # include any dependencies your code has within the compressed file. You can
276
+ # learn more about code packaging in the [Appwrite Cloud Functions
277
+ # tutorial](/docs/functions).
278
+ #
279
+ # Use the "command" param to set the entry point used to execute your code.
275
280
  #
276
281
  # @param [string] function_id Function ID.
277
- # @param [string] data String of custom data to send to function.
282
+ # @param [string] entrypoint Entrypoint File.
283
+ # @param [file] code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
284
+ # @param [boolean] activate Automatically activate the deployment when it is finished building.
278
285
  #
279
- # @return [Execution]
280
- def create_execution(function_id:, data: nil)
286
+ # @return [Deployment]
287
+ def create_deployment(function_id:, entrypoint:, code:, activate:, on_progress: nil)
281
288
  if function_id.nil?
282
289
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
283
290
  end
284
291
 
285
- path = '/functions/{functionId}/executions'
292
+ if entrypoint.nil?
293
+ raise Appwrite::Exception.new('Missing required parameter: "entrypoint"')
294
+ end
295
+
296
+ if code.nil?
297
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
298
+ end
299
+
300
+ if activate.nil?
301
+ raise Appwrite::Exception.new('Missing required parameter: "activate"')
302
+ end
303
+
304
+ path = '/functions/{functionId}/deployments'
286
305
  .gsub('{functionId}', function_id)
287
306
 
288
307
  params = {
289
- data: data,
308
+ entrypoint: entrypoint,
309
+ code: code,
310
+ activate: activate,
290
311
  }
291
312
 
292
313
  headers = {
293
- "content-type": 'application/json',
314
+ "content-type": 'multipart/form-data',
294
315
  }
295
316
 
296
- @client.call(
297
- method: 'POST',
317
+ param_name = 'code'
318
+
319
+ @client.chunked_upload(
298
320
  path: path,
299
- params: params,
300
321
  headers: headers,
301
- response_type: Execution
322
+ params: params,
323
+ param_name: param_name,
324
+ on_progress: on_progress,
325
+ response_type: Models::Deployment
302
326
  )
303
327
  end
304
328
 
305
- # Get a function execution log by its unique ID.
329
+ # Get a code deployment by its unique ID.
306
330
  #
307
331
  # @param [string] function_id Function ID.
308
- # @param [string] execution_id Execution ID.
332
+ # @param [string] deployment_id Deployment ID.
309
333
  #
310
- # @return [Execution]
311
- def get_execution(function_id:, execution_id:)
334
+ # @return [DeploymentList]
335
+ def get_deployment(function_id:, deployment_id:)
312
336
  if function_id.nil?
313
337
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
314
338
  end
315
339
 
316
- if execution_id.nil?
317
- raise Appwrite::Exception.new('Missing required parameter: "executionId"')
340
+ if deployment_id.nil?
341
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
318
342
  end
319
343
 
320
- path = '/functions/{functionId}/executions/{executionId}'
344
+ path = '/functions/{functionId}/deployments/{deploymentId}'
321
345
  .gsub('{functionId}', function_id)
322
- .gsub('{executionId}', execution_id)
346
+ .gsub('{deploymentId}', deployment_id)
323
347
 
324
348
  params = {
325
349
  }
@@ -331,34 +355,34 @@ module Appwrite
331
355
  @client.call(
332
356
  method: 'GET',
333
357
  path: path,
334
- params: params,
335
358
  headers: headers,
336
- response_type: Execution
359
+ params: params,
360
+ response_type: Models::DeploymentList
337
361
  )
338
362
  end
339
363
 
340
- # Update the function code tag ID using the unique function ID. Use this
341
- # endpoint to switch the code tag that should be executed by the execution
342
- # endpoint.
364
+ # Update the function code deployment ID using the unique function ID. Use
365
+ # this endpoint to switch the code deployment that should be executed by the
366
+ # execution endpoint.
343
367
  #
344
368
  # @param [string] function_id Function ID.
345
- # @param [string] tag Tag ID.
369
+ # @param [string] deployment_id Deployment ID.
346
370
  #
347
371
  # @return [Function]
348
- def update_tag(function_id:, tag:)
372
+ def update_deployment(function_id:, deployment_id:)
349
373
  if function_id.nil?
350
374
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
351
375
  end
352
376
 
353
- if tag.nil?
354
- raise Appwrite::Exception.new('Missing required parameter: "tag"')
377
+ if deployment_id.nil?
378
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
355
379
  end
356
380
 
357
- path = '/functions/{functionId}/tag'
381
+ path = '/functions/{functionId}/deployments/{deploymentId}'
358
382
  .gsub('{functionId}', function_id)
383
+ .gsub('{deploymentId}', deployment_id)
359
384
 
360
385
  params = {
361
- tag: tag,
362
386
  }
363
387
 
364
388
  headers = {
@@ -368,39 +392,32 @@ module Appwrite
368
392
  @client.call(
369
393
  method: 'PATCH',
370
394
  path: path,
371
- params: params,
372
395
  headers: headers,
373
- response_type: Function
396
+ params: params,
397
+ response_type: Models::Function
374
398
  )
375
399
  end
376
400
 
377
- # Get a list of all the project's code tags. You can use the query params to
378
- # filter your results.
401
+ # Delete a code deployment by its unique ID.
379
402
  #
380
403
  # @param [string] function_id Function ID.
381
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
382
- # @param [number] limit Maximum number of tags to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
383
- # @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)
384
- # @param [string] cursor ID of the tag used as the starting point for the query, excluding the tag itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
385
- # @param [string] cursor_direction Direction of the cursor.
386
- # @param [string] order_type Order result by ASC or DESC order.
404
+ # @param [string] deployment_id Deployment ID.
387
405
  #
388
- # @return [TagList]
389
- def list_tags(function_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
406
+ # @return []
407
+ def delete_deployment(function_id:, deployment_id:)
390
408
  if function_id.nil?
391
409
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
392
410
  end
393
411
 
394
- path = '/functions/{functionId}/tags'
412
+ if deployment_id.nil?
413
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
414
+ end
415
+
416
+ path = '/functions/{functionId}/deployments/{deploymentId}'
395
417
  .gsub('{functionId}', function_id)
418
+ .gsub('{deploymentId}', deployment_id)
396
419
 
397
420
  params = {
398
- search: search,
399
- limit: limit,
400
- offset: offset,
401
- cursor: cursor,
402
- cursorDirection: cursor_direction,
403
- orderType: order_type,
404
421
  }
405
422
 
406
423
  headers = {
@@ -408,84 +425,80 @@ module Appwrite
408
425
  }
409
426
 
410
427
  @client.call(
411
- method: 'GET',
428
+ method: 'DELETE',
412
429
  path: path,
413
- params: params,
414
430
  headers: headers,
415
- response_type: TagList
431
+ params: params,
416
432
  )
417
433
  end
418
434
 
419
- # Create a new function code tag. Use this endpoint to upload a new version
420
- # of your code function. To execute your newly uploaded code, you'll need to
421
- # update the function's tag to use your new tag UID.
422
- #
423
- # This endpoint accepts a tar.gz file compressed with your code. Make sure to
424
- # include any dependencies your code has within the compressed file. You can
425
- # learn more about code packaging in the [Appwrite Cloud Functions
426
- # tutorial](/docs/functions).
427
435
  #
428
- # Use the "command" param to set the entry point used to execute your code.
429
436
  #
430
437
  # @param [string] function_id Function ID.
431
- # @param [string] command Code execution command.
432
- # @param [File] code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
438
+ # @param [string] deployment_id Deployment ID.
439
+ # @param [string] build_id Build unique ID.
433
440
  #
434
- # @return [Tag]
435
- def create_tag(function_id:, command:, code:)
441
+ # @return []
442
+ def retry_build(function_id:, deployment_id:, build_id:)
436
443
  if function_id.nil?
437
444
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
438
445
  end
439
446
 
440
- if command.nil?
441
- raise Appwrite::Exception.new('Missing required parameter: "command"')
447
+ if deployment_id.nil?
448
+ raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
442
449
  end
443
450
 
444
- if code.nil?
445
- raise Appwrite::Exception.new('Missing required parameter: "code"')
451
+ if build_id.nil?
452
+ raise Appwrite::Exception.new('Missing required parameter: "buildId"')
446
453
  end
447
454
 
448
- path = '/functions/{functionId}/tags'
455
+ path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'
449
456
  .gsub('{functionId}', function_id)
457
+ .gsub('{deploymentId}', deployment_id)
458
+ .gsub('{buildId}', build_id)
450
459
 
451
460
  params = {
452
- command: command,
453
- code: code,
454
461
  }
455
462
 
456
463
  headers = {
457
- "content-type": 'multipart/form-data',
464
+ "content-type": 'application/json',
458
465
  }
459
466
 
460
467
  @client.call(
461
468
  method: 'POST',
462
469
  path: path,
463
- params: params,
464
470
  headers: headers,
465
- response_type: Tag
471
+ params: params,
466
472
  )
467
473
  end
468
474
 
469
- # Get a code tag by its unique ID.
475
+ # Get a list of all the current user function execution logs. You can use the
476
+ # query params to filter your results. On admin mode, this endpoint will
477
+ # return a list of all of the project's executions. [Learn more about
478
+ # different API modes](/docs/admin).
470
479
  #
471
480
  # @param [string] function_id Function ID.
472
- # @param [string] tag_id Tag ID.
481
+ # @param [number] limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
482
+ # @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)
483
+ # @param [string] search Search term to filter your list results. Max length: 256 chars.
484
+ # @param [string] cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
485
+ # @param [string] cursor_direction Direction of the cursor.
473
486
  #
474
- # @return [Tag]
475
- def get_tag(function_id:, tag_id:)
487
+ # @return [ExecutionList]
488
+ def list_executions(function_id:, limit: nil, offset: nil, search: nil, cursor: nil, cursor_direction: nil)
476
489
  if function_id.nil?
477
490
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
478
491
  end
479
492
 
480
- if tag_id.nil?
481
- raise Appwrite::Exception.new('Missing required parameter: "tagId"')
482
- end
483
-
484
- path = '/functions/{functionId}/tags/{tagId}'
493
+ path = '/functions/{functionId}/executions'
485
494
  .gsub('{functionId}', function_id)
486
- .gsub('{tagId}', tag_id)
487
495
 
488
496
  params = {
497
+ limit: limit,
498
+ offset: offset,
499
+ search: search,
500
+ cursor: cursor,
501
+ cursorDirection: cursor_direction,
489
502
  }
490
503
 
491
504
  headers = {
@@ -495,30 +508,66 @@ module Appwrite
495
508
  @client.call(
496
509
  method: 'GET',
497
510
  path: path,
511
+ headers: headers,
498
512
  params: params,
513
+ response_type: Models::ExecutionList
514
+ )
515
+ end
516
+
517
+ # Trigger a function execution. The returned object will return you the
518
+ # current execution status. You can ping the `Get Execution` endpoint to get
519
+ # updates on the current execution status. Once this endpoint is called, your
520
+ # function execution process will start asynchronously.
521
+ #
522
+ # @param [string] function_id Function ID.
523
+ # @param [string] data String of custom data to send to function.
524
+ # @param [boolean] async Execute code asynchronously. Default value is true.
525
+ #
526
+ # @return [Execution]
527
+ def create_execution(function_id:, data: nil, async: nil)
528
+ if function_id.nil?
529
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
530
+ end
531
+
532
+ path = '/functions/{functionId}/executions'
533
+ .gsub('{functionId}', function_id)
534
+
535
+ params = {
536
+ data: data,
537
+ async: async,
538
+ }
539
+
540
+ headers = {
541
+ "content-type": 'application/json',
542
+ }
543
+
544
+ @client.call(
545
+ method: 'POST',
546
+ path: path,
499
547
  headers: headers,
500
- response_type: Tag
548
+ params: params,
549
+ response_type: Models::Execution
501
550
  )
502
551
  end
503
552
 
504
- # Delete a code tag by its unique ID.
553
+ # Get a function execution log by its unique ID.
505
554
  #
506
555
  # @param [string] function_id Function ID.
507
- # @param [string] tag_id Tag ID.
556
+ # @param [string] execution_id Execution ID.
508
557
  #
509
- # @return []
510
- def delete_tag(function_id:, tag_id:)
558
+ # @return [Execution]
559
+ def get_execution(function_id:, execution_id:)
511
560
  if function_id.nil?
512
561
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
513
562
  end
514
563
 
515
- if tag_id.nil?
516
- raise Appwrite::Exception.new('Missing required parameter: "tagId"')
564
+ if execution_id.nil?
565
+ raise Appwrite::Exception.new('Missing required parameter: "executionId"')
517
566
  end
518
567
 
519
- path = '/functions/{functionId}/tags/{tagId}'
568
+ path = '/functions/{functionId}/executions/{executionId}'
520
569
  .gsub('{functionId}', function_id)
521
- .gsub('{tagId}', tag_id)
570
+ .gsub('{executionId}', execution_id)
522
571
 
523
572
  params = {
524
573
  }
@@ -528,10 +577,11 @@ module Appwrite
528
577
  }
529
578
 
530
579
  @client.call(
531
- method: 'DELETE',
580
+ method: 'GET',
532
581
  path: path,
533
- params: params,
534
582
  headers: headers,
583
+ params: params,
584
+ response_type: Models::Execution
535
585
  )
536
586
  end
537
587