Class: InfluxDB2::QueryApi
- Inherits:
-
DefaultApi
- Object
- DefaultApi
- InfluxDB2::QueryApi
- Defined in:
- lib/influxdb2/client/query_api.rb
Overview
The client of the InfluxDB 2.x that implement Query HTTP API endpoint.
Constant Summary collapse
- DEFAULT_DIALECT =
InfluxDB2::Dialect.new(header: true, delimiter: ',', comment_prefix: '#', annotations: %w[datatype group default])
Constants inherited from DefaultApi
DefaultApi::DEFAULT_REDIRECT_COUNT, DefaultApi::DEFAULT_TIMEOUT, DefaultApi::HEADER_CONTENT_TYPE
Instance Method Summary collapse
-
#initialize(options:) ⇒ QueryApi
constructor
A new instance of QueryApi.
-
#query(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ Array
List of FluxTables which are matched the query.
-
#query_raw(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ String
Result of query.
-
#query_stream(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ Object
Stream of Flux Records.
Methods inherited from DefaultApi
Constructor Details
#initialize(options:) ⇒ QueryApi
Returns a new instance of QueryApi.
33 34 35 |
# File 'lib/influxdb2/client/query_api.rb', line 33 def initialize(options:) super(options: ) end |
Instance Method Details
#query(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ Array
Returns list of FluxTables which are matched the query.
49 50 51 52 53 54 55 |
# File 'lib/influxdb2/client/query_api.rb', line 49 def query(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) response = query_raw(query: query, org: org, dialect: dialect, params: params) parser = InfluxDB2::FluxCsvParser.new(response) parser.parse parser.tables end |
#query_raw(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ String
Returns result of query.
41 42 43 |
# File 'lib/influxdb2/client/query_api.rb', line 41 def query_raw(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) _post_query(query: query, org: org, dialect: dialect, params: params).read_body end |
#query_stream(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) ⇒ Object
Returns stream of Flux Records.
61 62 63 64 65 |
# File 'lib/influxdb2/client/query_api.rb', line 61 def query_stream(query: nil, org: nil, dialect: DEFAULT_DIALECT, params: nil) response = _post_query(query: query, org: org, dialect: dialect, params: params) InfluxDB2::FluxCsvParser.new(response, stream: true) end |