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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#inspect, #update_attributes

Constructor Details

#initialize(attributes = {}) ⇒ KeyPair

Returns a new instance of KeyPair.



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

def initialize(attributes = {})
  remap_attributes(attributes, {
    'keyFingerprint'  => :fingerprint,
    'keyMaterial'     => :material,
    'keyName'         => :name
  })
  super
end

Instance Attribute Details

#fingerprintObject

Returns the value of attribute fingerprint.



7
8
9
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 7

def fingerprint
  @fingerprint
end

#materialObject

Returns the value of attribute material.



7
8
9
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 7

def material
  @material
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/fog/aws/models/ec2/key_pair.rb', line 7

def name
  @name
end

Instance Method Details

#deleteObject



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

def delete
  connection.delete_key_pair(@name)
end

#saveObject



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

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