module Hyperb::Funcs

funcs api wrapper

Public Instance Methods

call_func(params = {}) click to toggle source

call a func

@see docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Func/call.html

@raise [Hyperb::Error::Unauthorized] raised when credentials are not valid. @raise [Hyperb::Error::NotFound] no such func @raise [ArgumentError] when required arguments are not provided.

@param params [Hash] A customizable set of params.

@param params :name [String] the function name. @param params :uuid [String] function uuid. @param params :sync [Boolean] block until function reply

# 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 = {}) click to toggle source

create a func

@see docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Func/create.html

@raise [Hyperb::Error::Unauthorized] raised when credentials are not valid. @raise [Hyperb::Error::Conflict] raised when func already exist @raise [Hyperb::Error::BadRequest] raised when a bad parameter is sent @raise [Hyperb::Error::InternalServerError] server error on hyper side. @raise [ArgumentError] when required arguments are not provided.

@param params [Hash] A customizable set of params.

@param params :name [String] the function name.

@param params :container_size [String] the size of containers to run the function (e.g. s1,s2, s3, s4, m1, m2, m3, l1, l2, l3)

@param params :timeout [String] default is 300 seconds, maximum is 86400 seconds. @param params :uuid [String] The uuid of function.

@param params :config [Hash] func configurations @param params config :tty [Boolean] attach streams to a tty @param params config :exposed_ports [Hash] an object mapping ports to an empty object in the form of: “ExposedPorts”: { “<port>/<tcp|udp>: {}” } @param params config :env [Array] list of env vars, “VAR=VALUE” @param params config :cmd [Array|String] list of env vars, “VAR=VALUE” @param params config :image [String] image to run @param params config :entrypoint [String] entrypoint @param params config :working_dir [String] working directory @param params config :labels [Hash] labels

@param params :host_config [Hash] func host configurations @param params host_config :links [Array] list of links @param params host_config :port_bindings [Hash] @param params host_config :publish_all_ports [Boolean] @param params host_config :volumes_from [Array] @param params host_config :network_mode [String]

# 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() click to toggle source

list funcs

@see docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Func/list.html

@raise [Hyperb::Error::Unauthorized] raised when credentials are not valid. @raise [Hyperb::Error::InternalServerError] raised hyper servers return 5xx.

@return [Hyperb::Func] Array of Funcs.

# 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 = {}) click to toggle source

remove a func

@see docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Func/remove.html

@raise [Hyperb::Error::Unauthorized] raised when credentials are not valid. @raise [Hyperb::Error::Conflict] raised when func with that name is running @raise [Hyperb::Error::BadRequest] raised when a bad parameter is sent @raise [Hyperb::Error::InternalServerError] server error on hyper side. @raise [ArgumentError] when required arguments are not provided.

@param params [Hash] A customizable set of params.

@param params :name [String] the function name.

# 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 = {}) click to toggle source

func status

@see docs.hyper.sh/Reference/API/2016-04-04%20[Ver.%201.23]/Func/status.html

@raise [Hyperb::Error::Unauthorized] raised when credentials are not valid. @raise [Hyperb::Error::InternalServerError] raised hyper servers return 5xx.

@return [Hash] Array of Funcs.

@param params [Hash] A customizable set of params.

@param params :name [String] the function name. @param params :uuid [String] the function uuid.

# 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