mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
42 lines
891 B
Ruby
42 lines
891 B
Ruby
module Fog
|
|
module AWS
|
|
class EC2
|
|
|
|
class KeyPair < Fog::Model
|
|
|
|
attribute :fingerprint, 'keyFingerprint'
|
|
attribute :material, 'keyMaterial'
|
|
attribute :name, 'keyName'
|
|
|
|
def destroy
|
|
connection.delete_key_pair(@name)
|
|
true
|
|
end
|
|
|
|
def key_pairs
|
|
@key_pairs
|
|
end
|
|
|
|
def reload
|
|
new_attributes = key_pairs.all(@name).first.attributes
|
|
merge_attributes(new_attributes)
|
|
end
|
|
|
|
def save
|
|
data = connection.create_key_pair(@name).body
|
|
new_attributes = data.reject {|key,value| !['keyFingerprint', 'keyMaterial', 'keyName'].include?(key)}
|
|
update_attributes(new_attributes)
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def key_pairs=(new_key_pairs)
|
|
@key_pairs = new_key_pairs
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|