class RHC::Rest::Key

Attributes

content[R]
name[R]
type[R]

Public Class Methods

new(args) click to toggle source
# File lib/rhc/rest/key.rb, line 6
def initialize(args)
  @name = args[:name] || args["name"]
  @type = args[:type] || args["type"]
  @content = args[:content] || args["content"]
  @links = args[:links] || args["links"]
end

Public Instance Methods

delete() click to toggle source
Alias for: destroy
destroy() click to toggle source

Delete Key

# File lib/rhc/rest/key.rb, line 24
def destroy
  logger.debug "Deleting key #{self.name}" if @mydebug
  url = @links['DELETE']['href']
  method =  @links['DELETE']['method']
  request = new_request(:url => url, :method => method, :headers => @@headers)
  return request(request)
end
Also aliased as: delete
fingerprint() click to toggle source
# File lib/rhc/rest/key.rb, line 33
def fingerprint
  begin
    public_key = Net::SSH::KeyFactory.load_data_public_key("#{type} #{content}")
    public_key.fingerprint
  rescue NotImplementedError, OpenSSL::PKey::PKeyError => e
    'Invalid key'
  end
  
end
update(type, content) click to toggle source

Update Key

# File lib/rhc/rest/key.rb, line 14
def update(type, content)
  logger.debug "Updating key #{self.name}" if @mydebug
  url = @links['UPDATE']['href']
  method =  @links['UPDATE']['method']
  payload = {:type => type, :content => content}
  request = new_request(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return request(request)
end