Class: InfluxDB2::PingApi

Inherits:
DefaultApi show all
Defined in:
lib/influxdb2/client/ping_api.rb

Overview

The client of the InfluxDB 2.x that implement Ping HTTP API endpoint.

Constant Summary

Constants inherited from DefaultApi

DefaultApi::DEFAULT_REDIRECT_COUNT, DefaultApi::DEFAULT_TIMEOUT, DefaultApi::HEADER_CONTENT_TYPE

Instance Method Summary collapse

Methods inherited from DefaultApi

create_logger, #log

Constructor Details

#initialize(options:) ⇒ PingApi

Returns a new instance of PingApi.

Parameters:

  • options (Hash)

    The options to be used by the client.



27
28
29
# File 'lib/influxdb2/client/ping_api.rb', line 27

def initialize(options:)
  super(options: options)
end

Instance Method Details

#pingPing

Checks the status of InfluxDB instance and version of InfluxDB.

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/influxdb2/client/ping_api.rb', line 34

def ping
  uri = _parse_uri('/ping')
  headers = _get(uri)
  Ping.new.tap do |model|
    model.status = 'ok'
    model.build = headers['X-Influxdb-Build']
    model.version = headers['X-Influxdb-Version']
    model.message = 'ready for queries and writes'
  end
rescue StandardError => e
  Ping.new.tap do |model|
    model.status = 'fail'
    model.message = e.message
  end
end