influxdb-client 1.0.0.pre.121 → 1.0.0.pre.159

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37721226ace63cea9b14c9e7cbb6474c44406f1d96bce46fcde735f9a7f47de3
4
- data.tar.gz: 529302573c9122ea91301dec3cca2738ed7bfa1e106ca0ed59765e6d8948c1f6
3
+ metadata.gz: 7ffb84415d36902228797e8a00d2ac07e8c6330bd6020fc313ab14cb4c2217ac
4
+ data.tar.gz: e9933199fb5be92f37cd26c933047cf630fb493ca246c1266436500686575561
5
5
  SHA512:
6
- metadata.gz: 6c2dbe6f3efdc655d6bf322b1a698da6951d9cf5c019ac0b4eda389b31ec70550ad5c0af88a34e3a0bfa733c56c81ced06911cb2f1176cd07be3a0e9f7a8eb9e
7
- data.tar.gz: 73053187a5d3af888d542fc71428a56e0a48c998df4743265b24fc4ae6f02e75e90a978db00c060ffdb9df109c9e2b29a947fbf18d7ee3fc3e4caf21c1559126
6
+ metadata.gz: 110ad7524b27e5d686417f52d847c8e15a9616d3ee5f0da6adbab0eabaf2b847baa85457c987799e35cf861bbc3516830fb0ea6f69f4c1d4bccfade9b9e157f0
7
+ data.tar.gz: e5d5a833f9b0b9abdddf9f742ace87855032e8f3dfaa5ff109493ba259601fbed3f63d9be5d3afef989f16a8948bb3cb3c529ff5e74f69505c087f32799ac4f5
@@ -48,7 +48,8 @@ commands:
48
48
  name: Install dependencies
49
49
  command: |
50
50
  gem install bundler
51
- bundle install --jobs=4 --retry=3 --path vendor/bundle
51
+ bundle config set path 'vendor/bundle'
52
+ bundle install --jobs=4 --retry=3
52
53
  - run:
53
54
  name: Static code analyze
54
55
  command: |
@@ -75,9 +76,12 @@ jobs:
75
76
  ruby-image:
76
77
  type: string
77
78
  default: &default-ruby-image "circleci/ruby:2.6-stretch"
79
+ influxdb-image:
80
+ type: string
81
+ default: &default-influxdb-image "influxdb:2.0.0-beta"
78
82
  docker:
79
83
  - image: << parameters.ruby-image >>
80
- - image: &influx-image quay.io/influxdb/influx:nightly
84
+ - image: &influx-image quay.io/influxdb/<< parameters.influxdb-image >>
81
85
  steps:
82
86
  - prepare
83
87
  - test:
@@ -85,6 +89,10 @@ jobs:
85
89
  - storing-test-results
86
90
 
87
91
  deploy-preview:
92
+ parameters:
93
+ influxdb-image:
94
+ type: string
95
+ default: *default-influxdb-image
88
96
  docker:
89
97
  - image: *default-ruby-image
90
98
  - image: *influx-image
@@ -112,8 +120,14 @@ workflows:
112
120
  version: 2
113
121
  build:
114
122
  jobs:
123
+ - tests-ruby:
124
+ name: ruby-2.7
125
+ ruby-image: "circleci/ruby:2.7-buster"
115
126
  - tests-ruby:
116
127
  name: ruby-2.6
128
+ - tests-ruby:
129
+ name: ruby-2.6-nightly
130
+ influxdb-image: "influx:nightly"
117
131
  - tests-ruby:
118
132
  name: ruby-2.5
119
133
  ruby-image: "circleci/ruby:2.5-stretch"
@@ -122,7 +136,9 @@ workflows:
122
136
  ruby-image: "circleci/ruby:2.4-stretch"
123
137
  - deploy-preview:
124
138
  requires:
139
+ - ruby-2.7
125
140
  - ruby-2.6
141
+ - ruby-2.6-nightly
126
142
  - ruby-2.5
127
143
  - ruby-2.4
128
144
  filters:
@@ -138,4 +154,4 @@ workflows:
138
154
  only:
139
155
  - master
140
156
  jobs:
141
- - tests-ruby
157
+ - tests-ruby
data/README.md CHANGED
@@ -10,6 +10,7 @@
10
10
  This repository contains the reference Ruby client for the InfluxDB 2.0.
11
11
 
12
12
  #### Note: This library is for use with InfluxDB 2.x. For connecting to InfluxDB 1.x instances, please use the [influxdb-ruby](https://github.com/influxdata/influxdb-ruby) client.
13
+ #### Disclaimer: This library is a work in progress and should not be considered production ready yet.
13
14
 
14
15
  ## Installation
15
16
 
@@ -32,7 +33,7 @@ gem install influxdb-client --pre
32
33
  Use **InfluxDB::Client** to create a client connected to a running InfluxDB 2 instance.
33
34
 
34
35
  ```ruby
35
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token')
36
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token')
36
37
  ```
37
38
 
38
39
  #### Client Options
@@ -49,19 +50,19 @@ client = InfluxDB::Client.new('https://localhost:9999', 'my-token')
49
50
  | use_ssl | Turn on/off SSL for HTTP communication | bool | true |
50
51
 
