dkron-rb 0.11.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,152 +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`.\n\nDkron 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.\n\nDefault API responses are unformatted JSON add the `pretty=true` param to format the response.\n
|
5
|
-
|
6
|
-
OpenAPI spec version: 0.7.2
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module Dkron
|
16
|
-
# Node basic details
|
17
|
-
class Agent
|
18
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
-
def self.attribute_map
|
20
|
-
{
|
21
|
-
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
# Attribute type mapping.
|
26
|
-
def self.swagger_types
|
27
|
-
{
|
28
|
-
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def initialize(attributes = {})
|
33
|
-
return unless attributes.is_a?(Hash)
|
34
|
-
|
35
|
-
# convert string to symbol for hash key
|
36
|
-
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
# Check equality by comparing each attribute.
|
42
|
-
def ==(o)
|
43
|
-
return true if self.equal?(o)
|
44
|
-
self.class == o.class
|
45
|
-
end
|
46
|
-
|
47
|
-
# @see the `==` method
|
48
|
-
def eql?(o)
|
49
|
-
self == o
|
50
|
-
end
|
51
|
-
|
52
|
-
# Calculate hash code according to all attributes.
|
53
|
-
def hash
|
54
|
-
[].hash
|
55
|
-
end
|
56
|
-
|
57
|
-
# build the object from hash
|
58
|
-
def build_from_hash(attributes)
|
59
|
-
return nil unless attributes.is_a?(Hash)
|
60
|
-
self.class.swagger_types.each_pair do |key, type|
|
61
|
-
if type =~ /^Array<(.*)>/i
|
62
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
63
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
64
|
-
else
|
65
|
-
#TODO show warning in debug mode
|
66
|
-
end
|
67
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
68
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
69
|
-
else
|
70
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
self
|
75
|
-
end
|
76
|
-
|
77
|
-
def _deserialize(type, value)
|
78
|
-
case type.to_sym
|
79
|
-
when :DateTime
|
80
|
-
DateTime.parse(value)
|
81
|
-
when :Date
|
82
|
-
Date.parse(value)
|
83
|
-
when :String
|
84
|
-
value.to_s
|
85
|
-
when :Integer
|
86
|
-
value.to_i
|
87
|
-
when :Float
|
88
|
-
value.to_f
|
89
|
-
when :BOOLEAN
|
90
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
91
|
-
true
|
92
|
-
else
|
93
|
-
false
|
94
|
-
end
|
95
|
-
when :Object
|
96
|
-
# generic object (usually a Hash), return directly
|
97
|
-
value
|
98
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
99
|
-
inner_type = Regexp.last_match[:inner_type]
|
100
|
-
value.map { |v| _deserialize(inner_type, v) }
|
101
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
102
|
-
k_type = Regexp.last_match[:k_type]
|
103
|
-
v_type = Regexp.last_match[:v_type]
|
104
|
-
{}.tap do |hash|
|
105
|
-
value.each do |k, v|
|
106
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
else # model
|
110
|
-
_model = Dkron.const_get(type).new
|
111
|
-
_model.build_from_hash(value)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def to_s
|
116
|
-
to_hash.to_s
|
117
|
-
end
|
118
|
-
|
119
|
-
# to_body is an alias to to_body (backward compatibility))
|
120
|
-
def to_body
|
121
|
-
to_hash
|
122
|
-
end
|
123
|
-
|
124
|
-
# return the object in the form of hash
|
125
|
-
def to_hash
|
126
|
-
hash = {}
|
127
|
-
self.class.attribute_map.each_pair do |attr, param|
|
128
|
-
value = self.send(attr)
|
129
|
-
next if value.nil?
|
130
|
-
hash[param] = _to_hash(value)
|
131
|
-
end
|
132
|
-
hash
|
133
|
-
end
|
134
|
-
|
135
|
-
# Method to output non-array value in the form of hash
|
136
|
-
# For object, use to_hash. Otherwise, just return the value
|
137
|
-
def _to_hash(value)
|
138
|
-
if value.is_a?(Array)
|
139
|
-
value.compact.map{ |v| _to_hash(v) }
|
140
|
-
elsif value.is_a?(Hash)
|
141
|
-
{}.tap do |hash|
|
142
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
143
|
-
end
|
144
|
-
elsif value.respond_to? :to_hash
|
145
|
-
value.to_hash
|
146
|
-
else
|
147
|
-
value
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
@@ -1,208 +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
|
-
# Shell executor runs a command in shell
|
17
|
-
class ExecutorShell
|
18
|
-
# Command to run
|
19
|
-
attr_accessor :command
|
20
|
-
|
21
|
-
# Comma separated environment variables pair
|
22
|
-
attr_accessor :env
|
23
|
-
|
24
|
-
attr_accessor :shell
|
25
|
-
|
26
|
-
|
27
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
-
def self.attribute_map
|
29
|
-
{
|
30
|
-
:'command' => :'command',
|
31
|
-
:'env' => :'env',
|
32
|
-
:'shell' => :'shell'
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Attribute type mapping.
|
37
|
-
def self.swagger_types
|
38
|
-
{
|
39
|
-
:'command' => :'String',
|
40
|
-
:'env' => :'String',
|
41
|
-
:'shell' => :'BOOLEAN'
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
# Initializes the object
|
46
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
-
def initialize(attributes = {})
|
48
|
-
return unless attributes.is_a?(Hash)
|
49
|
-
|
50
|
-
# convert string to symbol for hash key
|
51
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
52
|
-
|
53
|
-
if attributes.has_key?(:'command')
|
54
|
-
self.command = attributes[:'command']
|
55
|
-
end
|
56
|
-
|
57
|
-
if attributes.has_key?(:'env')
|
58
|
-
self.env = attributes[:'env']
|
59
|
-
end
|
60
|
-
|
61
|
-
if attributes.has_key?(:'shell')
|
62
|
-
self.shell = attributes[:'shell']
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
68
|
-
# @return Array for valid properties with the reasons
|
69
|
-
def list_invalid_properties
|
70
|
-
invalid_properties = Array.new
|
71
|
-
return invalid_properties
|
72
|
-
end
|
73
|
-
|
74
|
-
# Check to see if the all the properties in the model are valid
|
75
|
-
# @return true if the model is valid
|
76
|
-
def valid?
|
77
|
-
return true
|
78
|
-
end
|
79
|
-
|
80
|
-
# Checks equality by comparing each attribute.
|
81
|
-
# @param [Object] Object to be compared
|
82
|
-
def ==(o)
|
83
|
-
return true if self.equal?(o)
|
84
|
-
self.class == o.class &&
|
85
|
-
command == o.command &&
|
86
|
-
env == o.env &&
|
87
|
-
shell == o.shell
|
88
|
-
end
|
89
|
-
|
90
|
-
# @see the `==` method
|
91
|
-
# @param [Object] Object to be compared
|
92
|
-
def eql?(o)
|
93
|
-
self == o
|
94
|
-
end
|
95
|
-
|
96
|
-
# Calculates hash code according to all attributes.
|
97
|
-
# @return [Fixnum] Hash code
|
98
|
-
def hash
|
99
|
-
[command, env, shell].hash
|
100
|
-
end
|
101
|
-
|
102
|
-
# Builds the object from hash
|
103
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
-
# @return [Object] Returns the model itself
|
105
|
-
def build_from_hash(attributes)
|
106
|
-
return nil unless attributes.is_a?(Hash)
|
107
|
-
self.class.swagger_types.each_pair do |key, type|
|
108
|
-
if type =~ /\AArray<(.*)>/i
|
109
|
-
# check to ensure the input is an array given that the the attribute
|
110
|
-
# is documented as an array but the input is not
|
111
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
112
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
113
|
-
end
|
114
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
115
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
116
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
117
|
-
end
|
118
|
-
|
119
|
-
self
|
120
|
-
end
|
121
|
-
|
122
|
-
# Deserializes the data based on type
|
123
|
-
# @param string type Data type
|
124
|
-
# @param string value Value to be deserialized
|
125
|
-
# @return [Object] Deserialized data
|
126
|
-
def _deserialize(type, value)
|
127
|
-
case type.to_sym
|
128
|
-
when :DateTime
|
129
|
-
DateTime.parse(value)
|
130
|
-
when :Date
|
131
|
-
Date.parse(value)
|
132
|
-
when :String
|
133
|
-
value.to_s
|
134
|
-
when :Integer
|
135
|
-
value.to_i
|
136
|
-
when :Float
|
137
|
-
value.to_f
|
138
|
-
when :BOOLEAN
|
139
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
140
|
-
true
|
141
|
-
else
|
142
|
-
false
|
143
|
-
end
|
144
|
-
when :Object
|
145
|
-
# generic object (usually a Hash), return directly
|
146
|
-
value
|
147
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
148
|
-
inner_type = Regexp.last_match[:inner_type]
|
149
|
-
value.map { |v| _deserialize(inner_type, v) }
|
150
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
151
|
-
k_type = Regexp.last_match[:k_type]
|
152
|
-
v_type = Regexp.last_match[:v_type]
|
153
|
-
{}.tap do |hash|
|
154
|
-
value.each do |k, v|
|
155
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
else # model
|
159
|
-
temp_model = Dkron.const_get(type).new
|
160
|
-
temp_model.build_from_hash(value)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# Returns the string representation of the object
|
165
|
-
# @return [String] String presentation of the object
|
166
|
-
def to_s
|
167
|
-
to_hash.to_s
|
168
|
-
end
|
169
|
-
|
170
|
-
# to_body is an alias to to_hash (backward compatibility)
|
171
|
-
# @return [Hash] Returns the object in the form of hash
|
172
|
-
def to_body
|
173
|
-
to_hash
|
174
|
-
end
|
175
|
-
|
176
|
-
# Returns the object in the form of hash
|
177
|
-
# @return [Hash] Returns the object in the form of hash
|
178
|
-
def to_hash
|
179
|
-
hash = {}
|
180
|
-
self.class.attribute_map.each_pair do |attr, param|
|
181
|
-
value = self.send(attr)
|
182
|
-
next if value.nil?
|
183
|
-
hash[param] = _to_hash(value)
|
184
|
-
end
|
185
|
-
hash
|
186
|
-
end
|
187
|
-
|
188
|
-
# Outputs non-array value in the form of hash
|
189
|
-
# For object, use to_hash. Otherwise, just return the value
|
190
|
-
# @param [Object] value Any valid value
|
191
|
-
# @return [Hash] Returns the value in the form of hash
|
192
|
-
def _to_hash(value)
|
193
|
-
if value.is_a?(Array)
|
194
|
-
value.compact.map{ |v| _to_hash(v) }
|
195
|
-
elsif value.is_a?(Hash)
|
196
|
-
{}.tap do |hash|
|
197
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
198
|
-
end
|
199
|
-
elsif value.respond_to? :to_hash
|
200
|
-
value.to_hash
|
201
|
-
else
|
202
|
-
value
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
end
|
@@ -1,181 +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`.\n\nDkron 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.\n\nDefault API responses are unformatted JSON add the `pretty=true` param to format the response.\n
|
5
|
-
|
6
|
-
OpenAPI spec version: 0.7.2
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
|
15
|
-
module Dkron
|
16
|
-
class InlineResponse200
|
17
|
-
attr_accessor :agent
|
18
|
-
|
19
|
-
attr_accessor :serf
|
20
|
-
|
21
|
-
attr_accessor :tags
|
22
|
-
|
23
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
-
def self.attribute_map
|
25
|
-
{
|
26
|
-
|
27
|
-
:'agent' => :'agent',
|
28
|
-
|
29
|
-
:'serf' => :'serf',
|
30
|
-
|
31
|
-
:'tags' => :'tags'
|
32
|
-
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# Attribute type mapping.
|
37
|
-
def self.swagger_types
|
38
|
-
{
|
39
|
-
:'agent' => :'Agent',
|
40
|
-
:'serf' => :'Serf',
|
41
|
-
:'tags' => :'Tags'
|
42
|
-
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
def initialize(attributes = {})
|
47
|
-
return unless attributes.is_a?(Hash)
|
48
|
-
|
49
|
-
# convert string to symbol for hash key
|
50
|
-
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
51
|
-
|
52
|
-
|
53
|
-
if attributes[:'agent']
|
54
|
-
self.agent = attributes[:'agent']
|
55
|
-
end
|
56
|
-
|
57
|
-
if attributes[:'serf']
|
58
|
-
self.serf = attributes[:'serf']
|
59
|
-
end
|
60
|
-
|
61
|
-
if attributes[:'tags']
|
62
|
-
self.tags = attributes[:'tags']
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
# Check equality by comparing each attribute.
|
68
|
-
def ==(o)
|
69
|
-
return true if self.equal?(o)
|
70
|
-
self.class == o.class &&
|
71
|
-
agent == o.agent &&
|
72
|
-
serf == o.serf &&
|
73
|
-
tags == o.tags
|
74
|
-
end
|
75
|
-
|
76
|
-
# @see the `==` method
|
77
|
-
def eql?(o)
|
78
|
-
self == o
|
79
|
-
end
|
80
|
-
|
81
|
-
# Calculate hash code according to all attributes.
|
82
|
-
def hash
|
83
|
-
[agent, serf, tags].hash
|
84
|
-
end
|
85
|
-
|
86
|
-
# build the object from hash
|
87
|
-
def build_from_hash(attributes)
|
88
|
-
return nil unless attributes.is_a?(Hash)
|
89
|
-
self.class.swagger_types.each_pair do |key, type|
|
90
|
-
if type =~ /^Array<(.*)>/i
|
91
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
93
|
-
else
|
94
|
-
#TODO show warning in debug mode
|
95
|
-
end
|
96
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
97
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
98
|
-
else
|
99
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
self
|
104
|
-
end
|
105
|
-
|
106
|
-
def _deserialize(type, value)
|
107
|
-
case type.to_sym
|
108
|
-
when :DateTime
|
109
|
-
DateTime.parse(value)
|
110
|
-
when :Date
|
111
|
-
Date.parse(value)
|
112
|
-
when :String
|
113
|
-
value.to_s
|
114
|
-
when :Integer
|
115
|
-
value.to_i
|
116
|
-
when :Float
|
117
|
-
value.to_f
|
118
|
-
when :BOOLEAN
|
119
|
-
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
120
|
-
true
|
121
|
-
else
|
122
|
-
false
|
123
|
-
end
|
124
|
-
when :Object
|
125
|
-
# generic object (usually a Hash), return directly
|
126
|
-
value
|
127
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
128
|
-
inner_type = Regexp.last_match[:inner_type]
|
129
|
-
value.map { |v| _deserialize(inner_type, v) }
|
130
|
-
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
131
|
-
k_type = Regexp.last_match[:k_type]
|
132
|
-
v_type = Regexp.last_match[:v_type]
|
133
|
-
{}.tap do |hash|
|
134
|
-
value.each do |k, v|
|
135
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
else # model
|
139
|
-
_model = Dkron.const_get(type).new
|
140
|
-
_model.build_from_hash(value)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def to_s
|
145
|
-
to_hash.to_s
|
146
|
-
end
|
147
|
-
|
148
|
-
# to_body is an alias to to_body (backward compatibility))
|
149
|
-
def to_body
|
150
|
-
to_hash
|
151
|
-
end
|
152
|
-
|
153
|
-
# return the object in the form of hash
|
154
|
-
def to_hash
|
155
|
-
hash = {}
|
156
|
-
self.class.attribute_map.each_pair do |attr, param|
|
157
|
-
value = self.send(attr)
|
158
|
-
next if value.nil?
|
159
|
-
hash[param] = _to_hash(value)
|
160
|
-
end
|
161
|
-
hash
|
162
|
-
end
|
163
|
-
|
164
|
-
# Method to output non-array value in the form of hash
|
165
|
-
# For object, use to_hash. Otherwise, just return the value
|
166
|
-
def _to_hash(value)
|
167
|
-
if value.is_a?(Array)
|
168
|
-
value.compact.map{ |v| _to_hash(v) }
|
169
|
-
elsif value.is_a?(Hash)
|
170
|
-
{}.tap do |hash|
|
171
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
172
|
-
end
|
173
|
-
elsif value.respond_to? :to_hash
|
174
|
-
value.to_hash
|
175
|
-
else
|
176
|
-
value
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
end
|