Module: PuppetX::Kapacitor::API

Defined in:
lib/puppet_x/kapacitor/api.rb

Constant Summary collapse

@@client =
nil

Instance Method Summary collapse

Instance Method Details

#apiObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/puppet_x/kapacitor/api.rb', line 8

def api
  return @@client if @@client

  begin
    @@client = ::Kapacitor::Client.new(url: ENV['KAPACITOR_API_URL'] || "http://localhost:9092/kapacitor", version: ENV['KAPACITOR_API_VERSION'] || 'v1preview')
  rescue Exception => e
    fail "#{e.message} (#{e.error})"
  end

  @@client
end