51
52
  ```ruby
52
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
53
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
53
54
  bucket: 'my-bucket',
54
55
  org: 'my-org',
55
- precision: InfluxDB::WritePrecision::NANOSECOND)
56
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
56
57
  ```
57
58
 
58
59
  ### Writing data
59
60
 
60
61
  ```ruby
61
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
62
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
62
63
  bucket: 'my-bucket',
63
64
  org: 'my-org',
64
- precision: InfluxDB::WritePrecision::NANOSECOND)
65
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
65
66
 
66
67
  write_api = client.create_write_api
67
68
  write_api.write(data: 'h2o,location=west value=33i 15')
@@ -71,20 +72,20 @@ write_api.write(data: 'h2o,location=west value=33i 15')
71
72
 
72
73
  Configure default time precision:
73
74
  ```ruby
74
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
75
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
75
76
  bucket: 'my-bucket',
76
77
  org: 'my-org',
77
- precision: InfluxDB::WritePrecision::NANOSECOND)
78
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
78
79
  ```
79
80
 
80
81
  Configure precision per write:
81
82
  ```ruby
82
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
83
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
83
84
  bucket: 'my-bucket',
84
85
  org: 'my-org')
85
86
 
86
87
  write_api = client.create_write_api
87
- write_api.write(data: 'h2o,location=west value=33i 15', precision: InfluxDB::WritePrecision::SECOND)
88
+ write_api.write(data: 'h2o,location=west value=33i 15', precision: InfluxDB2::WritePrecision::SECOND)
88
89
  ```
89
90
 
90
91
  Allowed values for precision are:
@@ -97,7 +98,7 @@ Allowed values for precision are:
97
98
 
98
99
  Default `bucket` and `organization` destination are configured via `InfluxDB::Client`:
99
100
  ```ruby
100
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
101
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
101
102
  bucket: 'my-bucket',
102
103
  org: 'my-org')
103
104
  ```
@@ -105,7 +106,7 @@ client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
105
106
  but there is also possibility to override configuration per write:
106
107
 
107
108
  ```ruby
108
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token')
109
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token')
109
110
 
110
111
  write_api = client.create_write_api
111
112
  write_api.write(data: 'h2o,location=west value=33i 15', bucket: 'production-data', org: 'customer-1')
@@ -121,12 +122,12 @@ The data could be written as:
121
122
  1. `Array` of above items
122
123
 
