Class: RestKey

Inherits:
OpenShift::Model
  • Object
show all
Defined in:
app/models/rest_key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, content, type, url, nolinks = false) ⇒ RestKey

Returns a new instance of RestKey.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/rest_key.rb', line 4

def initialize(name, content, type, url, nolinks=false)
  self.name= name
  self.content = content
  self.type = type || Key::DEFAULT_SSH_KEY_TYPE

  self.links = {
    "GET" => Link.new("Get SSH key", "GET", URI::join(url, "user/keys/#{name}")),
    "UPDATE" => Link.new("Update SSH key", "PUT", URI::join(url, "user/keys/#{name}"), [
      Param.new("type", "string", "Type of Key", Key::VALID_SSH_KEY_TYPES),
      Param.new("content", "string", "The key portion of an ssh key (excluding ssh type and comment)"),
    ]),
    "DELETE" => Link.new("Delete SSH key", "DELETE", URI::join(url, "user/keys/#{name}"))
  } unless nolinks
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



2
3
4
# File 'app/models/rest_key.rb', line 2

def content
  @content
end

Returns the value of attribute links.



2
3
4
# File 'app/models/rest_key.rb', line 2

def links
  @links
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'app/models/rest_key.rb', line 2

def name
  @name
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'app/models/rest_key.rb', line 2

def type
  @type
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



19
20
21
22
# File 'app/models/rest_key.rb', line 19

def to_xml(options={})
  options[:tag_name] = "key"
  super(options)
end