influxdb-client 1.4.0.pre.771 → 1.5.0.pre.902

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
- require 'influxdb2/client'
2
+ require 'influxdb-client'
3
3
 
4
4
  username = 'username'
5
5
  password = 'password'
@@ -34,6 +34,10 @@ module InfluxDB2
34
34
 
35
35
  private
36
36
 
37
+ def _parse_uri(api_path)
38
+ URI.parse(File.join(@options[:url], api_path))
39
+ end
40
+
37
41
  def _post_json(payload, uri, headers: {})
38
42
  _check_arg_type(:headers, headers, Hash)
39
43
  _post(payload, uri, headers: headers.merge(HEADER_CONTENT_TYPE => 'application/json'))
@@ -61,7 +61,7 @@ module InfluxDB2
61
61
  _check('bucket', bucket_param)
62
62
  _check('org', org_param)
63
63
 
64
- uri = URI.parse(File.join(@options[:url], '/api/v2/delete'))
64
+ uri = _parse_uri('/api/v2/delete')
65
65
  uri.query = URI.encode_www_form(org: org_param, bucket: bucket_param)
66
66
 
67
67
  _post_json(delete_request.to_body.to_json, uri)
@@ -32,7 +32,7 @@ module InfluxDB2
32
32
  #
33
33
  # @return [HealthCheck]
34
34
  def health
35
- uri = URI.parse(File.join(@options[:url], '/health'))
35
+ uri = _parse_uri('/health')
36
36
  body = _get(uri).body
37
37
  data = JSON.parse("[#{body}]", symbolize_names: true)[0]
38
38
  HealthCheck.new.tap do |model|
@@ -22,6 +22,10 @@ module InfluxDB2
22
22
 
23
23
  attr_accessor :status
24
24
 
25
+ attr_accessor :version
26
+
27
+ attr_accessor :commit
28
+
25
29
  class EnumAttributeValidator
26
30
  attr_reader :datatype
27
31
  attr_reader :allowable_values
@@ -50,7 +54,9 @@ module InfluxDB2
50
54
  :'name' => :'name',
51
55
  :'message' => :'message',
52
56
  :'checks' => :'checks',
53
- :'status' => :'status'
57
+ :'status' => :'status',
58
+ :'version' => :'version',
59
+ :'commit' => :'commit'
54
60
  }
55
61
  end
56
62
 
@@ -60,7 +66,9 @@ module InfluxDB2
60
66
  :'name' => :'String',
61
67
  :'message' => :'String',
62
68
  :'checks' => :'Array<HealthCheck>',
63
- :'status' => :'String'
69
+ :'status' => :'String',
70
+ :'version' => :'String',
71
+ :'commit' => :'String'
64
72
  }
65
73
  end
66
74
 
@@ -89,6 +97,14 @@ module InfluxDB2
89
97
  if attributes.has_key?(:'status')
90
98
  self.status = attributes[:'status']
91
99
  end
100
+
101
+ if attributes.has_key?(:'version')
102
+ self.version = attributes[:'version']
103
+ end
104
+
105
+ if attributes.has_key?(:'commit')
106
+ self.commit = attributes[:'commit']
107
+ end
92
108
  end
93
109
 
94
110
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -134,7 +150,9 @@ module InfluxDB2
134
150
  name == o.name &&
135
151
  message == o.message &&
136
152
  checks == o.checks &&
137
- status == o.status
153
+ status == o.status &&
154
+ version == o.version &&
155
+ commit == o.commit
138
156
  end
139
157
 
140
158
  # @see the `==` method
@@ -146,7 +164,7 @@ module InfluxDB2
146
164
  # Calculates hash code according to all attributes.
147
165
  # @return [Fixnum] Hash code
148
166
  def hash
149
- [name, message, checks, status].hash
167
+ [name, message, checks, status, version, commit].hash
150
168
  end
151
169
 
152
170
  # Builds the object from hash
@@ -13,27 +13,21 @@ OpenAPI Generator version: 3.3.4
13
13
  require 'date'
14
14
 
15
15
  module InfluxDB2
16
- # Query influx with specific return formatting.
16
+ # Query influx using the Flux language
17
17
  class Query
18
18
  attr_accessor :extern
19
19
 
20
20
  # Query script to execute.
21
21
  attr_accessor :query
22
22
 
23
- # The type of query.
23
+ # The type of query. Must be \"flux\".
24
24
  attr_accessor :type
25
25
 
26
- # Required for `influxql` type queries.
27
- attr_accessor :db
28
-
29
- # Required for `influxql` type queries.
30
- attr_accessor :rp
31
-
32
- # Required for `influxql` type queries.
33
- attr_accessor :cluster
34
-
35
26
  attr_accessor :dialect
36
27
 
28
+ # Specifies the time that should be reported as \"now\" in the query. Default is the server's now time.
29
+ attr_accessor :now
30
+
37
31
  class EnumAttributeValidator
38
32
  attr_reader :datatype
39
33
  attr_reader :allowable_values
