Class: Fog::Image::OpenStack::V1::Images

Inherits:
OpenStack::Collection show all
Defined in:
lib/fog/openstack/models/image_v1/images.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from OpenStack::Collection

#load_response

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/fog/openstack/models/image_v1/images.rb', line 46

def method_missing(method_sym, *arguments, &block)
  if method_sym.to_s =~ /^find_by_(.*)$/
    load(service.list_public_images_detailed($1 ,arguments.first).body['images'])
  else
    super
  end
end

Instance Method Details

#all(options = {}) ⇒ Object



12
13
14
# File 'lib/fog/openstack/models/image_v1/images.rb', line 12

def all(options = {})
  load_response(service.list_public_images_detailed(options), 'images')
end

#destroy(id) ⇒ Object



41
42
43
44
# File 'lib/fog/openstack/models/image_v1/images.rb', line 41

def destroy(id)
  image = self.find_by_id(id)
  image.destroy
end

#details(options = {}, deprecated_query = nil) ⇒ Object



20
21
22
23
24
# File 'lib/fog/openstack/models/image_v1/images.rb', line 20

def details(options = {}, deprecated_query = nil)
  Fog::Logger.deprecation("Calling OpenStack[:glance].images.details will be removed, "\
                          " call .images.all for detailed list.")
  load_response(service.list_public_images_detailed(options, deprecated_query), 'images')
end

#find_attribute(attribute, value) ⇒ Object



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

def find_attribute(attribute,value)
  attribute = attribute.to_s.gsub("find_by_", "")
  load(service.list_public_images_detailed(attribute , value).body['images'])
end

#find_by_id(id) ⇒ Object Also known as: get



26
27
28
# File 'lib/fog/openstack/models/image_v1/images.rb', line 26

def find_by_id(id)
  all.find {|image| image.id == id}
end

#find_by_size_max(size) ⇒ Object



58
59
60
# File 'lib/fog/openstack/models/image_v1/images.rb', line 58

def find_by_size_max(size)
  find_attribute(__method__, size)
end

#find_by_size_min(size) ⇒ Object



54
55
56
# File 'lib/fog/openstack/models/image_v1/images.rb', line 54

def find_by_size_min(size)
  find_attribute(__method__, size)
end

#privateObject



36
37
38
39
# File 'lib/fog/openstack/models/image_v1/images.rb', line 36

def private
  images = load(service.list_public_images_detailed.body['images'])
  images.delete_if{|image| image.is_public}
end

#publicObject



31
32
33
34
# File 'lib/fog/openstack/models/image_v1/images.rb', line 31

def public
  images = load(service.list_public_images_detailed.body['images'])
  images.delete_if{|image| image.is_public == false}
end

#summary(options = {}) ⇒ Object



16
17
18
# File 'lib/fog/openstack/models/image_v1/images.rb', line 16

def summary(options = {})
  load_response(service.list_public_images(options), 'images')
end