fn_ruby 0.1.29
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/LICENSE +201 -0
- data/README.md +110 -0
- data/Rakefile +8 -0
- data/VERSION +1 -0
- data/docs/App.md +9 -0
- data/docs/AppWrapper.md +9 -0
- data/docs/AppsApi.md +244 -0
- data/docs/AppsWrapper.md +9 -0
- data/docs/Error.md +8 -0
- data/docs/ErrorBody.md +9 -0
- data/docs/NewTask.md +9 -0
- data/docs/Route.md +17 -0
- data/docs/RouteWrapper.md +10 -0
- data/docs/RoutesApi.md +262 -0
- data/docs/RoutesWrapper.md +9 -0
- data/docs/Task.md +18 -0
- data/docs/TaskWrapper.md +8 -0
- data/docs/TasksApi.md +50 -0
- data/docs/Version.md +8 -0
- data/docs/VersionApi.md +48 -0
- data/fn_ruby.gemspec +46 -0
- data/git_push.sh +55 -0
- data/lib/fn_ruby/api/apps_api.rb +297 -0
- data/lib/fn_ruby/api/routes_api.rb +327 -0
- data/lib/fn_ruby/api/tasks_api.rb +72 -0
- data/lib/fn_ruby/api/version_api.rb +72 -0
- data/lib/fn_ruby/api_client.rb +388 -0
- data/lib/fn_ruby/api_error.rb +38 -0
- data/lib/fn_ruby/configuration.rb +202 -0
- data/lib/fn_ruby/models/app.rb +201 -0
- data/lib/fn_ruby/models/app_wrapper.rb +202 -0
- data/lib/fn_ruby/models/apps_wrapper.rb +204 -0
- data/lib/fn_ruby/models/error.rb +188 -0
- data/lib/fn_ruby/models/error_body.rb +197 -0
- data/lib/fn_ruby/models/new_task.rb +204 -0
- data/lib/fn_ruby/models/route.rb +328 -0
- data/lib/fn_ruby/models/route_wrapper.rb +211 -0
- data/lib/fn_ruby/models/routes_wrapper.rb +204 -0
- data/lib/fn_ruby/models/task.rb +329 -0
- data/lib/fn_ruby/models/task_wrapper.rb +193 -0
- data/lib/fn_ruby/models/version.rb +188 -0
- data/lib/fn_ruby/version.rb +15 -0
- data/lib/fn_ruby.rb +55 -0
- data/spec/api/apps_api_spec.rb +95 -0
- data/spec/api/routes_api_spec.rb +100 -0
- data/spec/api/tasks_api_spec.rb +46 -0
- data/spec/api/version_api_spec.rb +46 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/app_spec.rb +48 -0
- data/spec/models/app_wrapper_spec.rb +48 -0
- data/spec/models/apps_wrapper_spec.rb +48 -0
- data/spec/models/error_body_spec.rb +48 -0
- data/spec/models/error_spec.rb +42 -0
- data/spec/models/new_task_spec.rb +48 -0
- data/spec/models/route_spec.rb +104 -0
- data/spec/models/route_wrapper_spec.rb +54 -0
- data/spec/models/routes_wrapper_spec.rb +48 -0
- data/spec/models/task_spec.rb +106 -0
- data/spec/models/task_wrapper_spec.rb +42 -0
- data/spec/models/version_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- metadata +305 -0
@@ -0,0 +1,328 @@
|
|
1
|
+
=begin
|
2
|
+
#IronFunctions
|
3
|
+
|
4
|
+
#The open source serverless platform.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.1.29
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module OracleFunctions
|
16
|
+
|
17
|
+
class Route
|
18
|
+
# URL path that will be matched to this route
|
19
|
+
attr_accessor :path
|
20
|
+
|
21
|
+
# Name of Docker image to use in this route. You should include the image tag, which should be a version number, to be more accurate. Can be overridden on a per route basis with route.image.
|
22
|
+
attr_accessor :image
|
23
|
+
|
24
|
+
# Map of http headers that will be sent with the response
|
25
|
+
attr_accessor :headers
|
26
|
+
|
27
|
+
# Max usable memory for this route (MiB).
|
28
|
+
attr_accessor :memory
|
29
|
+
|
30
|
+
# Route type
|
31
|
+
attr_accessor :type
|
32
|
+
|
33
|
+
# Payload format sent into function.
|
34
|
+
attr_accessor :format
|
35
|
+
|
36
|
+
# Maximum number of hot functions concurrency
|
37
|
+
attr_accessor :max_concurrency
|
38
|
+
|
39
|
+
# Route configuration - overrides application configuration
|
40
|
+
attr_accessor :config
|
41
|
+
|
42
|
+
# Timeout for executions of this route. Value in Seconds
|
43
|
+
attr_accessor :timeout
|
44
|
+
|
45
|
+
# Hot functions idle timeout before termination. Value in Seconds
|
46
|
+
attr_accessor :idle_timeout
|
47
|
+
|
48
|
+
class EnumAttributeValidator
|
49
|
+
attr_reader :datatype
|
50
|
+
attr_reader :allowable_values
|
51
|
+
|
52
|
+
def initialize(datatype, allowable_values)
|
53
|
+
@allowable_values = allowable_values.map do |value|
|
54
|
+
case datatype.to_s
|
55
|
+
when /Integer/i
|
56
|
+
value.to_i
|
57
|
+
when /Float/i
|
58
|
+
value.to_f
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def valid?(value)
|
66
|
+
!value || allowable_values.include?(value)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
71
|
+
def self.attribute_map
|
72
|
+
{
|
73
|
+
:'path' => :'path',
|
74
|
+
:'image' => :'image',
|
75
|
+
:'headers' => :'headers',
|
76
|
+
:'memory' => :'memory',
|
77
|
+
:'type' => :'type',
|
78
|
+
:'format' => :'format',
|
79
|
+
:'max_concurrency' => :'max_concurrency',
|
80
|
+
:'config' => :'config',
|
81
|
+
:'timeout' => :'timeout',
|
82
|
+
:'idle_timeout' => :'idle_timeout'
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
# Attribute type mapping.
|
87
|
+
def self.swagger_types
|
88
|
+
{
|
89
|
+
:'path' => :'String',
|
90
|
+
:'image' => :'String',
|
91
|
+
:'headers' => :'Hash<String, Array<String>>',
|
92
|
+
:'memory' => :'Integer',
|
93
|
+
:'type' => :'String',
|
94
|
+
:'format' => :'String',
|
95
|
+
:'max_concurrency' => :'Integer',
|
96
|
+
:'config' => :'Hash<String, String>',
|
97
|
+
:'timeout' => :'Integer',
|
98
|
+
:'idle_timeout' => :'Integer'
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
# Initializes the object
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
def initialize(attributes = {})
|
105
|
+
return unless attributes.is_a?(Hash)
|
106
|
+
|
107
|
+
# convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
109
|
+
|
110
|
+
if attributes.has_key?(:'path')
|
111
|
+
self.path = attributes[:'path']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.has_key?(:'image')
|
115
|
+
self.image = attributes[:'image']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.has_key?(:'headers')
|
119
|
+
if (value = attributes[:'headers']).is_a?(Array)
|
120
|
+
self.headers = value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.has_key?(:'memory')
|
125
|
+
self.memory = attributes[:'memory']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.has_key?(:'type')
|
129
|
+
self.type = attributes[:'type']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.has_key?(:'format')
|
133
|
+
self.format = attributes[:'format']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.has_key?(:'max_concurrency')
|
137
|
+
self.max_concurrency = attributes[:'max_concurrency']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.has_key?(:'config')
|
141
|
+
if (value = attributes[:'config']).is_a?(Array)
|
142
|
+
self.config = value
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
if attributes.has_key?(:'timeout')
|
147
|
+
self.timeout = attributes[:'timeout']
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.has_key?(:'idle_timeout')
|
151
|
+
self.idle_timeout = attributes[:'idle_timeout']
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
157
|
+
# @return Array for valid properies with the reasons
|
158
|
+
def list_invalid_properties
|
159
|
+
invalid_properties = Array.new
|
160
|
+
return invalid_properties
|
161
|
+
end
|
162
|
+
|
163
|
+
# Check to see if the all the properties in the model are valid
|
164
|
+
# @return true if the model is valid
|
165
|
+
def valid?
|
166
|
+
type_validator = EnumAttributeValidator.new('String', ["sync", "async"])
|
167
|
+
return false unless type_validator.valid?(@type)
|
168
|
+
format_validator = EnumAttributeValidator.new('String', ["default", "http", "json"])
|
169
|
+
return false unless format_validator.valid?(@format)
|
170
|
+
return true
|
171
|
+
end
|
172
|
+
|
173
|
+
# Custom attribute writer method checking allowed values (enum).
|
174
|
+
# @param [Object] type Object to be assigned
|
175
|
+
def type=(type)
|
176
|
+
validator = EnumAttributeValidator.new('String', ["sync", "async"])
|
177
|
+
unless validator.valid?(type)
|
178
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
179
|
+
end
|
180
|
+
@type = type
|
181
|
+
end
|
182
|
+
|
183
|
+
# Custom attribute writer method checking allowed values (enum).
|
184
|
+
# @param [Object] format Object to be assigned
|
185
|
+
def format=(format)
|
186
|
+
validator = EnumAttributeValidator.new('String', ["default", "http", "json"])
|
187
|
+
unless validator.valid?(format)
|
188
|
+
fail ArgumentError, "invalid value for 'format', must be one of #{validator.allowable_values}."
|
189
|
+
end
|
190
|
+
@format = format
|
191
|
+
end
|
192
|
+
|
193
|
+
# Checks equality by comparing each attribute.
|
194
|
+
# @param [Object] Object to be compared
|
195
|
+
def ==(o)
|
196
|
+
return true if self.equal?(o)
|
197
|
+
self.class == o.class &&
|
198
|
+
path == o.path &&
|
199
|
+
image == o.image &&
|
200
|
+
headers == o.headers &&
|
201
|
+
memory == o.memory &&
|
202
|
+
type == o.type &&
|
203
|
+
format == o.format &&
|
204
|
+
max_concurrency == o.max_concurrency &&
|
205
|
+
config == o.config &&
|
206
|
+
timeout == o.timeout &&
|
207
|
+
idle_timeout == o.idle_timeout
|
208
|
+
end
|
209
|
+
|
210
|
+
# @see the `==` method
|
211
|
+
# @param [Object] Object to be compared
|
212
|
+
def eql?(o)
|
213
|
+
self == o
|
214
|
+
end
|
215
|
+
|
216
|
+
# Calculates hash code according to all attributes.
|
217
|
+
# @return [Fixnum] Hash code
|
218
|
+
def hash
|
219
|
+
[path, image, headers, memory, type, format, max_concurrency, config, timeout, idle_timeout].hash
|
220
|
+
end
|
221
|
+
|
222
|
+
# Builds the object from hash
|
223
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
224
|
+
# @return [Object] Returns the model itself
|
225
|
+
def build_from_hash(attributes)
|
226
|
+
return nil unless attributes.is_a?(Hash)
|
227
|
+
self.class.swagger_types.each_pair do |key, type|
|
228
|
+
if type =~ /\AArray<(.*)>/i
|
229
|
+
# check to ensure the input is an array given that the the attribute
|
230
|
+
# is documented as an array but the input is not
|
231
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
232
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
233
|
+
end
|
234
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
235
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
236
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
237
|
+
end
|
238
|
+
|
239
|
+
self
|
240
|
+
end
|
241
|
+
|
242
|
+
# Deserializes the data based on type
|
243
|
+
# @param string type Data type
|
244
|
+
# @param string value Value to be deserialized
|
245
|
+
# @return [Object] Deserialized data
|
246
|
+
def _deserialize(type, value)
|
247
|
+
case type.to_sym
|
248
|
+
when :DateTime
|
249
|
+
DateTime.parse(value)
|
250
|
+
when :Date
|
251
|
+
Date.parse(value)
|
252
|
+
when :String
|
253
|
+
value.to_s
|
254
|
+
when :Integer
|
255
|
+
value.to_i
|
256
|
+
when :Float
|
257
|
+
value.to_f
|
258
|
+
when :BOOLEAN
|
259
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
260
|
+
true
|
261
|
+
else
|
262
|
+
false
|
263
|
+
end
|
264
|
+
when :Object
|
265
|
+
# generic object (usually a Hash), return directly
|
266
|
+
value
|
267
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
268
|
+
inner_type = Regexp.last_match[:inner_type]
|
269
|
+
value.map { |v| _deserialize(inner_type, v) }
|
270
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
271
|
+
k_type = Regexp.last_match[:k_type]
|
272
|
+
v_type = Regexp.last_match[:v_type]
|
273
|
+
{}.tap do |hash|
|
274
|
+
value.each do |k, v|
|
275
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
else # model
|
279
|
+
temp_model = OracleFunctions.const_get(type).new
|
280
|
+
temp_model.build_from_hash(value)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns the string representation of the object
|
285
|
+
# @return [String] String presentation of the object
|
286
|
+
def to_s
|
287
|
+
to_hash.to_s
|
288
|
+
end
|
289
|
+
|
290
|
+
# to_body is an alias to to_hash (backward compatibility)
|
291
|
+
# @return [Hash] Returns the object in the form of hash
|
292
|
+
def to_body
|
293
|
+
to_hash
|
294
|
+
end
|
295
|
+
|
296
|
+
# Returns the object in the form of hash
|
297
|
+
# @return [Hash] Returns the object in the form of hash
|
298
|
+
def to_hash
|
299
|
+
hash = {}
|
300
|
+
self.class.attribute_map.each_pair do |attr, param|
|
301
|
+
value = self.send(attr)
|
302
|
+
next if value.nil?
|
303
|
+
hash[param] = _to_hash(value)
|
304
|
+
end
|
305
|
+
hash
|
306
|
+
end
|
307
|
+
|
308
|
+
# Outputs non-array value in the form of hash
|
309
|
+
# For object, use to_hash. Otherwise, just return the value
|
310
|
+
# @param [Object] value Any valid value
|
311
|
+
# @return [Hash] Returns the value in the form of hash
|
312
|
+
def _to_hash(value)
|
313
|
+
if value.is_a?(Array)
|
314
|
+
value.compact.map{ |v| _to_hash(v) }
|
315
|
+
elsif value.is_a?(Hash)
|
316
|
+
{}.tap do |hash|
|
317
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
318
|
+
end
|
319
|
+
elsif value.respond_to? :to_hash
|
320
|
+
value.to_hash
|
321
|
+
else
|
322
|
+
value
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
=begin
|
2
|
+
#IronFunctions
|
3
|
+
|
4
|
+
#The open source serverless platform.
|
5
|
+
|
6
|
+
OpenAPI spec version: 0.1.29
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module OracleFunctions
|
16
|
+
|
17
|
+
class RouteWrapper
|
18
|
+
attr_accessor :message
|
19
|
+
|
20
|
+
attr_accessor :error
|
21
|
+
|
22
|
+
attr_accessor :route
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'message' => :'message',
|
29
|
+
:'error' => :'error',
|
30
|
+
:'route' => :'route'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.swagger_types
|
36
|
+
{
|
37
|
+
:'message' => :'String',
|
38
|
+
:'error' => :'ErrorBody',
|
39
|
+
:'route' => :'Route'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
return unless attributes.is_a?(Hash)
|
47
|
+
|
48
|
+
# convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
50
|
+
|
51
|
+
if attributes.has_key?(:'message')
|
52
|
+
self.message = attributes[:'message']
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes.has_key?(:'error')
|
56
|
+
self.error = attributes[:'error']
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.has_key?(:'route')
|
60
|
+
self.route = attributes[:'route']
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properies with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
invalid_properties = Array.new
|
69
|
+
if @route.nil?
|
70
|
+
invalid_properties.push("invalid value for 'route', route cannot be nil.")
|
71
|
+
end
|
72
|
+
|
73
|
+
return invalid_properties
|
74
|
+
end
|
75
|
+
|
76
|
+
# Check to see if the all the properties in the model are valid
|
77
|
+
# @return true if the model is valid
|
78
|
+
def valid?
|
79
|
+
return false if @route.nil?
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks equality by comparing each attribute.
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def ==(o)
|
86
|
+
return true if self.equal?(o)
|
87
|
+
self.class == o.class &&
|
88
|
+
message == o.message &&
|
89
|
+
error == o.error &&
|
90
|
+
route == o.route
|
91
|
+
end
|
92
|
+
|
93
|
+
# @see the `==` method
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def eql?(o)
|
96
|
+
self == o
|
97
|
+
end
|
98
|
+
|
99
|
+
# Calculates hash code according to all attributes.
|
100
|
+
# @return [Fixnum] Hash code
|
101
|
+
def hash
|
102
|
+
[message, error, route].hash
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.swagger_types.each_pair do |key, type|
|
111
|
+
if type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the the attribute
|
113
|
+
# is documented as an array but the input is not
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
116
|
+
end
|
117
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
118
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
119
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
120
|
+
end
|
121
|
+
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Deserializes the data based on type
|
126
|
+
# @param string type Data type
|
127
|
+
# @param string value Value to be deserialized
|
128
|
+
# @return [Object] Deserialized data
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :BOOLEAN
|
142
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
temp_model = OracleFunctions.const_get(type).new
|
163
|
+
temp_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the string representation of the object
|
168
|
+
# @return [String] String presentation of the object
|
169
|
+
def to_s
|
170
|
+
to_hash.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
# to_body is an alias to to_hash (backward compatibility)
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_body
|
176
|
+
to_hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the object in the form of hash
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_hash
|
182
|
+
hash = {}
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
184
|
+
value = self.send(attr)
|
185
|
+
next if value.nil?
|
186
|
+
hash[param] = _to_hash(value)
|
187
|
+
end
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map{ |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to? :to_hash
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|