@@ -62,10 +56,8 @@ module InfluxDB2
62
56
  :'extern' => :'extern',
63
57
  :'query' => :'query',
64
58
  :'type' => :'type',
65
- :'db' => :'db',
66
- :'rp' => :'rp',
67
- :'cluster' => :'cluster',
68
- :'dialect' => :'dialect'
59
+ :'dialect' => :'dialect',
60
+ :'now' => :'now'
69
61
  }
70
62
  end
71
63
 
@@ -75,10 +67,8 @@ module InfluxDB2
75
67
  :'extern' => :'File',
76
68
  :'query' => :'String',
77
69
  :'type' => :'String',
78
- :'db' => :'String',
79
- :'rp' => :'String',
80
- :'cluster' => :'String',
81
- :'dialect' => :'Dialect'
70
+ :'dialect' => :'Dialect',
71
+ :'now' => :'DateTime'
82
72
  }
83
73
  end
84
74
 
@@ -100,25 +90,15 @@ module InfluxDB2
100
90
 
101
91
  if attributes.has_key?(:'type')
102
92
  self.type = attributes[:'type']
103
- else
104
- self.type = 'flux'
105
- end
106
-
107
- if attributes.has_key?(:'db')
108
- self.db = attributes[:'db']
109
- end
110
-
111
- if attributes.has_key?(:'rp')
112
- self.rp = attributes[:'rp']
113
- end
114
-
115
- if attributes.has_key?(:'cluster')
116
- self.cluster = attributes[:'cluster']
117
93
  end
118
94
 
119
95
  if attributes.has_key?(:'dialect')
120
96
  self.dialect = attributes[:'dialect']
121
97
  end
98
+
99
+ if attributes.has_key?(:'now')
100
+ self.now = attributes[:'now']
101
+ end
122
102
  end
123
103
 
124
104
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -136,7 +116,7 @@ module InfluxDB2
136
116
  # @return true if the model is valid
137
117
  def valid?
138
118
  return false if @query.nil?
139
- type_validator = EnumAttributeValidator.new('String', ['flux', 'influxql'])
119
+ type_validator = EnumAttributeValidator.new('String', ['flux'])
140
120
  return false unless type_validator.valid?(@type)
141
121
  true
142
122
  end
@@ -144,7 +124,7 @@ module InfluxDB2
144
124
  # Custom attribute writer method checking allowed values (enum).
145
125
  # @param [Object] type Object to be assigned
146
126
  def type=(type)
147
- validator = EnumAttributeValidator.new('String', ['flux', 'influxql'])
127
+ validator = EnumAttributeValidator.new('String', ['flux'])
148
128
  unless validator.valid?(type)
149
129
  fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.'
150
130
  end
@@ -159,10 +139,8 @@ module InfluxDB2
159
139
  extern == o.extern &&
160
140
  query == o.query &&
161
141
  type == o.type &&
162
- db == o.db &&
163
- rp == o.rp &&
164
- cluster == o.cluster &&
165
- dialect == o.dialect
142
+ dialect == o.dialect &&
143
+ now == o.now
166
144
  end
167
145
 
168
146
  # @see the `==` method
@@ -174,7 +152,7 @@ module InfluxDB2
174
152
  # Calculates hash code according to all attributes.
175
153
  # @return [Fixnum] Hash code
176
154
  def hash
177
- [extern, query, type, db, rp, cluster, dialect].hash
155
+ [extern, query, type, dialect, now].hash
178
156
  end
179
157
 
180
158
  # Builds the object from hash
@@ -28,7 +28,7 @@ module InfluxDB2
28
28
  class Point
29
29
  # Create DataPoint instance for specified measurement name.
30
30
  #
31
- # @example InfluxDB::Point.new(name: "h2o",
31
+ # @example InfluxDB2::Point.new(name: "h2o",
32
32
  # tags: {host: 'aws', region: 'us'},
33
33
  # fields: {level: 5, saturation: "99%"},
34
34
  # time: 123)
@@ -64,7 +64,7 @@ module InfluxDB2
64
64
 
65
65
  # Adds or replaces a tag value for a point.
66
66
  #
67
- # @example InfluxDB::Point.new(name: "h2o")
67
+ # @example InfluxDB2::Point.new(name: "h2o")
68
68
  # .add_tag("location", "europe")
69
69
  # .add_field("level", 2)
70
70
  #
@@ -77,7 +77,7 @@ module InfluxDB2
77
77
 
78
78
  # Adds or replaces a field value for a point.
79
79
  #
80
- # @example InfluxDB::Point.new(name: "h2o")
80
+ # @example InfluxDB2::Point.new(name: "h2o")
81
81
  # .add_tag("location", "europe")
82
82
  # .add_field("level", 2)
83
83
  #
@@ -90,15 +90,15 @@ module InfluxDB2
90
90
 
91
91
  # Updates the timestamp for the point.
92
92
  #
93
- # @example InfluxDB::Point.new(name: "h2o")
93
+ # @example InfluxDB2::Point.new(name: "h2o")
94
94
  # .add_tag("location", "europe")
