2013-07-17 03:18:27 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
2013-07-31 15:12:43 -04:00
|
|
|
class KeyPair < Fog::Model
|
2013-07-26 10:04:29 -04:00
|
|
|
# @!attribute [rw] name
|
|
|
|
# @return [String] the keypair name
|
|
|
|
identity :name
|
|
|
|
|
|
|
|
# @!attribute [r] public_key
|
|
|
|
# @return [String] the public key
|
2013-07-17 03:18:27 -04:00
|
|
|
attribute :public_key
|
2013-07-26 10:04:29 -04:00
|
|
|
|
|
|
|
# @!attribute [r] private_key
|
|
|
|
# @return [String] the private key
|
2013-07-17 03:18:27 -04:00
|
|
|
attribute :private_key
|
2013-07-26 10:04:29 -04:00
|
|
|
|
|
|
|
# @!attribute [r] user_id
|
|
|
|
# @return [String] the user_id associated to
|
2013-07-17 03:18:27 -04:00
|
|
|
attribute :user_id
|
2013-07-26 10:04:29 -04:00
|
|
|
|
|
|
|
# @!attribute [r] fingerprint
|
|
|
|
# @return [String] unique fingerprint
|
2013-07-17 03:18:27 -04:00
|
|
|
attribute :fingerprint
|
|
|
|
|
2013-07-26 10:04:29 -04:00
|
|
|
# Creates a keypair
|
|
|
|
# @return [Boolean] true if the keypair is successfully created
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-07-17 03:18:27 -04:00
|
|
|
def save
|
|
|
|
requires :name
|
2014-01-08 10:18:17 -05:00
|
|
|
data = service.create_keypair(name, attributes)
|
2013-07-17 03:18:27 -04:00
|
|
|
merge_attributes(data.body['keypair'])
|
|
|
|
data.body['keypair']['name'] == name
|
|
|
|
end
|
|
|
|
|
2013-07-26 10:04:29 -04:00
|
|
|
# Destroys a keypair
|
|
|
|
# @return [Boolean] true if the keypair is successfully deleted
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError]
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-07-17 03:18:27 -04:00
|
|
|
def destroy
|
2013-07-26 09:00:45 -04:00
|
|
|
requires :identity
|
|
|
|
service.delete_keypair(identity)
|
2013-07-25 16:58:05 -04:00
|
|
|
true
|
2013-07-17 03:18:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|