class InfluxDB2::HealthApi

The client of the InfluxDB 2.0 that implement Health HTTP API endpoint.

Public Class Methods

new(options:) click to toggle source

@param [Hash] options The options to be used by the client.

Calls superclass method InfluxDB2::DefaultApi::new
# File lib/influxdb2/client/health_api.rb, line 27
def initialize(options:)
  super(options: options)
end

Public Instance Methods

health() click to toggle source

Get the health of an instance.

@return [HealthCheck]

# File lib/influxdb2/client/health_api.rb, line 34
def health
  uri = _parse_uri('/health')
  body = _get(uri).body
  data = JSON.parse("[#{body}]", symbolize_names: true)[0]
  HealthCheck.new.tap do |model|
    model.build_from_hash data
  end
rescue StandardError => e
  HealthCheck.new.tap do |model|
    model.name = 'influxdb'
    model.status = 'fail'
    model.message = e.message
  end
end