Class: Fog::Compute::RackspaceV2::KeyPairs

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/rackspace/models/compute_v2/key_pairs.rb

Instance Method Summary collapse

Instance Method Details

#allFog::Compute::RackspaceV2::Keypairs

Fetch the list of known keypairs

Returns:

  • (Fog::Compute::RackspaceV2::Keypairs)

    the retreived keypairs

Raises:



16
17
18
19
20
21
22
# File 'lib/fog/rackspace/models/compute_v2/key_pairs.rb', line 16

def all
  data = []
  service.list_keypairs.body['keypairs'].each do |kp|
    data << kp['keypair'] if kp['keypair']
  end
  load(data)
end

#get(key_name) ⇒ Fog::Compute::RackspaceV2::Keypair

Fetch keypair details

Parameters:

  • key_name (String)

    name of the key to request

Returns:

  • (Fog::Compute::RackspaceV2::Keypair)

    the requested keypair or ‘nil’ when not found

Raises:



30
31
32
33
34
35
36
# File 'lib/fog/rackspace/models/compute_v2/key_pairs.rb', line 30

def get(key_name)
    begin
        new(service.get_keypair(key_name).body['keypair'])
    rescue Fog::Compute::RackspaceV2::NotFound
        nil
    end
end