Sha256: 9340194f2623c080c8263639d28503d56136e2d00b026daaf0607c09f148238d

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

class Ey::Core::Client
  class Real
    def attach_address(params={})
      id = params.delete("id")

      request(
        :method => :put,
        :path   => "addresses/#{id}/attach",
        :params => params,
      )
    end
  end # Real

  class Mock
    def attach_address(params={})
      resource_id = params.delete("id")
      server_id   = params.delete("server").to_i
      request_id  = self.uuid

      server = self.find(:servers, server_id)
      server.merge!(
        "address_url" => "/addresses/#{resource_id}",
      )

      resource = self.data[:addresses][resource_id]
      resource.merge!(
        "server_url" => "/servers/#{server_id}",
      )

      request = {
        "id"          => request_id,
        "type"        => "attach_address",
        "successful"  => "true",
        "started_at"  => Time.now,
        "finished_at" => nil,
        "resource"    => [:addresses, resource_id, resource],
      }

      self.data[:requests][request_id] = request

      response_hash = request.dup
      response_hash.delete("resource")

      response(
        :body    => {"request" => response_hash},
        :status  => 200,
        :headers => {
          "Content-Type" => "application/json; charset=utf8"
        }
      )
    end
  end # Mock
end # Ey::Core::Client

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ey-core-3.6.6 lib/ey-core/requests/attach_address.rb
ey-core-3.4.5 lib/ey-core/requests/attach_address.rb
ey-core-3.6.5 lib/ey-core/requests/attach_address.rb