Skip to content

Commit 4bcbd31

Browse files
authoredSep 19, 2024
Merge pull request #9 from appwrite/fix-1.6
fix: 1.6x
2 parents cc23f7c + 3de0137 commit 4bcbd31

File tree

6 files changed

+117
-10
lines changed

6 files changed

+117
-10
lines changed
 

‎Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ group :development, :test do
66
gem "rubocop"
77
end
88

9-
gem "appwrite", "~> 7.1"
9+
gem 'appwrite', '~> 11.0', '>= 11.0.2'
1010
gem "colorize"
1111
gem "dotenv"
1212
gem "mime-types"

‎Gemfile.lock

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
GIT
2+
remote: https://github.com/appwrite/sdk-for-ruby.git
3+
revision: 35e13f6537baabf00819d5b29b08f02d17b67f0b
4+
tag: 12.0.0-rc.1
5+
specs:
6+
appwrite (12.0.0.pre.rc.1)
7+
mime-types (~> 3.4.1)
8+
19
GEM
210
remote: https://rubygems.org/
311
specs:
4-
appwrite (7.1.0)
5-
mime-types (~> 3.4.1)
612
ast (2.4.2)
713
colorize (0.8.1)
814
dotenv (2.8.1)
@@ -33,9 +39,10 @@ GEM
3339

3440
PLATFORMS
3541
arm64-darwin-21
42+
arm64-darwin-22
3643

3744
DEPENDENCIES
38-
appwrite (~> 7)
45+
appwrite!
3946
colorize
4047
dotenv
4148
mime-types

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This playground does not adhere to Ruby best practices but rather is intended to
2323
4. Copy Project ID, endpoint and API key from Appwrite console into `lib/playground.rb`
2424
5. Run the playground:
2525
Ruby:
26-
- Install dependencies using pip `bundle install`
26+
- Install dependencies using bundle `bundle install`
2727
- Execute the command `bundle exec ruby lib/playground.rb`
2828
Docker:
2929
- Execute the command `docker compose up`

‎lib/playground.rb

+93-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
include Appwrite
99

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'
1313

1414
$client = Client.new
1515
.set_endpoint(appwrite_endpoint) # Your API Endpoint
@@ -107,7 +107,6 @@ def create_collection
107107
key: "name",
108108
size: 255,
109109
required: true,
110-
default: "",
111110
array: false
112111
)
113112
responses << $databases.create_integer_attribute(
@@ -140,7 +139,6 @@ def create_collection
140139
collection_id: $collection_id,
141140
key: 'email',
142141
required: false,
143-
default: ''
144142
)
145143
sleep(3)
146144
responses << $databases.create_index(
@@ -318,6 +316,14 @@ def list_functions
318316
puts JSON.pretty_generate(functions.to_map)
319317
end
320318

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+
321327
def delete_function
322328
puts "Running Delete Function API".green
323329

@@ -326,6 +332,80 @@ def delete_function
326332
puts JSON.pretty_generate(response)
327333
end
328334

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+
329409
# Users
330410
create_user
331411
list_users
@@ -352,6 +432,14 @@ def delete_function
352432
# Functions
353433
create_function
354434
list_functions
435+
get_function
436+
create_deployment
437+
list_deployments
438+
create_execution
439+
list_executions
440+
get_execution
355441
delete_function
442+
delete_execution
443+
delete_deployments
356444

357445
puts "Successfully Ran playground!".bold.green

‎resources/code.tar.gz

278 Bytes
Binary file not shown.

‎resources/index.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require "appwrite"
2+
3+
def main(context)
4+
return context.res.json(
5+
{
6+
"motto": "Build like a team of hundreds_",
7+
"learn": "https://appwrite.io/docs",
8+
"connect": "https://appwrite.io/discord",
9+
"getInspired": "https://builtwith.appwrite.io",
10+
}
11+
)
12+
end

0 commit comments

Comments
 (0)