Class: Fog::AWS::Compute::KeyPair

Inherits:
Model
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/compute/models/aws/key_pair.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods included from Deprecation

deprecate, self_deprecate

Methods inherited from Model

#initialize, #inspect, #reload, #to_json, #wait_for

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

This class inherits a constructor from Fog::Model

Instance Attribute Details

#public_keyObject

Returns the value of attribute public_key.



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

def public_key
  @public_key
end

Instance Method Details

#destroyObject



18
19
20
21
22
23
# File 'lib/fog/compute/models/aws/key_pair.rb', line 18

def destroy
  requires :name

  connection.delete_key_pair(name)
  true
end

#saveObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/models/aws/key_pair.rb', line 25

def save
  requires :name

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