class COMAP::DockerClient

Simple Engine API client

Public Class Methods

new(url, port, ssl = {}) click to toggle source
# File lib/comap/docker_client.rb, line 25
def initialize(url, port, ssl = {})
  @conn = Faraday.new(url: "#{url}:#{port}", ssl: ssl) do |faraday|
    faraday.options.params_encoder = Faraday::FlatParamsEncoder
    faraday.adapter Faraday.default_adapter
  end
end

Public Instance Methods

call(route, filters = {}) click to toggle source
# File lib/comap/docker_client.rb, line 32
def call(route, filters = {})
  response = @conn.get(route) do |req|
    req.params['filters'] = filters.to_json
  end
  JSON.parse(response.body)
rescue StandardError => e
  puts "Could not connect to Docker API #{@conn.url_prefix}"
  puts e.message
end