dkron-rb 0.11.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +0 -0
- data/README.md +8 -7
- data/Rakefile +0 -4
- data/dkron-rb.gemspec +10 -11
- data/docs/DefaultApi.md +0 -0
- data/docs/Execution.md +0 -0
- data/docs/ExecutionsApi.md +1 -1
- data/docs/ExecutorConfig.md +0 -0
- data/docs/Job.md +0 -0
- data/docs/JobsApi.md +60 -6
- data/docs/Member.md +0 -0
- data/docs/MembersApi.md +0 -0
- data/docs/Processors.md +0 -0
- data/docs/Status.md +3 -0
- data/git_push.sh +3 -3
- data/lib/dkron-rb.rb +2 -2
- data/lib/dkron-rb/api/default_api.rb +12 -21
- data/lib/dkron-rb/api/executions_api.rb +6 -9
- data/lib/dkron-rb/api/jobs_api.rb +73 -33
- data/lib/dkron-rb/api/members_api.rb +6 -9
- data/lib/dkron-rb/api_client.rb +10 -10
- data/lib/dkron-rb/api_error.rb +2 -2
- data/lib/dkron-rb/configuration.rb +3 -3
- data/lib/dkron-rb/models/execution.rb +7 -11
- data/lib/dkron-rb/models/executor_config.rb +7 -11
- data/lib/dkron-rb/models/job.rb +9 -13
- data/lib/dkron-rb/models/member.rb +7 -11
- data/lib/dkron-rb/models/processors.rb +7 -11
- data/lib/dkron-rb/models/status.rb +37 -11
- data/lib/dkron-rb/version.rb +3 -3
- data/spec/api/default_api_spec.rb +5 -8
- data/spec/api/executions_api_spec.rb +3 -4
- data/spec/api/jobs_api_spec.rb +19 -12
- data/spec/api/members_api_spec.rb +3 -4
- data/spec/api_client_spec.rb +36 -36
- data/spec/configuration_spec.rb +10 -10
- data/spec/models/execution_spec.rb +8 -9
- data/spec/models/executor_config_spec.rb +2 -3
- data/spec/models/job_spec.rb +20 -21
- data/spec/models/member_spec.rb +13 -14
- data/spec/models/processors_spec.rb +2 -3
- data/spec/models/status_spec.rb +20 -3
- data/spec/spec_helper.rb +2 -2
- metadata +18 -45
- data/Gemfile.lock +0 -67
- data/LICENSE +0 -201
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/config.json +0 -5
- data/docs/Agent.md +0 -7
- data/docs/ExecutorShell.md +0 -10
- data/docs/InlineResponse200.md +0 -10
- data/docs/MainApi.md +0 -90
- data/docs/ProcessorFiles.md +0 -9
- data/docs/ProcessorLog.md +0 -8
- data/docs/ProcessorSyslog.md +0 -8
- data/docs/Serf.md +0 -7
- data/docs/Tags.md +0 -7
- data/lib/dkron-rb/cron.rb +0 -152
- data/lib/dkron-rb/models/agent.rb +0 -152
- data/lib/dkron-rb/models/executor_shell.rb +0 -208
- data/lib/dkron-rb/models/inline_response_200.rb +0 -181
- data/lib/dkron-rb/models/processor_files.rb +0 -198
- data/lib/dkron-rb/models/processor_log.rb +0 -189
- data/lib/dkron-rb/models/processor_syslog.rb +0 -189
- data/lib/dkron-rb/models/serf.rb +0 -152
- data/lib/dkron-rb/models/tags.rb +0 -152
- data/lib/dkron-rb/numeric_seconds.rb +0 -48
- data/lib/dkron.rb +0 -9
- data/node_modules/isarray/build/build.js +0 -209
- data/node_modules/mime/build/build.js +0 -11
- data/node_modules/mime/build/test.js +0 -57
@@ -1,198 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Dkron REST API
|
3
|
-
|
4
|
-
#You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response.
|
5
|
-
|
6
|
-
OpenAPI spec version: 0.10.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module Dkron
|
16
|
-
# Files processor save execution output to disk files.
|
17
|
-
class ProcessorFiles
|
18
|
-
# Forward the output to the next processor
|
19
|
-
attr_accessor :forward
|
20
|
-
|
21
|
-
attr_accessor :log_dir
|
22
|
-
|
23
|
-
|
24
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
-
def self.attribute_map
|
26
|
-
{
|
27
|
-
:'forward' => :'forward',
|
28
|
-
:'log_dir' => :'log_dir'
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
# Attribute type mapping.
|
33
|
-
def self.swagger_types
|
34
|
-
{
|
35
|
-
:'forward' => :'BOOLEAN',
|
36
|
-
:'log_dir' => :'String'
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
# Initializes the object
|
41
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
-
def initialize(attributes = {})
|
43
|
-
return unless attributes.is_a?(Hash)
|
44
|
-
|
45
|
-
# convert string to symbol for hash key
|
46
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
47
|
-
|
48
|
-
if attributes.has_key?(:'forward')
|
49
|
-
self.forward = attributes[:'forward']
|
50
|
-
end
|
51
|
-
|
52
|
-
if attributes.has_key?(:'log_dir')
|
53
|
-
self.log_dir = attributes[:'log_dir']
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
59
|
-
# @return Array for valid properties with the reasons
|
60
|
-
def list_invalid_properties
|
61
|
-
invalid_properties = Array.new
|
62
|
-
return invalid_properties
|
63
|
-
end
|
64
|
-
|
65
|
-
# Check to see if the all the properties in the model are valid
|
66
|
-
# @return true if the model is valid
|
67
|
-
def valid?
|
68
|
-
return true
|
69
|
-
end
|
70
|
-
|
71
|
-
# Checks equality by comparing each attribute.
|
72
|
-
# @param [Object] Object to be compared
|
73
|
-
def ==(o)
|
74
|
-
return true if self.equal?(o)
|
75
|
-
self.class == o.class &&
|
76
|
-
forward == o.forward &&
|
77
|
-
log_dir == o.log_dir
|
78
|
-
end
|
79
|
-
|
80
|
-
# @see the `==` method
|
81
|
-
# @param [Object] Object to be compared
|
82
|
-
def eql?(o)
|
83
|
-
self == o
|
84
|
-
end
|
85
|
-
|
86
|
-
# Calculates hash code according to all attributes.
|
87
|
-
# @return [Fixnum] Hash code
|
88
|
-
def hash
|
89
|
-
[forward, log_dir].hash
|
90
|
-
end
|
91
|
-
|
92
|
-
# Builds the object from hash
|
93
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
-
# @return [Object] Returns the model itself
|
95
|
-
def build_from_hash(attributes)
|
96
|
-
return nil unless attributes.is_a?(Hash)
|
97
|
-
self.class.swagger_types.each_pair do |key, type|
|
98
|
-
if type =~ /\AArray<(.*)>/i
|
99
|
-
# check to ensure the input is an array given that the the attribute
|
100
|
-
# is documented as an array but the input is not
|
101
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
102
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
103
|
-
end
|
104
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
105
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
106
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
107
|
-
end
|
108
|
-
|
109
|
-
self
|
110
|
-
end
|
111
|
-
|
112
|
-
# Deserializes the data based on type
|
113
|
-
# @param string type Data type
|
114
|
-
# @param string value Value to be deserialized
|
115
|
-
# @return [Object] Deserialized data
|
116
|
-
def _deserialize(type, value)
|
117
|
-
case type.to_sym
|
118
|
-
when :DateTime
|
119
|
-
DateTime.parse(value)
|
120
|
-
when :Date
|
121
|
-
Date.parse(value)
|
122
|
-
when :String
|
123
|
-
value.to_s
|
124
|
-
when :Integer
|
125
|
-
value.to_i
|
126
|
-
when :Float
|
127
|
-
value.to_f
|
128
|
-
when :BOOLEAN
|
129
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
-
true
|
131
|
-
else
|
132
|
-
false
|
133
|
-
end
|
134
|
-
when :Object
|
135
|
-
# generic object (usually a Hash), return directly
|
136
|
-
value
|
137
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
138
|
-
inner_type = Regexp.last_match[:inner_type]
|
139
|
-
value.map { |v| _deserialize(inner_type, v) }
|
140
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
141
|
-
k_type = Regexp.last_match[:k_type]
|
142
|
-
v_type = Regexp.last_match[:v_type]
|
143
|
-
{}.tap do |hash|
|
144
|
-
value.each do |k, v|
|
145
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
else # model
|
149
|
-
temp_model = Dkron.const_get(type).new
|
150
|
-
temp_model.build_from_hash(value)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# Returns the string representation of the object
|
155
|
-
# @return [String] String presentation of the object
|
156
|
-
def to_s
|
157
|
-
to_hash.to_s
|
158
|
-
end
|
159
|
-
|
160
|
-
# to_body is an alias to to_hash (backward compatibility)
|
161
|
-
# @return [Hash] Returns the object in the form of hash
|
162
|
-
def to_body
|
163
|
-
to_hash
|
164
|
-
end
|
165
|
-
|
166
|
-
# Returns the object in the form of hash
|
167
|
-
# @return [Hash] Returns the object in the form of hash
|
168
|
-
def to_hash
|
169
|
-
hash = {}
|
170
|
-
self.class.attribute_map.each_pair do |attr, param|
|
171
|
-
value = self.send(attr)
|
172
|
-
next if value.nil?
|
173
|
-
hash[param] = _to_hash(value)
|
174
|
-
end
|
175
|
-
hash
|
176
|
-
end
|
177
|
-
|
178
|
-
# Outputs non-array value in the form of hash
|
179
|
-
# For object, use to_hash. Otherwise, just return the value
|
180
|
-
# @param [Object] value Any valid value
|
181
|
-
# @return [Hash] Returns the value in the form of hash
|
182
|
-
def _to_hash(value)
|
183
|
-
if value.is_a?(Array)
|
184
|
-
value.compact.map{ |v| _to_hash(v) }
|
185
|
-
elsif value.is_a?(Hash)
|
186
|
-
{}.tap do |hash|
|
187
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
188
|
-
end
|
189
|
-
elsif value.respond_to? :to_hash
|
190
|
-
value.to_hash
|
191
|
-
else
|
192
|
-
value
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Dkron REST API
|
3
|
-
|
4
|
-
#You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response.
|
5
|
-
|
6
|
-
OpenAPI spec version: 0.10.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module Dkron
|
16
|
-
# Log processor saves executions output to the dkron log
|
17
|
-
class ProcessorLog
|
18
|
-
# Forward the output to the next processor
|
19
|
-
attr_accessor :forward
|
20
|
-
|
21
|
-
|
22
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
-
def self.attribute_map
|
24
|
-
{
|
25
|
-
:'forward' => :'forward'
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
# Attribute type mapping.
|
30
|
-
def self.swagger_types
|
31
|
-
{
|
32
|
-
:'forward' => :'BOOLEAN'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Initializes the object
|
37
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
-
def initialize(attributes = {})
|
39
|
-
return unless attributes.is_a?(Hash)
|
40
|
-
|
41
|
-
# convert string to symbol for hash key
|
42
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
43
|
-
|
44
|
-
if attributes.has_key?(:'forward')
|
45
|
-
self.forward = attributes[:'forward']
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
51
|
-
# @return Array for valid properties with the reasons
|
52
|
-
def list_invalid_properties
|
53
|
-
invalid_properties = Array.new
|
54
|
-
return invalid_properties
|
55
|
-
end
|
56
|
-
|
57
|
-
# Check to see if the all the properties in the model are valid
|
58
|
-
# @return true if the model is valid
|
59
|
-
def valid?
|
60
|
-
return true
|
61
|
-
end
|
62
|
-
|
63
|
-
# Checks equality by comparing each attribute.
|
64
|
-
# @param [Object] Object to be compared
|
65
|
-
def ==(o)
|
66
|
-
return true if self.equal?(o)
|
67
|
-
self.class == o.class &&
|
68
|
-
forward == o.forward
|
69
|
-
end
|
70
|
-
|
71
|
-
# @see the `==` method
|
72
|
-
# @param [Object] Object to be compared
|
73
|
-
def eql?(o)
|
74
|
-
self == o
|
75
|
-
end
|
76
|
-
|
77
|
-
# Calculates hash code according to all attributes.
|
78
|
-
# @return [Fixnum] Hash code
|
79
|
-
def hash
|
80
|
-
[forward].hash
|
81
|
-
end
|
82
|
-
|
83
|
-
# Builds the object from hash
|
84
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
-
# @return [Object] Returns the model itself
|
86
|
-
def build_from_hash(attributes)
|
87
|
-
return nil unless attributes.is_a?(Hash)
|
88
|
-
self.class.swagger_types.each_pair do |key, type|
|
89
|
-
if type =~ /\AArray<(.*)>/i
|
90
|
-
# check to ensure the input is an array given that the the attribute
|
91
|
-
# is documented as an array but the input is not
|
92
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
94
|
-
end
|
95
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
-
end
|
99
|
-
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
# Deserializes the data based on type
|
104
|
-
# @param string type Data type
|
105
|
-
# @param string value Value to be deserialized
|
106
|
-
# @return [Object] Deserialized data
|
107
|
-
def _deserialize(type, value)
|
108
|
-
case type.to_sym
|
109
|
-
when :DateTime
|
110
|
-
DateTime.parse(value)
|
111
|
-
when :Date
|
112
|
-
Date.parse(value)
|
113
|
-
when :String
|
114
|
-
value.to_s
|
115
|
-
when :Integer
|
116
|
-
value.to_i
|
117
|
-
when :Float
|
118
|
-
value.to_f
|
119
|
-
when :BOOLEAN
|
120
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
-
true
|
122
|
-
else
|
123
|
-
false
|
124
|
-
end
|
125
|
-
when :Object
|
126
|
-
# generic object (usually a Hash), return directly
|
127
|
-
value
|
128
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
-
inner_type = Regexp.last_match[:inner_type]
|
130
|
-
value.map { |v| _deserialize(inner_type, v) }
|
131
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
-
k_type = Regexp.last_match[:k_type]
|
133
|
-
v_type = Regexp.last_match[:v_type]
|
134
|
-
{}.tap do |hash|
|
135
|
-
value.each do |k, v|
|
136
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
else # model
|
140
|
-
temp_model = Dkron.const_get(type).new
|
141
|
-
temp_model.build_from_hash(value)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the string representation of the object
|
146
|
-
# @return [String] String presentation of the object
|
147
|
-
def to_s
|
148
|
-
to_hash.to_s
|
149
|
-
end
|
150
|
-
|
151
|
-
# to_body is an alias to to_hash (backward compatibility)
|
152
|
-
# @return [Hash] Returns the object in the form of hash
|
153
|
-
def to_body
|
154
|
-
to_hash
|
155
|
-
end
|
156
|
-
|
157
|
-
# Returns the object in the form of hash
|
158
|
-
# @return [Hash] Returns the object in the form of hash
|
159
|
-
def to_hash
|
160
|
-
hash = {}
|
161
|
-
self.class.attribute_map.each_pair do |attr, param|
|
162
|
-
value = self.send(attr)
|
163
|
-
next if value.nil?
|
164
|
-
hash[param] = _to_hash(value)
|
165
|
-
end
|
166
|
-
hash
|
167
|
-
end
|
168
|
-
|
169
|
-
# Outputs non-array value in the form of hash
|
170
|
-
# For object, use to_hash. Otherwise, just return the value
|
171
|
-
# @param [Object] value Any valid value
|
172
|
-
# @return [Hash] Returns the value in the form of hash
|
173
|
-
def _to_hash(value)
|
174
|
-
if value.is_a?(Array)
|
175
|
-
value.compact.map{ |v| _to_hash(v) }
|
176
|
-
elsif value.is_a?(Hash)
|
177
|
-
{}.tap do |hash|
|
178
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
179
|
-
end
|
180
|
-
elsif value.respond_to? :to_hash
|
181
|
-
value.to_hash
|
182
|
-
else
|
183
|
-
value
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
#Dkron REST API
|
3
|
-
|
4
|
-
#You can communicate with Dkron using a RESTful JSON API over HTTP. Dkron nodes usually listen on port `8080` for API requests. All examples in this section assume that you've found a running leader at `localhost:8080`. Dkron implements a RESTful JSON API over HTTP to communicate with software clients. Dkron listens in port `8080` by default. All examples in this section assume that you're using the default port. Default API responses are unformatted JSON add the `pretty=true` param to format the response.
|
5
|
-
|
6
|
-
OpenAPI spec version: 0.10.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.3.1
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module Dkron
|
16
|
-
# Syslog processor route execution output to syslog
|
17
|
-
class ProcessorSyslog
|
18
|
-
# Forward the output to the next processor
|
19
|
-
attr_accessor :forward
|
20
|
-
|
21
|
-
|
22
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
-
def self.attribute_map
|
24
|
-
{
|
25
|
-
:'forward' => :'forward'
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
# Attribute type mapping.
|
30
|
-
def self.swagger_types
|
31
|
-
{
|
32
|
-
:'forward' => :'BOOLEAN'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Initializes the object
|
37
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
-
def initialize(attributes = {})
|
39
|
-
return unless attributes.is_a?(Hash)
|
40
|
-
|
41
|
-
# convert string to symbol for hash key
|
42
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
43
|
-
|
44
|
-
if attributes.has_key?(:'forward')
|
45
|
-
self.forward = attributes[:'forward']
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
51
|
-
# @return Array for valid properties with the reasons
|
52
|
-
def list_invalid_properties
|
53
|
-
invalid_properties = Array.new
|
54
|
-
return invalid_properties
|
55
|
-
end
|
56
|
-
|
57
|
-
# Check to see if the all the properties in the model are valid
|
58
|
-
# @return true if the model is valid
|
59
|
-
def valid?
|
60
|
-
return true
|
61
|
-
end
|
62
|
-
|
63
|
-
# Checks equality by comparing each attribute.
|
64
|
-
# @param [Object] Object to be compared
|
65
|
-
def ==(o)
|
66
|
-
return true if self.equal?(o)
|
67
|
-
self.class == o.class &&
|
68
|
-
forward == o.forward
|
69
|
-
end
|
70
|
-
|
71
|
-
# @see the `==` method
|
72
|
-
# @param [Object] Object to be compared
|
73
|
-
def eql?(o)
|
74
|
-
self == o
|
75
|
-
end
|
76
|
-
|
77
|
-
# Calculates hash code according to all attributes.
|
78
|
-
# @return [Fixnum] Hash code
|
79
|
-
def hash
|
80
|
-
[forward].hash
|
81
|
-
end
|
82
|
-
|
83
|
-
# Builds the object from hash
|
84
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
-
# @return [Object] Returns the model itself
|
86
|
-
def build_from_hash(attributes)
|
87
|
-
return nil unless attributes.is_a?(Hash)
|
88
|
-
self.class.swagger_types.each_pair do |key, type|
|
89
|
-
if type =~ /\AArray<(.*)>/i
|
90
|
-
# check to ensure the input is an array given that the the attribute
|
91
|
-
# is documented as an array but the input is not
|
92
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
94
|
-
end
|
95
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
-
end
|
99
|
-
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
# Deserializes the data based on type
|
104
|
-
# @param string type Data type
|
105
|
-
# @param string value Value to be deserialized
|
106
|
-
# @return [Object] Deserialized data
|
107
|
-
def _deserialize(type, value)
|
108
|
-
case type.to_sym
|
109
|
-
when :DateTime
|
110
|
-
DateTime.parse(value)
|
111
|
-
when :Date
|
112
|
-
Date.parse(value)
|
113
|
-
when :String
|
114
|
-
value.to_s
|
115
|
-
when :Integer
|
116
|
-
value.to_i
|
117
|
-
when :Float
|
118
|
-
value.to_f
|
119
|
-
when :BOOLEAN
|
120
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
-
true
|
122
|
-
else
|
123
|
-
false
|
124
|
-
end
|
125
|
-
when :Object
|
126
|
-
# generic object (usually a Hash), return directly
|
127
|
-
value
|
128
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
-
inner_type = Regexp.last_match[:inner_type]
|
130
|
-
value.map { |v| _deserialize(inner_type, v) }
|
131
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
-
k_type = Regexp.last_match[:k_type]
|
133
|
-
v_type = Regexp.last_match[:v_type]
|
134
|
-
{}.tap do |hash|
|
135
|
-
value.each do |k, v|
|
136
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
else # model
|
140
|
-
temp_model = Dkron.const_get(type).new
|
141
|
-
temp_model.build_from_hash(value)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the string representation of the object
|
146
|
-
# @return [String] String presentation of the object
|
147
|
-
def to_s
|
148
|
-
to_hash.to_s
|
149
|
-
end
|
150
|
-
|
151
|
-
# to_body is an alias to to_hash (backward compatibility)
|
152
|
-
# @return [Hash] Returns the object in the form of hash
|
153
|
-
def to_body
|
154
|
-
to_hash
|
155
|
-
end
|
156
|
-
|
157
|
-
# Returns the object in the form of hash
|
158
|
-
# @return [Hash] Returns the object in the form of hash
|
159
|
-
def to_hash
|
160
|
-
hash = {}
|
161
|
-
self.class.attribute_map.each_pair do |attr, param|
|
162
|
-
value = self.send(attr)
|
163
|
-
next if value.nil?
|
164
|
-
hash[param] = _to_hash(value)
|
165
|
-
end
|
166
|
-
hash
|
167
|
-
end
|
168
|
-
|
169
|
-
# Outputs non-array value in the form of hash
|
170
|
-
# For object, use to_hash. Otherwise, just return the value
|
171
|
-
# @param [Object] value Any valid value
|
172
|
-
# @return [Hash] Returns the value in the form of hash
|
173
|
-
def _to_hash(value)
|
174
|
-
if value.is_a?(Array)
|
175
|
-
value.compact.map{ |v| _to_hash(v) }
|
176
|
-
elsif value.is_a?(Hash)
|
177
|
-
{}.tap do |hash|
|
178
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
179
|
-
end
|
180
|
-
elsif value.respond_to? :to_hash
|
181
|
-
value.to_hash
|
182
|
-
else
|
183
|
-
value
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|