class Lxd::API::V1_0 include Lxd::API def config get '/1.0' end def config= config={} put '/1.0', config: config end def certificates get('/1.0/certificates').map { |uri| { :uri => uri }.merge get(uri) } end def add_certificate data={} # TODO validate hash post '/1.0/certificates', data end def delete_certificate fingerprint delete '/1.0/certificates/' + fingerprint end def handle_response resp """ 100 Operation created 101 Started 102 Stopped 103 Running 104 Cancelling 105 Pending 106 Starting 107 Stopping 108 Aborting 109 Freezing 110 Frozen 111 Thawed 200 Success 400 Failure 401 Cancelled 100 to 199: resource state (started, stopped, ready, ...) 200 to 399: positive action result 400 to 599: negative action result 600 to 999: future use """ if resp['error_code'] and resp['error_code'] != 403 raise Lxd::API::Exception( "api error: (#{resp['error_code']}) #{resp['error']}" ) end resp['metadata'] end end # vim: set et ts=2 sw=2: