cloudsmith-api 2.0.23 → 2.0.24

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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +17 -4
  4. data/build.json +1 -1
  5. data/docs/FormatSupport.md +1 -0
  6. data/docs/GenericPackageUpload.md +90 -0
  7. data/docs/GenericPackageUploadRequest.md +13 -0
  8. data/docs/GenericUpstream.md +33 -0
  9. data/docs/GenericUpstreamRequest.md +21 -0
  10. data/docs/GenericUpstreamRequestPatch.md +21 -0
  11. data/docs/MavenUpstream.md +1 -0
  12. data/docs/MavenUpstreamRequest.md +1 -0
  13. data/docs/MavenUpstreamRequestPatch.md +1 -0
  14. data/docs/OrganizationTeam.md +1 -1
  15. data/docs/OrganizationTeamRequest.md +1 -1
  16. data/docs/OrganizationTeamRequestPatch.md +1 -1
  17. data/docs/Package.md +1 -0
  18. data/docs/PackageCopy.md +1 -0
  19. data/docs/PackageCopyRequest.md +1 -1
  20. data/docs/PackageMove.md +1 -0
  21. data/docs/PackageMoveRequest.md +1 -1
  22. data/docs/PackageQuarantine.md +1 -0
  23. data/docs/PackageResync.md +1 -0
  24. data/docs/PackageTag.md +1 -0
  25. data/docs/PackagesApi.md +131 -0
  26. data/docs/ReposApi.md +401 -0
  27. data/lib/cloudsmith-api/api/packages_api.rb +123 -0
  28. data/lib/cloudsmith-api/api/repos_api.rb +395 -0
  29. data/lib/cloudsmith-api/models/format_support.rb +16 -1
  30. data/lib/cloudsmith-api/models/generic_package_upload.rb +992 -0
  31. data/lib/cloudsmith-api/models/generic_package_upload_request.rb +245 -0
  32. data/lib/cloudsmith-api/models/generic_upstream.rb +503 -0
  33. data/lib/cloudsmith-api/models/generic_upstream_request.rb +375 -0
  34. data/lib/cloudsmith-api/models/generic_upstream_request_patch.rb +365 -0
  35. data/lib/cloudsmith-api/models/maven_upstream.rb +25 -1
  36. data/lib/cloudsmith-api/models/maven_upstream_request.rb +25 -1
  37. data/lib/cloudsmith-api/models/maven_upstream_request_patch.rb +25 -1
  38. data/lib/cloudsmith-api/models/organization_team.rb +1 -0
  39. data/lib/cloudsmith-api/models/organization_team_request.rb +1 -0
  40. data/lib/cloudsmith-api/models/organization_team_request_patch.rb +1 -0
  41. data/lib/cloudsmith-api/models/package.rb +11 -1
  42. data/lib/cloudsmith-api/models/package_copy.rb +11 -1
  43. data/lib/cloudsmith-api/models/package_copy_request.rb +1 -0
  44. data/lib/cloudsmith-api/models/package_move.rb +11 -1
  45. data/lib/cloudsmith-api/models/package_move_request.rb +1 -0
  46. data/lib/cloudsmith-api/models/package_quarantine.rb +11 -1
  47. data/lib/cloudsmith-api/models/package_resync.rb +11 -1
  48. data/lib/cloudsmith-api/models/package_tag.rb +11 -1
  49. data/lib/cloudsmith-api/version.rb +1 -1
  50. data/lib/cloudsmith-api.rb +5 -0
  51. data/spec/api/packages_api_spec.rb +28 -0
  52. data/spec/api/repos_api_spec.rb +87 -0
  53. data/spec/models/format_support_spec.rb +6 -0
  54. data/spec/models/generic_package_upload_request_spec.rb +71 -0
  55. data/spec/models/generic_package_upload_spec.rb +537 -0
  56. data/spec/models/generic_upstream_request_patch_spec.rb +127 -0
  57. data/spec/models/generic_upstream_request_spec.rb +127 -0
  58. data/spec/models/generic_upstream_spec.rb +203 -0
  59. data/spec/models/maven_upstream_request_patch_spec.rb +10 -0
  60. data/spec/models/maven_upstream_request_spec.rb +10 -0
  61. data/spec/models/maven_upstream_spec.rb +10 -0
  62. data/spec/models/package_copy_spec.rb +6 -0
  63. data/spec/models/package_move_spec.rb +6 -0
  64. data/spec/models/package_quarantine_spec.rb +6 -0
  65. data/spec/models/package_resync_spec.rb +6 -0
  66. data/spec/models/package_spec.rb +6 -0
  67. data/spec/models/package_tag_spec.rb +6 -0
  68. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/autotest-fsevent-0.3.1/gem_make.out +1 -1
  69. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/bigdecimal-4.0.1/gem_make.out +2 -2
  70. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/bigdecimal-4.0.1/mkmf.log +4 -4
  71. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.17.3/gem_make.out +2 -2
  72. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.17.3/mkmf.log +1 -1
  73. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.7.6/gem_make.out +2 -2
  74. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.7.6/mkmf.log +1 -1
  75. data/vendor/bundle/ruby/2.6.0/gems/bigdecimal-4.0.1/ext/bigdecimal/Makefile +2 -2
  76. data/vendor/bundle/ruby/2.6.0/gems/ffi-1.17.3/ext/ffi_c/Makefile +2 -2
  77. data/vendor/bundle/ruby/2.6.0/gems/json-2.7.6/ext/json/ext/generator/Makefile +2 -2
  78. data/vendor/bundle/ruby/2.6.0/gems/json-2.7.6/ext/json/ext/parser/Makefile +2 -2
  79. metadata +25 -5