95
95
  # .add_field("level", 2)
96
- # .time(Time.new(2015, 10, 15, 8, 20, 15), InfluxDB::WritePrecision::MILLISECOND)
96
+ # .time(Time.new(2015, 10, 15, 8, 20, 15), InfluxDB2::WritePrecision::MILLISECOND)
97
97
  #
98
- # @example InfluxDB::Point.new(name: "h2o")
98
+ # @example InfluxDB2::Point.new(name: "h2o")
99
99
  # .add_tag("location", "europe")
100
100
  # .add_field("level", 2)
101
- # .time(123, InfluxDB::WritePrecision::NANOSECOND)
101
+ # .time(123, InfluxDB2::WritePrecision::NANOSECOND)
102
102
  #
103
103
  # @param [Object] time the timestamp
104
104
  # @param [WritePrecision] precision the timestamp precision
@@ -70,7 +70,7 @@ module InfluxDB2
70
70
  payload = _generate_payload(query, dialect)
71
71
  return nil if payload.nil?
72
72
 
73
- uri = URI.parse(File.join(@options[:url], '/api/v2/query'))
73
+ uri = _parse_uri('/api/v2/query')
74
74
  uri.query = URI.encode_www_form(org: org_param)
75
75
 
76
76
  _post_json(payload.to_body.to_json, uri)
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module InfluxDB2
22
- VERSION = '1.4.0'.freeze
22
+ VERSION = '1.5.0'.freeze
23
23
  end
@@ -101,14 +101,14 @@ module InfluxDB2
101
101
  # },
102
102
  # {name: 'gpu', fields: {value: 0.9999}}
103
103
  # ],
104
- # precision: InfluxDB::WritePrecision::NANOSECOND,
104
+ # precision: InfluxDB2::WritePrecision::NANOSECOND,
105
105
  # bucket: 'my-bucket',
106
106
  # org: 'my-org'
107
107
  # )
108
108
  #
109
109
  # @example write(data: 'h2o,location=west value=33i 15')
110
110
  #
111
- # @example point = InfluxDB::Point.new(name: 'h2o')
111
+ # @example point = InfluxDB2::Point.new(name: 'h2o')
112
112
  # .add_tag('location', 'europe')
113
113
  # .add_field('level', 2)
114
114
  #
@@ -160,7 +160,7 @@ module InfluxDB2
160
160
 
161
161
  return nil unless payload.instance_of?(String) || payload.empty?
162
162
 
163
- uri = URI.parse(File.join(@options[:url], '/api/v2/write'))
163
+ uri = _parse_uri('/api/v2/write')
164
164
  uri.query = URI.encode_www_form(bucket: bucket_param, org: org_param, precision: precision_param.to_s)
165
165
 
166
166
  _post_text(payload, uri)
@@ -89,4 +89,11 @@ class ClientTest < Minitest::Test
89
89
  assert_equal 'influxdb', health.name
90
90
  assert_equal 'fail', health.status
91
91
  end
92
+
93
+ def test_trailing_slash_in_url
94
+ uri = URI.parse(File.join('http://localhost:8099', '/api/v2/write'))
95
+ assert_equal 'http://localhost:8099/api/v2/write', uri.to_s
96
+ uri = URI.parse(File.join('http://localhost:8099/', '/api/v2/write'))
97
+ assert_equal 'http://localhost:8099/api/v2/write', uri.to_s
98
+ end
92
99
  end
@@ -272,4 +272,19 @@ class WriteApiTest < MiniTest::Test
272
272
  assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
273
273
  times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
274
274
  end
275
+
276
+ def test_trailing_slash_in_url
277
+ stub_request(:any, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
278
+ .to_return(status: 204)
279
+ client = InfluxDB2::Client.new('http://localhost:9999/', 'my-token',
280
+ bucket: 'my-bucket',
281
+ org: 'my-org',
282
+ precision: InfluxDB2::WritePrecision::NANOSECOND,
283
+ use_ssl: false)
284
+
285
+ client.create_write_api.write(data: 'h2o,location=west value=33i 15')
286
+
287
+ assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
288
+ times: 1, body: 'h2o,location=west value=33i 15')
289
+ end
275
290
  end
@@ -30,7 +30,7 @@ if ENV['CI'] == 'true'
30
30
  end
31
31
 
32
32
  $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
33
- require 'influxdb2/client'
33
+ require 'influxdb-client'
34
34
 
35
35
  require 'minitest/autorun'
36
36
  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.4.0.pre.771
4
+ version: 1.5.0.pre.902
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-04-17 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,7 +147,7 @@ files:
147
147
  - bin/swagger.yml
148
148
  - examples/influxdb_18_example.rb
149
149
  - influxdb-client.gemspec
150
- - lib/influxdb2/client.rb
150
+ - lib/influxdb-client.rb
151
151
  - lib/influxdb2/client/client.rb
152
152
  - lib/influxdb2/client/default_api.rb
153
153
  - lib/influxdb2/client/delete_api.rb