pulp_file_client 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -17
  3. data/docs/ContentFilesApi.md +5 -5
  4. data/docs/DistributionsFileApi.md +3 -3
  5. data/docs/{Export.md → ExportRead.md} +4 -4
  6. data/docs/ExportersFileExportsApi.md +16 -16
  7. data/docs/ExportersFilesystemApi.md +52 -52
  8. data/docs/{FileFileContent.md → FileFileContentRead.md} +2 -2
  9. data/docs/FileFileDistributionRead.md +29 -0
  10. data/docs/{FileFileFileSystemExporter.md → FileFileFilesystemExporter.md} +2 -2
  11. data/docs/FileFileFilesystemExporterRead.md +23 -0
  12. data/docs/FileFilePublicationRead.md +27 -0
  13. data/docs/FileFileRemote.md +7 -3
  14. data/docs/FileFileRemoteRead.md +43 -0
  15. data/docs/FileFileRepositoryRead.md +27 -0
  16. data/docs/InlineResponse200.md +1 -1
  17. data/docs/InlineResponse2001.md +1 -1
  18. data/docs/InlineResponse2002.md +1 -1
  19. data/docs/InlineResponse2003.md +1 -1
  20. data/docs/InlineResponse2004.md +1 -1
  21. data/docs/InlineResponse2005.md +1 -1
  22. data/docs/InlineResponse2006.md +1 -1
  23. data/docs/InlineResponse2007.md +1 -1
  24. data/docs/PublicationsFileApi.md +3 -3
  25. data/docs/RemotesFileApi.md +5 -5
  26. data/docs/RepositoriesFileApi.md +10 -10
  27. data/docs/RepositoriesFileVersionsApi.md +3 -3
  28. data/docs/RepositoryVersionRead.md +25 -0
  29. data/lib/pulp_file_client/api/content_files_api.rb +5 -5
  30. data/lib/pulp_file_client/api/distributions_file_api.rb +3 -3
  31. data/lib/pulp_file_client/api/exporters_file_exports_api.rb +27 -27
  32. data/lib/pulp_file_client/api/exporters_filesystem_api.rb +78 -78
  33. data/lib/pulp_file_client/api/publications_file_api.rb +3 -3
  34. data/lib/pulp_file_client/api/remotes_file_api.rb +6 -6
  35. data/lib/pulp_file_client/api/repositories_file_api.rb +15 -15
  36. data/lib/pulp_file_client/api/repositories_file_versions_api.rb +3 -3
  37. data/lib/pulp_file_client/configuration.rb +2 -2
  38. data/lib/pulp_file_client/models/{export.rb → export_read.rb} +4 -13
  39. data/lib/pulp_file_client/models/{file_file_content.rb → file_file_content_read.rb} +3 -3
  40. data/lib/pulp_file_client/models/file_file_distribution_read.rb +331 -0
  41. data/lib/pulp_file_client/models/{file_file_file_system_exporter.rb → file_file_filesystem_exporter.rb} +3 -3
  42. data/lib/pulp_file_client/models/file_file_filesystem_exporter_read.rb +284 -0
  43. data/lib/pulp_file_client/models/file_file_publication_read.rb +274 -0
  44. data/lib/pulp_file_client/models/file_file_remote.rb +56 -4
  45. data/lib/pulp_file_client/models/file_file_remote_read.rb +531 -0
  46. data/lib/pulp_file_client/models/file_file_repository_read.rb +294 -0
  47. data/lib/pulp_file_client/models/inline_response200.rb +1 -1
  48. data/lib/pulp_file_client/models/inline_response2001.rb +1 -1
  49. data/lib/pulp_file_client/models/inline_response2002.rb +1 -1
  50. data/lib/pulp_file_client/models/inline_response2003.rb +1 -1
  51. data/lib/pulp_file_client/models/inline_response2004.rb +1 -1
  52. data/lib/pulp_file_client/models/inline_response2005.rb +1 -1
  53. data/lib/pulp_file_client/models/inline_response2006.rb +1 -1
  54. data/lib/pulp_file_client/models/inline_response2007.rb +1 -1
  55. data/lib/pulp_file_client/models/repository_version_read.rb +244 -0
  56. data/lib/pulp_file_client/version.rb +1 -1
  57. data/lib/pulp_file_client.rb +9 -3
  58. data/spec/api/content_files_api_spec.rb +2 -2
  59. data/spec/api/distributions_file_api_spec.rb +1 -1
  60. data/spec/api/exporters_file_exports_api_spec.rb +6 -6
  61. data/spec/api/exporters_filesystem_api_spec.rb +20 -20
  62. data/spec/api/publications_file_api_spec.rb +1 -1
  63. data/spec/api/remotes_file_api_spec.rb +2 -2
  64. data/spec/api/repositories_file_api_spec.rb +6 -6
  65. data/spec/api/repositories_file_versions_api_spec.rb +1 -1
  66. data/spec/configuration_spec.rb +3 -3
  67. data/spec/models/{export_spec.rb → export_read_spec.rb} +6 -6
  68. data/spec/models/{file_file_content_spec.rb → file_file_content_read_spec.rb} +6 -6
  69. data/spec/models/file_file_distribution_read_spec.rb +77 -0
  70. data/spec/models/file_file_filesystem_exporter_read_spec.rb +59 -0
  71. data/spec/models/{file_file_file_system_exporter_spec.rb → file_file_filesystem_exporter_spec.rb} +6 -6
  72. data/spec/models/file_file_publication_read_spec.rb +71 -0
  73. data/spec/models/file_file_remote_read_spec.rb +123 -0
  74. data/spec/models/file_file_remote_spec.rb +12 -0
  75. data/spec/models/file_file_repository_read_spec.rb +71 -0
  76. data/spec/models/repository_version_read_spec.rb +65 -0
  77. metadata +38 -14
@@ -0,0 +1,531 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpFileClient
16
+ class FileFileRemoteRead
17
+ attr_accessor :pulp_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :pulp_created
21
+
22
+ # A unique name for this remote.
23
+ attr_accessor :name
24
+
25
+ # The URL of an external content source.
26
+ attr_accessor :url
27
+
28
+ # A string containing the PEM encoded CA certificate used to validate the server certificate presented by the remote server. All new line characters must be escaped.
29
+ attr_accessor :ca_cert
30
+
31
+ # A string containing the PEM encoded client certificate used for authentication. All new line characters must be escaped.
32
+ attr_accessor :client_cert
33
+
34
+ # A PEM encoded private key used for authentication.
35
+ attr_accessor :client_key
36
+
37
+ # If True, TLS peer validation must be performed.
38
+ attr_accessor :tls_validation
39
+
40
+ # The proxy URL. Format: scheme://user:password@host:port
41
+ attr_accessor :proxy_url
42
+
43
+ # The username to be used for authentication when syncing.
44
+ attr_accessor :username
45
+
46
+ # The password to be used for authentication when syncing.
47
+ attr_accessor :password
48
+
49
+ # Timestamp of the most recent update of the remote.
50
+ attr_accessor :pulp_last_updated
51
+
52
+ # Total number of simultaneous connections.
53
+ attr_accessor :download_concurrency
54
+
55
+ # The policy to use when downloading content. The possible values include: 'immediate', 'on_demand', and 'streamed'. 'immediate' is the default.
56
+ attr_accessor :policy
57
+
58
+ class EnumAttributeValidator
59
+ attr_reader :datatype
60
+ attr_reader :allowable_values
61
+
62
+ def initialize(datatype, allowable_values)
63
+ @allowable_values = allowable_values.map do |value|
64
+ case datatype.to_s
65
+ when /Integer/i
66
+ value.to_i
67
+ when /Float/i
68
+ value.to_f
69
+ else
70
+ value
71
+ end
72
+ end
73
+ end
74
+
75
+ def valid?(value)
76
+ !value || allowable_values.include?(value)
77
+ end
78
+ end
79
+
80
+ # Attribute mapping from ruby-style variable name to JSON key.
81
+ def self.attribute_map
82
+ {
83
+ :'pulp_href' => :'pulp_href',
84
+ :'pulp_created' => :'pulp_created',
85
+ :'name' => :'name',
86
+ :'url' => :'url',
87
+ :'ca_cert' => :'ca_cert',
88
+ :'client_cert' => :'client_cert',
89
+ :'client_key' => :'client_key',
90
+ :'tls_validation' => :'tls_validation',
91
+ :'proxy_url' => :'proxy_url',
92
+ :'username' => :'username',
93
+ :'password' => :'password',
94
+ :'pulp_last_updated' => :'pulp_last_updated',
95
+ :'download_concurrency' => :'download_concurrency',
96
+ :'policy' => :'policy'
97
+ }
98
+ end
99
+
100
+ # Attribute type mapping.
101
+ def self.openapi_types
102
+ {
103
+ :'pulp_href' => :'String',
104
+ :'pulp_created' => :'DateTime',
105
+ :'name' => :'String',
106
+ :'url' => :'String',
107
+ :'ca_cert' => :'String',
108
+ :'client_cert' => :'String',
109
+ :'client_key' => :'String',
110
+ :'tls_validation' => :'Boolean',
111
+ :'proxy_url' => :'String',
112
+ :'username' => :'String',
113
+ :'password' => :'String',
114
+ :'pulp_last_updated' => :'DateTime',
115
+ :'download_concurrency' => :'Integer',
116
+ :'policy' => :'String'
117
+ }
118
+ end
119
+
120
+ # List of attributes with nullable: true
121
+ def self.openapi_nullable
122
+ Set.new([
123
+ :'ca_cert',
124
+ :'client_cert',
125
+ :'client_key',
126
+ :'proxy_url',
127
+ :'username',
128
+ :'password',
129
+ ])
130
+ end
131
+
132
+ # Initializes the object
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ def initialize(attributes = {})
135
+ if (!attributes.is_a?(Hash))
136
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpFileClient::FileFileRemoteRead` initialize method"
137
+ end
138
+
139
+ # check to see if the attribute exists and convert string to symbol for hash key
140
+ attributes = attributes.each_with_object({}) { |(k, v), h|
141
+ if (!self.class.attribute_map.key?(k.to_sym))
142
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpFileClient::FileFileRemoteRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
143
+ end
144
+ h[k.to_sym] = v
145
+ }
146
+
147
+ if attributes.key?(:'pulp_href')
148
+ self.pulp_href = attributes[:'pulp_href']
149
+ end
150
+
151
+ if attributes.key?(:'pulp_created')
152
+ self.pulp_created = attributes[:'pulp_created']
153
+ end
154
+
155
+ if attributes.key?(:'name')
156
+ self.name = attributes[:'name']
157
+ end
158
+
159
+ if attributes.key?(:'url')
160
+ self.url = attributes[:'url']
161
+ end
162
+
163
+ if attributes.key?(:'ca_cert')
164
+ self.ca_cert = attributes[:'ca_cert']
165
+ end
166
+
167
+ if attributes.key?(:'client_cert')
168
+ self.client_cert = attributes[:'client_cert']
169
+ end
170
+
171
+ if attributes.key?(:'client_key')
172
+ self.client_key = attributes[:'client_key']
173
+ end
174
+
175
+ if attributes.key?(:'tls_validation')
176
+ self.tls_validation = attributes[:'tls_validation']
177
+ end
178
+
179
+ if attributes.key?(:'proxy_url')
180
+ self.proxy_url = attributes[:'proxy_url']
181
+ end
182
+
183
+ if attributes.key?(:'username')
184
+ self.username = attributes[:'username']
185
+ end
186
+
187
+ if attributes.key?(:'password')
188
+ self.password = attributes[:'password']
189
+ end
190
+
191
+ if attributes.key?(:'pulp_last_updated')
192
+ self.pulp_last_updated = attributes[:'pulp_last_updated']
193
+ end
194
+
195
+ if attributes.key?(:'download_concurrency')
196
+ self.download_concurrency = attributes[:'download_concurrency']
197
+ end
198
+
199
+ if attributes.key?(:'policy')
200
+ self.policy = attributes[:'policy']
201
+ else
202
+ self.policy = 'immediate'
203
+ end
204
+ end
205
+
206
+ # Show invalid properties with the reasons. Usually used together with valid?
207
+ # @return Array for valid properties with the reasons
208
+ def list_invalid_properties
209
+ invalid_properties = Array.new
210
+ if @name.nil?
211
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
212
+ end
213
+
214
+ if @name.to_s.length < 1
215
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
216
+ end
217
+
218
+ if @url.nil?
219
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
220
+ end
221
+
222
+ if @url.to_s.length < 1
223
+ invalid_properties.push('invalid value for "url", the character length must be great than or equal to 1.')
224
+ end
225
+
226
+ if !@ca_cert.nil? && @ca_cert.to_s.length < 1
227
+ invalid_properties.push('invalid value for "ca_cert", the character length must be great than or equal to 1.')
228
+ end
229
+
230
+ if !@client_cert.nil? && @client_cert.to_s.length < 1
231
+ invalid_properties.push('invalid value for "client_cert", the character length must be great than or equal to 1.')
232
+ end
233
+
234
+ if !@client_key.nil? && @client_key.to_s.length < 1
235
+ invalid_properties.push('invalid value for "client_key", the character length must be great than or equal to 1.')
236
+ end
237
+
238
+ if !@proxy_url.nil? && @proxy_url.to_s.length < 1
239
+ invalid_properties.push('invalid value for "proxy_url", the character length must be great than or equal to 1.')
240
+ end
241
+
242
+ if !@username.nil? && @username.to_s.length < 1
243
+ invalid_properties.push('invalid value for "username", the character length must be great than or equal to 1.')
244
+ end
245
+
246
+ if !@password.nil? && @password.to_s.length < 1
247
+ invalid_properties.push('invalid value for "password", the character length must be great than or equal to 1.')
248
+ end
249
+
250
+ if !@download_concurrency.nil? && @download_concurrency < 1
251
+ invalid_properties.push('invalid value for "download_concurrency", must be greater than or equal to 1.')
252
+ end
253
+
254
+ invalid_properties
255
+ end
256
+
257
+ # Check to see if the all the properties in the model are valid
258
+ # @return true if the model is valid
259
+ def valid?
260
+ return false if @name.nil?
261
+ return false if @name.to_s.length < 1
262
+ return false if @url.nil?
263
+ return false if @url.to_s.length < 1
264
+ return false if !@ca_cert.nil? && @ca_cert.to_s.length < 1
265
+ return false if !@client_cert.nil? && @client_cert.to_s.length < 1
266
+ return false if !@client_key.nil? && @client_key.to_s.length < 1
267
+ return false if !@proxy_url.nil? && @proxy_url.to_s.length < 1
268
+ return false if !@username.nil? && @username.to_s.length < 1
269
+ return false if !@password.nil? && @password.to_s.length < 1
270
+ return false if !@download_concurrency.nil? && @download_concurrency < 1
271
+ policy_validator = EnumAttributeValidator.new('String', ["immediate", "on_demand", "streamed"])
272
+ return false unless policy_validator.valid?(@policy)
273
+ true
274
+ end
275
+
276
+ # Custom attribute writer method with validation
277
+ # @param [Object] name Value to be assigned
278
+ def name=(name)
279
+ if name.nil?
280
+ fail ArgumentError, 'name cannot be nil'
281
+ end
282
+
283
+ if name.to_s.length < 1
284
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
285
+ end
286
+
287
+ @name = name
288
+ end
289
+
290
+ # Custom attribute writer method with validation
291
+ # @param [Object] url Value to be assigned
292
+ def url=(url)
293
+ if url.nil?
294
+ fail ArgumentError, 'url cannot be nil'
295
+ end
296
+
297
+ if url.to_s.length < 1
298
+ fail ArgumentError, 'invalid value for "url", the character length must be great than or equal to 1.'
299
+ end
300
+
301
+ @url = url
302
+ end
303
+
304
+ # Custom attribute writer method with validation
305
+ # @param [Object] ca_cert Value to be assigned
306
+ def ca_cert=(ca_cert)
307
+ if !ca_cert.nil? && ca_cert.to_s.length < 1
308
+ fail ArgumentError, 'invalid value for "ca_cert", the character length must be great than or equal to 1.'
309
+ end
310
+
311
+ @ca_cert = ca_cert
312
+ end
313
+
314
+ # Custom attribute writer method with validation
315
+ # @param [Object] client_cert Value to be assigned
316
+ def client_cert=(client_cert)
317
+ if !client_cert.nil? && client_cert.to_s.length < 1
318
+ fail ArgumentError, 'invalid value for "client_cert", the character length must be great than or equal to 1.'
319
+ end
320
+
321
+ @client_cert = client_cert
322
+ end
323
+
324
+ # Custom attribute writer method with validation
325
+ # @param [Object] client_key Value to be assigned
326
+ def client_key=(client_key)
327
+ if !client_key.nil? && client_key.to_s.length < 1
328
+ fail ArgumentError, 'invalid value for "client_key", the character length must be great than or equal to 1.'
329
+ end
330
+
331
+ @client_key = client_key
332
+ end
333
+
334
+ # Custom attribute writer method with validation
335
+ # @param [Object] proxy_url Value to be assigned
336
+ def proxy_url=(proxy_url)
337
+ if !proxy_url.nil? && proxy_url.to_s.length < 1
338
+ fail ArgumentError, 'invalid value for "proxy_url", the character length must be great than or equal to 1.'
339
+ end
340
+
341
+ @proxy_url = proxy_url
342
+ end
343
+
344
+ # Custom attribute writer method with validation
345
+ # @param [Object] username Value to be assigned
346
+ def username=(username)
347
+ if !username.nil? && username.to_s.length < 1
348
+ fail ArgumentError, 'invalid value for "username", the character length must be great than or equal to 1.'
349
+ end
350
+
351
+ @username = username
352
+ end
353
+
354
+ # Custom attribute writer method with validation
355
+ # @param [Object] password Value to be assigned
356
+ def password=(password)
357
+ if !password.nil? && password.to_s.length < 1
358
+ fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 1.'
359
+ end
360
+
361
+ @password = password
362
+ end
363
+
364
+ # Custom attribute writer method with validation
365
+ # @param [Object] download_concurrency Value to be assigned
366
+ def download_concurrency=(download_concurrency)
367
+ if !download_concurrency.nil? && download_concurrency < 1
368
+ fail ArgumentError, 'invalid value for "download_concurrency", must be greater than or equal to 1.'
369
+ end
370
+
371
+ @download_concurrency = download_concurrency
372
+ end
373
+
374
+ # Custom attribute writer method checking allowed values (enum).
375
+ # @param [Object] policy Object to be assigned
376
+ def policy=(policy)
377
+ validator = EnumAttributeValidator.new('String', ["immediate", "on_demand", "streamed"])
378
+ unless validator.valid?(policy)
379
+ fail ArgumentError, "invalid value for \"policy\", must be one of #{validator.allowable_values}."
380
+ end
381
+ @policy = policy
382
+ end
383
+
384
+ # Checks equality by comparing each attribute.
385
+ # @param [Object] Object to be compared
386
+ def ==(o)
387
+ return true if self.equal?(o)
388
+ self.class == o.class &&
389
+ pulp_href == o.pulp_href &&
390
+ pulp_created == o.pulp_created &&
391
+ name == o.name &&
392
+ url == o.url &&
393
+ ca_cert == o.ca_cert &&
394
+ client_cert == o.client_cert &&
395
+ client_key == o.client_key &&
396
+ tls_validation == o.tls_validation &&
397
+ proxy_url == o.proxy_url &&
398
+ username == o.username &&
399
+ password == o.password &&
400
+ pulp_last_updated == o.pulp_last_updated &&
401
+ download_concurrency == o.download_concurrency &&
402
+ policy == o.policy
403
+ end
404
+
405
+ # @see the `==` method
406
+ # @param [Object] Object to be compared
407
+ def eql?(o)
408
+ self == o
409
+ end
410
+
411
+ # Calculates hash code according to all attributes.
412
+ # @return [Integer] Hash code
413
+ def hash
414
+ [pulp_href, pulp_created, name, url, ca_cert, client_cert, client_key, tls_validation, proxy_url, username, password, pulp_last_updated, download_concurrency, policy].hash
415
+ end
416
+
417
+ # Builds the object from hash
418
+ # @param [Hash] attributes Model attributes in the form of hash
419
+ # @return [Object] Returns the model itself
420
+ def self.build_from_hash(attributes)
421
+ new.build_from_hash(attributes)
422
+ end
423
+
424
+ # Builds the object from hash
425
+ # @param [Hash] attributes Model attributes in the form of hash
426
+ # @return [Object] Returns the model itself
427
+ def build_from_hash(attributes)
428
+ return nil unless attributes.is_a?(Hash)
429
+ self.class.openapi_types.each_pair do |key, type|
430
+ if type =~ /\AArray<(.*)>/i
431
+ # check to ensure the input is an array given that the attribute
432
+ # is documented as an array but the input is not
433
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
434
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
435
+ end
436
+ elsif !attributes[self.class.attribute_map[key]].nil?
437
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
438
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
439
+ end
440
+
441
+ self
442
+ end
443
+
444
+ # Deserializes the data based on type
445
+ # @param string type Data type
446
+ # @param string value Value to be deserialized
447
+ # @return [Object] Deserialized data
448
+ def _deserialize(type, value)
449
+ case type.to_sym
450
+ when :DateTime
451
+ DateTime.parse(value)
452
+ when :Date
453
+ Date.parse(value)
454
+ when :String
455
+ value.to_s
456
+ when :Integer
457
+ value.to_i
458
+ when :Float
459
+ value.to_f
460
+ when :Boolean
461
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
462
+ true
463
+ else
464
+ false
465
+ end
466
+ when :Object
467
+ # generic object (usually a Hash), return directly
468
+ value
469
+ when /\AArray<(?<inner_type>.+)>\z/
470
+ inner_type = Regexp.last_match[:inner_type]
471
+ value.map { |v| _deserialize(inner_type, v) }
472
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
473
+ k_type = Regexp.last_match[:k_type]
474
+ v_type = Regexp.last_match[:v_type]
475
+ {}.tap do |hash|
476
+ value.each do |k, v|
477
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
478
+ end
479
+ end
480
+ else # model
481
+ PulpFileClient.const_get(type).build_from_hash(value)
482
+ end
483
+ end
484
+
485
+ # Returns the string representation of the object
486
+ # @return [String] String presentation of the object
487
+ def to_s
488
+ to_hash.to_s
489
+ end
490
+
491
+ # to_body is an alias to to_hash (backward compatibility)
492
+ # @return [Hash] Returns the object in the form of hash
493
+ def to_body
494
+ to_hash
495
+ end
496
+
497
+ # Returns the object in the form of hash
498
+ # @return [Hash] Returns the object in the form of hash
499
+ def to_hash
500
+ hash = {}
501
+ self.class.attribute_map.each_pair do |attr, param|
502
+ value = self.send(attr)
503
+ if value.nil?
504
+ is_nullable = self.class.openapi_nullable.include?(attr)
505
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
506
+ end
507
+
508
+ hash[param] = _to_hash(value)
509
+ end
510
+ hash
511
+ end
512
+
513
+ # Outputs non-array value in the form of hash
514
+ # For object, use to_hash. Otherwise, just return the value
515
+ # @param [Object] value Any valid value
516
+ # @return [Hash] Returns the value in the form of hash
517
+ def _to_hash(value)
518
+ if value.is_a?(Array)
519
+ value.compact.map { |v| _to_hash(v) }
520
+ elsif value.is_a?(Hash)
521
+ {}.tap do |hash|
522
+ value.each { |k, v| hash[k] = _to_hash(v) }
523
+ end
524
+ elsif value.respond_to? :to_hash
525
+ value.to_hash
526
+ else
527
+ value
528
+ end
529
+ end
530
+ end
531
+ end