Sha256: d95ae4af62026f1c0afec37912544c416de94f896a4dbfea3faf0ade2a1630b1

Contents?: true

Size: 1.98 KB

Versions: 79

Compression:

Stored size: 1.98 KB

Contents

module Fog
  module Compute
    class Linode
      class Real

        def avail_stackscripts(options={})
          result = request(
            :expects  => 200,
            :method   => 'GET',
            :query    => { :api_action => 'avail.stackscripts' }.merge!(options)
          )
          result.body['DATA'].each { |r| r['DISTRIBUTIONIDLIST'] = r['DISTRIBUTIONIDLIST'].to_s }
          result
        end

      end

      class Mock
        def avail_stackscripts(stackscript_id=nil)
          response = Excon::Response.new
          response.status = 200

          body = {
            "ERRORARRAY" => [],
            "ACTION" => "avail.stackscripts"
          }
          if stackscript_id
            mock_stackscript = create_mock_stackscript(stackscript_id)
            response.body = body.merge("DATA" => [mock_stackscript])
          else
            mock_stackscripts = []
            10.times do
              stackscript_id = rand(1..200)
              mock_stackscripts << create_mock_stackscript(stackscript_id)
            end
            response.body = body.merge("DATA" => mock_stackscripts)
          end
          response
        end

        private

        def create_mock_stackscript(stackscript_id)
          {
            "CREATE_DT"          => "2011-10-07 00:28:13.0",
            "DEPLOYMENTSACTIVE"  => 0,
            "DEPLOYMENTSTOTAL"   => 1,
            "DESCRIPTION"        => "Prints 'foobar' to the screen. Magic!",
            "DISTRIBUTIONIDLIST" => "77,78,64,65,82,83,50,51,73,74,41,42",
            "ISPUBLIC"           => 1,
            "LABEL"              => "foobar",
            "LATESTREV"          => 15149,
            "REV_DT"             => "2011-10-07 00:33:58.0",
            "REV_NOTE"           => "Updated update_rubygems_install function.",
            "SCRIPT"             => "#!/bin/bash\n#\n#\n\necho \"foobar\"",
            "STACKSCRIPTID"      => stackscript_id,
            "USERID"             => 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_stackscripts.rb
fog-1.21.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.20.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-1.19.0 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/linode/requests/compute/avail_stackscripts.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/linode/requests/compute/avail_stackscripts.rb