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
|
|
|
|
data = connection.get_templates.body['templates']
|
|
|
|
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)
|
|
|
|
rescue Excon::Errors::Forbidden, Excon::Errors::NotFound
|
2010-05-24 13:29:01 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|