Sha256: 8017803f170c9e7d8ce7acfefa9d942f5b2404cda3a0b5bcef9210bb6b6992ea

Contents?: true

Size: 1.57 KB

Versions: 17

Compression:

Stored size: 1.57 KB

Contents

class Ey::Core::Client
  class Real
    def create_untracked_address(params={})
      request(
        :body   => params,
        :method => :post,
        :path   => "/untracked-addresses",
        :url    => params.delete("url"),
      )
    end
  end # Real

  class Mock
    def create_untracked_address(params={})
      url         = params["url"]

      provider_id ||= params["provider"] || (url && path_params(url)["providers"])
      find(:providers, provider_id)

      resource = params["untracked_address"].dup

      require_parameters(resource, "location", "provisioned_id", "provisioner_id")
      existing_address = self.data[:addresses].find {|id, a| a['provisioned_id'] == resource["provisioned_id"] }

      if existing_address
        existing_id, existing_address = existing_address
        response(
          :body => {"errors" => ["Address '#{resource['provisioned_id']}' is tracked."],
                    "address" => url_for("/addresses/#{existing_id}")},
          :status => 409,
        )
      else
        resource_id = self.serial_id
        self.data[:addresses][resource_id] = resource.merge(
          "provider" => provider_id, "id" => resource_id, "resource_url" => "/addresses/#{resource_id}")

        resource.merge!(
          "provider" => url_for("/providers/#{provider_id}"),
          "location" => resource['location'],
          "address" => url_for("/addresses/#{resource_id}"),
        )

        response(
          :body   => { "untracked_address" => resource },
          :status => 201,
        )
      end
    end
  end # Mock
end # Ey::Core::Client

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
ey-core-3.6.0.autoscaling1 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.6.4 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.6.3 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.6.1 lib/ey-core/requests/create_untracked_address.rb
groove-ey-core-3.6.3 lib/ey-core/requests/create_untracked_address.rb
groove-ey-core-3.6.2 lib/ey-core/requests/create_untracked_address.rb
groove-ey-core-3.6.1 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.5.0 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.4.4 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.4.2 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.4.1 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.4.0 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.3.1 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.3.0 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.2.6 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.2.5 lib/ey-core/requests/create_untracked_address.rb
ey-core-3.2.4 lib/ey-core/requests/create_untracked_address.rb