Skip to content

Commit 7297785

Browse files
authored
feat(apis): add Task API (#126)
1 parent 6fef96a commit 7297785

File tree

18 files changed

+4283
-6
lines changed

18 files changed

+4283
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 2.9.0 [unreleased]
22

3+
### Features
4+
1. [#126](https://github.com/influxdata/influxdb-client-ruby/pull/126): Add `Task` API
5+
36
### Bug Fixes
47
1. [#123](https://github.com/influxdata/influxdb-client-ruby/pull/123): Duplicate columns warning shows in improper situations
58
1. [#124](https://github.com/influxdata/influxdb-client-ruby/pull/124): Query return type is `Array` instead of `Hash`

apis/lib/influxdb-client-apis.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
require 'influxdb2/apis/generated/models/label_update'
4545
require 'influxdb2/apis/generated/models/labels_response'
4646
require 'influxdb2/apis/generated/models/links'
47+
require 'influxdb2/apis/generated/models/log_event'
48+
require 'influxdb2/apis/generated/models/logs'
4749
require 'influxdb2/apis/generated/models/organization'
4850
require 'influxdb2/apis/generated/models/organization_links'
4951
require 'influxdb2/apis/generated/models/organizations'
@@ -62,6 +64,15 @@
6264
require 'influxdb2/apis/generated/models/resource_owner_all_of'
6365
require 'influxdb2/apis/generated/models/resource_owners'
6466
require 'influxdb2/apis/generated/models/retention_rule'
67+
require 'influxdb2/apis/generated/models/run'
68+
require 'influxdb2/apis/generated/models/run_links'
69+
require 'influxdb2/apis/generated/models/runs'
70+
require 'influxdb2/apis/generated/models/task'
71+
require 'influxdb2/apis/generated/models/task_create_request'
72+
require 'influxdb2/apis/generated/models/task_links'
73+
require 'influxdb2/apis/generated/models/task_status_type'
74+
require 'influxdb2/apis/generated/models/task_update_request'
75+
require 'influxdb2/apis/generated/models/tasks'
6576
require 'influxdb2/apis/generated/models/user'
6677
require 'influxdb2/apis/generated/models/users'
6778
require 'influxdb2/apis/generated/models/user_response'
@@ -73,3 +84,4 @@
7384
require 'influxdb2/apis/generated/api/labels_api'
7485
require 'influxdb2/apis/generated/api/organizations_api'
7586
require 'influxdb2/apis/generated/api/users_api'
87+
require 'influxdb2/apis/generated/api/tasks_api'

apis/lib/influxdb2/apis/api.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ def create_organizations_api
8686
def create_users_api
8787
InfluxDB2::API::UsersApi.new(@api_client)
8888
end
89+
90+
# Create a new instance of TasksApi.
91+
#
92+
# @return [InfluxDB2::API::TasksApi] New instance of TasksApi.
93+
def create_tasks_api
94+
InfluxDB2::API::TasksApi.new(@api_client)
95+
end
8996
end
9097
end
9198
end

apis/lib/influxdb2/apis/generated/api/tasks_api.rb

Lines changed: 1419 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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 LogEvent
18+
# The time ([RFC3339Nano date/time format](https://docs.influxdata.com/influxdb/latest/reference/glossary/#rfc3339nano-timestamp)) that the event occurred.
19+
attr_accessor :time
20+
21+
# A description of the event that occurred.
22+
attr_accessor :message
23+
24+
# The ID of the task run that generated the event.
25+
attr_accessor :run_id
26+
27+
# Attribute mapping from ruby-style variable name to JSON key.
28+
def self.attribute_map
29+
{
30+
:'time' => :'time',
31+
:'message' => :'message',
32+
:'run_id' => :'runID',
33+
}
34+
end
35+
36+
# Attribute type mapping.
37+
def self.openapi_types
38+
{
39+
:'time' => :'Time',
40+
:'message' => :'String',
41+
:'run_id' => :'String'
42+
}
43+
end
44+
45+
# List of attributes with nullable: true
46+
def self.openapi_nullable
47+
Set.new([
48+
])
49+
end
50+
51+
# Initializes the object
52+
# @param [Hash] attributes Model attributes in the form of hash
53+
def initialize(attributes = {})
54+
if (!attributes.is_a?(Hash))
55+
fail ArgumentError, "The input argument (attributes) must be a hash in `InfluxDB2::LogEvent` initialize method"
56+
end
57+
58+
# check to see if the attribute exists and convert string to symbol for hash key
59+
attributes = attributes.each_with_object({}) { |(k, v), h|
60+
if (!self.class.attribute_map.key?(k.to_sym))
61+
fail ArgumentError, "`#{k}` is not a valid attribute in `InfluxDB2::LogEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62+
end
63+
h[k.to_sym] = v
64+
}
65+
66+
if attributes.key?(:'time')
67+
self.time = attributes[:'time']
68+
end
69+
70+
if attributes.key?(:'message')
71+
self.message = attributes[:'message']
72+
end
73+
74+
if attributes.key?(:'run_id')
75+
self.run_id = attributes[:'run_id']
76+
end
77+
end
78+
79+
# Show invalid properties with the reasons. Usually used together with valid?
80+
# @return Array for valid properties with the reasons
81+
def list_invalid_properties
82+
invalid_properties = Array.new
83+
invalid_properties
84+
end
85+
86+
# Check to see if the all the properties in the model are valid
87+
# @return true if the model is valid
88+
def valid?
89+
true
90+
end
91+
92+
# Checks equality by comparing each attribute.
93+
# @param [Object] Object to be compared
94+
def ==(o)
95+
return true if self.equal?(o)
96+
self.class == o.class &&
97+
time == o.time &&
98+
message == o.message &&
99+
run_id == o.run_id
100+
end
101+
102+
# @see the `==` method
103+
# @param [Object] Object to be compared
104+
def eql?(o)
105+
self == o
106+
end
107+
108+
# Calculates hash code according to all attributes.
109+
# @return [Integer] Hash code
110+
def hash
111+
[time, message, run_id].hash
112+
end
113+
114+
# Builds the object from hash
115+
# @param [Hash] attributes Model attributes in the form of hash
116+
# @return [Object] Returns the model itself
117+
def self.build_from_hash(attributes)
118+
new.build_from_hash(attributes)
119+
end
120+
121+
# Builds the object from hash
122+
# @param [Hash] attributes Model attributes in the form of hash
123+
# @return [Object] Returns the model itself
124+
def build_from_hash(attributes)
125+
return nil unless attributes.is_a?(Hash)
126+
self.class.openapi_types.each_pair do |key, type|
127+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
128+
self.send("#{key}=", nil)
129+
elsif type =~ /\AArray<(.*)>/i
130+
# check to ensure the input is an array given that the attribute
131+
# is documented as an array but the input is not
132+
if attributes[self.class.attribute_map[key]].is_a?(Array)
133+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
134+
end
135+
elsif !attributes[self.class.attribute_map[key]].nil?
136+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
137+
end
138+
end
139+
140+
self
141+
end
142+
143+
# Deserializes the data based on type
144+
# @param string type Data type
145+
# @param string value Value to be deserialized
146+
# @return [Object] Deserialized data
147+
def _deserialize(type, value)
148+
case type.to_sym
149+
when :Time
150+
Time.parse(value)
151+
when :Date
152+
Date.parse(value)
153+
when :String
154+
value.to_s
155+
when :Integer
156+
value.to_i
157+
when :Float
158+
value.to_f
159+
when :Boolean
160+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
161+
true
162+
else
163+
false
164+
end
165+
when :Object
166+
# generic object (usually a Hash), return directly
167+
value
168+
when /\AArray<(?<inner_type>.+)>\z/
169+
inner_type = Regexp.last_match[:inner_type]
170+
value.map { |v| _deserialize(inner_type, v) }
171+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
172+
k_type = Regexp.last_match[:k_type]
173+
v_type = Regexp.last_match[:v_type]
174+
{}.tap do |hash|
175+
value.each do |k, v|
176+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
177+
end
178+
end
179+
else # model
180+
InfluxDB2::API.const_get(type).build_from_hash(value)
181+
end
182+
end
183+
184+
# Returns the string representation of the object
185+
# @return [String] String presentation of the object
186+
def to_s
187+
to_hash.to_s
188+
end
189+
190+
# to_body is an alias to to_hash (backward compatibility)
191+
# @return [Hash] Returns the object in the form of hash
192+
def to_body
193+
to_hash
194+
end
195+
196+
# Returns the object in the form of hash
197+
# @return [Hash] Returns the object in the form of hash
198+
def to_hash
199+
hash = {}
200+
self.class.attribute_map.each_pair do |attr, param|
201+
value = self.send(attr)
202+
if value.nil?
203+
is_nullable = self.class.openapi_nullable.include?(attr)
204+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
205+
end
206+
207+
hash[param] = _to_hash(value)
208+
end
209+
hash
210+
end
211+
212+
# Outputs non-array value in the form of hash
213+
# For object, use to_hash. Otherwise, just return the value
214+
# @param [Object] value Any valid value
215+
# @return [Hash] Returns the value in the form of hash
216+
def _to_hash(value)
217+
if value.is_a?(Array)
218+
value.compact.map { |v| _to_hash(v) }
219+
elsif value.is_a?(Hash)
220+
{}.tap do |hash|
221+
value.each { |k, v| hash[k] = _to_hash(v) }
222+
end
223+
elsif value.respond_to? :to_hash
224+
value.to_hash
225+
else
226+
value
227+
end
228+
end
229+
230+
end
231+
end

0 commit comments

Comments
 (0)