Skip to content

Commit

Permalink
chore: update SDKs to new RC version
Browse files Browse the repository at this point in the history
  • Loading branch information
christyjacob4 committed Aug 20, 2024
1 parent 35e13f6 commit b7913a4
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 16 deletions.
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|

spec.name = 'appwrite'
spec.version = '12.0.0-rc.1'
spec.version = '12.0.0-rc.2'
spec.license = 'BSD-3-Clause'
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'
spec.author = 'Appwrite Team'
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/functions/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ result = functions.create(
template_repository: '<TEMPLATE_REPOSITORY>', # optional
template_owner: '<TEMPLATE_OWNER>', # optional
template_root_directory: '<TEMPLATE_ROOT_DIRECTORY>', # optional
template_version: '<TEMPLATE_VERSION>' # optional
template_version: '<TEMPLATE_VERSION>', # optional
specification: '' # optional
)
12 changes: 12 additions & 0 deletions docs/examples/functions/list-specifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'appwrite'

include Appwrite

client = Client.new
.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
.set_project('&lt;YOUR_PROJECT_ID&gt;') # Your project ID
.set_key('&lt;YOUR_API_KEY&gt;') # Your secret API key

functions = Functions.new(client)

result = functions.list_specifications()
3 changes: 2 additions & 1 deletion docs/examples/functions/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ result = functions.update(
provider_repository_id: '<PROVIDER_REPOSITORY_ID>', # optional
provider_branch: '<PROVIDER_BRANCH>', # optional
provider_silent_mode: false, # optional
provider_root_directory: '<PROVIDER_ROOT_DIRECTORY>' # optional
provider_root_directory: '<PROVIDER_ROOT_DIRECTORY>', # optional
specification: '' # optional
)
2 changes: 2 additions & 0 deletions lib/appwrite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
require_relative 'appwrite/models/topic_list'
require_relative 'appwrite/models/subscriber_list'
require_relative 'appwrite/models/target_list'
require_relative 'appwrite/models/specification_list'
require_relative 'appwrite/models/database'
require_relative 'appwrite/models/collection'
require_relative 'appwrite/models/attribute_list'
Expand Down Expand Up @@ -96,6 +97,7 @@
require_relative 'appwrite/models/health_certificate'
require_relative 'appwrite/models/health_time'
require_relative 'appwrite/models/headers'
require_relative 'appwrite/models/specification'
require_relative 'appwrite/models/mfa_challenge'
require_relative 'appwrite/models/mfa_recovery_codes'
require_relative 'appwrite/models/mfa_type'
Expand Down
2 changes: 1 addition & 1 deletion lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize
'x-sdk-name'=> 'Ruby',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'ruby',
'x-sdk-version'=> '12.0.0-rc.1',
'x-sdk-version'=> '12.0.0-rc.2',
'X-Appwrite-Response-Format' => '1.6.0'
}
@endpoint = 'https://cloud.appwrite.io/v1'
Expand Down
11 changes: 8 additions & 3 deletions lib/appwrite/models/function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Function
attr_reader :provider_branch
attr_reader :provider_root_directory
attr_reader :provider_silent_mode
attr_reader :specification

def initialize(
id:,
Expand All @@ -50,7 +51,8 @@ def initialize(
provider_repository_id:,
provider_branch:,
provider_root_directory:,
provider_silent_mode:
provider_silent_mode:,
specification:
)
@id = id
@created_at = created_at
Expand All @@ -75,6 +77,7 @@ def initialize(
@provider_branch = provider_branch
@provider_root_directory = provider_root_directory
@provider_silent_mode = provider_silent_mode
@specification = specification
end

def self.from(map:)
Expand All @@ -101,7 +104,8 @@ def self.from(map:)
provider_repository_id: map["providerRepositoryId"],
provider_branch: map["providerBranch"],
provider_root_directory: map["providerRootDirectory"],
provider_silent_mode: map["providerSilentMode"]
provider_silent_mode: map["providerSilentMode"],
specification: map["specification"]
)
end

Expand Down Expand Up @@ -129,7 +133,8 @@ def to_map
"providerRepositoryId": @provider_repository_id,
"providerBranch": @provider_branch,
"providerRootDirectory": @provider_root_directory,
"providerSilentMode": @provider_silent_mode
"providerSilentMode": @provider_silent_mode,
"specification": @specification
}
end
end
Expand Down
42 changes: 42 additions & 0 deletions lib/appwrite/models/specification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#frozen_string_literal: true

