allq_client 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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/README.md +111 -0
  5. data/Rakefile +8 -0
  6. data/allq_client.gemspec +46 -0
  7. data/docs/ActionsApi.md +544 -0
  8. data/docs/AdminApi.md +98 -0
  9. data/docs/BasicPayload.md +11 -0
  10. data/docs/BasicResponse.md +8 -0
  11. data/docs/JobRef.md +8 -0
  12. data/docs/JobResponse.md +12 -0
  13. data/docs/NewJob.md +13 -0
  14. data/docs/NewParentJob.md +16 -0
  15. data/docs/StatsInfo.md +9 -0
  16. data/docs/StatsResults.md +10 -0
  17. data/docs/StatsTube.md +14 -0
  18. data/docs/Throttle.md +9 -0
  19. data/docs/TubeRef.md +8 -0
  20. data/git_push.sh +55 -0
  21. data/lib/allq_client.rb +52 -0
  22. data/lib/allq_client/api/actions_api.rb +642 -0
  23. data/lib/allq_client/api/admin_api.rb +128 -0
  24. data/lib/allq_client/api_client.rb +388 -0
  25. data/lib/allq_client/api_error.rb +38 -0
  26. data/lib/allq_client/configuration.rb +202 -0
  27. data/lib/allq_client/models/basic_payload.rb +223 -0
  28. data/lib/allq_client/models/basic_response.rb +193 -0
  29. data/lib/allq_client/models/job_ref.rb +194 -0
  30. data/lib/allq_client/models/job_response.rb +253 -0
  31. data/lib/allq_client/models/new_job.rb +274 -0
  32. data/lib/allq_client/models/new_parent_job.rb +306 -0
  33. data/lib/allq_client/models/stats_info.rb +208 -0
  34. data/lib/allq_client/models/stats_results.rb +226 -0
  35. data/lib/allq_client/models/stats_tube.rb +289 -0
  36. data/lib/allq_client/models/throttle.rb +213 -0
  37. data/lib/allq_client/models/tube_ref.rb +194 -0
  38. data/lib/allq_client/version.rb +15 -0
  39. data/spec/api/actions_api_spec.rb +169 -0
  40. data/spec/api/admin_api_spec.rb +58 -0
  41. data/spec/api_client_spec.rb +226 -0
  42. data/spec/configuration_spec.rb +42 -0
  43. data/spec/models/basic_payload_spec.rb +60 -0
  44. data/spec/models/basic_response_spec.rb +42 -0
  45. data/spec/models/job_ref_spec.rb +42 -0
  46. data/spec/models/job_response_spec.rb +66 -0
  47. data/spec/models/new_job_spec.rb +72 -0
  48. data/spec/models/new_parent_job_spec.rb +90 -0
  49. data/spec/models/stats_info_spec.rb +48 -0
  50. data/spec/models/stats_results_spec.rb +54 -0
  51. data/spec/models/stats_tube_spec.rb +78 -0
  52. data/spec/models/throttle_spec.rb +48 -0
  53. data/spec/models/tube_ref_spec.rb +42 -0
  54. data/spec/spec_helper.rb +111 -0
  55. metadata +292 -0
