2010-05-24 13:29:01 -04:00
|
|
|
require 'fog/collection'
|
2010-05-24 14:03:52 -04:00
|
|
|
require 'fog/bluebox/models/image'
|
2010-05-24 13:29:01 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Bluebox
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
def images(attributes = {})
|
2010-05-24 14:03:52 -04:00
|
|
|
Fog::Bluebox::Images.new({
|
2010-05-24 13:29:01 -04:00
|
|
|
:connection => self
|
|
|
|
}.merge!(attributes))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
|
|
|
def images(attributes = {})
|
2010-05-24 14:03:52 -04:00
|
|
|
Fog::Bluebox::Images.new({
|
2010-05-24 13:29:01 -04:00
|
|
|
:connection => self
|
|
|
|
}.merge!(attributes))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-02 01:01:10 -04:00
|
|
|
class Images < Fog::Collection
|
2010-05-24 13:29:01 -04:00
|
|
|
|
2010-05-24 14:03:52 -04:00
|
|
|
model Fog::Bluebox::Image
|
2010-05-24 13:29:01 -04:00
|
|
|
|
|
|
|
def all
|
2010-06-02 22:38:50 -04:00
|
|
|
data = connection.get_templates.body
|
2010-05-24 13:29:01 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(template_id)
|
2010-06-02 11:44:51 -04:00
|
|
|
response = connection.get_template(template_id)
|
2010-06-02 01:01:10 -04:00
|
|
|
new(response.body)
|
2010-06-02 22:43:58 -04:00
|
|
|
rescue Excon::Errors::NotFound
|
2010-05-24 13:29:01 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|