influxdb-client 1.0.0.pre.191 → 1.1.0.pre.459

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,317 @@
1
+ =begin
2
+ #Influx API Service
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ OpenAPI spec version: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.4
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module InfluxDB2
16
+ # Dialect are options to change the default CSV output format; https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-descriptions
17
+ class Dialect
18
+ # If true, the results will contain a header row
19
+ attr_accessor :header
20
+
21
+ # Separator between cells; the default is ,
22
+ attr_accessor :delimiter
23
+
24
+ # Https://www.w3.org/TR/2015/REC-tabular-data-model-20151217/#columns
25
+ attr_accessor :annotations
26
+
27
+ # Character prefixed to comment strings
28
+ attr_accessor :comment_prefix
29
+
30
+ # Format of timestamps
31
+ attr_accessor :date_time_format
32
+
33
+ class EnumAttributeValidator
34
+ attr_reader :datatype
35
+ attr_reader :allowable_values
36
+
37
+ def initialize(datatype, allowable_values)
38
+ @allowable_values = allowable_values.map do |value|
39
+ case datatype.to_s
40
+ when /Integer/i
41
+ value.to_i
42
+ when /Float/i
43
+ value.to_f
44
+ else
45
+ value
46
+ end
47
+ end
48
+ end
49
+
50
+ def valid?(value)
51
+ !value || allowable_values.include?(value)
52
+ end
53
+ end
54
+
55
+ # Attribute mapping from ruby-style variable name to JSON key.
56
+ def self.attribute_map
57
+ {
58
+ :'header' => :'header',
59
+ :'delimiter' => :'delimiter',
60
+ :'annotations' => :'annotations',
61
+ :'comment_prefix' => :'commentPrefix',
62
+ :'date_time_format' => :'dateTimeFormat'
63
+ }
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'header' => :'BOOLEAN',
70
+ :'delimiter' => :'String',
71
+ :'annotations' => :'Array<String>',
72
+ :'comment_prefix' => :'String',
73
+ :'date_time_format' => :'String'
74
+ }
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ return unless attributes.is_a?(Hash)
81
+
82
+ # convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
84
+
85
+ if attributes.has_key?(:'header')
86
+ self.header = attributes[:'header']
87
+ else
88
+ self.header = true
89
+ end
90
+
91
+ if attributes.has_key?(:'delimiter')
92
+ self.delimiter = attributes[:'delimiter']
93
+ else
94
+ self.delimiter = ','
95
+ end
96
+
97
+ if attributes.has_key?(:'annotations')
98
+ if (value = attributes[:'annotations']).is_a?(Array)
99
+ self.annotations = value
100
+ end
101
+ end
102
+
103
+ if attributes.has_key?(:'commentPrefix')
104
+ self.comment_prefix = attributes[:'commentPrefix']
105
+ else
106
+ self.comment_prefix = '#'
107
+ end
108
+
109
+ if attributes.has_key?(:'dateTimeFormat')
110
+ self.date_time_format = attributes[:'dateTimeFormat']
111
+ else
112
+ self.date_time_format = 'RFC3339'
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ invalid_properties = Array.new
120
+ if !@delimiter.nil? && @delimiter.to_s.length > 1
121
+ invalid_properties.push('invalid value for "delimiter", the character length must be smaller than or equal to 1.')
122
+ end
123
+
124
+ if !@delimiter.nil? && @delimiter.to_s.length < 1
125
+ invalid_properties.push('invalid value for "delimiter", the character length must be great than or equal to 1.')
126
+ end
127
+
128
+ if !@comment_prefix.nil? && @comment_prefix.to_s.length > 1
129
+ invalid_properties.push('invalid value for "comment_prefix", the character length must be smaller than or equal to 1.')
130
+ end
131
+
132
+ if !@comment_prefix.nil? && @comment_prefix.to_s.length < 0
133
+ invalid_properties.push('invalid value for "comment_prefix", the character length must be great than or equal to 0.')
134
+ end
135
+
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ return false if !@delimiter.nil? && @delimiter.to_s.length > 1
143
+ return false if !@delimiter.nil? && @delimiter.to_s.length < 1
144
+ return false if !@comment_prefix.nil? && @comment_prefix.to_s.length > 1
145
+ return false if !@comment_prefix.nil? && @comment_prefix.to_s.length < 0
146
+ date_time_format_validator = EnumAttributeValidator.new('String', ['RFC3339', 'RFC3339Nano'])
147
+ return false unless date_time_format_validator.valid?(@date_time_format)
148
+ true
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] delimiter Value to be assigned
153
+ def delimiter=(delimiter)
154
+ if !delimiter.nil? && delimiter.to_s.length > 1
155
+ fail ArgumentError, 'invalid value for "delimiter", the character length must be smaller than or equal to 1.'
156
+ end
157
+
158
+ if !delimiter.nil? && delimiter.to_s.length < 1
159
+ fail ArgumentError, 'invalid value for "delimiter", the character length must be great than or equal to 1.'
160
+ end
161
+
162
+ @delimiter = delimiter
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] comment_prefix Value to be assigned
167
+ def comment_prefix=(comment_prefix)
168
+ if !comment_prefix.nil? && comment_prefix.to_s.length > 1
169
+ fail ArgumentError, 'invalid value for "comment_prefix", the character length must be smaller than or equal to 1.'
170
+ end
171
+
172
+ if !comment_prefix.nil? && comment_prefix.to_s.length < 0
173
+ fail ArgumentError, 'invalid value for "comment_prefix", the character length must be great than or equal to 0.'
174
+ end
175
+
176
+ @comment_prefix = comment_prefix
177
+ end
178
+
179
+ # Custom attribute writer method checking allowed values (enum).
180
+ # @param [Object] date_time_format Object to be assigned
181
+ def date_time_format=(date_time_format)
182
+ validator = EnumAttributeValidator.new('String', ['RFC3339', 'RFC3339Nano'])
183
+ unless validator.valid?(date_time_format)
184
+ fail ArgumentError, 'invalid value for "date_time_format", must be one of #{validator.allowable_values}.'
185
+ end
186
+ @date_time_format = date_time_format
187
+ end
188
+
189
+ # Checks equality by comparing each attribute.
190
+ # @param [Object] Object to be compared
191
+ def ==(o)
192
+ return true if self.equal?(o)
193
+ self.class == o.class &&
194
+ header == o.header &&
195
+ delimiter == o.delimiter &&
196
+ annotations == o.annotations &&
197
+ comment_prefix == o.comment_prefix &&
198
+ date_time_format == o.date_time_format
199
+ end
200
+
201
+ # @see the `==` method
202
+ # @param [Object] Object to be compared
203
+ def eql?(o)
204
+ self == o
205
+ end
206
+
207
+ # Calculates hash code according to all attributes.
208
+ # @return [Fixnum] Hash code
209
+ def hash
210
+ [header, delimiter, annotations, comment_prefix, date_time_format].hash
211
+ end
212
+
213
+ # Builds the object from hash
214
+ # @param [Hash] attributes Model attributes in the form of hash
215
+ # @return [Object] Returns the model itself
216
+ def build_from_hash(attributes)
217
+ return nil unless attributes.is_a?(Hash)
218
+ 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
221
+ # is documented as an array but the input is not
222
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
223
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
224
+ end
225
+ elsif !attributes[self.class.attribute_map[key]].nil?
226
+ 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
228
+ end
229
+
230
+ self
231
+ end
232
+
233
+ # Deserializes the data based on type
234
+ # @param string type Data type
235
+ # @param string value Value to be deserialized
236
+ # @return [Object] Deserialized data
237
+ def _deserialize(type, value)
238
+ case type.to_sym
239
+ when :DateTime
240
+ DateTime.parse(value)
241
+ when :Date
242
+ Date.parse(value)
243
+ when :String
244
+ value.to_s
245
+ when :Integer
246
+ value.to_i
247
+ when :Float
248
+ value.to_f
249
+ when :BOOLEAN
250
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
251
+ true
252
+ else
253
+ false
254
+ end
255
+ when :Object
256
+ # generic object (usually a Hash), return directly
257
+ value
258
+ when /\AArray<(?<inner_type>.+)>\z/
259
+ inner_type = Regexp.last_match[:inner_type]
260
+ value.map { |v| _deserialize(inner_type, v) }
261
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
262
+ k_type = Regexp.last_match[:k_type]
263
+ v_type = Regexp.last_match[:v_type]
264
+ {}.tap do |hash|
265
+ value.each do |k, v|
266
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
267
+ end
268
+ end
269
+ else # model
270
+ temp_model = InfluxDB2.const_get(type).new
271
+ temp_model.build_from_hash(value)
272
+ end
273
+ end
274
+
275
+ # Returns the string representation of the object
276
+ # @return [String] String presentation of the object
277
+ def to_s
278
+ to_hash.to_s
279
+ end
280
+
281
+ # to_body is an alias to to_hash (backward compatibility)
282
+ # @return [Hash] Returns the object in the form of hash
283
+ def to_body
284
+ to_hash
285
+ end
286
+
287
+ # Returns the object in the form of hash
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_hash
290
+ hash = {}
291
+ self.class.attribute_map.each_pair do |attr, param|
292
+ value = self.send(attr)
293
+ next if value.nil?
294
+ hash[param] = _to_hash(value)
295
+ end
296
+ hash
297
+ end
298
+
299
+ # Outputs non-array value in the form of hash
300
+ # For object, use to_hash. Otherwise, just return the value
301
+ # @param [Object] value Any valid value
302
+ # @return [Hash] Returns the value in the form of hash
303
+ def _to_hash(value)
304
+ if value.is_a?(Array)
305
+ value.compact.map { |v| _to_hash(v) }
306
+ elsif value.is_a?(Hash)
307
+ {}.tap do |hash|
308
+ value.each { |k, v| hash[k] = _to_hash(v) }
309
+ end
310
+ elsif value.respond_to? :to_hash
311
+ value.to_hash
312
+ else
313
+ value
314
+ end
315
+ end
316
+ end
317
+ end
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #Influx API Service
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ OpenAPI spec version: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.4
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module InfluxDB2
16
+ # Query influx with specific return formatting.
17
+ class Query
18
+ attr_accessor :extern
19
+
20
+ # Query script to execute.
21
+ attr_accessor :query
22
+
23
+ # The type of query.
24
+ attr_accessor :type
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
+ attr_accessor :dialect
36
+
37
+ class EnumAttributeValidator
38
+ attr_reader :datatype
39
+ attr_reader :allowable_values
40
+
41
+ def initialize(datatype, allowable_values)
42
+ @allowable_values = allowable_values.map do |value|
43
+ case datatype.to_s
44
+ when /Integer/i
45
+ value.to_i
46
+ when /Float/i
47
+ value.to_f
48
+ else
49
+ value
50
+ end
51
+ end
52
+ end
53
+
54
+ def valid?(value)
55
+ !value || allowable_values.include?(value)
56
+ end
57
+ end
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'extern' => :'extern',
63
+ :'query' => :'query',
64
+ :'type' => :'type',
65
+ :'db' => :'db',
66
+ :'rp' => :'rp',
67
+ :'cluster' => :'cluster',
68
+ :'dialect' => :'dialect'
69
+ }
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'extern' => :'File',
76
+ :'query' => :'String',
77
+ :'type' => :'String',
78
+ :'db' => :'String',
79
+ :'rp' => :'String',
80
+ :'cluster' => :'String',
81
+ :'dialect' => :'Dialect'
82
+ }
83
+ end
84
+
85
+ # Initializes the object
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ def initialize(attributes = {})
88
+ return unless attributes.is_a?(Hash)
89
+
90
+ # convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
92
+
93
+ if attributes.has_key?(:'extern')
94
+ self.extern = attributes[:'extern']
95
+ end
96
+
97
+ if attributes.has_key?(:'query')
98
+ self.query = attributes[:'query']
99
+ end
100
+
101
+ if attributes.has_key?(:'type')
102
+ 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
+ end
118
+
119
+ if attributes.has_key?(:'dialect')
120
+ self.dialect = attributes[:'dialect']
121
+ end
122
+ end
123
+
124
+ # Show invalid properties with the reasons. Usually used together with valid?
125
+ # @return Array for valid properties with the reasons
126
+ def list_invalid_properties
127
+ invalid_properties = Array.new
128
+ if @query.nil?
129
+ invalid_properties.push('invalid value for "query", query cannot be nil.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ return false if @query.nil?
139
+ type_validator = EnumAttributeValidator.new('String', ['flux', 'influxql'])
140
+ return false unless type_validator.valid?(@type)
141
+ true
142
+ end
143
+
144
+ # Custom attribute writer method checking allowed values (enum).
145
+ # @param [Object] type Object to be assigned
146
+ def type=(type)
147
+ validator = EnumAttributeValidator.new('String', ['flux', 'influxql'])
148
+ unless validator.valid?(type)
149
+ fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.'
150
+ end
151
+ @type = type
152
+ end
153
+
154
+ # Checks equality by comparing each attribute.
155
+ # @param [Object] Object to be compared
156
+ def ==(o)
157
+ return true if self.equal?(o)
158
+ self.class == o.class &&
159
+ extern == o.extern &&
160
+ query == o.query &&
161
+ type == o.type &&
162
+ db == o.db &&
163
+ rp == o.rp &&
164
+ cluster == o.cluster &&
165
+ dialect == o.dialect
166
+ end
167
+
168
+ # @see the `==` method
169
+ # @param [Object] Object to be compared
170
+ def eql?(o)
171
+ self == o
172
+ end
173
+
174
+ # Calculates hash code according to all attributes.
175
+ # @return [Fixnum] Hash code
176
+ def hash
177
+ [extern, query, type, db, rp, cluster, dialect].hash
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+ self.class.openapi_types.each_pair do |key, type|
186
+ if type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
190
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
191
+ end
192
+ elsif !attributes[self.class.attribute_map[key]].nil?
193
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
194
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
195
+ end
196
+
197
+ self
198
+ end
199
+
200
+ # Deserializes the data based on type
201
+ # @param string type Data type
202
+ # @param string value Value to be deserialized
203
+ # @return [Object] Deserialized data
204
+ def _deserialize(type, value)
205
+ case type.to_sym
206
+ when :DateTime
207
+ DateTime.parse(value)
208
+ when :Date
209
+ Date.parse(value)
210
+ when :String
211
+ value.to_s
212
+ when :Integer
213
+ value.to_i
214
+ when :Float
215
+ value.to_f
216
+ when :BOOLEAN
217
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
218
+ true
219
+ else
220
+ false
221
+ end
222
+ when :Object
223
+ # generic object (usually a Hash), return directly
224
+ value
225
+ when /\AArray<(?<inner_type>.+)>\z/
226
+ inner_type = Regexp.last_match[:inner_type]
227
+ value.map { |v| _deserialize(inner_type, v) }
228
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
229
+ k_type = Regexp.last_match[:k_type]
230
+ v_type = Regexp.last_match[:v_type]
231
+ {}.tap do |hash|
232
+ value.each do |k, v|
233
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
234
+ end
235
+ end
236
+ else # model
237
+ temp_model = InfluxDB2.const_get(type).new
238
+ temp_model.build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ next if value.nil?
261
+ hash[param] = _to_hash(value)
262
+ end
263
+ hash
264
+ end
265
+
266
+ # Outputs non-array value in the form of hash
267
+ # For object, use to_hash. Otherwise, just return the value
268
+ # @param [Object] value Any valid value
269
+ # @return [Hash] Returns the value in the form of hash
270
+ def _to_hash(value)
271
+ if value.is_a?(Array)
272
+ value.compact.map { |v| _to_hash(v) }
273
+ elsif value.is_a?(Hash)
274
+ {}.tap do |hash|
275
+ value.each { |k, v| hash[k] = _to_hash(v) }
276
+ end
277
+ elsif value.respond_to? :to_hash
278
+ value.to_hash
279
+ else
280
+ value
281
+ end
282
+ end
283
+ end
284
+ end