influxdb-client-apis 2.9.0.pre.6326 → 2.9.0.pre.6549
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/influxdb-client-apis.rb +12 -0
- data/lib/influxdb2/apis/api.rb +7 -0
- data/lib/influxdb2/apis/generated/api/tasks_api.rb +1419 -0
- data/lib/influxdb2/apis/generated/models/log_event.rb +231 -0
- data/lib/influxdb2/apis/generated/models/logs.rb +212 -0
- data/lib/influxdb2/apis/generated/models/run.rb +333 -0
- data/lib/influxdb2/apis/generated/models/run_links.rb +228 -0
- data/lib/influxdb2/apis/generated/models/runs.rb +221 -0
- data/lib/influxdb2/apis/generated/models/task.rb +440 -0
- data/lib/influxdb2/apis/generated/models/task_create_request.rb +265 -0
- data/lib/influxdb2/apis/generated/models/task_links.rb +261 -0
- data/lib/influxdb2/apis/generated/models/task_status_type.rb +37 -0
- data/lib/influxdb2/apis/generated/models/task_update_request.rb +270 -0
- data/lib/influxdb2/apis/generated/models/tasks.rb +221 -0
- data/test/influxdb2/tasks_api_test.rb +104 -0
- data/test/test_helper.rb +1 -1
- metadata +18 -4
@@ -0,0 +1,270 @@
|
|
1
|
+
=begin
|
2
|
+
#InfluxDB OSS API Service
|
3
|
+
|
4
|
+
#The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
require 'set'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module InfluxDB2::API
|
17
|
+
class TaskUpdateRequest
|
18
|
+
attr_accessor :status
|
19
|
+
|
20
|
+
# Flux with [task configuration options](https://docs.influxdata.com/influxdb/latest/process-data/task-options/) and the script for the task to run. #### Related guides - [Task configuration options](https://docs.influxdata.com/influxdb/latest/process-data/task-options/)
|
21
|
+
attr_accessor :flux
|
22
|
+
|
23
|
+
# The name of the task.
|
24
|
+
attr_accessor :name
|
25
|
+
|
26
|
+
# The interval ([duration literal](https://docs.influxdata.com/influxdb/latest/reference/glossary/#rfc3339-timestamp)) at which the task runs. `every` also determines when the task first runs, depending on the specified time.
|
27
|
+
attr_accessor :every
|
28
|
+
|
29
|
+
# A [Cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. InfluxDB uses the system time when evaluating Cron expressions.
|
30
|
+
attr_accessor :cron
|
31
|
+
|
32
|
+
# A [duration](https://docs.influxdata.com/flux/v0.x/spec/lexical-elements/#duration-literals) to delay execution of the task after the scheduled time has elapsed. `0` removes the offset.
|
33
|
+
attr_accessor :offset
|
34
|
+
|
35
|
+
# A description of the task.
|
36
|
+
attr_accessor :description
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:'status' => :'status',
|
42
|
+
:'flux' => :'flux',
|
43
|
+
:'name' => :'name',
|
44
|
+
:'every' => :'every',
|
45
|
+
:'cron' => :'cron',
|
46
|
+
:'offset' => :'offset',
|
47
|
+
:'description' => :'description',
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.openapi_types
|
53
|
+
{
|
54
|
+
:'status' => :'TaskStatusType',
|
55
|
+
:'flux' => :'String',
|
56
|
+
:'name' => :'String',
|
57
|
+
:'every' => :'String',
|
58
|
+
:'cron' => :'String',
|
59
|
+
:'offset' => :'String',
|
60
|
+
:'description' => :'String'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# List of attributes with nullable: true
|
65
|
+
def self.openapi_nullable
|
66
|
+
Set.new([
|
67
|
+
])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Initializes the object
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
72
|
+
def initialize(attributes = {})
|
73
|
+
if (!attributes.is_a?(Hash))
|
74
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `InfluxDB2::TaskUpdateRequest` initialize method"
|
75
|
+
end
|
76
|
+
|
77
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
78
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
79
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
80
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `InfluxDB2::TaskUpdateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
81
|
+
end
|
82
|
+
h[k.to_sym] = v
|
83
|
+
}
|
84
|
+
|
85
|
+
if attributes.key?(:'status')
|
86
|
+
self.status = attributes[:'status']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'flux')
|
90
|
+
self.flux = attributes[:'flux']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'name')
|
94
|
+
self.name = attributes[:'name']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'every')
|
98
|
+
self.every = attributes[:'every']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'cron')
|
102
|
+
self.cron = attributes[:'cron']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'offset')
|
106
|
+
self.offset = attributes[:'offset']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'description')
|
110
|
+
self.description = attributes[:'description']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
115
|
+
# @return Array for valid properties with the reasons
|
116
|
+
def list_invalid_properties
|
117
|
+
invalid_properties = Array.new
|
118
|
+
invalid_properties
|
119
|
+
end
|
120
|
+
|
121
|
+
# Check to see if the all the properties in the model are valid
|
122
|
+
# @return true if the model is valid
|
123
|
+
def valid?
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
127
|
+
# Checks equality by comparing each attribute.
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def ==(o)
|
130
|
+
return true if self.equal?(o)
|
131
|
+
self.class == o.class &&
|
132
|
+
status == o.status &&
|
133
|
+
flux == o.flux &&
|
134
|
+
name == o.name &&
|
135
|
+
every == o.every &&
|
136
|
+
cron == o.cron &&
|
137
|
+
offset == o.offset &&
|
138
|
+
description == o.description
|
139
|
+
end
|
140
|
+
|
141
|
+
# @see the `==` method
|
142
|
+
# @param [Object] Object to be compared
|
143
|
+
def eql?(o)
|
144
|
+
self == o
|
145
|
+
end
|
146
|
+
|
147
|
+
# Calculates hash code according to all attributes.
|
148
|
+
# @return [Integer] Hash code
|
149
|
+
def hash
|
150
|
+
[status, flux, name, every, cron, offset, description].hash
|
151
|
+
end
|
152
|
+
|
153
|
+
# Builds the object from hash
|
154
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
+
# @return [Object] Returns the model itself
|
156
|
+
def self.build_from_hash(attributes)
|
157
|
+
new.build_from_hash(attributes)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Builds the object from hash
|
161
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
162
|
+
# @return [Object] Returns the model itself
|
163
|
+
def build_from_hash(attributes)
|
164
|
+
return nil unless attributes.is_a?(Hash)
|
165
|
+
self.class.openapi_types.each_pair do |key, type|
|
166
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
167
|
+
self.send("#{key}=", nil)
|
168
|
+
elsif type =~ /\AArray<(.*)>/i
|
169
|
+
# check to ensure the input is an array given that the attribute
|
170
|
+
# is documented as an array but the input is not
|
171
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
172
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
173
|
+
end
|
174
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
175
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
self
|
180
|
+
end
|
181
|
+
|
182
|
+
# Deserializes the data based on type
|
183
|
+
# @param string type Data type
|
184
|
+
# @param string value Value to be deserialized
|
185
|
+
# @return [Object] Deserialized data
|
186
|
+
def _deserialize(type, value)
|
187
|
+
case type.to_sym
|
188
|
+
when :Time
|
189
|
+
Time.parse(value)
|
190
|
+
when :Date
|
191
|
+
Date.parse(value)
|
192
|
+
when :String
|
193
|
+
value.to_s
|
194
|
+
when :Integer
|
195
|
+
value.to_i
|
196
|
+
when :Float
|
197
|
+
value.to_f
|
198
|
+
when :Boolean
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
else # model
|
219
|
+
InfluxDB2::API.const_get(type).build_from_hash(value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the string representation of the object
|
224
|
+
# @return [String] String presentation of the object
|
225
|
+
def to_s
|
226
|
+
to_hash.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
# to_body is an alias to to_hash (backward compatibility)
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_body
|
232
|
+
to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns the object in the form of hash
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
237
|
+
def to_hash
|
238
|
+
hash = {}
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
240
|
+
value = self.send(attr)
|
241
|
+
if value.nil?
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
244
|
+
end
|
245
|
+
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map { |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
=begin
|
2
|
+
#InfluxDB OSS API Service
|
3
|
+
|
4
|
+
#The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
require 'set'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module InfluxDB2::API
|
17
|
+
class Tasks
|
18
|
+
attr_accessor :links
|
19
|
+
|
20
|
+
attr_accessor :tasks
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'links' => :'links',
|
26
|
+
:'tasks' => :'tasks',
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.openapi_types
|
32
|
+
{
|
33
|
+
:'links' => :'Links',
|
34
|
+
:'tasks' => :'Array<Task>'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# List of attributes with nullable: true
|
39
|
+
def self.openapi_nullable
|
40
|
+
Set.new([
|
41
|
+
])
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
if (!attributes.is_a?(Hash))
|
48
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `InfluxDB2::Tasks` initialize method"
|
49
|
+
end
|
50
|
+
|
51
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
52
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
53
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
54
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `InfluxDB2::Tasks`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
55
|
+
end
|
56
|
+
h[k.to_sym] = v
|
57
|
+
}
|
58
|
+
|
59
|
+
if attributes.key?(:'links')
|
60
|
+
self.links = attributes[:'links']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.key?(:'tasks')
|
64
|
+
if (value = attributes[:'tasks']).is_a?(Array)
|
65
|
+
self.tasks = value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
71
|
+
# @return Array for valid properties with the reasons
|
72
|
+
def list_invalid_properties
|
73
|
+
invalid_properties = Array.new
|
74
|
+
invalid_properties
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check to see if the all the properties in the model are valid
|
78
|
+
# @return true if the model is valid
|
79
|
+
def valid?
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks equality by comparing each attribute.
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def ==(o)
|
86
|
+
return true if self.equal?(o)
|
87
|
+
self.class == o.class &&
|
88
|
+
links == o.links &&
|
89
|
+
tasks == o.tasks
|
90
|
+
end
|
91
|
+
|
92
|
+
# @see the `==` method
|
93
|
+
# @param [Object] Object to be compared
|
94
|
+
def eql?(o)
|
95
|
+
self == o
|
96
|
+
end
|
97
|
+
|
98
|
+
# Calculates hash code according to all attributes.
|
99
|
+
# @return [Integer] Hash code
|
100
|
+
def hash
|
101
|
+
[links, tasks].hash
|
102
|
+
end
|
103
|
+
|
104
|
+
# Builds the object from hash
|
105
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
106
|
+
# @return [Object] Returns the model itself
|
107
|
+
def self.build_from_hash(attributes)
|
108
|
+
new.build_from_hash(attributes)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Builds the object from hash
|
112
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
113
|
+
# @return [Object] Returns the model itself
|
114
|
+
def build_from_hash(attributes)
|
115
|
+
return nil unless attributes.is_a?(Hash)
|
116
|
+
self.class.openapi_types.each_pair do |key, type|
|
117
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
118
|
+
self.send("#{key}=", nil)
|
119
|
+
elsif type =~ /\AArray<(.*)>/i
|
120
|
+
# check to ensure the input is an array given that the attribute
|
121
|
+
# is documented as an array but the input is not
|
122
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
123
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
124
|
+
end
|
125
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
126
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
self
|
131
|
+
end
|
132
|
+
|
133
|
+
# Deserializes the data based on type
|
134
|
+
# @param string type Data type
|
135
|
+
# @param string value Value to be deserialized
|
136
|
+
# @return [Object] Deserialized data
|
137
|
+
def _deserialize(type, value)
|
138
|
+
case type.to_sym
|
139
|
+
when :Time
|
140
|
+
Time.parse(value)
|
141
|
+
when :Date
|
142
|
+
Date.parse(value)
|
143
|
+
when :String
|
144
|
+
value.to_s
|
145
|
+
when :Integer
|
146
|
+
value.to_i
|
147
|
+
when :Float
|
148
|
+
value.to_f
|
149
|
+
when :Boolean
|
150
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
151
|
+
true
|
152
|
+
else
|
153
|
+
false
|
154
|
+
end
|
155
|
+
when :Object
|
156
|
+
# generic object (usually a Hash), return directly
|
157
|
+
value
|
158
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
159
|
+
inner_type = Regexp.last_match[:inner_type]
|
160
|
+
value.map { |v| _deserialize(inner_type, v) }
|
161
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
162
|
+
k_type = Regexp.last_match[:k_type]
|
163
|
+
v_type = Regexp.last_match[:v_type]
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each do |k, v|
|
166
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else # model
|
170
|
+
InfluxDB2::API.const_get(type).build_from_hash(value)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the string representation of the object
|
175
|
+
# @return [String] String presentation of the object
|
176
|
+
def to_s
|
177
|
+
to_hash.to_s
|
178
|
+
end
|
179
|
+
|
180
|
+
# to_body is an alias to to_hash (backward compatibility)
|
181
|
+
# @return [Hash] Returns the object in the form of hash
|
182
|
+
def to_body
|
183
|
+
to_hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the object in the form of hash
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
188
|
+
def to_hash
|
189
|
+
hash = {}
|
190
|
+
self.class.attribute_map.each_pair do |attr, param|
|
191
|
+
value = self.send(attr)
|
192
|
+
if value.nil?
|
193
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
194
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
195
|
+
end
|
196
|
+
|
197
|
+
hash[param] = _to_hash(value)
|
198
|
+
end
|
199
|
+
hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Outputs non-array value in the form of hash
|
203
|
+
# For object, use to_hash. Otherwise, just return the value
|
204
|
+
# @param [Object] value Any valid value
|
205
|
+
# @return [Hash] Returns the value in the form of hash
|
206
|
+
def _to_hash(value)
|
207
|
+
if value.is_a?(Array)
|
208
|
+
value.compact.map { |v| _to_hash(v) }
|
209
|
+
elsif value.is_a?(Hash)
|
210
|
+
{}.tap do |hash|
|
211
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
212
|
+
end
|
213
|
+
elsif value.respond_to? :to_hash
|
214
|
+
value.to_hash
|
215
|
+
else
|
216
|
+
value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
require 'base_api_test'
|
21
|
+
require 'test_helper'
|
22
|
+
|
23
|
+
class TasksApiTest < BaseApiTests
|
24
|
+
def setup
|
25
|
+
super
|
26
|
+
@client.create_tasks_api.get_tasks.tasks.each do |task|
|
27
|
+
next unless task.name.end_with?('_TEST')
|
28
|
+
|
29
|
+
@client.create_tasks_api.delete_tasks_id(task.id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_create_task
|
34
|
+
name = generate_name('task')
|
35
|
+
flux = "option task = {name: \"#{name}\", every: 1h}
|
36
|
+
|
37
|
+
from(bucket: \"telegraf\")
|
38
|
+
|> range(start: -1h)
|
39
|
+
|> filter(fn: (r) => r._measurement == \"cpu\")
|
40
|
+
|> filter(fn: (r) => r._field == \"usage_system\")"
|
41
|
+
|
42
|
+
request = InfluxDB2::API::TaskCreateRequest.new(org_id: @my_org.id,
|
43
|
+
description: 'This task testing API',
|
44
|
+
flux: flux,
|
45
|
+
status: InfluxDB2::API::TaskStatusType::ACTIVE)
|
46
|
+
|
47
|
+
task = @client.create_tasks_api.post_tasks(request)
|
48
|
+
|
49
|
+
refute_nil task.id
|
50
|
+
assert_equal name, task.name
|
51
|
+
assert_equal @my_org.name, task.org
|
52
|
+
assert_equal @my_org.id, task.org_id
|
53
|
+
assert_equal 'This task testing API', task.description
|
54
|
+
assert_equal InfluxDB2::API::TaskStatusType::ACTIVE, task.status
|
55
|
+
assert_equal flux, task.flux
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_update_task
|
59
|
+
task = _create_task
|
60
|
+
|
61
|
+
request = InfluxDB2::API::TaskUpdateRequest.new(flux: task.flux,
|
62
|
+
description: 'Updated description for testing Task')
|
63
|
+
task = @client.create_tasks_api.patch_tasks_id(task.id, request)
|
64
|
+
|
65
|
+
assert_equal 'Updated description for testing Task', task.description
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_list_task
|
69
|
+
task = _create_task
|
70
|
+
|
71
|
+
tasks = @client.create_tasks_api.get_tasks.tasks
|
72
|
+
assert_equal 1, tasks.length
|
73
|
+
assert_equal task.name, tasks[0].name
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_delete_task
|
77
|
+
task = _create_task
|
78
|
+
|
79
|
+
tasks = @client.create_tasks_api.get_tasks.tasks
|
80
|
+
assert_equal 1, tasks.length
|
81
|
+
|
82
|
+
@client.create_tasks_api.delete_tasks_id(task.id)
|
83
|
+
|
84
|
+
tasks = @client.create_tasks_api.get_tasks.tasks
|
85
|
+
assert_equal 0, tasks.length
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def _create_task
|
91
|
+
flux = "option task = {name: \"#{generate_name('task')}\", every: 1h}
|
92
|
+
|
93
|
+
from(bucket: \"telegraf\")
|
94
|
+
|> range(start: -1h)
|
95
|
+
|> filter(fn: (r) => r._measurement == \"cpu\")
|
96
|
+
|> filter(fn: (r) => r._field == \"usage_system\")"
|
97
|
+
|
98
|
+
request = InfluxDB2::API::TaskCreateRequest.new(org_id: @my_org.id,
|
99
|
+
flux: flux,
|
100
|
+
status: InfluxDB2::API::TaskStatusType::ACTIVE)
|
101
|
+
|
102
|
+
@client.create_tasks_api.post_tasks(request)
|
103
|
+
end
|
104
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client-apis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.0.pre.
|
4
|
+
version: 2.9.0.pre.6549
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: influxdb-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.9.0.pre.
|
19
|
+
version: 2.9.0.pre.6549
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.9.0.pre.
|
26
|
+
version: 2.9.0.pre.6549
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: typhoeus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/influxdb2/apis/generated/api/buckets_api.rb
|
159
159
|
- lib/influxdb2/apis/generated/api/labels_api.rb
|
160
160
|
- lib/influxdb2/apis/generated/api/organizations_api.rb
|
161
|
+
- lib/influxdb2/apis/generated/api/tasks_api.rb
|
161
162
|
- lib/influxdb2/apis/generated/api/users_api.rb
|
162
163
|
- lib/influxdb2/apis/generated/api_client.rb
|
163
164
|
- lib/influxdb2/apis/generated/api_error.rb
|
@@ -179,6 +180,8 @@ files:
|
|
179
180
|
- lib/influxdb2/apis/generated/models/label_update.rb
|
180
181
|
- lib/influxdb2/apis/generated/models/labels_response.rb
|
181
182
|
- lib/influxdb2/apis/generated/models/links.rb
|
183
|
+
- lib/influxdb2/apis/generated/models/log_event.rb
|
184
|
+
- lib/influxdb2/apis/generated/models/logs.rb
|
182
185
|
- lib/influxdb2/apis/generated/models/organization.rb
|
183
186
|
- lib/influxdb2/apis/generated/models/organization_links.rb
|
184
187
|
- lib/influxdb2/apis/generated/models/organizations.rb
|
@@ -197,6 +200,15 @@ files:
|
|
197
200
|
- lib/influxdb2/apis/generated/models/resource_owner_all_of.rb
|
198
201
|
- lib/influxdb2/apis/generated/models/resource_owners.rb
|
199
202
|
- lib/influxdb2/apis/generated/models/retention_rule.rb
|
203
|
+
- lib/influxdb2/apis/generated/models/run.rb
|
204
|
+
- lib/influxdb2/apis/generated/models/run_links.rb
|
205
|
+
- lib/influxdb2/apis/generated/models/runs.rb
|
206
|
+
- lib/influxdb2/apis/generated/models/task.rb
|
207
|
+
- lib/influxdb2/apis/generated/models/task_create_request.rb
|
208
|
+
- lib/influxdb2/apis/generated/models/task_links.rb
|
209
|
+
- lib/influxdb2/apis/generated/models/task_status_type.rb
|
210
|
+
- lib/influxdb2/apis/generated/models/task_update_request.rb
|
211
|
+
- lib/influxdb2/apis/generated/models/tasks.rb
|
200
212
|
- lib/influxdb2/apis/generated/models/user.rb
|
201
213
|
- lib/influxdb2/apis/generated/models/user_response.rb
|
202
214
|
- lib/influxdb2/apis/generated/models/user_response_links.rb
|
@@ -208,6 +220,7 @@ files:
|
|
208
220
|
- test/influxdb2/buckets_api_test.rb
|
209
221
|
- test/influxdb2/labels_api_test.rb
|
210
222
|
- test/influxdb2/organizations_api_test.rb
|
223
|
+
- test/influxdb2/tasks_api_test.rb
|
211
224
|
- test/influxdb2/users_api_test.rb
|
212
225
|
- test/test_helper.rb
|
213
226
|
homepage: https://github.com/influxdata/influxdb-client-ruby
|
@@ -243,5 +256,6 @@ test_files:
|
|
243
256
|
- test/influxdb2/buckets_api_test.rb
|
244
257
|
- test/influxdb2/labels_api_test.rb
|
245
258
|
- test/influxdb2/organizations_api_test.rb
|
259
|
+
- test/influxdb2/tasks_api_test.rb
|
246
260
|
- test/influxdb2/users_api_test.rb
|
247
261
|
- test/test_helper.rb
|