Class: Rhc::Rest::Key

Inherits:
Object
  • Object
show all
Includes:
Rhc::Rest
Defined in:
lib/rhc-rest/key.rb

Constant Summary

Constants included from Rhc::Rest

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Rhc::Rest

#logger, #parse_response, #process_error_response, #send

Constructor Details

#initialize(args) ⇒ Key

Returns a new instance of Key.



6
7
8
9
10
11
# 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

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/rhc-rest/key.rb', line 5

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rhc-rest/key.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/rhc-rest/key.rb', line 5

def type
  @type
end

Instance Method Details

#destroyObject Also known as: delete

Delete Key



24
25
26
27
28
29
30
# 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 = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
  return send(request)
end

#update(type, content) ⇒ Object

Update Key



14
15
16
17
18
19
20
21
# 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 = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
  return send(request)
end