2012-07-30 16:50:16 -04:00
|
|
|
require 'fog/core/collection'
|
2012-07-30 18:22:16 -04:00
|
|
|
require 'fog/rackspace/models/compute_v2/flavor'
|
2012-07-30 16:50:16 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
|
|
|
class Flavors < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::RackspaceV2::Flavor
|
|
|
|
|
2013-01-30 10:05:10 -05:00
|
|
|
# Retrieves information for all available flavors
|
2013-03-27 10:50:30 -04:00
|
|
|
# @return [Fog::Compute::RackspaceV2::Flavors] list of flavors
|
2013-04-15 14:12:14 -04:00
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-01-30 10:05:10 -05:00
|
|
|
# @note Fog's currentl implementation only returns 1000 flavors.
|
|
|
|
# @note Fog does not retrieve all flavor details. Please use #get to retrieve all details for a specific flavor.
|
2012-07-30 16:50:16 -04:00
|
|
|
def all
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_flavors.body['flavors']
|
2012-07-30 16:50:16 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2013-01-30 10:05:10 -05:00
|
|
|
# Retrieve image
|
|
|
|
# @param [String] flavor_id id of flavor
|
|
|
|
# @return [Fog::Compute::RackspaceV2::Flavor] flavor
|
2013-04-15 14:12:14 -04:00
|
|
|
# @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
|
|
|
|
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
2013-01-30 10:05:10 -05:00
|
|
|
# @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Get_Flavor_Details-d1e4317.html
|
|
|
|
def get(flavor_id)
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.get_flavor(flavor_id).body['flavor']
|
2012-07-30 16:50:16 -04:00
|
|
|
new(data)
|
|
|
|
rescue Fog::Compute::RackspaceV2::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|