123
124
  ```ruby
124
- client = InfluxDB::Client.new('https://localhost:9999', 'my-token',
125
+ client = InfluxDB2::Client.new('https://localhost:9999', 'my-token',
125
126
  bucket: 'my-bucket',
126
127
  org: 'my-org',
127
- precision: InfluxDB::WritePrecision::NANOSECOND)
128
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
128
129
 
129
- point = InfluxDB::Point.new(name: 'h2o')
130
+ point = InfluxDB2::Point.new(name: 'h2o')
130
131
  .add_tag('location', 'europe')
131
132
  .add_field('level', 2)
132
133
 
@@ -26,9 +26,11 @@ set -e
26
26
  DEFAULT_DOCKER_REGISTRY="quay.io/influxdb/"
27
27
  DOCKER_REGISTRY="${DOCKER_REGISTRY:-$DEFAULT_DOCKER_REGISTRY}"
28
28
 
29
- DEFAULT_INFLUXDB_V2_VERSION="nightly"
29
+ DEFAULT_INFLUXDB_V2_REPOSITORY="influxdb"
30
+ DEFAULT_INFLUXDB_V2_VERSION="2.0.0-beta"
31
+ INFLUXDB_V2_REPOSITORY="${INFLUXDB_V2_REPOSITORY:-$DEFAULT_INFLUXDB_V2_REPOSITORY}"
30
32
  INFLUXDB_V2_VERSION="${INFLUXDB_V2_VERSION:-$DEFAULT_INFLUXDB_V2_VERSION}"
31
- INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}influx:${INFLUXDB_V2_VERSION}
33
+ INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}${INFLUXDB_V2_REPOSITORY}:${INFLUXDB_V2_VERSION}
32
34
 
33
35
  SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
34
36
 
@@ -20,11 +20,11 @@
20
20
 
21
21
  lib = File.expand_path('lib', __dir__)
22
22
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
23
- require 'influxdb/client/version'
23
+ require 'influxdb2/client/version'
24
24
 
25
25
  Gem::Specification.new do |spec|
26
26
  spec.name = 'influxdb-client'
27
- spec.version = ENV['CIRCLE_BUILD_NUM'] ? "#{InfluxDB::VERSION}-#{ENV['CIRCLE_BUILD_NUM']}" : InfluxDB::VERSION
27
+ spec.version = ENV['CIRCLE_BUILD_NUM'] ? "#{InfluxDB2::VERSION}-#{ENV['CIRCLE_BUILD_NUM']}" : InfluxDB2::VERSION
28
28
  spec.authors = ['Jakub Bednar']
29
29
  spec.email = ['jakub.bednar@gmail.com']
30
30
 
@@ -18,8 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require 'influxdb/client/version'
22
- require 'influxdb/client/client'
23
- require 'influxdb/client/influx_error'
24
- require 'influxdb/client/write_api'
25
- require 'influxdb/client/point'
21
+ require 'influxdb2/client/version'
22
+ require 'influxdb2/client/client'
23
+ require 'influxdb2/client/influx_error'
24
+ require 'influxdb2/client/write_api'
25
+ require 'influxdb2/client/point'
@@ -17,8 +17,9 @@
17
17
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
+ require 'net/http'
20
21
 
21
- module InfluxDB
22
+ module InfluxDB2
22
23
  # The client is the entry point to HTTP API defined
23
24
  # in https://github.com/influxdata/influxdb/blob/master/http/swagger.yml.
24
25
  class Client
@@ -1,4 +1,4 @@
1
- module InfluxDB
1
+ module InfluxDB2
2
2
  # InfluxError that is raised during HTTP communication.
3
3
  class InfluxError < StandardError
4
4
  # HTTP status code
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- module InfluxDB
21
+ module InfluxDB2
22
22
  DEFAULT_WRITE_PRECISION = WritePrecision::NANOSECOND
23
23
  ESCAPE_KEY_LIST = ['\\'.freeze, ','.freeze, ' '.freeze, '='.freeze].freeze
24
24
  ESCAPE_VALUE_LIST = ['\\'.freeze, '"'.freeze].freeze
@@ -197,13 +197,13 @@ module InfluxDB
197
197
  nano_seconds = @time.to_i * 1e9
198
198
  nano_seconds += @time.tv_nsec
199
199
  case @precision || DEFAULT_WRITE_PRECISION
200
- when InfluxDB::WritePrecision::MILLISECOND then
200
+ when InfluxDB2::WritePrecision::MILLISECOND then
201
201
  (nano_seconds / 1e6).round
202
- when InfluxDB::WritePrecision::SECOND then
202
+ when InfluxDB2::WritePrecision::SECOND then
203
203
  (nano_seconds / 1e9).round
204
- when InfluxDB::WritePrecision::MICROSECOND then
204
+ when InfluxDB2::WritePrecision::MICROSECOND then
205
205
  (nano_seconds / 1e3).round
206
- when InfluxDB::WritePrecision::NANOSECOND then
206
+ when InfluxDB2::WritePrecision::NANOSECOND then
207
207
  nano_seconds.round
208
208
  end
209
209
  else
@@ -18,6 +18,6 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- module InfluxDB
21
+ module InfluxDB2
22
22
  VERSION = '1.0.0'.freeze
23
23
  end
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- module InfluxDB
21
+ module InfluxDB2
22
22
  # Precision constants.
23
23
  #
24
24
  class WritePrecision
@@ -22,49 +22,49 @@ require 'test_helper'
22
22
 
23
23
  class ClientTest < Minitest::Test
24
24
  def test_defined_version_number
25
- refute_nil ::InfluxDB::VERSION
25
+ refute_nil ::InfluxDB2::VERSION
26
26
  end
27
27
 
28
28
  def test_client_new
29
- refute_nil InfluxDB::Client.new('http://localhost:9999', 'my-token')
29
+ refute_nil InfluxDB2::Client.new('http://localhost:9999', 'my-token')
30
30
  end
31
31
 
32
32
  def test_client_hash
33
- client1 = InfluxDB::Client.new('http://localhost:9999', 'my-token')
34
- client2 = InfluxDB::Client.new('http://localhost:9999', 'my-token-diff')
33
+ client1 = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
34
+ client2 = InfluxDB2::Client.new('http://localhost:9999', 'my-token-diff')
35
35
 
36
36
  refute_equal client1.hash, client2.hash
37
37
  assert_equal client1.hash, client1.hash
38
38
  end
39
39
 
40
40
  def test_client_eq
41
- client1 = InfluxDB::Client.new('http://localhost:9999', 'my-token')
42
- client2 = InfluxDB::Client.new('http://localhost:9999', 'my-token-diff')
41
+ client1 = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
42
+ client2 = InfluxDB2::Client.new('http://localhost:9999', 'my-token-diff')
43
43
 
44
44
  refute_equal client1, client2
45
45
  assert_equal client1, client1
46
46
  end
47
47
 
48
48
  def test_client_options
49
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token')
49
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
50
50
 
51
51
  assert_equal 'http://localhost:9999', client.options[:url]
52
52
  assert_equal 'my-token', client.options[:token]
53
53
  end
54
54
 
55
55
  def test_close
56
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token')
56
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
57
57
 
58
58
  assert_equal true, client.close!
59
59
  assert_equal true, client.close!
60
60
  end
61
61
 
62
62
  def test_get_write_api
63
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token')
63
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
64
64
 
65
65
  write_api = client.create_write_api
66
66
 
67
67
  refute_nil write_api
68
- assert_instance_of InfluxDB::WriteApi, write_api
68
+ assert_instance_of InfluxDB2::WriteApi, write_api
69
69
  end
70
70
  end
@@ -22,90 +22,90 @@ require 'test_helper'
22
22
 
23
23
  class PointTest < MiniTest::Test
24
24
  def test_to_line_protocol
25
- point_args = InfluxDB::Point.new(name: 'h2o',
26
- tags: { host: 'aws', region: 'us' },
27
- fields: { level: 5, saturation: '99%' }, time: 123)
25
+ point_args = InfluxDB2::Point.new(name: 'h2o',
26
+ tags: { host: 'aws', region: 'us' },
27
+ fields: { level: 5, saturation: '99%' }, time: 123)
28
28
  assert_equal 'h2o,host=aws,region=us level=5i,saturation="99%" 123', point_args.to_line_protocol
29
29
 
30
- point_hash = InfluxDB::Point.from_hash(name: 'h2o',
31
- tags: { host: 'aws', region: 'us' },
32
- fields: { level: 5, saturation: '99%' }, time: 123)
30
+ point_hash = InfluxDB2::Point.from_hash(name: 'h2o',
31
+ tags: { host: 'aws', region: 'us' },
32
+ fields: { level: 5, saturation: '99%' }, time: 123)
33
33
  assert_equal 'h2o,host=aws,region=us level=5i,saturation="99%" 123', point_hash.to_line_protocol
34
34
  end
35
35
 
36
36
  def test_measurement_escape
37
- point = InfluxDB::Point.new(name: 'h2 o', tags: { location: 'europe' }, fields: { level: 2 })
37
+ point = InfluxDB2::Point.new(name: 'h2 o', tags: { location: 'europe' }, fields: { level: 2 })
38
38
  assert_equal 'h2\\ o,location=europe level=2i', point.to_line_protocol
39
39
 
40
- point = InfluxDB::Point.new(name: 'h2,o', tags: { location: 'europe' }, fields: { level: 2 })
40
+ point = InfluxDB2::Point.new(name: 'h2,o', tags: { location: 'europe' }, fields: { level: 2 })
41
41
  assert_equal 'h2\\,o,location=europe level=2i', point.to_line_protocol
42
42
  end
43
43
 
44
44
  def test_tag_empty_key
45
- point = InfluxDB::Point.new(name: 'h2o', fields: { level: 2 }).add_tag('location', 'europe').add_tag('', 'warn')
45
+ point = InfluxDB2::Point.new(name: 'h2o', fields: { level: 2 }).add_tag('location', 'europe').add_tag('', 'warn')
46
46
 
47
47
  assert_equal 'h2o,location=europe level=2i', point.to_line_protocol
48
48
  end
49
49
 
50
50
  def test_tag_empty_value
51
- point = InfluxDB::Point.new(name: 'h2o', fields: { level: 2 }).add_tag('location', 'europe').add_tag('log', '')
51
+ point = InfluxDB2::Point.new(name: 'h2o', fields: { level: 2 }).add_tag('location', 'europe').add_tag('log', '')
52
52
 
53
53
  assert_equal 'h2o,location=europe level=2i', point.to_line_protocol
54
54
  end
55
55
 
56
56
  def test_override_tag_and_field
57
- point = InfluxDB::Point.new(name: 'h2o', fields: { level: '1' })
58
- .add_tag('location', 'europe')
59
- .add_tag('location', 'europe2')
60
- .add_field(:level, 2)
61
- .add_field(:level, 3)
57
+ point = InfluxDB2::Point.new(name: 'h2o', fields: { level: '1' })
58
+ .add_tag('location', 'europe')
59
+ .add_tag('location', 'europe2')
60
+ .add_field(:level, 2)
61
+ .add_field(:level, 3)
62
62
 
63
63
  assert_equal 'h2o,location=europe2 level=3i', point.to_line_protocol
64
64
  end
65
65
 
66
66
  def test_field_types
67
- point = InfluxDB::Point.new(name: 'h2o')
68
- .add_tag('tag_b', 'b')
69
- .add_tag('tag_a', 'a')
70
- .add_field('n1', -2)
71
- .add_field('n2', 10)
72
- .add_field('n3', 1_265_437_718_438_866_624_512)
73
- .add_field('n4', 5.5)
74
- .add_field('bool', true)
75
- .add_field('string', 'string value')
67
+ point = InfluxDB2::Point.new(name: 'h2o')
68
+ .add_tag('tag_b', 'b')
69
+ .add_tag('tag_a', 'a')
70
+ .add_field('n1', -2)
71
+ .add_field('n2', 10)
72
+ .add_field('n3', 1_265_437_718_438_866_624_512)
73
+ .add_field('n4', 5.5)
74
+ .add_field('bool', true)
75
+ .add_field('string', 'string value')
76
76
 
77
77
  expected = 'h2o,tag_a=a,tag_b=b bool=true,n1=-2i,n2=10i,n3=1265437718438866624512i,n4=5.5,string="string value"'
78
78
  assert_equal expected, point.to_line_protocol
79
79
  end
80
80
 
81
81
  def test_field_null_value
82
- point = InfluxDB::Point.new(name: 'h2o')
83
- .add_tag('location', 'europe')
84
- .add_field('level', 2)
85
- .add_field('warning', nil)
82
+ point = InfluxDB2::Point.new(name: 'h2o')
83
+ .add_tag('location', 'europe')
84
+ .add_field('level', 2)
85
+ .add_field('warning', nil)
86
86
 
87
87
  assert_equal 'h2o,location=europe level=2i', point.to_line_protocol
88
88
  end
89
89
 
90
90
  def test_field_escape
91
- point = InfluxDB::Point.new(name: 'h2o')
92
- .add_tag('location', 'europe')
93
- .add_field('level', 'string esc\\ape value')
91
+ point = InfluxDB2::Point.new(name: 'h2o')
92
+ .add_tag('location', 'europe')
93
+ .add_field('level', 'string esc\\ape value')
94
94
 
95
95
  assert_equal 'h2o,location=europe level="string esc\\\\ape value"', point.to_line_protocol
96
96
 
97
- point = InfluxDB::Point.new(name: 'h2o')
98
- .add_tag('location', 'europe')
99
- .add_field('level', 'string esc"ape value')
97
+ point = InfluxDB2::Point.new(name: 'h2o')
98
+ .add_tag('location', 'europe')
99
+ .add_field('level', 'string esc"ape value')
100
100
 
101
101
  assert_equal 'h2o,location=europe level="string esc\"ape value"', point.to_line_protocol
102
102
  end
103
103
 
104
104
  def test_time
105
- point = InfluxDB::Point.new(name: 'h2o')
106
- .add_tag('location', 'europe')
107
- .add_field('level', 2)
108
- .time(123, InfluxDB::WritePrecision::NANOSECOND)
105
+ point = InfluxDB2::Point.new(name: 'h2o')
106
+ .add_tag('location', 'europe')
107
+ .add_field('level', 2)
108
+ .time(123, InfluxDB2::WritePrecision::NANOSECOND)
109
109
 
110
110
  assert_equal 'h2o,location=europe level=2i 123', point.to_line_protocol
111
111
  end
@@ -113,31 +113,31 @@ class PointTest < MiniTest::Test
113
113
  def test_time_formatting
114
114
  time = Time.utc(2015, 10, 15, 8, 20, 15)
115
115
 
116
- point = InfluxDB::Point.new(name: 'h2o')
117
- .add_tag('location', 'europe')
118
- .add_field('level', 2)
119
- .time(time, InfluxDB::WritePrecision::MILLISECOND)
116
+ point = InfluxDB2::Point.new(name: 'h2o')
117
+ .add_tag('location', 'europe')
118
+ .add_field('level', 2)
119
+ .time(time, InfluxDB2::WritePrecision::MILLISECOND)
120
120
 
121
121
  assert_equal 'h2o,location=europe level=2i 1444897215000', point.to_line_protocol
122
122
 
123
- point = InfluxDB::Point.new(name: 'h2o')
124
- .add_tag('location', 'europe')
125
- .add_field('level', 2)
126
- .time(time, InfluxDB::WritePrecision::SECOND)
123
+ point = InfluxDB2::Point.new(name: 'h2o')
124
+ .add_tag('location', 'europe')
125
+ .add_field('level', 2)
126
+ .time(time, InfluxDB2::WritePrecision::SECOND)
127
127
 
128
128
  assert_equal 'h2o,location=europe level=2i 1444897215', point.to_line_protocol
129
129
 
130
- point = InfluxDB::Point.new(name: 'h2o')
131
- .add_tag('location', 'europe')
132
- .add_field('level', 2)
133
- .time(time, InfluxDB::WritePrecision::MICROSECOND)
130
+ point = InfluxDB2::Point.new(name: 'h2o')
131
+ .add_tag('location', 'europe')
132
+ .add_field('level', 2)
133
+ .time(time, InfluxDB2::WritePrecision::MICROSECOND)
134
134
 
135
135
  assert_equal 'h2o,location=europe level=2i 1444897215000000', point.to_line_protocol
136
136
 
137
- point = InfluxDB::Point.new(name: 'h2o')
138
- .add_tag('location', 'europe')
139
- .add_field('level', 2)
140
- .time(time, InfluxDB::WritePrecision::NANOSECOND)
137
+ point = InfluxDB2::Point.new(name: 'h2o')
138
+ .add_tag('location', 'europe')
139
+ .add_field('level', 2)
140
+ .time(time, InfluxDB2::WritePrecision::NANOSECOND)
141
141
 
142
142
  assert_equal 'h2o,location=europe level=2i 1444897215000000000', point.to_line_protocol
143
143
  end
@@ -145,76 +145,76 @@ class PointTest < MiniTest::Test
145
145
  def test_time_formatting_default
146
146
  time = Time.utc(2015, 10, 15, 8, 20, 15)
147
147
 
148
- point = InfluxDB::Point.new(name: 'h2o', time: time)
149
- .add_tag('location', 'europe')
150
- .add_field('level', 2)
148
+ point = InfluxDB2::Point.new(name: 'h2o', time: time)
149
+ .add_tag('location', 'europe')
150
+ .add_field('level', 2)
151
151
 
152
152
  assert_equal 'h2o,location=europe level=2i 1444897215000000000', point.to_line_protocol
153
153
 
154
- point = InfluxDB::Point.new(name: 'h2o')
155
- .add_tag('location', 'europe')
156
- .add_field('level', 2)
157
- .time(time, nil)
154
+ point = InfluxDB2::Point.new(name: 'h2o')
155
+ .add_tag('location', 'europe')
156
+ .add_field('level', 2)
157
+ .time(time, nil)
158
158
 
159
159
  assert_equal 'h2o,location=europe level=2i 1444897215000000000', point.to_line_protocol
160
160
  end
161
161
 
162
162
  def test_time_string
163
- point_args = InfluxDB::Point.new(name: 'h2o',
164
- tags: { host: 'aws', region: 'us' },
165
- fields: { level: 5 }, time: '123')
163
+ point_args = InfluxDB2::Point.new(name: 'h2o',
164
+ tags: { host: 'aws', region: 'us' },
165
+ fields: { level: 5 }, time: '123')
166
166
 
167
167
  assert_equal 'h2o,host=aws,region=us level=5i 123', point_args.to_line_protocol
168
168
  end
169
169
 
170
170
  def test_time_float
171
- point_args = InfluxDB::Point.new(name: 'h2o',
172
- tags: { host: 'aws', region: 'us' },
173
- fields: { level: 5 }, time: 1.444897215e+18)
171
+ point_args = InfluxDB2::Point.new(name: 'h2o',
172
+ tags: { host: 'aws', region: 'us' },
173
+ fields: { level: 5 }, time: 1.444897215e+18)
174
174
 
175
175
  assert_equal 'h2o,host=aws,region=us level=5i 1444897215000000000', point_args.to_line_protocol
176
176
 
177
- point_args = InfluxDB::Point.new(name: 'h2o',
178
- tags: { host: 'aws', region: 'us' },
179
- fields: { level: 5 }, time: 102_030_405_060)
177
+ point_args = InfluxDB2::Point.new(name: 'h2o',
178
+ tags: { host: 'aws', region: 'us' },
179
+ fields: { level: 5 }, time: 102_030_405_060)
180
180
 
181
181
  assert_equal 'h2o,host=aws,region=us level=5i 102030405060', point_args.to_line_protocol
182
182
  end
183
183
 
184
184
  def test_utf_8
185
- point = InfluxDB::Point.new(name: 'h2o')
186
- .add_tag('location', 'Přerov')
187
- .add_field('level', 2)
188
- .time(123, InfluxDB::WritePrecision::NANOSECOND)
185
+ point = InfluxDB2::Point.new(name: 'h2o')
186
+ .add_tag('location', 'Přerov')
187
+ .add_field('level', 2)
188
+ .time(123, InfluxDB2::WritePrecision::NANOSECOND)
189
189
 
190
190
  assert_equal 'h2o,location=Přerov level=2i 123', point.to_line_protocol
191
191
  end
192
192
 
193
193
  def test_infinity_values
194
- point = InfluxDB::Point.new(name: 'h2o')
195
- .add_tag('location', 'europe')
196
- .add_field('infinity_constant', Float::INFINITY)
197
- .add_field('infinity_positive', 1 / 0.0)
198
- .add_field('infinity_negative', -1 / 0.0)
199
- .add_field('level', 2)
194
+ point = InfluxDB2::Point.new(name: 'h2o')
195
+ .add_tag('location', 'europe')
196
+ .add_field('infinity_constant', Float::INFINITY)
197
+ .add_field('infinity_positive', 1 / 0.0)
198
+ .add_field('infinity_negative', -1 / 0.0)
199
+ .add_field('level', 2)
200
200
 
201
201
  assert_equal 'h2o,location=europe level=2i', point.to_line_protocol
202
202
  end
203
203
 
204
204
  def test_only_infinity_values
205
- point = InfluxDB::Point.new(name: 'h2o')
206
- .add_tag('location', 'europe')
207
- .add_field('infinity_constant', Float::INFINITY)
208
- .add_field('infinity_positive', 1 / 0.0)
209
- .add_field('infinity_negative', -1 / 0.0)
205
+ point = InfluxDB2::Point.new(name: 'h2o')
206
+ .add_tag('location', 'europe')
207
+ .add_field('infinity_constant', Float::INFINITY)
208
+ .add_field('infinity_positive', 1 / 0.0)
209
+ .add_field('infinity_negative', -1 / 0.0)
210
210
 
211
211
  assert_nil point.to_line_protocol
212
212
  end
213
213
 
214
214
  def test_without_tags
215
- point = InfluxDB::Point.new(name: 'h2o')
216
- .add_field('level', 2)
217
- .time(123, InfluxDB::WritePrecision::NANOSECOND)
215
+ point = InfluxDB2::Point.new(name: 'h2o')
216
+ .add_field('level', 2)
217
+ .time(123, InfluxDB2::WritePrecision::NANOSECOND)
218
218
 
219
219
  assert_equal 'h2o level=2i 123', point.to_line_protocol
220
220
  end
@@ -27,19 +27,19 @@ class WriteApiIntegrationTest < MiniTest::Test
27
27
  end
28
28
 
29
29
  def test_write_into_influx_db
30
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
31
- bucket: 'my-bucket',
32
- org: 'my-org',
33
- precision: InfluxDB::WritePrecision::NANOSECOND,
34
- use_ssl: false)
30
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
31
+ bucket: 'my-bucket',
32
+ org: 'my-org',
33
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
34
+ use_ssl: false)
35
35
 
36
36
  now = Time.now.utc
37
37
 
38
38
  measurement = 'h2o_' + now.to_i.to_s
39
- point = InfluxDB::Point.new(name: measurement)
40
- .add_tag('location', 'europe')
41
- .add_field('level', 2)
42
- .time(now, InfluxDB::WritePrecision::NANOSECOND)
39
+ point = InfluxDB2::Point.new(name: measurement)
40
+ .add_tag('location', 'europe')
41
+ .add_field('level', 2)
42
+ .time(now, InfluxDB2::WritePrecision::NANOSECOND)
43
43
 
44
44
  client.create_write_api.write(data: point)
45
45
 
@@ -26,7 +26,7 @@ class WriteApiTest < MiniTest::Test
26
26
  end
27
27
 
28
28
  def test_required_arguments
29
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token')
29
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token')
30
30
  write_api = client.create_write_api
31
31
 
32
32
  # precision
@@ -35,19 +35,19 @@ class WriteApiTest < MiniTest::Test
35
35
  end
36
36
  # bucket
37
37
  assert_raises ArgumentError do
38
- write_api.write(data: {}, org: 'my-org', precision: InfluxDB::WritePrecision::NANOSECOND)
38
+ write_api.write(data: {}, org: 'my-org', precision: InfluxDB2::WritePrecision::NANOSECOND)
39
39
  end
40
40
  # org
41
41
  assert_raises ArgumentError do
42
- write_api.write(data: {}, bucket: 'my-bucket', precision: InfluxDB::WritePrecision::NANOSECOND)
42
+ write_api.write(data: {}, bucket: 'my-bucket', precision: InfluxDB2::WritePrecision::NANOSECOND)
43
43
  end
44
44
  end
45
45
 
46
46
  def test_default_arguments_
47
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
48
- bucket: 'my-bucket',
49
- org: 'my-org',
50
- precision: InfluxDB::WritePrecision::NANOSECOND)
47
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
48
+ bucket: 'my-bucket',
49
+ org: 'my-org',
50
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
51
51
  write_api = client.create_write_api
52
52
 
53
53
  # without argument errors
@@ -57,11 +57,11 @@ class WriteApiTest < MiniTest::Test
57
57
  def test_write_line_protocol
58
58
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
59
59
  .to_return(status: 204)
60
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
61
- bucket: 'my-bucket',
62
- org: 'my-org',
63
- precision: InfluxDB::WritePrecision::NANOSECOND,
64
- use_ssl: false)
60
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
61
+ bucket: 'my-bucket',
62
+ org: 'my-org',
63
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
64
+ use_ssl: false)
65
65
 
66
66
  client.create_write_api.write(data: 'h2o,location=west value=33i 15')
67
67
 
@@ -72,13 +72,13 @@ class WriteApiTest < MiniTest::Test
72
72
  def test_write_point
73
73
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
74
74
  .to_return(status: 204)
75
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
76
- bucket: 'my-bucket',
77
- org: 'my-org',
78
- precision: InfluxDB::WritePrecision::NANOSECOND,
79
- use_ssl: false)
75
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
76
+ bucket: 'my-bucket',
77
+ org: 'my-org',
78
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
79
+ use_ssl: false)
80
80
 
81
- client.create_write_api.write(data: InfluxDB::Point.new(name: 'h2o')
81
+ client.create_write_api.write(data: InfluxDB2::Point.new(name: 'h2o')
82
82
  .add_tag('location', 'europe')
83
83
  .add_field('level', 2))
84
84
 
@@ -89,11 +89,11 @@ class WriteApiTest < MiniTest::Test
89
89
  def test_write_hash
90
90
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
91
91
  .to_return(status: 204)
92
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
93
- bucket: 'my-bucket',
94
- org: 'my-org',
95
- precision: InfluxDB::WritePrecision::NANOSECOND,
96
- use_ssl: false)
92
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
93
+ bucket: 'my-bucket',
94
+ org: 'my-org',
95
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
96
+ use_ssl: false)
97
97
 
98
98
  client.create_write_api.write(data: { name: 'h2o',
99
99
  tags: { host: 'aws', region: 'us' },
@@ -107,15 +107,15 @@ class WriteApiTest < MiniTest::Test
107
107
  def test_write_collection
108
108
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
109
109
  .to_return(status: 204)
110
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
111
- bucket: 'my-bucket',
112
- org: 'my-org',
113
- precision: InfluxDB::WritePrecision::NANOSECOND,
114
- use_ssl: false)
110
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
111
+ bucket: 'my-bucket',
112
+ org: 'my-org',
113
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
114
+ use_ssl: false)
115
115
 
116
- point = InfluxDB::Point.new(name: 'h2o')
117
- .add_tag('location', 'europe')
118
- .add_field('level', 2)
116
+ point = InfluxDB2::Point.new(name: 'h2o')
117
+ .add_tag('location', 'europe')
118
+ .add_field('level', 2)
119
119
 
120
120
  hash = { name: 'h2o',
121
121
  tags: { host: 'aws', region: 'us' },
@@ -132,11 +132,11 @@ class WriteApiTest < MiniTest::Test
132
132
  def test_authorization_header
133
133
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
134
134
  .to_return(status: 204)
135
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
136
- bucket: 'my-bucket',
137
- org: 'my-org',
138
- precision: InfluxDB::WritePrecision::NANOSECOND,
139
- use_ssl: false)
135
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
136
+ bucket: 'my-bucket',
137
+ org: 'my-org',
138
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
139
+ use_ssl: false)
140
140
 
141
141
  client.create_write_api.write(data: 'h2o,location=west value=33i 15')
142
142
 
@@ -147,10 +147,10 @@ class WriteApiTest < MiniTest::Test
147
147
  def test_without_data
148
148
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
149
149
  .to_return(status: 204)
150
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
151
- bucket: 'my-bucket',
152
- org: 'my-org',
153
- precision: InfluxDB::WritePrecision::NANOSECOND)
150
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
151
+ bucket: 'my-bucket',
152
+ org: 'my-org',
153
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
154
154
 
155
155
  client.create_write_api.write(data: '')
156
156
 
@@ -164,13 +164,13 @@ class WriteApiTest < MiniTest::Test
164
164
  stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
165
165
  .to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
166
166
 
167
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
168
- bucket: 'my-bucket',
169
- org: 'my-org',
170
- precision: InfluxDB::WritePrecision::NANOSECOND,
171
- use_ssl: false)
167
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
168
+ bucket: 'my-bucket',
169
+ org: 'my-org',
170
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
171
+ use_ssl: false)
172
172
 
173
- error = assert_raises InfluxDB::InfluxError do
173
+ error = assert_raises InfluxDB2::InfluxError do
174
174
  client.create_write_api.write(data: 'h2o,location=west value=33i 15')
175
175
  end
176
176
 
@@ -187,11 +187,11 @@ class WriteApiTest < MiniTest::Test
187
187
  stub_request(:any, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
188
188
  .to_return(status: 204)
189
189
 
190
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
191
- bucket: 'my-bucket',
192
- org: 'my-org',
193
- precision: InfluxDB::WritePrecision::NANOSECOND,
194
- use_ssl: false)
190
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
191
+ bucket: 'my-bucket',
192
+ org: 'my-org',
193
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
194
+ use_ssl: false)
195
195
 
196
196
  client.create_write_api.write(data: 'h2o,location=west value=33i 15')
197
197
 
@@ -206,14 +206,14 @@ class WriteApiTest < MiniTest::Test
206
206
  .to_return(status: 307, headers:
207
207
  { 'location' => 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns' })
208
208
 
209
- client = InfluxDB::Client.new('http://localhost:9999', 'my-token',
210
- bucket: 'my-bucket',
211
- org: 'my-org',
212
- precision: InfluxDB::WritePrecision::NANOSECOND,
213
- max_redirect_count: 5,
214
- use_ssl: false)
209
+ client = InfluxDB2::Client.new('http://localhost:9999', 'my-token',
210
+ bucket: 'my-bucket',
211
+ org: 'my-org',
212
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
213
+ max_redirect_count: 5,
214
+ use_ssl: false)
215
215
 
216
- error = assert_raises InfluxDB::InfluxError do
216
+ error = assert_raises InfluxDB2::InfluxError do
217
217
  client.create_write_api.write(data: 'h2o,location=west value=33i 15')
218
218
  end
219
219
 
@@ -221,13 +221,13 @@ class WriteApiTest < MiniTest::Test
221
221
  end
222
222
 
223
223
  def test_write_precision_constant
224
- assert_equal InfluxDB::WritePrecision::SECOND, InfluxDB::WritePrecision.new.get_from_value('s')
225
- assert_equal InfluxDB::WritePrecision::MILLISECOND, InfluxDB::WritePrecision.new.get_from_value('ms')
226
- assert_equal InfluxDB::WritePrecision::MICROSECOND, InfluxDB::WritePrecision.new.get_from_value('us')
227
- assert_equal InfluxDB::WritePrecision::NANOSECOND, InfluxDB::WritePrecision.new.get_from_value('ns')
224
+ assert_equal InfluxDB2::WritePrecision::SECOND, InfluxDB2::WritePrecision.new.get_from_value('s')
225
+ assert_equal InfluxDB2::WritePrecision::MILLISECOND, InfluxDB2::WritePrecision.new.get_from_value('ms')
226
+ assert_equal InfluxDB2::WritePrecision::MICROSECOND, InfluxDB2::WritePrecision.new.get_from_value('us')
227
+ assert_equal InfluxDB2::WritePrecision::NANOSECOND, InfluxDB2::WritePrecision.new.get_from_value('ns')
228
228
 
229
229
  error = assert_raises RuntimeError do
230
- InfluxDB::WritePrecision.new.get_from_value('not_supported')
230
+ InfluxDB2::WritePrecision.new.get_from_value('not_supported')
231
231
  end
232
232
 
233
233
  assert_equal 'The time precision not_supported is not supported.', error.message
@@ -27,7 +27,7 @@ if ENV['CI'] == 'true'
27
27
  end
28
28
 
29
29
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
30
- require 'influxdb/client'
30
+ require 'influxdb2/client'
31
31
 
32
32
  require 'minitest/autorun'
33
33
  require 'minitest/reporters'
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.0.0.pre.121
4
+ version: 1.0.0.pre.159
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-08 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,12 +142,12 @@ files:
142
142
  - bin/influxdb-onboarding.sh
143
143
  - bin/influxdb-restart.sh
144
144
  - influxdb-client.gemspec
145
- - lib/influxdb/client.rb
146
- - lib/influxdb/client/client.rb
147
- - lib/influxdb/client/influx_error.rb
148
- - lib/influxdb/client/point.rb
149
- - lib/influxdb/client/version.rb
150
- - lib/influxdb/client/write_api.rb
145
+ - lib/influxdb2/client.rb
146
+ - lib/influxdb2/client/client.rb
147
+ - lib/influxdb2/client/influx_error.rb
148
+ - lib/influxdb2/client/point.rb
149
+ - lib/influxdb2/client/version.rb
150
+ - lib/influxdb2/client/write_api.rb
151
151
  - test/influxdb/client_test.rb
152
152
  - test/influxdb/point_test.rb
153
153
  - test/influxdb/write_api_integration_test.rb