Sha256: faf8eb5265d8d55d6d3bc6704a6200ff1e4b6c015c2082920ec0c4af446525a8

Contents?: true

Size: 899 Bytes

Versions: 4

Compression:

Stored size: 899 Bytes

Contents

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
          if new_key_pair = key_pairs.get(@name)
            merge_attributes(new_key_pair.attributes)
          end
        end

        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

        private

        def key_pairs=(new_key_pairs)
          @key_pairs = new_key_pairs
        end

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.0.29 lib/fog/aws/models/ec2/key_pair.rb
fog-0.0.28 lib/fog/aws/models/ec2/key_pair.rb
fog-0.0.27 lib/fog/aws/models/ec2/key_pair.rb
fog-0.0.26 lib/fog/aws/models/ec2/key_pair.rb