Sha256: fc7fc656d08e3dc4f2521ae7016e27e2f6c568d1977f6fef9375ead8557e6108

Contents?: true

Size: 1.84 KB

Versions: 79

Compression:

Stored size: 1.84 KB

Contents

module Fog
  module Compute
    class Linode
      class Real

        # Get available distributions
        #
        # ==== Parameters
        # * distributionId<~Integer>: id to limit results to
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Array>:
        # TODO: docs
        def avail_distributions(distribution_id=nil)
          options = {}
          if distribution_id
            options.merge!(:distributionId => distribution_id)
          end
          request(
            :expects  => 200,
            :method   => 'GET',
            :query    => { :api_action => 'avail.distributions' }.merge!(options)
          )
        end

      end

      class Mock
        def avail_distributions(distribution_id=nil)
          response = Excon::Response.new
          response.status = 200

          body = {
            "ERRORARRAY" => [],
            "ACTION" => "avail.distributions"
          }
          if distribution_id
            mock_distribution = create_mock_distribution(distribution_id)
            response.body = body.merge("DATA" => [mock_distribution])
          else
            mock_distributions = []
            10.times do
              distribution_id = rand(1..99)
              mock_distributions << create_mock_distribution(distribution_id)
            end
            response.body = body.merge("DATA" => mock_distributions)
          end
          response
        end

        private

        def create_mock_distribution(distribution_id)
          {
            "CREATE_DT"           => "2012-04-26 17:25:16.0",
            "DISTRIBUTIONID"      => distribution_id,
            "IS64BIT"             => 0,
            "LABEL"               => "Ubuntu 12.04 LTS",
            "MINIMAGESIZE"        => 600,
            "REQUIRESPVOPSKERNEL" => 1
          }
        end
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 12 rubygems

Version Path
fog-1.22.0 lib/fog/linode/requests/compute/avail_distributions.rb
fog-1.21.0 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/linode/requests/compute/avail_distributions.rb
fog-1.20.0 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/linode/requests/compute/avail_distributions.rb
fog-1.19.0 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/linode/requests/compute/avail_distributions.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/linode/requests/compute/avail_distributions.rb