class InfluxDB2::Client
The client is the entry point to HTTP API defined in github.com/influxdata/influxdb/blob/master/http/swagger.yml.
Attributes
@return [ Hash ] options The configuration options.
Public Class Methods
Instantiate a new InfluxDB client.
@example Instantiate a client.
InfluxDBClient::Client.new(url: 'https://localhost:8086', token: 'my-token')
@param [Hash] options The options to be used by the client. @param [String] url InfluxDB URL to connect to (ex. localhost:8086). @param [String] token Access Token used for authenticating/authorizing the InfluxDB request sent by client.
@option options [String] :bucket the default destination bucket for writes @option options [String] :org the default organization bucket for writes @option options [WritePrecision] :precision the default precision for the unix timestamps within @option options [Integer] :open_timeout Number of seconds to wait for the connection to open @option options [Integer] :write_timeout Number of seconds to wait for one block of data to be written @option options [Integer] :read_timeout Number of seconds to wait for one block of data to be read @option options [Integer] :max_redirect_count Maximal number of followed HTTP redirects @option options [bool] :redirect_forward_authorization Pass Authorization header to different domain
during HTTP redirect.
@option options [bool] :use_ssl Turn on/off SSL for HTTP communication @option options [Integer] :verify_mode Sets the flags for the certification verification
at beginning of SSL/TLS session. Could be one of `OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER`. For more info see - https://docs.ruby-lang.org/en/3.0.0/Net/HTTP.html#verify_mode.
@option options [Logger] :logger Logger used for logging. Disable logging by set to false. @option options [Hash] :tags Default tags which will be added to each point written by api.
the body line-protocol
# File lib/influxdb2/client/client.rb, line 54 def initialize(url, token, options = nil) @auto_closeable = [] @options = options ? options.dup : {} @options[:url] = url if url.is_a? String @options[:token] = token if token.is_a? String @options[:logger] = @options[:logger].nil? ? DefaultApi.create_logger : @options[:logger] @closed = false at_exit { close! } end
Public Instance Methods
Close all connections into InfluxDB 2.
@return [ true ] Always true.
# File lib/influxdb2/client/client.rb, line 98 def close! @closed = true @auto_closeable.each(&:close!) true end
Get the Delete API to delete time series data from InfluxDB.
@return [DeleteApi] New instance of DeleteApi
.
# File lib/influxdb2/client/client.rb, line 84 def create_delete_api DeleteApi.new(options: @options) end
Write time series data into InfluxDB thought WriteApi
.
@return [WriteApi] New instance of WriteApi
.
# File lib/influxdb2/client/client.rb, line 68 def create_write_api(write_options: InfluxDB2::SYNCHRONOUS, point_settings: InfluxDB2::DEFAULT_POINT_SETTINGS) write_api = WriteApi.new(options: @options, write_options: write_options, point_settings: point_settings) @auto_closeable.push(write_api) write_api end
Get the health of an instance.
@return [HealthCheck]
# File lib/influxdb2/client/client.rb, line 91 def health HealthApi.new(options: @options).health end