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/ibm/models/compute/key.rb
2013-01-07 21:01:14 +00:00

35 lines
835 B
Ruby

require 'fog/core/model'
module Fog
module Compute
class IBM
class Key < Fog::Model
identity :name, :aliases => 'keyName'
attribute :default
attribute :public_key, :aliases => 'keyMaterial'
attribute :instance_ids, :aliases => 'instanceIds'
attribute :modified_at, :aliases => 'lastModifiedTime'
def save
requires :name
data = service.create_key(name, public_key)
merge_attributes(data.body)
data.body['keyName'] == name
end
def destroy
data = service.delete_key(identity)
data.body['success']
end
def default?
default
end
def instances
instance_ids.map { Fog::Compute[:ibm].servers.get(instance_id) }
end
end
end
end
end