Skip to content

Commit b7913a4

Browse files
committed
chore: update SDKs to new RC version
1 parent 35e13f6 commit b7913a4

File tree

10 files changed

+137
-16
lines changed

10 files changed

+137
-16
lines changed

appwrite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |spec|
22

33
spec.name = 'appwrite'
4-
spec.version = '12.0.0-rc.1'
4+
spec.version = '12.0.0-rc.2'
55
spec.license = 'BSD-3-Clause'
66
spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API'
77
spec.author = 'Appwrite Team'

docs/examples/functions/create.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ result = functions.create(
3131
template_repository: '<TEMPLATE_REPOSITORY>', # optional
3232
template_owner: '<TEMPLATE_OWNER>', # optional
3333
template_root_directory: '<TEMPLATE_ROOT_DIRECTORY>', # optional
34-
template_version: '<TEMPLATE_VERSION>' # optional
34+
template_version: '<TEMPLATE_VERSION>', # optional
35+
specification: '' # optional
3536
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'appwrite'
2+
3+
include Appwrite
4+
5+
client = Client.new
6+
.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
7+
.set_project('&lt;YOUR_PROJECT_ID&gt;') # Your project ID
8+
.set_key('&lt;YOUR_API_KEY&gt;') # Your secret API key
9+
10+
functions = Functions.new(client)
11+
12+
result = functions.list_specifications()

docs/examples/functions/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ result = functions.update(
2626
provider_repository_id: '<PROVIDER_REPOSITORY_ID>', # optional
2727
provider_branch: '<PROVIDER_BRANCH>', # optional
2828
provider_silent_mode: false, # optional
29-
provider_root_directory: '<PROVIDER_ROOT_DIRECTORY>' # optional
29+
provider_root_directory: '<PROVIDER_ROOT_DIRECTORY>', # optional
30+
specification: '' # optional
3031
)

lib/appwrite.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
require_relative 'appwrite/models/topic_list'
4242
require_relative 'appwrite/models/subscriber_list'
4343
require_relative 'appwrite/models/target_list'
44+
require_relative 'appwrite/models/specification_list'
4445
require_relative 'appwrite/models/database'
4546
require_relative 'appwrite/models/collection'
4647
require_relative 'appwrite/models/attribute_list'
@@ -96,6 +97,7 @@
9697
require_relative 'appwrite/models/health_certificate'
9798
require_relative 'appwrite/models/health_time'
9899
require_relative 'appwrite/models/headers'
100+
require_relative 'appwrite/models/specification'
99101
require_relative 'appwrite/models/mfa_challenge'
100102
require_relative 'appwrite/models/mfa_recovery_codes'
101103
require_relative 'appwrite/models/mfa_type'

lib/appwrite/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize
1515
'x-sdk-name'=> 'Ruby',
1616
'x-sdk-platform'=> 'server',
1717
'x-sdk-language'=> 'ruby',
18-
'x-sdk-version'=> '12.0.0-rc.1',
18+
'x-sdk-version'=> '12.0.0-rc.2',
1919
'X-Appwrite-Response-Format' => '1.6.0'
2020
}
2121
@endpoint = 'https://cloud.appwrite.io/v1'

lib/appwrite/models/function.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class Function
2626
attr_reader :provider_branch
2727
attr_reader :provider_root_directory
2828
attr_reader :provider_silent_mode
29+
attr_reader :specification
2930

3031
def initialize(
3132
id:,
@@ -50,7 +51,8 @@ def initialize(
5051
provider_repository_id:,
5152
provider_branch:,
5253
provider_root_directory:,
53-
provider_silent_mode:
54+
provider_silent_mode:,
55+
specification:
5456
)
5557
@id = id
5658
@created_at = created_at
@@ -75,6 +77,7 @@ def initialize(
7577
@provider_branch = provider_branch
7678
@provider_root_directory = provider_root_directory
7779
@provider_silent_mode = provider_silent_mode
80+
@specification = specification
7881
end
7982

8083
def self.from(map:)
@@ -101,7 +104,8 @@ def self.from(map:)
101104
provider_repository_id: map["providerRepositoryId"],
102105
provider_branch: map["providerBranch"],
103106
provider_root_directory: map["providerRootDirectory"],
104-
provider_silent_mode: map["providerSilentMode"]
107+
provider_silent_mode: map["providerSilentMode"],
108+
specification: map["specification"]
105109
)
106110
end
107111

@@ -129,7 +133,8 @@ def to_map
129133
"providerRepositoryId": @provider_repository_id,
130134
"providerBranch": @provider_branch,
131135
"providerRootDirectory": @provider_root_directory,
132-
"providerSilentMode": @provider_silent_mode
136+
"providerSilentMode": @provider_silent_mode,
137+
"specification": @specification
133138
}
134139
end
135140
end
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#frozen_string_literal: true
2+
3+
module Appwrite
4+
module Models
5+
class Specification
6+
attr_reader :memory
7+
attr_reader :cpus
8+
attr_reader :enabled
9+
attr_reader :slug
10+
11+
def initialize(
12+
memory:,
13+
cpus:,
14+
enabled:,
15+
slug:
16+
)
17+
@memory = memory
18+
@cpus = cpus
19+
@enabled = enabled
20+
@slug = slug
21+
end
22+
23+
def self.from(map:)
24+
Specification.new(
25+
memory: map["memory"],
26+
cpus: map["cpus"],
27+
enabled: map["enabled"],
28+
slug: map["slug"]
29+
)
30+
end
31+
32+
def to_map
33+
{
34+
"memory": @memory,
35+
"cpus": @cpus,
36+
"enabled": @enabled,
37+
"slug": @slug
38+
}
39+
end
40+
end
41+
end
42+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#frozen_string_literal: true
2+
3+
module Appwrite
4+
module Models
5+
class SpecificationList
6+
attr_reader :total
7+
attr_reader :specifications
8+
9+
def initialize(
10+
total:,
11+
specifications:
12+
)
13+
@total = total
14+
@specifications = specifications
15+
end
16+
17+
def self.from(map:)
18+
SpecificationList.new(
19+
total: map["total"],
20+
specifications: map["specifications"].map { |it| Specification.from(map: it) }
21+
)
22+
end
23+
24+
def to_map
25+
{
26+
"total": @total,
27+
"specifications": @specifications.map { |it| it.to_map }
28+
}
29+
end
30+
end
31+
end
32+
end

