Sha256: db0ab7919d00b4b18785da913d6ffab43f9180a35276e5ec6ea1a55cd455109a

Contents?: true

Size: 1.22 KB

Versions: 27

Compression:

Stored size: 1.22 KB

Contents

unless Fog.mocking?

  module Fog
    module Rackspace
      class Servers

        # Delete an existing server
        #
        # ==== Parameters
        # * id<~Integer> - Id of server to delete
        #
        def delete_server(server_id)
          request(
            :expects => 202,
            :method => 'DELETE',
            :path   => "servers/#{server_id}"
          )
        end

      end
    end
  end

else

  module Fog
    module Rackspace
      class Servers

        def delete_server(server_id)
          response = Excon::Response.new
          if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
            if server['status'] == 'BUILD'
              response.status = 409
              raise(Excon::Errors.status_error({:expects => 202}, response))
            else
              Fog::Rackspace::Servers.data[:last_modified][:servers].delete(server_id)
              Fog::Rackspace::Servers.data[:servers].delete(server_id)
              response.status = 202
            end
          else
            response.status = 404
            raise(Excon::Errors.status_error({:expects => 202}, response))
          end
          response
        end

      end
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
fog-0.0.58 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.57 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.56 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.55 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.54 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.53 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.52 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.51 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.50 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.49 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.48 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.47 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.46 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.45 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.44 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.43 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.42 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.41 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.40 lib/fog/rackspace/requests/servers/delete_server.rb
fog-0.0.39 lib/fog/rackspace/requests/servers/delete_server.rb