Class: Octopi::Key

Inherits:
Base
  • Object
show all
Includes:
Resource
Defined in:
lib/octopi/key.rb

Constant Summary

Constant Summary

Constants inherited from Base

Base::VALID

Instance Attribute Summary collapse

Attributes inherited from Base

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

for, included

Methods inherited from Base

#error=, #initialize, #property, #save

Constructor Details

This class inherits a constructor from Octopi::Base

Instance Attribute Details

#idObject

Returns the value of attribute id



5
6
7
# File 'lib/octopi/key.rb', line 5

def id
  @id
end

#keyObject

Returns the value of attribute key



5
6
7
# File 'lib/octopi/key.rb', line 5

def key
  @key
end

#titleObject

Returns the value of attribute title



5
6
7
# File 'lib/octopi/key.rb', line 5

def title
  @title
end

#userObject (readonly)

Returns the value of attribute user



8
9
10
# File 'lib/octopi/key.rb', line 8

def user
  @user
end

Class Method Details

.add(options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/octopi/key.rb', line 14

def self.add(options={})
  ensure_hash(options)
  Api.api.post("/user/key/add", { :title => options[:title], :key => options[:key], :cache => false })
  
end

.find_allObject



10
11
12
# File 'lib/octopi/key.rb', line 10

def self.find_all
  Api.api.get("user/keys")
end

Instance Method Details

#removeObject



20
21
22
23
# File 'lib/octopi/key.rb', line 20

def remove
  result = Api.api.post "/user/key/remove", { :id => id, :cache => false }
  keys = result["public_keys"].select { |k| k["title"] == title }
end