Sha256: d0d6343c6d8d5ea024e9b86b9405f146db40f883362bf4c72ea75de62ad92cc9

Contents?: true

Size: 1.1 KB

Versions: 39

Compression:

Stored size: 1.1 KB

Contents

class Ey::Core::Client
  class Real
    def destroy_server(id)
      request(
        :method => :delete,
        :path => "/servers/#{id}"
      )
    end
  end

  class Mock
    def destroy_server(id)
      deprovision_procedure = lambda do |_|
        server = self.data[:servers][id]

        server.merge!("deleted_at" => Time.now, "deprovisioned_at" => Time.now)

        if slot_id = resource_identity(server["slot"])
          self.data[:slots][slot_id]["server"] = nil
        end

        self.data[:volumes].values.select {|v| v["server"] == url_for("/servers/#{id}") }.each do |volume|
          volume.merge!("deleted_at" => Time.now)
        end

        nil
      end

      request_id = self.uuid

      self.data[:requests][request_id] = {
        "id"          => request_id,
        "finished_at" => nil,
        "successful"  => "true",
        "started_at"  => Time.now,
        "resource"    => [:servers, id, deprovision_procedure],
        "type"        => "deprovision_server",
      }

      response(
        :body   => {"request" => {id: request_id}},
        :status => 201,
      )
    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
ey-core-3.2.5 lib/ey-core/requests/destroy_server.rb
ey-core-3.2.4 lib/ey-core/requests/destroy_server.rb
ey-core-3.2.3 lib/ey-core/requests/destroy_server.rb
ey-core-3.2.2 lib/ey-core/requests/destroy_server.rb
ey-core-3.2.1 lib/ey-core/requests/destroy_server.rb
ey-core-3.2.0 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.11 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.10 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.9 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.8 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.7 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.6 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.5 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.4 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.3 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.2 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.1 lib/ey-core/requests/destroy_server.rb
ey-core-3.1.0 lib/ey-core/requests/destroy_server.rb
ey-core-3.0.5 lib/ey-core/requests/destroy_server.rb
ey-core-3.0.4 lib/ey-core/requests/destroy_server.rb