certificate.rb
621 Bytes
class Lxd::Certificate
include ActiveModel::Model
attr_accessor :api, :uri, :type, :certificate, :fingerprint
def self.all api
return [] unless api
api.certificates.map { |cert|
Lxd::Certificate.new({api: api}.merge cert)
}
end
def add password=nil, name='lex-deeit'
data = Hash.new
data[:type] = if @type then @type else 'client' end
data[:name] = name
data[:password] = password if password
data[:certificate] = @certificate if @certificate
@api.add_certificate data
end
def delete
@api.delete_certificate @fingerprint
end
end
# vim: set et ts=2 sw=2: