worker_ruby 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/README.md +118 -0
  4. data/VERSION +1 -0
  5. data/VERSION.txt +1 -0
  6. data/docs/Complete.md +10 -0
  7. data/docs/CoreApi.md +200 -0
  8. data/docs/Error.md +8 -0
  9. data/docs/ErrorBody.md +9 -0
  10. data/docs/Group.md +12 -0
  11. data/docs/GroupWrapper.md +8 -0
  12. data/docs/GroupsApi.md +197 -0
  13. data/docs/GroupsWrapper.md +8 -0
  14. data/docs/IdStatus.md +9 -0
  15. data/docs/Image.md +10 -0
  16. data/docs/ImageWrapper.md +8 -0
  17. data/docs/ImagesApi.md +98 -0
  18. data/docs/ImagesWrapper.md +8 -0
  19. data/docs/Job.md +25 -0
  20. data/docs/JobWrapper.md +8 -0
  21. data/docs/JobsApi.md +684 -0
  22. data/docs/JobsWrapper.md +10 -0
  23. data/docs/Log.md +8 -0
  24. data/docs/NewJob.md +14 -0
  25. data/docs/NewJobWithImage.md +15 -0
  26. data/docs/NewJobsWrapper.md +8 -0
  27. data/docs/NewTask.md +14 -0
  28. data/docs/NewTasksWrapper.md +8 -0
  29. data/docs/Reason.md +7 -0
  30. data/docs/RunnerApi.md +170 -0
  31. data/docs/Start.md +8 -0
  32. data/docs/Task.md +25 -0
  33. data/docs/TaskWrapper.md +8 -0
  34. data/docs/TasksApi.md +684 -0
  35. data/docs/TasksWrapper.md +10 -0
  36. data/git_push.sh +67 -0
  37. data/iron_ruby.gemspec +55 -0
  38. data/iron_titan.gemspec +32 -0
  39. data/lib/iron_ruby.rb +66 -0
  40. data/lib/iron_ruby/api/groups_api.rb +262 -0
  41. data/lib/iron_ruby/api/runner_api.rb +229 -0
  42. data/lib/iron_ruby/api/tasks_api.rb +842 -0
  43. data/lib/iron_ruby/api_client.rb +378 -0
  44. data/lib/iron_ruby/api_error.rb +47 -0
  45. data/lib/iron_ruby/configuration.rb +207 -0
  46. data/lib/iron_ruby/models/complete.rb +220 -0
  47. data/lib/iron_ruby/models/error.rb +199 -0
  48. data/lib/iron_ruby/models/error_body.rb +208 -0
  49. data/lib/iron_ruby/models/group.rb +242 -0
  50. data/lib/iron_ruby/models/group_wrapper.rb +200 -0
  51. data/lib/iron_ruby/models/groups_wrapper.rb +202 -0
  52. data/lib/iron_ruby/models/id_status.rb +243 -0
  53. data/lib/iron_ruby/models/new_task.rb +270 -0
  54. data/lib/iron_ruby/models/new_tasks_wrapper.rb +202 -0
  55. data/lib/iron_ruby/models/start.rb +200 -0
  56. data/lib/iron_ruby/models/task.rb +427 -0
  57. data/lib/iron_ruby/models/task_wrapper.rb +200 -0
  58. data/lib/iron_ruby/models/tasks_wrapper.rb +221 -0
  59. data/lib/iron_ruby/version.rb +26 -0
  60. data/lib/iron_titan.rb +66 -0
  61. data/lib/iron_titan/api/core_api.rb +260 -0
  62. data/lib/iron_titan/api/groups_api.rb +262 -0
  63. data/lib/iron_titan/api/images_api.rb +138 -0
  64. data/lib/iron_titan/api/jobs_api.rb +842 -0
  65. data/lib/iron_titan/api/runner_api.rb +229 -0
  66. data/lib/iron_titan/api_client.rb +372 -0
  67. data/lib/iron_titan/api_error.rb +47 -0
  68. data/lib/iron_titan/configuration.rb +186 -0
  69. data/lib/iron_titan/models/complete.rb +220 -0
  70. data/lib/iron_titan/models/error.rb +199 -0
  71. data/lib/iron_titan/models/error_body.rb +208 -0
  72. data/lib/iron_titan/models/group.rb +242 -0
  73. data/lib/iron_titan/models/group_wrapper.rb +200 -0
  74. data/lib/iron_titan/models/groups_wrapper.rb +202 -0
  75. data/lib/iron_titan/models/id_status.rb +243 -0
  76. data/lib/iron_titan/models/image.rb +184 -0
  77. data/lib/iron_titan/models/image_wrapper.rb +161 -0
  78. data/lib/iron_titan/models/images_wrapper.rb +163 -0
  79. data/lib/iron_titan/models/job.rb +427 -0
  80. data/lib/iron_titan/models/job_array.rb +160 -0
  81. data/lib/iron_titan/models/job_wrapper.rb +200 -0
  82. data/lib/iron_titan/models/jobs_wrapper.rb +221 -0
  83. data/lib/iron_titan/models/log.rb +161 -0
  84. data/lib/iron_titan/models/new_job.rb +270 -0
  85. data/lib/iron_titan/models/new_job_array.rb +160 -0
  86. data/lib/iron_titan/models/new_job_with_image.rb +249 -0
  87. data/lib/iron_titan/models/new_jobs_wrapper.rb +202 -0
  88. data/lib/iron_titan/models/reason.rb +164 -0
  89. data/lib/iron_titan/models/start.rb +200 -0
  90. data/lib/iron_titan/version.rb +26 -0
  91. data/lib/worker_ruby.rb +66 -0
  92. data/lib/worker_ruby/api/groups_api.rb +262 -0
  93. data/lib/worker_ruby/api/runner_api.rb +229 -0
  94. data/lib/worker_ruby/api/tasks_api.rb +842 -0
  95. data/lib/worker_ruby/api_client.rb +378 -0
  96. data/lib/worker_ruby/api_error.rb +47 -0
  97. data/lib/worker_ruby/configuration.rb +207 -0
  98. data/lib/worker_ruby/models/complete.rb +220 -0
  99. data/lib/worker_ruby/models/error.rb +199 -0
  100. data/lib/worker_ruby/models/error_body.rb +208 -0
  101. data/lib/worker_ruby/models/group.rb +242 -0
  102. data/lib/worker_ruby/models/group_wrapper.rb +200 -0
  103. data/lib/worker_ruby/models/groups_wrapper.rb +202 -0
  104. data/lib/worker_ruby/models/id_status.rb +243 -0
  105. data/lib/worker_ruby/models/new_task.rb +270 -0
  106. data/lib/worker_ruby/models/new_tasks_wrapper.rb +202 -0
  107. data/lib/worker_ruby/models/start.rb +200 -0
  108. data/lib/worker_ruby/models/task.rb +427 -0
  109. data/lib/worker_ruby/models/task_wrapper.rb +200 -0
  110. data/lib/worker_ruby/models/tasks_wrapper.rb +221 -0
  111. data/lib/worker_ruby/version.rb +26 -0
  112. data/spec/api/CoreApi_spec.rb +99 -0
  113. data/spec/api/JobsApi_spec.rb +131 -0
  114. data/spec/api/core_api_spec.rb +99 -0
  115. data/spec/api/groups_api_spec.rb +94 -0
  116. data/spec/api/images_api_spec.rb +66 -0
  117. data/spec/api/jobs_api_spec.rb +220 -0
  118. data/spec/api/runner_api_spec.rb +88 -0
  119. data/spec/api/tasks_api_spec.rb +220 -0
  120. data/spec/api_client_spec.rb +237 -0
  121. data/spec/configuration_spec.rb +53 -0
  122. data/spec/models/ErrorBody_spec.rb +56 -0
  123. data/spec/models/JobArray_spec.rb +46 -0
  124. data/spec/models/JobWrapper_spec.rb +46 -0
  125. data/spec/models/NewJobArray_spec.rb +46 -0
  126. data/spec/models/NewJob_spec.rb +96 -0
  127. data/spec/models/complete_spec.rb +65 -0
  128. data/spec/models/error_body_spec.rb +59 -0
  129. data/spec/models/error_spec.rb +53 -0
  130. data/spec/models/group_spec.rb +77 -0
  131. data/spec/models/group_wrapper_spec.rb +53 -0
  132. data/spec/models/groups_wrapper_spec.rb +53 -0
  133. data/spec/models/id_status_spec.rb +63 -0
  134. data/spec/models/image_spec.rb +66 -0
  135. data/spec/models/image_wrapper_spec.rb +46 -0
  136. data/spec/models/images_wrapper_spec.rb +46 -0
  137. data/spec/models/job_array_spec.rb +46 -0
  138. data/spec/models/job_spec.rb +161 -0
  139. data/spec/models/job_wrapper_spec.rb +53 -0
  140. data/spec/models/jobs_wrapper_spec.rb +65 -0
  141. data/spec/models/log_spec.rb +46 -0
  142. data/spec/models/new_job_array_spec.rb +46 -0
  143. data/spec/models/new_job_spec.rb +89 -0
  144. data/spec/models/new_job_with_image_spec.rb +116 -0
  145. data/spec/models/new_jobs_wrapper_spec.rb +53 -0
  146. data/spec/models/new_task_spec.rb +89 -0
  147. data/spec/models/new_tasks_wrapper_spec.rb +53 -0
  148. data/spec/models/reason_spec.rb +36 -0
  149. data/spec/models/start_spec.rb +53 -0
  150. data/spec/models/task_spec.rb +163 -0
  151. data/spec/models/task_wrapper_spec.rb +53 -0
  152. data/spec/models/tasks_wrapper_spec.rb +65 -0
  153. data/spec/spec_helper.rb +122 -0
  154. data/worker_ruby-0.5.5.gem +0 -0
  155. data/worker_ruby.gemspec +55 -0
  156. metadata +420 -0