@@ -0,0 +1,503 @@
1
+ =begin
2
+ #Cloudsmith API (v1)
3
+
4
+ #The API to the Cloudsmith Service
5
+
6
+ OpenAPI spec version: v1
7
+ Contact: support@cloudsmith.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.50
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudsmithApi
16
+ class GenericUpstream
17
+ # The authentication mode to use when accessing this upstream.
18
+ attr_accessor :auth_mode
19
+
20
+ # Secret to provide with requests to upstream.
21
+ attr_accessor :auth_secret
22
+
23
+ # Username to provide with requests to upstream.
24
+ attr_accessor :auth_username
25
+
26
+ attr_accessor :available
27
+
28
+ attr_accessor :can_reindex
29
+
30
+ # The datetime the upstream source was created.
31
+ attr_accessor :created_at
32
+
33
+ attr_accessor :disable_reason
34
+
35
+ # Human-readable explanation of why this upstream is disabled
36
+ attr_accessor :disable_reason_text
37
+
38
+ # The key for extra header #1 to send to upstream.
39
+ attr_accessor :extra_header_1
40
+
41
+ # The key for extra header #2 to send to upstream.
42
+ attr_accessor :extra_header_2
43
+
44
+ # The value for extra header #1 to send to upstream. This is stored as plaintext, and is NOT encrypted.
45
+ attr_accessor :extra_value_1
46
+
47
+ # The value for extra header #2 to send to upstream. This is stored as plaintext, and is NOT encrypted.
48
+ attr_accessor :extra_value_2
49
+
50
+ attr_accessor :has_failed_signature_verification
51
+
52
+ # The number of packages available in this upstream source
53
+ attr_accessor :index_package_count
54
+
55
+ # The current indexing status of this upstream source
56
+ attr_accessor :index_status
57
+
58
+ # Whether or not this upstream is active and ready for requests.
59
+ attr_accessor :is_active
60
+
61
+ # The last time this upstream source was indexed
62
+ attr_accessor :last_indexed
63
+
64
+ # The mode that this upstream should operate in. Upstream sources can be used to proxy resolved packages, as well as operate in a proxy/cache or cache only mode.
65
+ attr_accessor :mode
66
+
67
+ # A descriptive name for this upstream source. A shortened version of this name will be used for tagging cached packages retrieved from this upstream.
68
+ attr_accessor :name
69
+
70
+ # When true, this upstream source is pending validation.
71
+ attr_accessor :pending_validation
72
+
73
+ # Upstream sources are selected for resolving requests by sequential order (1..n), followed by creation date.
74
+ attr_accessor :priority
75
+
76
+ attr_accessor :slug_perm
77
+
78
+ attr_accessor :updated_at
79
+
80
+ # A unique prefix used to distinguish this upstream source within the repository. Generic upstreams can represent entirely different file servers, and we do not attempt to blend them. The prefix ensures each source remains separate, and requests including this prefix are routed to the correct upstream.
81
+ attr_accessor :upstream_prefix
82
+
83
+ # The URL for this upstream source. This must be a fully qualified URL including any path elements required to reach the root of the repository.
84
+ attr_accessor :upstream_url
85
+
86
+ # If enabled, SSL certificates are verified when requests are made to this upstream. It's recommended to leave this enabled for all public sources to help mitigate Man-In-The-Middle (MITM) attacks. Please note this only applies to HTTPS upstreams.
87
+ attr_accessor :verify_ssl
88
+
89
+ class EnumAttributeValidator
90
+ attr_reader :datatype
91
+ attr_reader :allowable_values
92
+
93
+ def initialize(datatype, allowable_values)
94
+ @allowable_values = allowable_values.map do |value|
95
+ case datatype.to_s
96
+ when /Integer/i
97
+ value.to_i
98
+ when /Float/i
99
+ value.to_f
100
+ else
101
+ value
102
+ end
103
+ end
104
+ end
105
+
106
+ def valid?(value)
107
+ !value || allowable_values.include?(value)
108
+ end
109
+ end
110
+
111
+ # Attribute mapping from ruby-style variable name to JSON key.
112
+ def self.attribute_map
113
+ {
114
+ :'auth_mode' => :'auth_mode',
115
+ :'auth_secret' => :'auth_secret',
116
+ :'auth_username' => :'auth_username',
117
+ :'available' => :'available',
118
+ :'can_reindex' => :'can_reindex',
119
+ :'created_at' => :'created_at',
120
+ :'disable_reason' => :'disable_reason',
121
+ :'disable_reason_text' => :'disable_reason_text',
122
+ :'extra_header_1' => :'extra_header_1',
123
+ :'extra_header_2' => :'extra_header_2',
124
+ :'extra_value_1' => :'extra_value_1',
125
+ :'extra_value_2' => :'extra_value_2',
126
+ :'has_failed_signature_verification' => :'has_failed_signature_verification',
127
+ :'index_package_count' => :'index_package_count',
128
+ :'index_status' => :'index_status',
129
+ :'is_active' => :'is_active',
130
+ :'last_indexed' => :'last_indexed',
131
+ :'mode' => :'mode',
132
+ :'name' => :'name',
133
+ :'pending_validation' => :'pending_validation',
134
+ :'priority' => :'priority',
135
+ :'slug_perm' => :'slug_perm',
136
+ :'updated_at' => :'updated_at',
137
+ :'upstream_prefix' => :'upstream_prefix',
138
+ :'upstream_url' => :'upstream_url',
139
+ :'verify_ssl' => :'verify_ssl'
140
+ }
141
+ end
142
+
143
+ # Attribute type mapping.
144
+ def self.swagger_types
145
+ {
146
+ :'auth_mode' => :'String',
147
+ :'auth_secret' => :'String',
148
+ :'auth_username' => :'String',
149
+ :'available' => :'String',
150
+ :'can_reindex' => :'String',
151
+ :'created_at' => :'DateTime',
152
+ :'disable_reason' => :'String',
153
+ :'disable_reason_text' => :'String',
154
+ :'extra_header_1' => :'String',
155
+ :'extra_header_2' => :'String',
156
+ :'extra_value_1' => :'String',
157
+ :'extra_value_2' => :'String',
158
+ :'has_failed_signature_verification' => :'String',
159
+ :'index_package_count' => :'String',
160
+ :'index_status' => :'String',
161
+ :'is_active' => :'BOOLEAN',
162
+ :'last_indexed' => :'String',
163
+ :'mode' => :'String',
164
+ :'name' => :'String',
165
+ :'pending_validation' => :'BOOLEAN',
166
+ :'priority' => :'Integer',
167
+ :'slug_perm' => :'String',
168
+ :'updated_at' => :'DateTime',
169
+ :'upstream_prefix' => :'String',
170
+ :'upstream_url' => :'String',
171
+ :'verify_ssl' => :'BOOLEAN'
172
+ }
173
+ end
174
+
175
+ # Initializes the object
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ def initialize(attributes = {})
178
+ return unless attributes.is_a?(Hash)
179
+
180
+ # convert string to symbol for hash key
181
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
182
+
183
+ if attributes.has_key?(:'auth_mode')
184
+ self.auth_mode = attributes[:'auth_mode']
185
+ else
186
+ self.auth_mode = 'None'
187
+ end
188
+
189
+ if attributes.has_key?(:'auth_secret')
190
+ self.auth_secret = attributes[:'auth_secret']
191
+ end
192
+
193
+ if attributes.has_key?(:'auth_username')
194
+ self.auth_username = attributes[:'auth_username']
195
+ end
196
+
197
+ if attributes.has_key?(:'available')
198
+ self.available = attributes[:'available']
199
+ end
200
+
201
+ if attributes.has_key?(:'can_reindex')
202
+ self.can_reindex = attributes[:'can_reindex']
203
+ end
204
+
205
+ if attributes.has_key?(:'created_at')
206
+ self.created_at = attributes[:'created_at']
207
+ end
208
+
209
+ if attributes.has_key?(:'disable_reason')
210
+ self.disable_reason = attributes[:'disable_reason']
211
+ else
212
+ self.disable_reason = 'N/A'
213
+ end
214
+
215
+ if attributes.has_key?(:'disable_reason_text')
216
+ self.disable_reason_text = attributes[:'disable_reason_text']
217
+ end
218
+
219
+ if attributes.has_key?(:'extra_header_1')
220
+ self.extra_header_1 = attributes[:'extra_header_1']
221
+ end
222
+
223
+ if attributes.has_key?(:'extra_header_2')
224
+ self.extra_header_2 = attributes[:'extra_header_2']
225
+ end
226
+
227
+ if attributes.has_key?(:'extra_value_1')
228
+ self.extra_value_1 = attributes[:'extra_value_1']
229
+ end
230
+
231
+ if attributes.has_key?(:'extra_value_2')
232
+ self.extra_value_2 = attributes[:'extra_value_2']
233
+ end
234
+
235
+ if attributes.has_key?(:'has_failed_signature_verification')
236
+ self.has_failed_signature_verification = attributes[:'has_failed_signature_verification']
237
+ end
238
+
239
+ if attributes.has_key?(:'index_package_count')
240
+ self.index_package_count = attributes[:'index_package_count']
241
+ end
242
+
243
+ if attributes.has_key?(:'index_status')
244
+ self.index_status = attributes[:'index_status']
245
+ end
246
+
247
+ if attributes.has_key?(:'is_active')
248
+ self.is_active = attributes[:'is_active']
249
+ end
250
+
251
+ if attributes.has_key?(:'last_indexed')
252
+ self.last_indexed = attributes[:'last_indexed']
253
+ end
254
+
255
+ if attributes.has_key?(:'mode')
256
+ self.mode = attributes[:'mode']
257
+ else
258
+ self.mode = 'Proxy Only'
259
+ end
260
+
261
+ if attributes.has_key?(:'name')
262
+ self.name = attributes[:'name']
263
+ end
264
+
265
+ if attributes.has_key?(:'pending_validation')
266
+ self.pending_validation = attributes[:'pending_validation']
267
+ end
268
+
269
+ if attributes.has_key?(:'priority')
270
+ self.priority = attributes[:'priority']
271
+ end
272
+
273
+ if attributes.has_key?(:'slug_perm')
274
+ self.slug_perm = attributes[:'slug_perm']
275
+ end
276
+
277
+ if attributes.has_key?(:'updated_at')
278
+ self.updated_at = attributes[:'updated_at']
279
+ end
280
+
281
+ if attributes.has_key?(:'upstream_prefix')
282
+ self.upstream_prefix = attributes[:'upstream_prefix']
283
+ end
284
+
285
+ if attributes.has_key?(:'upstream_url')
286
+ self.upstream_url = attributes[:'upstream_url']
287
+ end
288
+
289
+ if attributes.has_key?(:'verify_ssl')
290
+ self.verify_ssl = attributes[:'verify_ssl']
291
+ end
292
+ end
293
+
294
+ # Show invalid properties with the reasons. Usually used together with valid?
295
+ # @return Array for valid properties with the reasons
296
+ def list_invalid_properties
297
+ invalid_properties = Array.new
298
+ if @name.nil?
299
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
300
+ end
301
+
302
+ if @upstream_url.nil?
303
+ invalid_properties.push('invalid value for "upstream_url", upstream_url cannot be nil.')
304
+ end
305
+
306
+ invalid_properties
307
+ end
308
+
309
+ # Check to see if the all the properties in the model are valid
310
+ # @return true if the model is valid
311
+ def valid?
312
+ auth_mode_validator = EnumAttributeValidator.new('String', ['None', 'Username and Password', 'Token'])
313
+ return false unless auth_mode_validator.valid?(@auth_mode)
314
+ disable_reason_validator = EnumAttributeValidator.new('String', ['N/A', 'Upstream points to its own repository', 'Missing upstream source', 'Upstream was disabled by request of user'])
315
+ return false unless disable_reason_validator.valid?(@disable_reason)
316
+ mode_validator = EnumAttributeValidator.new('String', ['Proxy Only', 'Cache and Proxy'])
317
+ return false unless mode_validator.valid?(@mode)
318
+ return false if @name.nil?
319
+ return false if @upstream_url.nil?
320
+ true
321
+ end
322
+
323
+ # Custom attribute writer method checking allowed values (enum).
324
+ # @param [Object] auth_mode Object to be assigned
325
+ def auth_mode=(auth_mode)
326
+ validator = EnumAttributeValidator.new('String', ['None', 'Username and Password', 'Token'])
327
+ unless validator.valid?(auth_mode)
328
+ fail ArgumentError, 'invalid value for "auth_mode", must be one of #{validator.allowable_values}.'
329
+ end
330
+ @auth_mode = auth_mode
331
+ end
332
+
333
+ # Custom attribute writer method checking allowed values (enum).
334
+ # @param [Object] disable_reason Object to be assigned
335
+ def disable_reason=(disable_reason)
336
+ validator = EnumAttributeValidator.new('String', ['N/A', 'Upstream points to its own repository', 'Missing upstream source', 'Upstream was disabled by request of user'])
337
+ unless validator.valid?(disable_reason)
338
+ fail ArgumentError, 'invalid value for "disable_reason", must be one of #{validator.allowable_values}.'
339
+ end
340
+ @disable_reason = disable_reason
341
+ end
342
+
343
+ # Custom attribute writer method checking allowed values (enum).
344
+ # @param [Object] mode Object to be assigned
345
+ def mode=(mode)
346
+ validator = EnumAttributeValidator.new('String', ['Proxy Only', 'Cache and Proxy'])
347
+ unless validator.valid?(mode)
348
+ fail ArgumentError, 'invalid value for "mode", must be one of #{validator.allowable_values}.'
349
+ end
350
+ @mode = mode
351
+ end
352
+
353
+ # Checks equality by comparing each attribute.
354
+ # @param [Object] Object to be compared
355
+ def ==(o)
356
+ return true if self.equal?(o)
357
+ self.class == o.class &&
358
+ auth_mode == o.auth_mode &&
359
+ auth_secret == o.auth_secret &&
360
+ auth_username == o.auth_username &&
361
+ available == o.available &&
362
+ can_reindex == o.can_reindex &&
363
+ created_at == o.created_at &&
364
+ disable_reason == o.disable_reason &&
365
+ disable_reason_text == o.disable_reason_text &&
366
+ extra_header_1 == o.extra_header_1 &&
367
+ extra_header_2 == o.extra_header_2 &&
368
+ extra_value_1 == o.extra_value_1 &&
369
+ extra_value_2 == o.extra_value_2 &&
370
+ has_failed_signature_verification == o.has_failed_signature_verification &&
371
+ index_package_count == o.index_package_count &&
372
+ index_status == o.index_status &&
373
+ is_active == o.is_active &&
374
+ last_indexed == o.last_indexed &&
375
+ mode == o.mode &&
376
+ name == o.name &&
377
+ pending_validation == o.pending_validation &&
378
+ priority == o.priority &&
379
+ slug_perm == o.slug_perm &&
380
+ updated_at == o.updated_at &&
381
+ upstream_prefix == o.upstream_prefix &&
382
+ upstream_url == o.upstream_url &&
383
+ verify_ssl == o.verify_ssl
384
+ end
385
+
386
+ # @see the `==` method
387
+ # @param [Object] Object to be compared
388
+ def eql?(o)
389
+ self == o
390
+ end
391
+
392
+ # Calculates hash code according to all attributes.
393
+ # @return [Fixnum] Hash code
394
+ def hash
395
+ [auth_mode, auth_secret, auth_username, available, can_reindex, created_at, disable_reason, disable_reason_text, extra_header_1, extra_header_2, extra_value_1, extra_value_2, has_failed_signature_verification, index_package_count, index_status, is_active, last_indexed, mode, name, pending_validation, priority, slug_perm, updated_at, upstream_prefix, upstream_url, verify_ssl].hash
396
+ end
397
+
398
+ # Builds the object from hash
399
+ # @param [Hash] attributes Model attributes in the form of hash
400
+ # @return [Object] Returns the model itself
401
+ def build_from_hash(attributes)
402
+ return nil unless attributes.is_a?(Hash)
403
+ self.class.swagger_types.each_pair do |key, type|
404
+ if type =~ /\AArray<(.*)>/i
405
+ # check to ensure the input is an array given that the attribute
406
+ # is documented as an array but the input is not
407
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
408
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
409
+ end
410
+ elsif !attributes[self.class.attribute_map[key]].nil?
411
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
412
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
413
+ end
414
+
415
+ self
416
+ end
417
+
418
+ # Deserializes the data based on type
419
+ # @param string type Data type
420
+ # @param string value Value to be deserialized
421
+ # @return [Object] Deserialized data
422
+ def _deserialize(type, value)
423
+ case type.to_sym
424
+ when :DateTime
425
+ DateTime.parse(value)
426
+ when :Date
427
+ Date.parse(value)
428
+ when :String
429
+ value.to_s
430
+ when :Integer
431
+ value.to_i
432
+ when :Float
433
+ value.to_f
434
+ when :BOOLEAN
435
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
436
+ true
437
+ else
438
+ false
439
+ end
440
+ when :Object
441
+ # generic object (usually a Hash), return directly
442
+ value
443
+ when /\AArray<(?<inner_type>.+)>\z/
444
+ inner_type = Regexp.last_match[:inner_type]
445
+ value.map { |v| _deserialize(inner_type, v) }
446
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
447
+ k_type = Regexp.last_match[:k_type]
448
+ v_type = Regexp.last_match[:v_type]
449
+ {}.tap do |hash|
450
+ value.each do |k, v|
451
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
452
+ end
453
+ end
454
+ else # model
455
+ temp_model = CloudsmithApi.const_get(type).new
456
+ temp_model.build_from_hash(value)
457
+ end
458
+ end
459
+
460
+ # Returns the string representation of the object
461
+ # @return [String] String presentation of the object
462
+ def to_s
463
+ to_hash.to_s
464
+ end
465
+
466
+ # to_body is an alias to to_hash (backward compatibility)
467
+ # @return [Hash] Returns the object in the form of hash
468
+ def to_body
469
+ to_hash
470
+ end
471
+
472
+ # Returns the object in the form of hash
473
+ # @return [Hash] Returns the object in the form of hash
474
+ def to_hash
475
+ hash = {}
476
+ self.class.attribute_map.each_pair do |attr, param|
477
+ value = self.send(attr)
478
+ next if value.nil?
479
+ hash[param] = _to_hash(value)
480
+ end
481
+ hash
482
+ end
483
+
484
+ # Outputs non-array value in the form of hash
485
+ # For object, use to_hash. Otherwise, just return the value
486
+ # @param [Object] value Any valid value
487
+ # @return [Hash] Returns the value in the form of hash
488
+ def _to_hash(value)
489
+ if value.is_a?(Array)
490
+ value.compact.map { |v| _to_hash(v) }
491
+ elsif value.is_a?(Hash)
492
+ {}.tap do |hash|
493
+ value.each { |k, v| hash[k] = _to_hash(v) }
494
+ end
495
+ elsif value.respond_to? :to_hash
496
+ value.to_hash
497
+ else
498
+ value
499
+ end
500
+ end
501
+
502
+ end
503
+ end