Class: InfluxDB2::Client
- Inherits:
-
Object
- Object
- InfluxDB2::Client
- Defined in:
- lib/influxdb2/client/client.rb
Overview
The client is the entry point to HTTP API defined in github.com/influxdata/influxdb/blob/master/http/swagger.yml.
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options The configuration options.
Class Method Summary collapse
-
.use(*args) ⇒ Object
Instantiate a new InfluxDB client with code block.
Instance Method Summary collapse
-
#close! ⇒ true
Close all connections into InfluxDB 2.
-
#create_delete_api ⇒ DeleteApi
Get the Delete API to delete time series data from InfluxDB.
-
#create_invokable_scripts_api ⇒ InvokableScriptsApi
Create an InvokableScripts API instance.
-
#create_query_api ⇒ QueryApi
Get the Query client.
-
#create_write_api(write_options: InfluxDB2::SYNCHRONOUS, point_settings: InfluxDB2::DEFAULT_POINT_SETTINGS) ⇒ WriteApi
Write time series data into InfluxDB thought WriteApi.
-
#health ⇒ HealthCheck
deprecated
Deprecated.
Use ‘ping` instead
-
#initialize(url, token, options = nil) ⇒ Client
constructor
Instantiate a new InfluxDB client.
-
#ping ⇒ Ping
Checks the status of InfluxDB instance and version of InfluxDB.
Constructor Details
#initialize(url, token, options = nil) ⇒ Client
Instantiate a new InfluxDB client.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/influxdb2/client/client.rb', line 54 def initialize(url, token, = nil) @auto_closeable = [] @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] @options[:debugging] = @options[:debugging].nil? ? false : @options[:debugging] @closed = false at_exit { close! } end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options The configuration options.
27 28 29 |
# File 'lib/influxdb2/client/client.rb', line 27 def @options end |
Class Method Details
.use(*args) ⇒ Object
Instantiate a new InfluxDB client with code block. The client will be passed as an argument and will be automatically closed when the block terminates.
It takes same args as #initialize.
76 77 78 79 80 81 |
# File 'lib/influxdb2/client/client.rb', line 76 def self.use(*args) client = Client.new(*args) yield client ensure client.close! end |
Instance Method Details
#close! ⇒ true
Close all connections into InfluxDB 2.
131 132 133 134 135 |
# File 'lib/influxdb2/client/client.rb', line 131 def close! @closed = true @auto_closeable.each(&:close!) true end |
#create_delete_api ⇒ DeleteApi
Get the Delete API to delete time series data from InfluxDB.
102 103 104 |
# File 'lib/influxdb2/client/client.rb', line 102 def create_delete_api DeleteApi.new(options: @options) end |
#create_invokable_scripts_api ⇒ InvokableScriptsApi
Create an InvokableScripts API instance.
109 110 111 |
# File 'lib/influxdb2/client/client.rb', line 109 def create_invokable_scripts_api InvokableScriptsApi.new(options: @options) end |
#create_query_api ⇒ QueryApi
Get the Query client.
95 96 97 |
# File 'lib/influxdb2/client/client.rb', line 95 def create_query_api QueryApi.new(options: @options) end |
#create_write_api(write_options: InfluxDB2::SYNCHRONOUS, point_settings: InfluxDB2::DEFAULT_POINT_SETTINGS) ⇒ WriteApi
Write time series data into InfluxDB thought WriteApi.
86 87 88 89 90 |
# File 'lib/influxdb2/client/client.rb', line 86 def create_write_api(write_options: InfluxDB2::SYNCHRONOUS, point_settings: InfluxDB2::DEFAULT_POINT_SETTINGS) write_api = WriteApi.new(options: @options, write_options: , point_settings: point_settings) @auto_closeable.push(write_api) write_api end |
#health ⇒ HealthCheck
Use ‘ping` instead
Get the health of an instance.
117 118 119 |
# File 'lib/influxdb2/client/client.rb', line 117 def health HealthApi.new(options: @options).health end |