1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/models/compute_v2/key_pair.rb

55 lines
1.7 KiB
Ruby
Raw Normal View History

2013-07-17 03:18:27 -04:00
require 'fog/core/model'
module Fog
module Compute
class RackspaceV2
class KeyPair < Fog::Model
# @!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
# @!attribute [r] private_key
# @return [String] the private key
2013-07-17 03:18:27 -04:00
attribute :private_key
# @!attribute [r] user_id
# @return [String] the user_id associated to
2013-07-17 03:18:27 -04:00
attribute :user_id
# @!attribute [r] fingerprint
# @return [String] unique fingerprint
2013-07-17 03:18:27 -04:00
attribute :fingerprint
# 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
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
# 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
requires :identity
service.delete_keypair(identity)
true
2013-07-17 03:18:27 -04:00
end
end
end
end
end