Class: Fog::Image::OpenStack::Image

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/models/image/image.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#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

#initialize(attributes) ⇒ Image

Returns a new instance of Image.



34
35
36
37
# File 'lib/fog/openstack/models/image/image.rb', line 34

def initialize(attributes)
  @connection = attributes[:connection]
  super
end

Instance Method Details

#add_member(member_id) ⇒ Object



62
63
64
65
# File 'lib/fog/openstack/models/image/image.rb', line 62

def add_member(member_id)
  requires :id
  connection.add_member_to_image(self.id, member_id)
end

#createObject



44
45
46
47
48
# File 'lib/fog/openstack/models/image/image.rb', line 44

def create
  requires :name
  merge_attributes(connection.create_image(self.attributes).body['image'])
    self
end

#destroyObject



56
57
58
59
60
# File 'lib/fog/openstack/models/image/image.rb', line 56

def destroy
  requires :id
  connection.delete_image(self.id)
  true
end

#membersObject



72
73
74
75
# File 'lib/fog/openstack/models/image/image.rb', line 72

def members
  requires :id
  connection.get_image_members(self.id).body['members']
end

#metadataObject



77
78
79
80
# File 'lib/fog/openstack/models/image/image.rb', line 77

def 
  requires :id
  connection.get_image(self.id).headers
end

#remove_member(member_id) ⇒ Object



67
68
69
70
# File 'lib/fog/openstack/models/image/image.rb', line 67

def remove_member(member_id)
  requires :id
  connection.remove_member_from_image(self.id, member_id)
end

#saveObject



39
40
41
42
# File 'lib/fog/openstack/models/image/image.rb', line 39

def save
  requires :name
  identity ? update : create
end

#updateObject



50
51
52
53
54
# File 'lib/fog/openstack/models/image/image.rb', line 50

def update
  requires :name
  merge_attributes(connection.update_image(self.attributes).body['image'])
  self
end