Class: COMAP::DockerClient
- Inherits:
-
Object
- Object
- COMAP::DockerClient
- Defined in:
- lib/comap/docker_client.rb
Overview
Simple Engine API client
Instance Method Summary collapse
- #call(route, filters = {}) ⇒ Object
-
#initialize(url, port, ssl = {}) ⇒ DockerClient
constructor
A new instance of DockerClient.
Constructor Details
#initialize(url, port, ssl = {}) ⇒ DockerClient
Returns a new instance of DockerClient.
25 26 27 28 29 30 |
# File 'lib/comap/docker_client.rb', line 25 def initialize(url, port, ssl = {}) @conn = Faraday.new(url: "#{url}:#{port}", ssl: ssl) do |faraday| faraday..params_encoder = Faraday::FlatParamsEncoder faraday.adapter Faraday.default_adapter end end |
Instance Method Details
#call(route, filters = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# 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. end |