@@ -0,0 +1,200 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.4.9
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module IronTitan
27
+
28
+ class JobWrapper
29
+ attr_accessor :job
30
+
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'job' => :'job'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'job' => :'Job'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'job')
55
+ self.job = attributes[:'job']
56
+ end
57
+
58
+ end
59
+
60
+ # Show invalid properties with the reasons. Usually used together with valid?
61
+ # @return Array for valid properies with the reasons
62
+ def list_invalid_properties
63
+ invalid_properties = Array.new
64
+ return invalid_properties
65
+ end
66
+
67
+ # Check to see if the all the properties in the model are valid
68
+ # @return true if the model is valid
69
+ def valid?
70
+ return false if @job.nil?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ job == o.job
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [job].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /^Array<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = IronTitan.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end
@@ -0,0 +1,221 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.4.9
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module IronTitan
27
+
28
+ class JobsWrapper
29
+ attr_accessor :jobs
30
+
31
+ # Used to paginate results. If this is returned, pass it into the same query again to get more results.
32
+ attr_accessor :cursor
33
+
34
+ attr_accessor :error
35
+
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'jobs' => :'jobs',
41
+ :'cursor' => :'cursor',
42
+ :'error' => :'error'
43
+ }
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.swagger_types
48
+ {
49
+ :'jobs' => :'Array<Job>',
50
+ :'cursor' => :'String',
51
+ :'error' => :'ErrorBody'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
62
+
63
+ if attributes.has_key?(:'jobs')
64
+ if (value = attributes[:'jobs']).is_a?(Array)
65
+ self.jobs = value
66
+ end
67
+ end
68
+
69
+ if attributes.has_key?(:'cursor')
70
+ self.cursor = attributes[:'cursor']
71
+ end
72
+
73
+ if attributes.has_key?(:'error')
74
+ self.error = attributes[:'error']
75
+ end
76
+
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properies with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ return 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
+ return false if @jobs.nil?
90
+ return true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ jobs == o.jobs &&
99
+ cursor == o.cursor &&
100
+ error == o.error
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Fixnum] Hash code
111
+ def hash
112
+ [jobs, cursor, error].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def build_from_hash(attributes)
119
+ return nil unless attributes.is_a?(Hash)
120
+ self.class.swagger_types.each_pair do |key, type|
121
+ if type =~ /^Array<(.*)>/i
122
+ # check to ensure the input is an array given that the the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
125
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
126
+ end
127
+ elsif !attributes[self.class.attribute_map[key]].nil?
128
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
129
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
130
+ end
131
+
132
+ self
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def _deserialize(type, value)
140
+ case type.to_sym
141
+ when :DateTime
142
+ DateTime.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :BOOLEAN
152
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ temp_model = IronTitan.const_get(type).new
173
+ temp_model.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ next if value.nil?
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map{ |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
@@ -0,0 +1,161 @@
1
+ =begin
2
+ Titan API
3
+
4
+ The ultimate, language agnostic, container based job processing framework.
5
+
6
+ OpenAPI spec version: 0.1.1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IronTitan
16
+ class Log
17
+ attr_accessor :log
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+
23
+ :'log' => :'log'
24
+
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'log' => :'String'
32
+
33
+ }
34
+ end
35
+
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
41
+
42
+
43
+ if attributes[:'log']
44
+ self.log = attributes[:'log']
45
+ end
46
+
47
+ end
48
+
49
+ # Check equality by comparing each attribute.
50
+ def ==(o)
51
+ return true if self.equal?(o)
52
+ self.class == o.class &&
53
+ log == o.log
54
+ end
55
+
56
+ # @see the `==` method
57
+ def eql?(o)
58
+ self == o
59
+ end
60
+
61
+ # Calculate hash code according to all attributes.
62
+ def hash
63
+ [log].hash
64
+ end
65
+
66
+ # build the object from hash
67
+ def build_from_hash(attributes)
68
+ return nil unless attributes.is_a?(Hash)
69
+ self.class.swagger_types.each_pair do |key, type|
70
+ if type =~ /^Array<(.*)>/i
71
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
72
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
73
+ else
74
+ #TODO show warning in debug mode
75
+ end
76
+ elsif !attributes[self.class.attribute_map[key]].nil?
77
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
78
+ else
79
+ # data not found in attributes(hash), not an issue as the data can be optional
80
+ end
81
+ end
82
+
83
+ self
84
+ end
85
+
86
+ def _deserialize(type, value)
87
+ case type.to_sym
88
+ when :DateTime
89
+ DateTime.parse(value)
90
+ when :Date
91
+ Date.parse(value)
92
+ when :String
93
+ value.to_s
94
+ when :Integer
95
+ value.to_i
96
+ when :Float
97
+ value.to_f
98
+ when :BOOLEAN
99
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
100
+ true
101
+ else
102
+ false
103
+ end
104
+ when :Object
105
+ # generic object (usually a Hash), return directly
106
+ value
107
+ when /\AArray<(?<inner_type>.+)>\z/
108
+ inner_type = Regexp.last_match[:inner_type]
109
+ value.map { |v| _deserialize(inner_type, v) }
110
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
111
+ k_type = Regexp.last_match[:k_type]
112
+ v_type = Regexp.last_match[:v_type]
113
+ {}.tap do |hash|
114
+ value.each do |k, v|
115
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
116
+ end
117
+ end
118
+ else # model
119
+ _model = IronTitan.const_get(type).new
120
+ _model.build_from_hash(value)
121
+ end
122
+ end
123
+
124
+ def to_s
125
+ to_hash.to_s
126
+ end
127
+
128
+ # to_body is an alias to to_body (backward compatibility))
129
+ def to_body
130
+ to_hash
131
+ end
132
+
133
+ # return the object in the form of hash
134
+ def to_hash
135
+ hash = {}
136
+ self.class.attribute_map.each_pair do |attr, param|
137
+ value = self.send(attr)
138
+ next if value.nil?
139
+ hash[param] = _to_hash(value)
140
+ end
141
+ hash
142
+ end
143
+
144
+ # Method to output non-array value in the form of hash
145
+ # For object, use to_hash. Otherwise, just return the value
146
+ def _to_hash(value)
147
+ if value.is_a?(Array)
148
+ value.compact.map{ |v| _to_hash(v) }
149
+ elsif value.is_a?(Hash)
150
+ {}.tap do |hash|
151
+ value.each { |k, v| hash[k] = _to_hash(v) }
152
+ end
153
+ elsif value.respond_to? :to_hash
154
+ value.to_hash
155
+ else
156
+ value
157
+ end
158
+ end
159
+
160
+ end
161
+ end