Module: Hyperb::Funcs
Overview
funcs api wrapper
Instance Method Summary collapse
-
#call_func(params = {}) ⇒ Object
call a func.
-
#create_func(params = {}) ⇒ Object
create a func.
-
#funcs ⇒ Hyperb::Func
list funcs.
-
#remove_func(params = {}) ⇒ Object
remove a func.
-
#status_func(params = {}) ⇒ Hash
func status.
Methods included from Utils
#camelize, #check_arguments, #downcase_symbolize, #prepare_json, #underscore
Instance Method Details
#call_func(params = {}) ⇒ Object
call a func
122 123 124 125 126 127 |
# File 'lib/hyperb/funcs/funcs.rb', line 122 def call_func(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name', 'uuid') path = "call/#{params[:name]}/#{params[:uuid]}" path.concat('/sync') if params.key?(:sync) && params[:sync] Hyperb::FuncCallRequest.new(self, path, {}, 'post').perform end |
#create_func(params = {}) ⇒ Object
create a func
to run the function (e.g. s1,s2, s3, s4, m1, m2, m3, l1, l2, l3)
object in the form of: “ExposedPorts”: { “<port>/<tcp|udp>: {}” }
80 81 82 83 84 85 86 87 88 |
# File 'lib/hyperb/funcs/funcs.rb', line 80 def create_func(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name') path = '/funcs/create' body = {} body.merge!(prepare_json(params)) Hyperb::Request.new(self, path, {}, 'post', body).perform end |
#funcs ⇒ Hyperb::Func
list funcs
17 18 19 20 21 22 |
# File 'lib/hyperb/funcs/funcs.rb', line 17 def funcs path = '/funcs' query = {} response = JSON.parse(Hyperb::Request.new(self, path, query, 'get').perform) response.map { |func| Hyperb::Func.new(func) } end |
#remove_func(params = {}) ⇒ Object
remove a func
103 104 105 106 107 |
# File 'lib/hyperb/funcs/funcs.rb', line 103 def remove_func(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name') path = '/funcs/' + params[:name] Hyperb::Request.new(self, path, {}, 'delete').perform end |
#status_func(params = {}) ⇒ Hash
func status
37 38 39 40 41 |
# File 'lib/hyperb/funcs/funcs.rb', line 37 def status_func(params = {}) raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name', 'uuid') path = "status/#{params[:name]}/#{params[:uuid]}" JSON.parse(Hyperb::FuncCallRequest.new(self, path, {}, 'get').perform) end |