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, #service

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 Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

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

Constructor Details

#initialize(attributes) ⇒ Image

Returns a new instance of Image.



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

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#add_member(member_id) ⇒ Object



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

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

#createObject



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

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

#destroyObject



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

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

#membersObject



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

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

#metadataObject



83
84
85
86
# File 'lib/fog/openstack/models/image/image.rb', line 83

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

#remove_member(member_id) ⇒ Object



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

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

#saveObject



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

def save
  requires :name
  identity ? update : create
end

#updateObject



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

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

#update_members(members) ⇒ Object



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

def update_members(members)
  requires :id
  service.update_image_members(self.id, members)
end