Sha256: f654ebafbb1b91bcd8e659b69abd95063e779874051b2676a75669cac1922e57

Contents?: true

Size: 950 Bytes

Versions: 23

Compression:

Stored size: 950 Bytes

Contents

require 'fog/core/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

23 entries across 23 versions & 3 rubygems

Version Path
fog-0.5.3 lib/fog/compute/models/aws/key_pair.rb
fog-0.5.2 lib/fog/compute/models/aws/key_pair.rb
fog-0.5.1 lib/fog/compute/models/aws/key_pair.rb
fog-0.5.0 lib/fog/compute/models/aws/key_pair.rb
phpfog-fog-0.4.1.3 lib/fog/compute/models/aws/key_pair.rb
phpfog-fog-0.4.1.2 lib/fog/compute/models/aws/key_pair.rb
phpfog-fog-0.4.1.1 lib/fog/compute/models/aws/key_pair.rb
phpfog-fog-0.4.1 lib/fog/compute/models/aws/key_pair.rb
fog-0.4.1 lib/fog/compute/models/aws/key_pair.rb
fog-0.4.0 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.34 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.33 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.32 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.31 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.30 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.29 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.28 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.27 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.26 lib/fog/aws/models/compute/key_pair.rb
fog-0.3.25 lib/fog/aws/models/compute/key_pair.rb