Class: Fog::Compute::IBM::Key

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/ibm/models/compute/key.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#default?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rackspace-fog/ibm/models/compute/key.rb', line 25

def default?
  default
end

#destroyObject



20
21
22
23
# File 'lib/rackspace-fog/ibm/models/compute/key.rb', line 20

def destroy
  data = connection.delete_key(identity)
  data.body['success']
end

#instancesObject



29
30
31
# File 'lib/rackspace-fog/ibm/models/compute/key.rb', line 29

def instances
  instance_ids.map { Fog::Compute[:ibm].servers.get(instance_id) }
end

#saveObject



13
14
15
16
17
18
# File 'lib/rackspace-fog/ibm/models/compute/key.rb', line 13

def save
  requires :name
  data = connection.create_key(name, public_key)
  merge_attributes(data.body)
  data.body['keyName'] == name
end