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