Module: Miasma::Contrib::Lxd::Api
- Included in:
- Models::Compute::Lxd
- Defined in:
- lib/miasma/contrib/lxd.rb
Overview
API updates required for LXD communication
Constant Summary collapse
- DEFAULT_API_VERSION =
Default API version to require
'1.0'
Class Method Summary collapse
-
.included(klass) ⇒ Object
Load required attributes into API class.
Instance Method Summary collapse
-
#custom_setup(args) ⇒ Object
Clean up endpoint prior to data loading.
-
#endpoint ⇒ String
Versioned endpoint.
-
#make_request(connection, http_method, request_args) ⇒ HTTP::Response
Perform request.
Class Method Details
.included(klass) ⇒ Object
Load required attributes into API class
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/miasma/contrib/lxd.rb', line 15 def self.included(klass) klass.class_eval do attribute :name, String, :required => true, :default => Socket.gethostname attribute :password, String attribute :api_endpoint, String, :required => true attribute :ssl_certificate, String, :required => true attribute :ssl_key, String, :required => true attribute :version, Gem::Version, :coerce => lambda{|v| Gem::Version.new(v.to_s)}, :required => true, :default => lambda{ Miasma::Contrib::Lxd::Api::DEFAULT_API_VERSION } end end |
Instance Method Details
#custom_setup(args) ⇒ Object
Clean up endpoint prior to data loading
34 35 36 37 38 |
# File 'lib/miasma/contrib/lxd.rb', line 34 def custom_setup(args) if(args[:api_endpoint].to_s.end_with?('/')) args[:api_endpoint] = args[:api_endpoint][0, endpoint.length - 1] end end |
#endpoint ⇒ String
Returns versioned endpoint.
27 28 29 |
# File 'lib/miasma/contrib/lxd.rb', line 27 def endpoint "#{api_endpoint}/#{version}" end |
#make_request(connection, http_method, request_args) ⇒ HTTP::Response
Perform request
46 47 48 49 50 51 |
# File 'lib/miasma/contrib/lxd.rb', line 46 def make_request(connection, http_method, request_args) dest, = request_args = Smash.new unless [:ssl_context] = ssl_context connection.send(http_method, dest, ) end |