Class: Fog::AWS::EC2::KeyPairs

Inherits:
Collection show all
Defined in:
lib/fog/aws/models/ec2/key_pairs.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Fog::Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Attributes::InstanceMethods

#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

#initialize(attributes) ⇒ KeyPairs

Returns a new instance of KeyPairs.



20
21
22
23
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 20

def initialize(attributes)
  @key_name ||= []
  super
end

Instance Method Details

#all(key_name = @key_name) ⇒ Object



25
26
27
28
29
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 25

def all(key_name = @key_name)
  @key_name = key_name
  data = connection.describe_key_pairs(key_name).body
  load(data['keySet'])
end

#get(key_name) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/fog/aws/models/ec2/key_pairs.rb', line 31

def get(key_name)
  if key_name
    all(key_name).first
  end
rescue Fog::Errors::NotFound
  nil
end