Sha256: 0a936af103167a355eb295585e13d8792621d007b56f3d338151a08559007903

Contents?: true

Size: 946 Bytes

Versions: 8

Compression:

Stored size: 946 Bytes

Contents

require 'fog/model'

module Fog
  module AWS
    class Compute

      class KeyPair < Fog::Model
        extend Fog::Deprecation
        deprecate(:material, :private_key)

        identity  :name,        :aliases => 'keyName'

        attribute :fingerprint, :aliases => 'keyFingerprint'
        attribute :private_key, :aliases => 'keyMaterial'

        attr_accessor :public_key

        def destroy
          requires :name

          connection.delete_key_pair(@name)
          true
        end

        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

        private

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.3.7 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.6 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.5 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.4 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.3 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.2 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.1 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.0 lib/fog/aws/models/compute/key_pair.rb