influxdb-client 1.12.0.pre.1894 → 1.12.0.pre.1923

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348cc579c1aa802928e344e2075f7aa4896363108f9e30407e07c8fe8d293686
4
- data.tar.gz: 434a5039b83030ce068a3b913880e2c3d084f495cfbd119a839428ceb08f4f5e
3
+ metadata.gz: 362357eca37d1e260da7a5849ba03a1cb171b3ab7b2d42d3f38d270b1527be07
4
+ data.tar.gz: 0651ff8e0891520e83abc964b32a2c59cf885a9b8bea6c069440fe662230f81a
5
5
  SHA512:
6
- metadata.gz: f917dc680761aabd57d033211da42712cb560c7461cec2f15f581e40e9f22b6e511c1e8c9874ceaa6f8dc8502c512dc09640f4cdbfdce7e601ba970670ab1788
7
- data.tar.gz: e5d9bc0d90cf42b3b9b8cd2e10c771f095cbe176adeb022ed903b27e347b028abde77c01bcb59113a419589dcfcce92bb429a4881e82269d5dcf0abedbf7fa2d
6
+ metadata.gz: 900e575115840c8e482efc3e916382c4c2d60c48225eb43e5f880df21ca088423939dcf903cc7afa5b5c03131021160de69b08ea2cb2bec2e9e77c850e248cf6
7
+ data.tar.gz: 429664825449c2c62f0ecaf25f9b61adb657b22dd7d90c79cfa70d627bfe186e748f81364ddfa5c01f1c36cc65a8ba8b925e7045a9eee0996ab5eb1b5f425da1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,7 @@
1
1
  ## 1.12.0 [unreleased]
2
2
 
3
3
  ### Features