module Appwrite
module Models
class Specification
attr_reader :memory
attr_reader :cpus
attr_reader :enabled
attr_reader :slug

def initialize(
memory:,
cpus:,
enabled:,
slug:
)
@memory = memory
@cpus = cpus
@enabled = enabled
@slug = slug
end

def self.from(map:)
Specification.new(
memory: map["memory"],
cpus: map["cpus"],
enabled: map["enabled"],
slug: map["slug"]
)
end

def to_map
{
"memory": @memory,
"cpus": @cpus,
"enabled": @enabled,
"slug": @slug
}
end
end
end
end
32 changes: 32 additions & 0 deletions lib/appwrite/models/specification_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#frozen_string_literal: true

module Appwrite
module Models
class SpecificationList
attr_reader :total
attr_reader :specifications

def initialize(
total:,
specifications:
)
@total = total
@specifications = specifications
end

def self.from(map:)
SpecificationList.new(
total: map["total"],
specifications: map["specifications"].map { |it| Specification.from(map: it) }
)
end

def to_map
{
"total": @total,
"specifications": @specifications.map { |it| it.to_map }
}
end
end
end
end
44 changes: 35 additions & 9 deletions lib/appwrite/services/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def list(queries: nil, search: nil)
# @param [String] template_owner The name of the owner of the template.
# @param [String] template_root_directory Path to function code in the template repo.
# @param [String] template_version Version (tag) for the repo linked to the function template.
# @param [String] specification Runtime specification for the function and builds.
#
# @return [Function]
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)
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)
api_path = '/functions'

if function_id.nil?
Expand Down Expand Up @@ -101,6 +102,7 @@ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: n
templateOwner: template_owner,
templateRootDirectory: template_root_directory,
templateVersion: template_version,
specification: specification,
}

api_headers = {
Expand Down Expand Up @@ -141,6 +143,31 @@ def list_runtimes()
end


# List allowed function specifications for this instance.
#
#
#
# @return [SpecificationList]
def list_specifications()
api_path = '/functions/specifications'

api_params = {
}

api_headers = {
"content-type": 'application/json',
}

@client.call(
method: 'GET',
path: api_path,
headers: api_headers,
params: api_params,
response_type: Models::SpecificationList
)
end


# List available function templates. You can use template details in
# [createFunction](/docs/references/cloud/server-nodejs/functions#create)
# method.
Expand Down Expand Up @@ -256,9 +283,10 @@ def get(function_id:)
# @param [String] provider_branch Production branch for the repo linked to the function
# @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.
# @param [String] provider_root_directory Path to function code in the linked repo.
# @param [String] specification Runtime specification for the function and builds.
#
# @return [Function]
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)
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)
api_path = '/functions/{functionId}'
.gsub('{functionId}', function_id)

Expand Down Expand Up @@ -287,6 +315,7 @@ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedul
providerBranch: provider_branch,
providerSilentMode: provider_silent_mode,
providerRootDirectory: provider_root_directory,
specification: specification,
}

api_headers = {
Expand Down Expand Up @@ -694,7 +723,7 @@ def list_executions(function_id:, queries: nil, search: nil)
# @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.
#
# @return [Execution]
def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil, on_progress: nil)
def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil)
api_path = '/functions/{functionId}/executions'
.gsub('{functionId}', function_id)

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

api_headers = {
"content-type": 'multipart/form-data',
"content-type": 'application/json',
}

id_param_name = nil
@client.chunked_upload(
@client.call(
method: 'POST',
path: api_path,
headers: api_headers,
params: api_params,
param_name: param_name,
id_param_name: id_param_name,
on_progress: on_progress,
response_type: Models::Execution
)
end
Expand Down

0 comments on commit b7913a4

Please sign in to comment.