Class: Fog::AWS::EC2::KeyPair

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/ec2/key_pair.rb

Instance Method Summary collapse

Methods inherited from Model

aliases, attribute, #attributes, attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject



11
12
13
14
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 11

def destroy
  connection.delete_key_pair(@name)
  true
end

#key_pairsObject



16
17
18
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 16

def key_pairs
  @key_pairs
end

#reloadObject



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

def reload
  if new_key_pair = key_pairs.get(@name)
    merge_attributes(new_key_pair.attributes)
  end
end

#saveObject



26
27
28
29
30
31
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 26

def save
  data = connection.create_key_pair(@name).body
  new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
  merge_attributes(new_attributes)
  true
end