4
+ 1. [#69](https://github.com/influxdata/influxdb-client-ruby/pull/69): Created `influxdb-client-apis` package for Management API
4
5
  1. [#71](https://github.com/influxdata/influxdb-client-ruby/pull/71): Added possibility to specify the certification verification behaviour
5
6
 
6
7
  ## 1.11.0 [2021-01-29]
data/README.md CHANGED
@@ -12,6 +12,37 @@ This repository contains the reference Ruby client for the InfluxDB 2.0.
12
12
 
13
13
  #### Note: Use this client library with InfluxDB 2.x and InfluxDB 1.8+ ([see details](#influxdb-18-api-compatibility)). For connecting to InfluxDB 1.7 or earlier instances, use the [influxdb-ruby](https://github.com/influxdata/influxdb-ruby) client library.
14
14
 
15
+ - [Features](#features)
16
+ - [Installation](#installation)
17
+ - [Install the Gem](#install-the-gem)
18
+ - [Usage](#usage)
19
+ - [Creating a client](#creating-a-client)
20
+ - [Writing data](#writing-data)
21
+ - [Querying data](#queries)
22
+ - [Delete data](#delete-data)
23
+ - [Management API](#management-api)
24
+ - [Advanced Usage](#advanced-usage)
25
+ - [Default Tags](#default-tags)
26
+ - [Contributing](#contributing)
27
+ - [License](#license)
28
+
29
+ ## Features
30
+
31
+ InfluxDB 2.0 client consists of two packages
32
+
33
+ - `influxdb-client`
34
+ - Querying data using the Flux language
35
+ - Writing data
36
+ - batched in chunks on background
37
+ - automatic retries on write failures
38
+ - `influxdb-client-apis`
39
+ - provides all other InfluxDB 2.0 APIs for managing
40
+ - buckets
41
+ - labels
42
+ - authorizations
43
+ - ...
44
+ - built on top of `influxdb-client`
45
+
15
46
  ## Installation
16
47
 
17
48
  The InfluxDB 2 client is bundled as a gem and is hosted on [Rubygems](https://rubygems.org/gems/influxdb-client).
@@ -26,6 +57,12 @@ To install the client gem manually:
26
57
  gem install influxdb-client -v 1.11.0
27
58
  ```
28
59
 
60
+ For management API:
61
+
62
+ ```
63
+ gem install influxdb-client-apis --pre
64
+ ```
65
+
29
66
  ## Usage
30
67
 
31
68
  ### Creating a client
@@ -267,6 +304,86 @@ The time range could be specified as:
267
304
  1. DateTime - `DateTime.rfc3339('2019-03-03T04:05:06+07:00')`
268
305
  1. Time - `Time.utc(2015, 10, 16, 8, 20, 15)`
269
306
 
307
+ ### Management API
308
+
309
+ The client supports following management API:
310
+
311
+ | | API docs |
312
+ | --- | --- |
313
+ | [**AuthorizationsApi**](https://influxdata.github.io/influxdb-client-ruby/InfluxDB2/API/AuthorizationsApi.html) | https://docs.influxdata.com/influxdb/v2.0/api/#tag/Authorizations |
314
+ | [**BucketsApi**](https://influxdata.github.io/influxdb-client-ruby/InfluxDB2/API/BucketsApi.html) | https://docs.influxdata.com/influxdb/v2.0/api/#tag/Buckets |
315
+ | [**LabelsApi**](https://influxdata.github.io/influxdb-client-ruby/InfluxDB2/API/LabelsApi.html) | https://docs.influxdata.com/influxdb/v2.0/api/#tag/Labels |
316
+ | [**OrganizationsApi**](https://influxdata.github.io/influxdb-client-ruby/InfluxDB2/API/OrganizationsApi.html) | https://docs.influxdata.com/influxdb/v2.0/api/#tag/Organizations |
317
+ | [**UsersApi**](https://influxdata.github.io/influxdb-client-ruby/InfluxDB2/API/UsersApi.html) | https://docs.influxdata.com/influxdb/v2.0/api/#tag/Users |
318
+
319
+
320
+ The following example demonstrates how to use a InfluxDB 2.0 Management API to create new bucket. For further information see docs and [examples](/examples).
321
+
322
+ ```ruby
323
+ #
324
+ # This is an example how to create new bucket with permission to write.
325
+ #
326
+ # You could run example via: `cd apis && bundle exec ruby ../examples/create_new_bucket.rb`
327
+ #
328
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
329
+ require 'influxdb-client'
330
+ $LOAD_PATH.unshift File.expand_path('../apis/lib', __dir__)
331
+ require 'influxdb-client-apis'
332
+
333
+ url = 'http://localhost:8086'
334
+ bucket = 'my-bucket'
335
+ org = 'my-org'
336
+ token = 'my-token'
337
+
338
+ client = InfluxDB2::Client.new(url,
339
+ token,
340
+ bucket: bucket,
341
+ org: org,
342
+ use_ssl: false,
343
+ precision: InfluxDB2::WritePrecision::NANOSECOND)
344
+
345
+ api = InfluxDB2::API::Client.new(client)
346
+
347
+ # Find my organization
348
+ organization = api.create_organizations_api
349
+ .get_orgs
350
+ .orgs
351
+ .select { |it| it.name == 'my-org' }
352
+ .first
353
+
354
+ #
355
+ # Create new Bucket
356
+ #
357
+ retention_rule = InfluxDB2::API::RetentionRule.new(type: 'expire', every_seconds: 3600)
358
+ bucket_name = 'new-bucket-name'
359
+ request = InfluxDB2::API::PostBucketRequest.new(org_id: organization.id,
360
+ name: bucket_name,
361
+ retention_rules: [retention_rule])
362
+ bucket = api.create_buckets_api
363
+ .post_buckets(request)
364
+
365
+ #
366
+ # Create Permission to read/write from Bucket
367
+ #
368
+ resource = InfluxDB2::API::Resource.new(type: 'buckets',
369
+ id: bucket.id,
370
+ org_id: organization.id)
371
+ authorization = InfluxDB2::API::Authorization.new(description: "Authorization to read/write bucket: #{bucket.name}",
372
+ org_id: organization.id,
373
+ permissions: [
374
+ InfluxDB2::API::Permission.new(action: 'read', resource: resource),
375
+ InfluxDB2::API::Permission.new(action: 'write', resource: resource)
376
+ ])
377
+ result = api.create_authorizations_api
378
+ .post_authorizations(authorization)
379
+
380
+ print("The token: '#{result.token}' is authorized to read/write from/to bucket: '#{bucket.name}'.")
381
+
382
+ client.close!
383
+
384
+ ```
385
+ - sources - [create_new_bucket.rb](/examples/create_new_bucket.rb)
386
+
270
387
  ## Advanced Usage
271
388
 
272
389
  ### Check the server status
@@ -22,6 +22,7 @@ lib = File.expand_path('lib', __dir__)
22
22
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
23
23
  require 'influxdb2/client/version'
24
24
 
25
+ # noinspection DuplicatedCode
25
26
  Gem::Specification.new do |spec|
26
27
  spec.name = 'influxdb-client'
27
28
  spec.version = ENV['CIRCLE_BUILD_NUM'] ? "#{InfluxDB2::VERSION}-#{ENV['CIRCLE_BUILD_NUM']}" : InfluxDB2::VERSION
@@ -37,8 +38,9 @@ Gem::Specification.new do |spec|
37
38
  spec.metadata['source_code_uri'] = 'https://github.com/influxdata/influxdb-client-ruby'
38
39
  spec.metadata['changelog_uri'] = 'https://raw.githubusercontent.com/influxdata/influxdb-client-ruby/master/CHANGELOG.md'
39
40
 
40
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
41
- spec.test_files = spec.files.grep(%r{^(test|spec|features|smoke)/})
41
+ spec.files = Dir.glob('lib/**/*')
42
+ spec.files += %w[influxdb-client.gemspec LICENSE README.md CHANGELOG.md Rakefile]
43
+ spec.test_files = Dir.glob('test/**/*')
42
44
  spec.require_paths = ['lib']
43
45
  spec.required_ruby_version = '>= 2.2.0'
44
46
 
@@ -46,7 +48,7 @@ Gem::Specification.new do |spec|
46
48
  spec.add_development_dependency 'codecov', '~> 0.1.16'
47
49
  spec.add_development_dependency 'minitest', '~> 5.0'
48
50
  spec.add_development_dependency 'minitest-reporters', '~> 1.4'
49
- spec.add_development_dependency 'rake', '>= 12.3.3'
51
+ spec.add_development_dependency 'rake', '~> 12.3'
50
52
  spec.add_development_dependency 'rubocop', '~> 0.66.0'
51
53
  spec.add_development_dependency 'simplecov', '~> 0.17.1'
52
54
  spec.add_development_dependency 'webmock', '~> 3.7'
@@ -3,14 +3,15 @@
3
3
 
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
- OpenAPI spec version: 0.1.0
6
+ The version of the OpenAPI document: 0.1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.4
9
+ OpenAPI Generator version: 5.0.0-beta3
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module InfluxDB2
16
17
  # The delete predicate request.
@@ -24,41 +25,54 @@ module InfluxDB2
24
25
  # InfluxQL-like delete statement
25
26
  attr_accessor :predicate
26
27
 
27
- # Attribute mapping from ruby-style variable name to JSON key.
28
+ # Attribute mapping from ruby-style variable name to JSON key
28
29
  def self.attribute_map
29
30
  {
30
31
  :'start' => :'start',
31
32
  :'stop' => :'stop',
32
- :'predicate' => :'predicate'
33
+ :'predicate' => :'predicate',
33
34
  }
34
35
  end
35
36
 
36
37
  # Attribute type mapping.
37
38
  def self.openapi_types
38
39
  {
39
- :'start' => :'DateTime',
40
- :'stop' => :'DateTime',
41
- :'predicate' => :'String'
40
+ :'start' => :'Time',
41
+ :'stop' => :'Time',
42
+ :'predicate' => :'String',
42
43
  }
43
44
  end
44
45
 
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
45
52
  # Initializes the object
46
53
  # @param [Hash] attributes Model attributes in the form of hash
47
54
  def initialize(attributes = {})
48
- return unless attributes.is_a?(Hash)
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `InfluxDB2::DeletePredicateRequest` initialize method"
57
+ end
49
58
 
50
- # convert string to symbol for hash key
51
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `InfluxDB2::DeletePredicateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
52
66
 
53
- if attributes.has_key?(:'start')
67
+ if attributes.key?(:'start')
54
68
  self.start = attributes[:'start']
55
69
  end
56
70
 
57
- if attributes.has_key?(:'stop')
71
+ if attributes.key?(:'stop')
58
72
  self.stop = attributes[:'stop']
59
73
  end
60
74
 
61
- if attributes.has_key?(:'predicate')
75
+ if attributes.key?(:'predicate')
62
76
  self.predicate = attributes[:'predicate']
63
77
  end
64
78
  end
@@ -103,9 +117,16 @@ module InfluxDB2
103
117
  end
104
118
 
105
119
  # Calculates hash code according to all attributes.
106
- # @return [Fixnum] Hash code
120
+ # @return [Integer] Hash code
107
121
  def hash
108
- [start, stop, predicate].hash
122
+ [start, stop, predicate, ].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
109
130
  end
110
131
 
111
132
  # Builds the object from hash
@@ -114,15 +135,17 @@ module InfluxDB2
114
135
  def build_from_hash(attributes)
115
136
  return nil unless attributes.is_a?(Hash)
116
137
  self.class.openapi_types.each_pair do |key, type|
117
- if type =~ /\AArray<(.*)>/i
118
- # check to ensure the input is an array given that the the attribute
138
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
139
+ self.send("#{key}=", nil)
140
+ elsif type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
119
142
  # is documented as an array but the input is not
120
143
  if attributes[self.class.attribute_map[key]].is_a?(Array)
121
144
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
122
145
  end
123
146
  elsif !attributes[self.class.attribute_map[key]].nil?
124
147
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
125
- end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
126
149
  end
127
150
 
128
151
  self
@@ -134,8 +157,8 @@ module InfluxDB2
134
157
  # @return [Object] Deserialized data
135
158
  def _deserialize(type, value)
136
159
  case type.to_sym
137
- when :DateTime
138
- DateTime.parse(value)
160
+ when :Time
161
+ Time.parse(value)
139
162
  when :Date
140
163
  Date.parse(value)
141
164
  when :String
@@ -144,7 +167,7 @@ module InfluxDB2
144
167
  value.to_i
145
168
  when :Float
146
169
  value.to_f
147
- when :BOOLEAN
170
+ when :Boolean
148
171
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
172
  true
150
173
  else
@@ -165,8 +188,7 @@ module InfluxDB2
165
188
  end
166
189
  end
167
190
  else # model
168
- temp_model = InfluxDB2.const_get(type).new
169
- temp_model.build_from_hash(value)
191
+ InfluxDB2.const_get(type).build_from_hash(value)
170
192
  end
171
193
  end
172
194
 
@@ -188,7 +210,11 @@ module InfluxDB2
188
210
  hash = {}
189
211
  self.class.attribute_map.each_pair do |attr, param|
190
212
  value = self.send(attr)
191
- next if value.nil?
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
192
218
  hash[param] = _to_hash(value)
193
219
  end
194
220
  hash
@@ -211,5 +237,6 @@ module InfluxDB2
211
237
  value
212
238
  end
213
239
  end
240
+
214
241
  end
215
242
  end
@@ -3,14 +3,15 @@
3
3
 
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
- OpenAPI spec version: 0.1.0
6
+ The version of the OpenAPI document: 0.1.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 3.3.4
9
+ OpenAPI Generator version: 5.0.0-beta3
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module InfluxDB2
16
17
  # Dialect are options to change the default CSV output format; https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions
@@ -19,16 +20,16 @@ module InfluxDB2
19
20
  attr_accessor :header
20
21
 
21
22
  # Separator between cells; the default is ,
22
- attr_accessor :delimiter
23
+ attr_reader :delimiter
23
24
 
24
- # Https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns
25
+ # https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns
25
26
  attr_accessor :annotations
26
27
 
27
28
  # Character prefixed to comment strings
28
- attr_accessor :comment_prefix
29
+ attr_reader :comment_prefix
29
30
 
30
31
  # Format of timestamps
31
- attr_accessor :date_time_format
32
+ attr_reader :date_time_format
32
33
 
33
34
  class EnumAttributeValidator
34
35
  attr_reader :datatype
@@ -52,62 +53,75 @@ module InfluxDB2
52
53
  end
53
54
  end
54
55
 
55
- # Attribute mapping from ruby-style variable name to JSON key.
56
+ # Attribute mapping from ruby-style variable name to JSON key
56
57
  def self.attribute_map
57
58
  {
58
59
  :'header' => :'header',
59
60
  :'delimiter' => :'delimiter',
60
61
  :'annotations' => :'annotations',
61
62
  :'comment_prefix' => :'commentPrefix',
62
- :'date_time_format' => :'dateTimeFormat'
63
+ :'date_time_format' => :'dateTimeFormat',
63
64
  }
64
65
  end
65
66
 
66
67
  # Attribute type mapping.
67
68
  def self.openapi_types
68
69
  {
69
- :'header' => :'BOOLEAN',
70
+ :'header' => :'Boolean',
70
71
  :'delimiter' => :'String',
71
72
  :'annotations' => :'Array<String>',
72
73
  :'comment_prefix' => :'String',
73
- :'date_time_format' => :'String'
74
+ :'date_time_format' => :'String',
74
75
  }
75
76
  end
76
77
 
78
+ # List of attributes with nullable: true
79
+ def self.openapi_nullable
80
+ Set.new([
81
+ ])
82
+ end
83
+
77
84
  # Initializes the object
78
85
  # @param [Hash] attributes Model attributes in the form of hash
79
86
  def initialize(attributes = {})
80
- return unless attributes.is_a?(Hash)
87
+ if (!attributes.is_a?(Hash))
88
+ fail ArgumentError, "The input argument (attributes) must be a hash in `InfluxDB2::Dialect` initialize method"
89
+ end
81
90
 
82
- # convert string to symbol for hash key
83
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
91
+ # check to see if the attribute exists and convert string to symbol for hash key
92
+ attributes = attributes.each_with_object({}) { |(k, v), h|
93
+ if (!self.class.attribute_map.key?(k.to_sym))
94
+ fail ArgumentError, "`#{k}` is not a valid attribute in `InfluxDB2::Dialect`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
95
+ end
96
+ h[k.to_sym] = v
97
+ }
84
98
 
85
- if attributes.has_key?(:'header')
99
+ if attributes.key?(:'header')
86
100
  self.header = attributes[:'header']
87
101
  else
88
102
  self.header = true
89
103
  end
90
104
 
91
- if attributes.has_key?(:'delimiter')
105
+ if attributes.key?(:'delimiter')
92
106
  self.delimiter = attributes[:'delimiter']
93
107
  else
94
108
  self.delimiter = ','
95
109
  end
96
110
 
97
- if attributes.has_key?(:'annotations')
111
+ if attributes.key?(:'annotations')
98
112
  if (value = attributes[:'annotations']).is_a?(Array)
99
113
  self.annotations = value
100
114
  end
101
115
  end
102
116
 
103
- if attributes.has_key?(:'commentPrefix')
104
- self.comment_prefix = attributes[:'commentPrefix']
117
+ if attributes.key?(:'comment_prefix')
118
+ self.comment_prefix = attributes[:'comment_prefix']
105
119
  else
106
120
  self.comment_prefix = '#'
107
121
  end
108
122
 
109
- if attributes.has_key?(:'dateTimeFormat')
110
- self.date_time_format = attributes[:'dateTimeFormat']
123
+ if attributes.key?(:'date_time_format')
124
+ self.date_time_format = attributes[:'date_time_format']
111
125
  else
112
126
  self.date_time_format = 'RFC3339'
113
127
  end
@@ -143,7 +157,7 @@ module InfluxDB2
143
157
  return false if !@delimiter.nil? && @delimiter.to_s.length < 1
144
158
  return false if !@comment_prefix.nil? && @comment_prefix.to_s.length > 1
145
159
  return false if !@comment_prefix.nil? && @comment_prefix.to_s.length < 0
146
- date_time_format_validator = EnumAttributeValidator.new('String', ['RFC3339', 'RFC3339Nano'])
160
+ date_time_format_validator = EnumAttributeValidator.new('String', ["RFC3339", "RFC3339Nano"])
147
161
  return false unless date_time_format_validator.valid?(@date_time_format)
148
162
  true
149
163
  end
@@ -179,9 +193,9 @@ module InfluxDB2
179
193
  # Custom attribute writer method checking allowed values (enum).
180
194
  # @param [Object] date_time_format Object to be assigned
181
195
  def date_time_format=(date_time_format)
182
- validator = EnumAttributeValidator.new('String', ['RFC3339', 'RFC3339Nano'])
196
+ validator = EnumAttributeValidator.new('String', ["RFC3339", "RFC3339Nano"])
183
197
  unless validator.valid?(date_time_format)
184
- fail ArgumentError, 'invalid value for "date_time_format", must be one of #{validator.allowable_values}.'
198
+ fail ArgumentError, "invalid value for \"date_time_format\", must be one of #{validator.allowable_values}."
185
199
  end
186
200
  @date_time_format = date_time_format
187
201
  end
@@ -205,9 +219,16 @@ module InfluxDB2
205
219
  end
206
220
 
207
221
  # Calculates hash code according to all attributes.
208
- # @return [Fixnum] Hash code
222
+ # @return [Integer] Hash code
209
223
  def hash
210
- [header, delimiter, annotations, comment_prefix, date_time_format].hash
224
+ [header, delimiter, annotations, comment_prefix, date_time_format, ].hash
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def self.build_from_hash(attributes)
231
+ new.build_from_hash(attributes)
211
232
  end
212
233
 
213
234
  # Builds the object from hash
@@ -216,15 +237,17 @@ module InfluxDB2
216
237
  def build_from_hash(attributes)
217
238
  return nil unless attributes.is_a?(Hash)
218
239
  self.class.openapi_types.each_pair do |key, type|
219
- if type =~ /\AArray<(.*)>/i
220
- # check to ensure the input is an array given that the the attribute
240
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
241
+ self.send("#{key}=", nil)
242
+ elsif type =~ /\AArray<(.*)>/i
243
+ # check to ensure the input is an array given that the attribute
221
244
  # is documented as an array but the input is not
222
245
  if attributes[self.class.attribute_map[key]].is_a?(Array)
223
246
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
224
247
  end
225
248
  elsif !attributes[self.class.attribute_map[key]].nil?
226
249
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
227
- end # or else data not found in attributes(hash), not an issue as the data can be optional
250
+ end
228
251
  end
229
252
 
230
253
  self
@@ -236,8 +259,8 @@ module InfluxDB2
236
259
  # @return [Object] Deserialized data
237
260
  def _deserialize(type, value)
238
261
  case type.to_sym
239
- when :DateTime
240
- DateTime.parse(value)
262
+ when :Time
263
+ Time.parse(value)
241
264
  when :Date
242
265
  Date.parse(value)
243
266
  when :String
@@ -246,7 +269,7 @@ module InfluxDB2
246
269
  value.to_i
247
270
  when :Float
248
271
  value.to_f
249
- when :BOOLEAN
272
+ when :Boolean
250
273
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
251
274
  true
252
275
  else
@@ -267,8 +290,7 @@ module InfluxDB2
267
290
  end
268
291
  end
269
292
  else # model
270
- temp_model = InfluxDB2.const_get(type).new
271
- temp_model.build_from_hash(value)
293
+ InfluxDB2.const_get(type).build_from_hash(value)
272
294
  end
273
295
  end
274
296
 
@@ -290,7 +312,11 @@ module InfluxDB2
290
312
  hash = {}
291
313
  self.class.attribute_map.each_pair do |attr, param|
292
314
  value = self.send(attr)
293
- next if value.nil?
315
+ if value.nil?
316
+ is_nullable = self.class.openapi_nullable.include?(attr)
317
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
318
+ end
319
+
294
320
  hash[param] = _to_hash(value)
295
321
  end
296
322
  hash
@@ -313,5 +339,6 @@ module InfluxDB2
313
339
  value
314
340
  end
315
341
  end
342
+
316
343
  end
317
344
  end