Class: Rubineti::Compute
- Inherits:
-
Object
- Object
- Rubineti::Compute
- Defined in:
- lib/rubineti/compute.rb
Constant Summary collapse
- Headers =
{ :json => "application/json" }.freeze
Instance Method Summary collapse
-
#initialize(options) ⇒ Compute
constructor
Required:
user
: A String containing the username for use in HTTP Basic auth. -
#m ⇒ Object
Include endpoints.
-
#verb ⇒ Object
Perform an HTTP get, delete, post, or put.
Constructor Details
#initialize(options) ⇒ Compute
Required: user
: A String containing the username for use in HTTP Basic auth. password
: A String containing the password for use in HTTP Basic auth. host
: A String with the host to connect.
25 26 27 28 29 30 31 32 33 |
# File 'lib/rubineti/compute.rb', line 25 def initialize @user = [:user] @password = [:password] @host = [:host] @port = [:port] || 5080 @scheme = [:scheme] || "https" requires [:user, :password, :host] end |
Instance Method Details
#m ⇒ Object
Include endpoints. TODO: meta; discover the endpoints?
14 15 16 17 |
# File 'lib/rubineti/compute.rb', line 14 %w(jobs instances cluster node).each do |m| require "rubineti/compute/#{m}" include eval "Rubineti::#{m.capitalize}" end |
#verb ⇒ Object
Perform an HTTP get, delete, post, or put. path
: A String with the path to the HTTP resource. params
: A Hash with the following keys:
- +:query+: Query String in the format "foo=bar"
- +:body+: A sub Hash to be JSON encoded, and posted in
the message body.
43 44 45 46 47 48 49 50 51 |
# File 'lib/rubineti/compute.rb', line 43 %w(get delete post put).each do |verb| define_method verb do |*args| path = args[0] params = args[1] || {} clazz = eval "Net::HTTP::#{verb.capitalize}" parse response_for(clazz, path, params) end end |