7
7
8
8
include Appwrite
9
9
10
- appwrite_endpoint = 'YOUR_ENDPOINT '
11
- appwrite_project = 'YOUR_PROJECT_ID '
12
- appwrite_api_key = 'YOUR_API_KEY '
10
+ appwrite_endpoint = 'https://v16.appwrite.org/v1 '
11
+ appwrite_project = '66c466f6001a3c3e06ae '
12
+ appwrite_api_key = 'standard_2735ef3caa21929bc6940bdafe29ab9da0be16572a198be646998b7322c9422adaff18d519fc840d7e67f2d74b0dd1c0474aaa3e8521b62b0c11aca6aeee702f4a0aa4360a503df6b989c948ba678c5f236747602d4d673eda3775c3684da07fb5058b13414c9998f2aaf35c4448ee09f4dceb54f5f22694290b37d5b1796f9e '
13
13
14
14
$client = Client . new
15
15
. set_endpoint ( appwrite_endpoint ) # Your API Endpoint
@@ -107,7 +107,6 @@ def create_collection
107
107
key : "name" ,
108
108
size : 255 ,
109
109
required : true ,
110
- default : "" ,
111
110
array : false
112
111
)
113
112
responses << $databases. create_integer_attribute (
@@ -140,7 +139,6 @@ def create_collection
140
139
collection_id : $collection_id,
141
140
key : 'email' ,
142
141
required : false ,
143
- default : ''
144
142
)
145
143
sleep ( 3 )
146
144
responses << $databases. create_index (
@@ -318,6 +316,14 @@ def list_functions
318
316
puts JSON . pretty_generate ( functions . to_map )
319
317
end
320
318
319
+ def get_function
320
+ puts "Running Get Function API" . green
321
+
322
+ function = $functions. get ( function_id : $function_id)
323
+
324
+ puts JSON . pretty_generate ( function . to_map )
325
+ end
326
+
321
327
def delete_function
322
328
puts "Running Delete Function API" . green
323
329
@@ -326,6 +332,80 @@ def delete_function
326
332
puts JSON . pretty_generate ( response )
327
333
end
328
334
335
+ def create_deployment
336
+ puts "Running Upload Deployment API"
337
+
338
+ deployment = $functions. create_deployment (
339
+ function_id : $function_id,
340
+ code : InputFile . from_path ( "./resources/index.rb" ) ,
341
+ activate : true ,
342
+ entrypoint : "index.rb"
343
+ )
344
+ $deployment_id = deployment . id
345
+
346
+ puts JSON . pretty_generate ( deployment . to_map )
347
+
348
+ puts 'Waiting a little to ensure deployment has built ...'
349
+ sleep ( 5 )
350
+ end
351
+
352
+ def list_deployments
353
+ puts "Running List Deployments API"
354
+
355
+ deployments = $functions. list_deployments ( function_id : $function_id)
356
+
357
+ puts JSON . pretty_generate ( deployments . to_map )
358
+ end
359
+
360
+ def delete_deployments
361
+ puts "Running Delete Deployment API"
362
+
363
+ response = $functions. delete_deployment (
364
+ function_id : $function_id,
365
+ deployment_id : $deployment_id
366
+ )
367
+
368
+ puts JSON . pretty_generate ( response )
369
+ end
370
+
371
+ def create_execution
372
+ puts "Running Create Execution API"
373
+
374
+ execution = $functions. create_execution ( function_id : $function_id)
375
+
376
+ puts JSON . pretty_generate ( execution . to_map )
377
+ end
378
+
379
+ def list_executions
380
+ puts "Running List Executions API"
381
+
382
+ executions = $functions. list_executions ( function_id : $function_id)
383
+
384
+ puts JSON . pretty_generate ( executions . to_map )
385
+ end
386
+
387
+ def get_execution
388
+ puts "Running Get Execution API"
389
+
390
+ execution = $functions. get_execution (
391
+ function_id : $function_id,
392
+ execution_id : $execution_id
393
+ )
394
+
395
+ puts JSON . pretty_generate ( execution . to_map )
396
+ end
397
+
398
+ def delete_execution
399
+ puts "Running Delete Execution API"
400
+
401
+ response = $functions. delete_execution (
402
+ function_id : $function_id,
403
+ execution_id : $execution_id
404
+ )
405
+
406
+ puts JSON . pretty_generate ( response )
407
+ end
408
+
329
409
# Users
330
410
create_user
331
411
list_users
@@ -352,6 +432,14 @@ def delete_function
352
432
# Functions
353
433
create_function
354
434
list_functions
435
+ get_function
436
+ create_deployment
437
+ list_deployments
438
+ create_execution
439
+ list_executions
440
+ get_execution
355
441
delete_function
442
+ delete_execution
443
+ delete_deployments
356
444
357
445
puts "Successfully Ran playground!" . bold . green
0 commit comments