influxdb-client 1.1.0.pre.203 → 1.1.0.pre.323
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codecov.yml +3 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +3 -0
- data/README.md +29 -0
- data/bin/generate-sources.sh +30 -0
- data/bin/pom.xml +34 -0
- data/bin/swagger.yml +9867 -0
- data/lib/influxdb2/client.rb +3 -0
- data/lib/influxdb2/client/client.rb +7 -0
- data/lib/influxdb2/client/default_api.rb +68 -0
- data/lib/influxdb2/client/flux_csv_parser.rb +210 -0
- data/lib/influxdb2/client/flux_table.rb +99 -0
- data/lib/influxdb2/client/models/dialect.rb +317 -0
- data/lib/influxdb2/client/models/query.rb +284 -0
- data/lib/influxdb2/client/query_api.rb +79 -0
- data/lib/influxdb2/client/write_api.rb +2 -39
- data/test/influxdb/flux_csv_parser_test.rb +328 -0
- data/test/influxdb/query_api_integration_test.rb +58 -0
- data/test/influxdb/query_api_test.rb +75 -0
- data/test/test_helper.rb +4 -1
- metadata +18 -2
@@ -0,0 +1,58 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'test_helper'
|
22
|
+
|
23
|
+
class QueryApiIntegrationTest < MiniTest::Test
|
24
|
+
def setup
|
25
|
+
WebMock.allow_net_connect!
|
26
|
+
|
27
|
+
@client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
28
|
+
bucket: 'my-bucket',
|
29
|
+
org: 'my-org',
|
30
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
31
|
+
use_ssl: false)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_query
|
35
|
+
now = Time.now.utc
|
36
|
+
measurement = 'h2o_query_' + now.to_i.to_s
|
37
|
+
|
38
|
+
@client.create_write_api.write(data: InfluxDB2::Point.new(name: measurement)
|
39
|
+
.add_tag('location', 'europe')
|
40
|
+
.add_field('level', 2)
|
41
|
+
.time(now, InfluxDB2::WritePrecision::NANOSECOND))
|
42
|
+
|
43
|
+
result = @client.create_query_api.query(query: 'from(bucket: "my-bucket") |> range(start: -1m, stop: now()) '\
|
44
|
+
"|> filter(fn: (r) => r._measurement == \"#{measurement}\")")
|
45
|
+
|
46
|
+
assert_equal 1, result.size
|
47
|
+
|
48
|
+
records = result[0].records
|
49
|
+
assert_equal 1, records.size
|
50
|
+
|
51
|
+
record = records[0]
|
52
|
+
|
53
|
+
assert_equal measurement, record.measurement
|
54
|
+
assert_equal 'europe', record.values['location']
|
55
|
+
assert_equal 2, record.value
|
56
|
+
assert_equal 'level', record.field
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'test_helper'
|
22
|
+
|
23
|
+
class QueryApiTest < MiniTest::Test
|
24
|
+
def setup
|
25
|
+
WebMock.disable_net_connect!
|
26
|
+
end
|
27
|
+
|
28
|
+
SUCCESS_DATA = '#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,' \
|
29
|
+
"long,string,string,string,string\n" \
|
30
|
+
"#group,false,false,false,false,false,false,false,false,false,true\n" + "#default,_result,,,,,,,,,\n" \
|
31
|
+
",result,table,_start,_stop,_time,_value,_field,_measurement,host,region\n" \
|
32
|
+
",,0,1970-01-01T00:00:10Z,1970-01-01T00:00:20Z,1970-01-01T00:00:10Z,10,free,mem,A,west\n" \
|
33
|
+
",,0,1970-01-01T00:00:10Z,1970-01-01T00:00:20Z,1970-01-01T00:00:10Z,20,free,mem,B,west\n" \
|
34
|
+
",,0,1970-01-01T00:00:20Z,1970-01-01T00:00:30Z,1970-01-01T00:00:20Z,11,free,mem,A,west\n" \
|
35
|
+
',,0,1970-01-01T00:00:20Z,1970-01-01T00:00:30Z,1970-01-01T00:00:20Z,22,free,mem,B,west'
|
36
|
+
|
37
|
+
def test_query_raw
|
38
|
+
stub_request(:post, 'http://localhost:9999/api/v2/query?org=my-org')
|
39
|
+
.to_return(body: SUCCESS_DATA)
|
40
|
+
client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
41
|
+
bucket: 'my-bucket',
|
42
|
+
org: 'my-org',
|
43
|
+
use_ssl: false)
|
44
|
+
|
45
|
+
bucket = 'my-bucket'
|
46
|
+
result = client.create_query_api.query_raw(query:
|
47
|
+
'from(bucket:"' + bucket + '") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()')
|
48
|
+
|
49
|
+
assert_equal result, SUCCESS_DATA
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_query
|
53
|
+
stub_request(:post, 'http://localhost:9999/api/v2/query?org=my-org')
|
54
|
+
.to_return(body: SUCCESS_DATA)
|
55
|
+
|
56
|
+
client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
|
57
|
+
bucket: 'my-bucket',
|
58
|
+
org: 'my-org',
|
59
|
+
use_ssl: false)
|
60
|
+
|
61
|
+
bucket = 'my-bucket'
|
62
|
+
result = client.create_query_api.query(query:
|
63
|
+
'from(bucket:"' + bucket + '") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()')
|
64
|
+
|
65
|
+
assert_equal 1, result.length
|
66
|
+
assert_equal 4, result[0].records.length
|
67
|
+
|
68
|
+
record1 = result[0].records[0]
|
69
|
+
|
70
|
+
assert_equal Time.parse('1970-01-01T00:00:10Z').to_datetime.rfc3339, record1.time
|
71
|
+
assert_equal 'mem', record1.measurement
|
72
|
+
assert_equal 10, record1.value
|
73
|
+
assert_equal 'free', record1.field
|
74
|
+
end
|
75
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.pre.
|
4
|
+
version: 1.1.0.pre.323
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".circleci/config.yml"
|
133
133
|
- ".circleci/setup-rubygems.sh"
|
134
|
+
- ".codecov.yml"
|
134
135
|
- ".github/PULL_REQUEST_TEMPLATE"
|
135
136
|
- ".gitignore"
|
136
137
|
- ".rubocop.yml"
|
@@ -139,17 +140,29 @@ files:
|
|
139
140
|
- LICENSE
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|
143
|
+
- bin/generate-sources.sh
|
142
144
|
- bin/influxdb-onboarding.sh
|
143
145
|
- bin/influxdb-restart.sh
|
146
|
+
- bin/pom.xml
|
147
|
+
- bin/swagger.yml
|
144
148
|
- influxdb-client.gemspec
|
145
149
|
- lib/influxdb2/client.rb
|
146
150
|
- lib/influxdb2/client/client.rb
|
151
|
+
- lib/influxdb2/client/default_api.rb
|
152
|
+
- lib/influxdb2/client/flux_csv_parser.rb
|
153
|
+
- lib/influxdb2/client/flux_table.rb
|
147
154
|
- lib/influxdb2/client/influx_error.rb
|
155
|
+
- lib/influxdb2/client/models/dialect.rb
|
156
|
+
- lib/influxdb2/client/models/query.rb
|
148
157
|
- lib/influxdb2/client/point.rb
|
158
|
+
- lib/influxdb2/client/query_api.rb
|
149
159
|
- lib/influxdb2/client/version.rb
|
150
160
|
- lib/influxdb2/client/write_api.rb
|
151
161
|
- test/influxdb/client_test.rb
|
162
|
+
- test/influxdb/flux_csv_parser_test.rb
|
152
163
|
- test/influxdb/point_test.rb
|
164
|
+
- test/influxdb/query_api_integration_test.rb
|
165
|
+
- test/influxdb/query_api_test.rb
|
153
166
|
- test/influxdb/write_api_integration_test.rb
|
154
167
|
- test/influxdb/write_api_test.rb
|
155
168
|
- test/test_helper.rb
|
@@ -181,7 +194,10 @@ specification_version: 4
|
|
181
194
|
summary: Ruby library for InfluxDB 2.
|
182
195
|
test_files:
|
183
196
|
- test/influxdb/client_test.rb
|
197
|
+
- test/influxdb/flux_csv_parser_test.rb
|
184
198
|
- test/influxdb/point_test.rb
|
199
|
+
- test/influxdb/query_api_integration_test.rb
|
200
|
+
- test/influxdb/query_api_test.rb
|
185
201
|
- test/influxdb/write_api_integration_test.rb
|
186
202
|
- test/influxdb/write_api_test.rb
|
187
203
|
- test/test_helper.rb
|