Sha256: 5db8a311920e90fbe8293ce7ba68dc0b41a0310a890b1886604cea68ec6ac488

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

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

      request(
        :method => :post,
        :path   => "/connectors",
        :body   => params,
        :url    => url,
      )
    end
  end # Real

  class Mock
    def create_connector(params={})
      resource_id = self.uuid

      resource       = params["connector"].dup
      destination_id = resource.delete("destination")
      source_id      = resource.delete("source")

      resource["configuration"] = normalize_hash(resource["configuration"] || {})

      key, source = find([:cluster_components, :logical_databases], source_id)
      dest = find(:cluster_components, destination_id)

      environment_url = find(:clusters, dest["cluster"])["environment"] if dest.has_key?("cluster")
      environment_url = find(:clusters, source["cluster"])["environment"] unless environment_url

      resource.merge!(
        "source"       => url_for("/#{key}/#{source_id}"),
        "destination"  => url_for("/cluster-components/#{destination_id}"),
        "id"           => resource_id,
        "_environment" => environment_url,
      )

      self.data[:connectors][resource_id] = resource

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.15 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.14 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.13 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.12 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.11 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.10 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.9 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.8 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.7 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.6 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.5 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.4 lib/vendor/core/ey-core/requests/create_connector.rb
ey-pro-cli-0.0.3 lib/vendor/core/ey-core/requests/create_connector.rb