Sha256: 562ad6cbf116cc86adadb0181018842880355f9afa9a0a240d90405b5293d017

Contents?: true

Size: 1.49 KB

Versions: 39

Compression:

Stored size: 1.49 KB

Contents

require 'fog/core/collection'
require 'fog/rackspace/models/compute_v2/flavor'

module Fog
  module Compute
    class RackspaceV2
      class Flavors < Fog::Collection
        model Fog::Compute::RackspaceV2::Flavor

        # Retrieves information for all available flavors
        # @return [Fog::Compute::RackspaceV2::Flavors] list of flavors
        # @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]
        # @note Fog's currentl implementation only returns 1000 flavors.
        def all
          data = service.list_flavors_detail.body['flavors']
          load(data)
        end

        # Retrieve image
        # @param [String] flavor_id id of flavor
        # @return [Fog::Compute::RackspaceV2::Flavor] flavor
        # @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]
        # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Get_Flavor_Details-d1e4317.html
        def get(flavor_id)
          data = service.get_flavor(flavor_id).body['flavor']
          new(data)
        rescue Fog::Compute::RackspaceV2::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

39 entries across 37 versions & 6 rubygems

Version Path
fog-rackspace-0.1.6 lib/fog/rackspace/models/compute_v2/flavors.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/compute_v2/flavors.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/compute_v2/flavors.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.5 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.4 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.3 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.2 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.1 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-rackspace-0.1.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.37.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.36.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.35.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-2.0.0.pre.0 lib/fog/rackspace/models/compute_v2/flavors.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.34.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.33.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.32.0 lib/fog/rackspace/models/compute_v2/flavors.rb
fog-1.31.0 lib/fog/rackspace/models/compute_v2/flavors.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rackspace/models/compute_v2/flavors.rb