@@ -0,0 +1,208 @@
1
+ =begin
2
+ #AllQ
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 1.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 Allq
16
+ # Individual Server Info
17
+ class StatsInfo
18
+ # Name of tube
19
+ attr_accessor :tube_name
20
+
21
+ attr_accessor :info
22
+
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'tube_name' => :'tube_name',
28
+ :'info' => :'info'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'tube_name' => :'String',
36
+ :'info' => :'StatsTube'
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?(:'tube_name')
49
+ self.tube_name = attributes[:'tube_name']
50
+ end
51
+
52
+ if attributes.has_key?(:'info')
53
+ self.info = attributes[:'info']
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
+ if @tube_name.nil?
63
+ invalid_properties.push("invalid value for 'tube_name', tube_name cannot be nil.")
64
+ end
65
+
66
+ if @info.nil?
67
+ invalid_properties.push("invalid value for 'info', info cannot be nil.")
68
+ end
69
+
70
+ return invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ return false if @tube_name.nil?
77
+ return false if @info.nil?
78
+ return true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ tube_name == o.tube_name &&
87
+ info == o.info
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
+ [tube_name, info].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 = Allq.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
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #AllQ
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 1.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 Allq
16
+ # Stats result
17
+ class StatsResults
18
+ # ID of server
19
+ attr_accessor :server_name
20
+
21
+ # Array of server instances
22
+ attr_accessor :stats
23
+
24
+ # Total actions taken on server
25
+ attr_accessor :action_count
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'server_name' => :'server_name',
32
+ :'stats' => :'stats',
33
+ :'action_count' => :'action_count'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'server_name' => :'String',
41
+ :'stats' => :'Array<StatsTube>',
42
+ :'action_count' => :'Integer'
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?(:'server_name')
55
+ self.server_name = attributes[:'server_name']
56
+ end
57
+
58
+ if attributes.has_key?(:'stats')
59
+ if (value = attributes[:'stats']).is_a?(Array)
60
+ self.stats = value
61
+ end
62
+ end
63
+
64
+ if attributes.has_key?(:'action_count')
65
+ self.action_count = attributes[:'action_count']
66
+ end
67
+
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
+ if @server_name.nil?
75
+ invalid_properties.push("invalid value for 'server_name', server_name cannot be nil.")
76
+ end
77
+
78
+ if @stats.nil?
79
+ invalid_properties.push("invalid value for 'stats', stats cannot be nil.")
80
+ end
81
+
82
+ if @action_count.nil?
83
+ invalid_properties.push("invalid value for 'action_count', action_count cannot be nil.")
84
+ end
85
+
86
+ return invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ return false if @server_name.nil?
93
+ return false if @stats.nil?
94
+ return false if @action_count.nil?
95
+ return true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ server_name == o.server_name &&
104
+ stats == o.stats &&
105
+ action_count == o.action_count
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
116
+ def hash
117
+ [server_name, stats, action_count].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ self.class.swagger_types.each_pair do |key, type|
126
+ if type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :DateTime
147
+ DateTime.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :BOOLEAN
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ temp_model = Allq.const_get(type).new
178
+ temp_model.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ next if value.nil?
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map{ |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+
224
+ end
225
+
226
+ end
@@ -0,0 +1,289 @@
1
+ =begin
2
+ #AllQ
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 1.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 Allq
16
+ # Information about a single tube
17
+ class StatsTube
18
+ # Count of ready jobs
19
+ attr_accessor :ready
20
+
21
+ # Count of delayed jobs
22
+ attr_accessor :delayed
23
+
24
+ # Count of reserved jobs
25
+ attr_accessor :reserved
26
+
27
+ # Count of buried jobs
28
+ attr_accessor :buried
29
+
30
+ # Count of parent jobs
31
+ attr_accessor :parents
32
+
33
+ # TPS of throttle
34
+ attr_accessor :throttle_size
35
+
36
+ # Name of tube
37
+ attr_accessor :tube
38
+
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'ready' => :'ready',
44
+ :'delayed' => :'delayed',
45
+ :'reserved' => :'reserved',
46
+ :'buried' => :'buried',
47
+ :'parents' => :'parents',
48
+ :'throttle_size' => :'throttle_size',
49
+ :'tube' => :'tube'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.swagger_types
55
+ {
56
+ :'ready' => :'Integer',
57
+ :'delayed' => :'Integer',
58
+ :'reserved' => :'Integer',
59
+ :'buried' => :'Integer',
60
+ :'parents' => :'Integer',
61
+ :'throttle_size' => :'Integer',
62
+ :'tube' => :'String'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ return unless attributes.is_a?(Hash)
70
+
71
+ # convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
73
+
74
+ if attributes.has_key?(:'ready')
75
+ self.ready = attributes[:'ready']
76
+ else
77
+ self.ready = 0
78
+ end
79
+
80
+ if attributes.has_key?(:'delayed')
81
+ self.delayed = attributes[:'delayed']
82
+ else
83
+ self.delayed = 0
84
+ end
85
+
86
+ if attributes.has_key?(:'reserved')
87
+ self.reserved = attributes[:'reserved']
88
+ else
89
+ self.reserved = 0
90
+ end
91
+
92
+ if attributes.has_key?(:'buried')
93
+ self.buried = attributes[:'buried']
94
+ else
95
+ self.buried = 0
96
+ end
97
+
98
+ if attributes.has_key?(:'parents')
99
+ self.parents = attributes[:'parents']
100
+ else
101
+ self.parents = 0
102
+ end
103
+
104
+ if attributes.has_key?(:'throttle_size')
105
+ self.throttle_size = attributes[:'throttle_size']
106
+ end
107
+
108
+ if attributes.has_key?(:'tube')
109
+ self.tube = attributes[:'tube']
110
+ end
111
+
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
+ if @ready.nil?
119
+ invalid_properties.push("invalid value for 'ready', ready cannot be nil.")
120
+ end
121
+
122
+ if @delayed.nil?
123
+ invalid_properties.push("invalid value for 'delayed', delayed cannot be nil.")
124
+ end
125
+
126
+ if @reserved.nil?
127
+ invalid_properties.push("invalid value for 'reserved', reserved cannot be nil.")
128
+ end
129
+
130
+ if @buried.nil?
131
+ invalid_properties.push("invalid value for 'buried', buried cannot be nil.")
132
+ end
133
+
134
+ if @parents.nil?
135
+ invalid_properties.push("invalid value for 'parents', parents cannot be nil.")
136
+ end
137
+
138
+ if @tube.nil?
139
+ invalid_properties.push("invalid value for 'tube', tube cannot be nil.")
140
+ end
141
+
142
+ return invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ return false if @ready.nil?
149
+ return false if @delayed.nil?
150
+ return false if @reserved.nil?
151
+ return false if @buried.nil?
152
+ return false if @parents.nil?
153
+ return false if @tube.nil?
154
+ return true
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ ready == o.ready &&
163
+ delayed == o.delayed &&
164
+ reserved == o.reserved &&
165
+ buried == o.buried &&
166
+ parents == o.parents &&
167
+ throttle_size == o.throttle_size &&
168
+ tube == o.tube
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Fixnum] Hash code
179
+ def hash
180
+ [ready, delayed, reserved, buried, parents, throttle_size, tube].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def build_from_hash(attributes)
187
+ return nil unless attributes.is_a?(Hash)
188
+ self.class.swagger_types.each_pair do |key, type|
189
+ if type =~ /\AArray<(.*)>/i
190
+ # check to ensure the input is an array given that the the attribute
191
+ # is documented as an array but the input is not
192
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
193
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
194
+ end
195
+ elsif !attributes[self.class.attribute_map[key]].nil?
196
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
197
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
198
+ end
199
+
200
+ self
201
+ end
202
+
203
+ # Deserializes the data based on type
204
+ # @param string type Data type
205
+ # @param string value Value to be deserialized
206
+ # @return [Object] Deserialized data
207
+ def _deserialize(type, value)
208
+ case type.to_sym
209
+ when :DateTime
210
+ DateTime.parse(value)
211
+ when :Date
212
+ Date.parse(value)
213
+ when :String
214
+ value.to_s
215
+ when :Integer
216
+ value.to_i
217
+ when :Float
218
+ value.to_f
219
+ when :BOOLEAN
220
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
221
+ true
222
+ else
223
+ false
224
+ end
225
+ when :Object
226
+ # generic object (usually a Hash), return directly
227
+ value
228
+ when /\AArray<(?<inner_type>.+)>\z/
229
+ inner_type = Regexp.last_match[:inner_type]
230
+ value.map { |v| _deserialize(inner_type, v) }
231
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
232
+ k_type = Regexp.last_match[:k_type]
233
+ v_type = Regexp.last_match[:v_type]
234
+ {}.tap do |hash|
235
+ value.each do |k, v|
236
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
237
+ end
238
+ end
239
+ else # model
240
+ temp_model = Allq.const_get(type).new
241
+ temp_model.build_from_hash(value)
242
+ end
243
+ end
244
+
245
+ # Returns the string representation of the object
246
+ # @return [String] String presentation of the object
247
+ def to_s
248
+ to_hash.to_s
249
+ end
250
+
251
+ # to_body is an alias to to_hash (backward compatibility)
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_body
254
+ to_hash
255
+ end
256
+
257
+ # Returns the object in the form of hash
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_hash
260
+ hash = {}
261
+ self.class.attribute_map.each_pair do |attr, param|
262
+ value = self.send(attr)
263
+ next if value.nil?
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map{ |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+
287
+ end
288
+
289
+ end