lib/appwrite/services/functions.rb

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ def list(queries: nil, search: nil)
6262
# @param [String] template_owner The name of the owner of the template.
6363
# @param [String] template_root_directory Path to function code in the template repo.
6464
# @param [String] template_version Version (tag) for the repo linked to the function template.
65+
# @param [String] specification Runtime specification for the function and builds.
6566
#
6667
# @return [Function]
67-
def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, template_repository: nil, template_owner: nil, template_root_directory: nil, template_version: nil)
68+
def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, template_repository: nil, template_owner: nil, template_root_directory: nil, template_version: nil, specification: nil)
6869
api_path = '/functions'
6970

7071
if function_id.nil?
@@ -101,6 +102,7 @@ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: n
101102
templateOwner: template_owner,
102103
templateRootDirectory: template_root_directory,
103104
templateVersion: template_version,
105+
specification: specification,
104106
}
105107

106108
api_headers = {
@@ -141,6 +143,31 @@ def list_runtimes()
141143
end
142144

143145

146+
# List allowed function specifications for this instance.
147+
#
148+
#
149+
#
150+
# @return [SpecificationList]
151+
def list_specifications()
152+
api_path = '/functions/specifications'
153+
154+
api_params = {
155+
}
156+
157+
api_headers = {
158+
"content-type": 'application/json',
159+
}
160+
161+
@client.call(
162+
method: 'GET',
163+
path: api_path,
164+
headers: api_headers,
165+
params: api_params,
166+
response_type: Models::SpecificationList
167+
)
168+
end
169+
170+
144171
# List available function templates. You can use template details in
145172
# [createFunction](/docs/references/cloud/server-nodejs/functions#create)
146173
# method.
@@ -256,9 +283,10 @@ def get(function_id:)
256283
# @param [String] provider_branch Production branch for the repo linked to the function
257284
# @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
258285
# @param [String] provider_root_directory Path to function code in the linked repo.
286+
# @param [String] specification Runtime specification for the function and builds.
259287
#
260288
# @return [Function]
261-
def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil)
289+
def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, specification: nil)
262290
api_path = '/functions/{functionId}'
263291
.gsub('{functionId}', function_id)
264292

@@ -287,6 +315,7 @@ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedul
287315
providerBranch: provider_branch,
288316
providerSilentMode: provider_silent_mode,
289317
providerRootDirectory: provider_root_directory,
318+
specification: specification,
290319
}
291320

292321
api_headers = {
@@ -694,7 +723,7 @@ def list_executions(function_id:, queries: nil, search: nil)
694723
# @param [String] scheduled_at Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.
695724
#
696725
# @return [Execution]
697-
def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil, on_progress: nil)
726+
def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil)
698727
api_path = '/functions/{functionId}/executions'
699728
.gsub('{functionId}', function_id)
700729

@@ -712,17 +741,14 @@ def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: ni
712741
}
713742

714743
api_headers = {
715-
"content-type": 'multipart/form-data',
744+
"content-type": 'application/json',
716745
}
717746

718-
id_param_name = nil
719-
@client.chunked_upload(
747+
@client.call(
748+
method: 'POST',
720749
path: api_path,
721750
headers: api_headers,
722751
params: api_params,
723-
param_name: param_name,
724-
id_param_name: id_param_name,
725-
on_progress: on_progress,
726752
response_type: Models::Execution
727753
)
728754
end

0 commit comments

Comments
 (0)