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.0.3 lib/ey-core/requests/destroy_server.rb
ey-core-3.0.2 lib/ey-core/requests/destroy_server.rb
ey-core-3.0.1 lib/ey-core/requests/destroy_server.rb
ey-core-3.0.0 lib/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/requests/destroy_server.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/requests/destroy_server.rb