Class: Colombo::SshKeys

Inherits:
Container show all
Defined in:
lib/colombo/ssh_keys.rb

Instance Method Summary collapse

Methods inherited from Container

#find, #method_missing, #run_find_by_attr

Constructor Details

#initialize(client) ⇒ SshKeys

Returns a new instance of SshKeys.



8
9
10
11
12
13
14
15
# File 'lib/colombo/ssh_keys.rb', line 8

def initialize(client)
  @client = client
  @client.request(:get, '/ssh_keys/', {}) do |response|
     response['ssh_keys'].each do |ssh_key|
        self << SshKey.new(@client, ssh_key)
     end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Colombo::Container

Instance Method Details

#create(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/colombo/ssh_keys.rb', line 17

def create(options={})

  params = {
    :ssh_pub_key => options[:ssh_pub_key],
    :name        => options[:name]
  }

  ssh_key = nil

  response = @client.request(:get, "/ssh_keys/new/", params) do |response|
    ssh_key = SshKey.new(@client, response['ssh_key'])
    self << ssh_key
  end

  ssh_key
end