pulp_rpm_client 3.0.0b5 → 3.0.0b6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -6
- data/docs/ContentAdvisoriesApi.md +3 -3
- data/docs/ContentModulemdApi.md +210 -0
- data/docs/ContentModulemdDefaultsApi.md +200 -0
- data/docs/ContentPackagesApi.md +17 -9
- data/docs/DistributionTreesDistributionTreesApi.md +2 -2
- data/docs/DistributionsRpmApi.md +2 -2
- data/docs/InlineResponse2001.md +1 -1
- data/docs/InlineResponse2002.md +1 -1
- data/docs/InlineResponse2003.md +1 -1
- data/docs/InlineResponse2004.md +1 -1
- data/docs/InlineResponse2005.md +1 -1
- data/docs/InlineResponse2006.md +1 -1
- data/docs/InlineResponse2007.md +23 -0
- data/docs/InlineResponse2008.md +23 -0
- data/docs/Modulemd.md +45 -0
- data/docs/ModulemdDefaults.md +35 -0
- data/docs/Package.md +23 -19
- data/docs/PublicationsRpmApi.md +2 -2
- data/docs/RemotesRpmApi.md +2 -2
- data/docs/RepoMetadataFile.md +5 -1
- data/docs/RepoMetadataFilesRepoMetadataFilesApi.md +2 -2
- data/docs/RpmCopyApi.md +1 -1
- data/lib/pulp_rpm_client/api/content_advisories_api.rb +5 -5
- data/lib/pulp_rpm_client/api/content_modulemd_api.rb +319 -0
- data/lib/pulp_rpm_client/api/content_modulemd_defaults_api.rb +272 -0
- data/lib/pulp_rpm_client/api/content_packages_api.rb +32 -18
- data/lib/pulp_rpm_client/api/distribution_trees_distribution_trees_api.rb +3 -3
- data/lib/pulp_rpm_client/api/distributions_rpm_api.rb +3 -3
- data/lib/pulp_rpm_client/api/publications_rpm_api.rb +3 -3
- data/lib/pulp_rpm_client/api/remotes_rpm_api.rb +3 -3
- data/lib/pulp_rpm_client/api/repo_metadata_files_repo_metadata_files_api.rb +3 -3
- data/lib/pulp_rpm_client/api/rpm_copy_api.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2001.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2002.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2003.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2004.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2005.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2006.rb +1 -1
- data/lib/pulp_rpm_client/models/inline_response2007.rb +235 -0
- data/lib/pulp_rpm_client/models/inline_response2008.rb +235 -0
- data/lib/pulp_rpm_client/models/modulemd.rb +544 -0
- data/lib/pulp_rpm_client/models/modulemd_defaults.rb +396 -0
- data/lib/pulp_rpm_client/models/package.rb +73 -156
- data/lib/pulp_rpm_client/models/repo_metadata_file.rb +21 -6
- data/lib/pulp_rpm_client/version.rb +1 -1
- data/lib/pulp_rpm_client.rb +6 -1
- data/spec/api/content_advisories_api_spec.rb +2 -2
- data/spec/api/content_modulemd_api_spec.rb +88 -0
- data/spec/api/content_modulemd_defaults_api_spec.rb +83 -0
- data/spec/api/content_packages_api_spec.rb +7 -4
- data/spec/api/distribution_trees_distribution_trees_api_spec.rb +1 -1
- data/spec/api/distributions_rpm_api_spec.rb +1 -1
- data/spec/api/publications_rpm_api_spec.rb +1 -1
- data/spec/api/remotes_rpm_api_spec.rb +1 -1
- data/spec/api/repo_metadata_files_repo_metadata_files_api_spec.rb +1 -1
- data/spec/models/inline_response2007_spec.rb +59 -0
- data/spec/models/inline_response2008_spec.rb +59 -0
- data/spec/models/modulemd_defaults_spec.rb +95 -0
- data/spec/models/modulemd_spec.rb +125 -0
- data/spec/models/package_spec.rb +16 -4
- data/spec/models/repo_metadata_file_spec.rb +12 -0
- metadata +26 -6
- data/docs/RpmUploadApi.md +0 -66
- data/lib/pulp_rpm_client/api/rpm_upload_api.rb +0 -90
- data/spec/api/rpm_upload_api_spec.rb +0 -48
@@ -0,0 +1,544 @@
|
|
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.1.3-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpRpmClient
|
16
|
+
class Modulemd
|
17
|
+
attr_accessor :_href
|
18
|
+
|
19
|
+
# Timestamp of creation.
|
20
|
+
attr_accessor :_created
|
21
|
+
|
22
|
+
attr_accessor :_type
|
23
|
+
|
24
|
+
# Artifact file representing the physical content
|
25
|
+
attr_accessor :artifact
|
26
|
+
|
27
|
+
# Path where the artifact is located relative to distributions base_path
|
28
|
+
attr_accessor :relative_path
|
29
|
+
|
30
|
+
# An uploaded file that should be turned into the artifact of the content unit.
|
31
|
+
attr_accessor :file
|
32
|
+
|
33
|
+
# A URI of a repository the new content unit should be associated with.
|
34
|
+
attr_accessor :repository
|
35
|
+
|
36
|
+
# Modulemd name.
|
37
|
+
attr_accessor :name
|
38
|
+
|
39
|
+
# Stream name.
|
40
|
+
attr_accessor :stream
|
41
|
+
|
42
|
+
# Modulemd version.
|
43
|
+
attr_accessor :version
|
44
|
+
|
45
|
+
# Modulemd context.
|
46
|
+
attr_accessor :context
|
47
|
+
|
48
|
+
# Modulemd architecture.
|
49
|
+
attr_accessor :arch
|
50
|
+
|
51
|
+
# Modulemd artifacts.
|
52
|
+
attr_accessor :artifacts
|
53
|
+
|
54
|
+
# Modulemd dependencies.
|
55
|
+
attr_accessor :dependencies
|
56
|
+
|
57
|
+
# Modulemd artifacts' packages.
|
58
|
+
attr_accessor :packages
|
59
|
+
|
60
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
61
|
+
def self.attribute_map
|
62
|
+
{
|
63
|
+
:'_href' => :'_href',
|
64
|
+
:'_created' => :'_created',
|
65
|
+
:'_type' => :'_type',
|
66
|
+
:'artifact' => :'artifact',
|
67
|
+
:'relative_path' => :'relative_path',
|
68
|
+
:'file' => :'file',
|
69
|
+
:'repository' => :'repository',
|
70
|
+
:'name' => :'name',
|
71
|
+
:'stream' => :'stream',
|
72
|
+
:'version' => :'version',
|
73
|
+
:'context' => :'context',
|
74
|
+
:'arch' => :'arch',
|
75
|
+
:'artifacts' => :'artifacts',
|
76
|
+
:'dependencies' => :'dependencies',
|
77
|
+
:'packages' => :'packages'
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
# Attribute type mapping.
|
82
|
+
def self.openapi_types
|
83
|
+
{
|
84
|
+
:'_href' => :'String',
|
85
|
+
:'_created' => :'DateTime',
|
86
|
+
:'_type' => :'String',
|
87
|
+
:'artifact' => :'String',
|
88
|
+
:'relative_path' => :'String',
|
89
|
+
:'file' => :'String',
|
90
|
+
:'repository' => :'String',
|
91
|
+
:'name' => :'String',
|
92
|
+
:'stream' => :'String',
|
93
|
+
:'version' => :'String',
|
94
|
+
:'context' => :'String',
|
95
|
+
:'arch' => :'String',
|
96
|
+
:'artifacts' => :'String',
|
97
|
+
:'dependencies' => :'String',
|
98
|
+
:'packages' => :'Array<String>'
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
# Initializes the object
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
def initialize(attributes = {})
|
105
|
+
if (!attributes.is_a?(Hash))
|
106
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpRpmClient::Modulemd` initialize method"
|
107
|
+
end
|
108
|
+
|
109
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
110
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
111
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
112
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpRpmClient::Modulemd`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
113
|
+
end
|
114
|
+
h[k.to_sym] = v
|
115
|
+
}
|
116
|
+
|
117
|
+
if attributes.key?(:'_href')
|
118
|
+
self._href = attributes[:'_href']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:'_created')
|
122
|
+
self._created = attributes[:'_created']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'_type')
|
126
|
+
self._type = attributes[:'_type']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:'artifact')
|
130
|
+
self.artifact = attributes[:'artifact']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'relative_path')
|
134
|
+
self.relative_path = attributes[:'relative_path']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:'file')
|
138
|
+
self.file = attributes[:'file']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.key?(:'repository')
|
142
|
+
self.repository = attributes[:'repository']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'name')
|
146
|
+
self.name = attributes[:'name']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.key?(:'stream')
|
150
|
+
self.stream = attributes[:'stream']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.key?(:'version')
|
154
|
+
self.version = attributes[:'version']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.key?(:'context')
|
158
|
+
self.context = attributes[:'context']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.key?(:'arch')
|
162
|
+
self.arch = attributes[:'arch']
|
163
|
+
end
|
164
|
+
|
165
|
+
if attributes.key?(:'artifacts')
|
166
|
+
self.artifacts = attributes[:'artifacts']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.key?(:'dependencies')
|
170
|
+
self.dependencies = attributes[:'dependencies']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.key?(:'packages')
|
174
|
+
if (value = attributes[:'packages']).is_a?(Array)
|
175
|
+
self.packages = value
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
181
|
+
# @return Array for valid properties with the reasons
|
182
|
+
def list_invalid_properties
|
183
|
+
invalid_properties = Array.new
|
184
|
+
if !@_type.nil? && @_type.to_s.length < 1
|
185
|
+
invalid_properties.push('invalid value for "_type", the character length must be great than or equal to 1.')
|
186
|
+
end
|
187
|
+
|
188
|
+
if @relative_path.nil?
|
189
|
+
invalid_properties.push('invalid value for "relative_path", relative_path cannot be nil.')
|
190
|
+
end
|
191
|
+
|
192
|
+
if @relative_path.to_s.length < 1
|
193
|
+
invalid_properties.push('invalid value for "relative_path", the character length must be great than or equal to 1.')
|
194
|
+
end
|
195
|
+
|
196
|
+
if @name.nil?
|
197
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
198
|
+
end
|
199
|
+
|
200
|
+
if @name.to_s.length < 1
|
201
|
+
invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
|
202
|
+
end
|
203
|
+
|
204
|
+
if @stream.nil?
|
205
|
+
invalid_properties.push('invalid value for "stream", stream cannot be nil.')
|
206
|
+
end
|
207
|
+
|
208
|
+
if @stream.to_s.length < 1
|
209
|
+
invalid_properties.push('invalid value for "stream", the character length must be great than or equal to 1.')
|
210
|
+
end
|
211
|
+
|
212
|
+
if @version.nil?
|
213
|
+
invalid_properties.push('invalid value for "version", version cannot be nil.')
|
214
|
+
end
|
215
|
+
|
216
|
+
if @version.to_s.length < 1
|
217
|
+
invalid_properties.push('invalid value for "version", the character length must be great than or equal to 1.')
|
218
|
+
end
|
219
|
+
|
220
|
+
if @context.nil?
|
221
|
+
invalid_properties.push('invalid value for "context", context cannot be nil.')
|
222
|
+
end
|
223
|
+
|
224
|
+
if @context.to_s.length < 1
|
225
|
+
invalid_properties.push('invalid value for "context", the character length must be great than or equal to 1.')
|
226
|
+
end
|
227
|
+
|
228
|
+
if @arch.nil?
|
229
|
+
invalid_properties.push('invalid value for "arch", arch cannot be nil.')
|
230
|
+
end
|
231
|
+
|
232
|
+
if @arch.to_s.length < 1
|
233
|
+
invalid_properties.push('invalid value for "arch", the character length must be great than or equal to 1.')
|
234
|
+
end
|
235
|
+
|
236
|
+
if @artifacts.nil?
|
237
|
+
invalid_properties.push('invalid value for "artifacts", artifacts cannot be nil.')
|
238
|
+
end
|
239
|
+
|
240
|
+
if @artifacts.to_s.length < 1
|
241
|
+
invalid_properties.push('invalid value for "artifacts", the character length must be great than or equal to 1.')
|
242
|
+
end
|
243
|
+
|
244
|
+
if @dependencies.nil?
|
245
|
+
invalid_properties.push('invalid value for "dependencies", dependencies cannot be nil.')
|
246
|
+
end
|
247
|
+
|
248
|
+
if @dependencies.to_s.length < 1
|
249
|
+
invalid_properties.push('invalid value for "dependencies", the character length must be great than or equal to 1.')
|
250
|
+
end
|
251
|
+
|
252
|
+
invalid_properties
|
253
|
+
end
|
254
|
+
|
255
|
+
# Check to see if the all the properties in the model are valid
|
256
|
+
# @return true if the model is valid
|
257
|
+
def valid?
|
258
|
+
return false if !@_type.nil? && @_type.to_s.length < 1
|
259
|
+
return false if @relative_path.nil?
|
260
|
+
return false if @relative_path.to_s.length < 1
|
261
|
+
return false if @name.nil?
|
262
|
+
return false if @name.to_s.length < 1
|
263
|
+
return false if @stream.nil?
|
264
|
+
return false if @stream.to_s.length < 1
|
265
|
+
return false if @version.nil?
|
266
|
+
return false if @version.to_s.length < 1
|
267
|
+
return false if @context.nil?
|
268
|
+
return false if @context.to_s.length < 1
|
269
|
+
return false if @arch.nil?
|
270
|
+
return false if @arch.to_s.length < 1
|
271
|
+
return false if @artifacts.nil?
|
272
|
+
return false if @artifacts.to_s.length < 1
|
273
|
+
return false if @dependencies.nil?
|
274
|
+
return false if @dependencies.to_s.length < 1
|
275
|
+
true
|
276
|
+
end
|
277
|
+
|
278
|
+
# Custom attribute writer method with validation
|
279
|
+
# @param [Object] _type Value to be assigned
|
280
|
+
def _type=(_type)
|
281
|
+
if !_type.nil? && _type.to_s.length < 1
|
282
|
+
fail ArgumentError, 'invalid value for "_type", the character length must be great than or equal to 1.'
|
283
|
+
end
|
284
|
+
|
285
|
+
@_type = _type
|
286
|
+
end
|
287
|
+
|
288
|
+
# Custom attribute writer method with validation
|
289
|
+
# @param [Object] relative_path Value to be assigned
|
290
|
+
def relative_path=(relative_path)
|
291
|
+
if relative_path.nil?
|
292
|
+
fail ArgumentError, 'relative_path cannot be nil'
|
293
|
+
end
|
294
|
+
|
295
|
+
if relative_path.to_s.length < 1
|
296
|
+
fail ArgumentError, 'invalid value for "relative_path", the character length must be great than or equal to 1.'
|
297
|
+
end
|
298
|
+
|
299
|
+
@relative_path = relative_path
|
300
|
+
end
|
301
|
+
|
302
|
+
# Custom attribute writer method with validation
|
303
|
+
# @param [Object] name Value to be assigned
|
304
|
+
def name=(name)
|
305
|
+
if name.nil?
|
306
|
+
fail ArgumentError, 'name cannot be nil'
|
307
|
+
end
|
308
|
+
|
309
|
+
if name.to_s.length < 1
|
310
|
+
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
|
311
|
+
end
|
312
|
+
|
313
|
+
@name = name
|
314
|
+
end
|
315
|
+
|
316
|
+
# Custom attribute writer method with validation
|
317
|
+
# @param [Object] stream Value to be assigned
|
318
|
+
def stream=(stream)
|
319
|
+
if stream.nil?
|
320
|
+
fail ArgumentError, 'stream cannot be nil'
|
321
|
+
end
|
322
|
+
|
323
|
+
if stream.to_s.length < 1
|
324
|
+
fail ArgumentError, 'invalid value for "stream", the character length must be great than or equal to 1.'
|
325
|
+
end
|
326
|
+
|
327
|
+
@stream = stream
|
328
|
+
end
|
329
|
+
|
330
|
+
# Custom attribute writer method with validation
|
331
|
+
# @param [Object] version Value to be assigned
|
332
|
+
def version=(version)
|
333
|
+
if version.nil?
|
334
|
+
fail ArgumentError, 'version cannot be nil'
|
335
|
+
end
|
336
|
+
|
337
|
+
if version.to_s.length < 1
|
338
|
+
fail ArgumentError, 'invalid value for "version", the character length must be great than or equal to 1.'
|
339
|
+
end
|
340
|
+
|
341
|
+
@version = version
|
342
|
+
end
|
343
|
+
|
344
|
+
# Custom attribute writer method with validation
|
345
|
+
# @param [Object] context Value to be assigned
|
346
|
+
def context=(context)
|
347
|
+
if context.nil?
|
348
|
+
fail ArgumentError, 'context cannot be nil'
|
349
|
+
end
|
350
|
+
|
351
|
+
if context.to_s.length < 1
|
352
|
+
fail ArgumentError, 'invalid value for "context", the character length must be great than or equal to 1.'
|
353
|
+
end
|
354
|
+
|
355
|
+
@context = context
|
356
|
+
end
|
357
|
+
|
358
|
+
# Custom attribute writer method with validation
|
359
|
+
# @param [Object] arch Value to be assigned
|
360
|
+
def arch=(arch)
|
361
|
+
if arch.nil?
|
362
|
+
fail ArgumentError, 'arch cannot be nil'
|
363
|
+
end
|
364
|
+
|
365
|
+
if arch.to_s.length < 1
|
366
|
+
fail ArgumentError, 'invalid value for "arch", the character length must be great than or equal to 1.'
|
367
|
+
end
|
368
|
+
|
369
|
+
@arch = arch
|
370
|
+
end
|
371
|
+
|
372
|
+
# Custom attribute writer method with validation
|
373
|
+
# @param [Object] artifacts Value to be assigned
|
374
|
+
def artifacts=(artifacts)
|
375
|
+
if artifacts.nil?
|
376
|
+
fail ArgumentError, 'artifacts cannot be nil'
|
377
|
+
end
|
378
|
+
|
379
|
+
if artifacts.to_s.length < 1
|
380
|
+
fail ArgumentError, 'invalid value for "artifacts", the character length must be great than or equal to 1.'
|
381
|
+
end
|
382
|
+
|
383
|
+
@artifacts = artifacts
|
384
|
+
end
|
385
|
+
|
386
|
+
# Custom attribute writer method with validation
|
387
|
+
# @param [Object] dependencies Value to be assigned
|
388
|
+
def dependencies=(dependencies)
|
389
|
+
if dependencies.nil?
|
390
|
+
fail ArgumentError, 'dependencies cannot be nil'
|
391
|
+
end
|
392
|
+
|
393
|
+
if dependencies.to_s.length < 1
|
394
|
+
fail ArgumentError, 'invalid value for "dependencies", the character length must be great than or equal to 1.'
|
395
|
+
end
|
396
|
+
|
397
|
+
@dependencies = dependencies
|
398
|
+
end
|
399
|
+
|
400
|
+
# Checks equality by comparing each attribute.
|
401
|
+
# @param [Object] Object to be compared
|
402
|
+
def ==(o)
|
403
|
+
return true if self.equal?(o)
|
404
|
+
self.class == o.class &&
|
405
|
+
_href == o._href &&
|
406
|
+
_created == o._created &&
|
407
|
+
_type == o._type &&
|
408
|
+
artifact == o.artifact &&
|
409
|
+
relative_path == o.relative_path &&
|
410
|
+
file == o.file &&
|
411
|
+
repository == o.repository &&
|
412
|
+
name == o.name &&
|
413
|
+
stream == o.stream &&
|
414
|
+
version == o.version &&
|
415
|
+
context == o.context &&
|
416
|
+
arch == o.arch &&
|
417
|
+
artifacts == o.artifacts &&
|
418
|
+
dependencies == o.dependencies &&
|
419
|
+
packages == o.packages
|
420
|
+
end
|
421
|
+
|
422
|
+
# @see the `==` method
|
423
|
+
# @param [Object] Object to be compared
|
424
|
+
def eql?(o)
|
425
|
+
self == o
|
426
|
+
end
|
427
|
+
|
428
|
+
# Calculates hash code according to all attributes.
|
429
|
+
# @return [Integer] Hash code
|
430
|
+
def hash
|
431
|
+
[_href, _created, _type, artifact, relative_path, file, repository, name, stream, version, context, arch, artifacts, dependencies, packages].hash
|
432
|
+
end
|
433
|
+
|
434
|
+
# Builds the object from hash
|
435
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
436
|
+
# @return [Object] Returns the model itself
|
437
|
+
def self.build_from_hash(attributes)
|
438
|
+
new.build_from_hash(attributes)
|
439
|
+
end
|
440
|
+
|
441
|
+
# Builds the object from hash
|
442
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
443
|
+
# @return [Object] Returns the model itself
|
444
|
+
def build_from_hash(attributes)
|
445
|
+
return nil unless attributes.is_a?(Hash)
|
446
|
+
self.class.openapi_types.each_pair do |key, type|
|
447
|
+
if type =~ /\AArray<(.*)>/i
|
448
|
+
# check to ensure the input is an array given that the attribute
|
449
|
+
# is documented as an array but the input is not
|
450
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
451
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
452
|
+
end
|
453
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
454
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
455
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
456
|
+
end
|
457
|
+
|
458
|
+
self
|
459
|
+
end
|
460
|
+
|
461
|
+
# Deserializes the data based on type
|
462
|
+
# @param string type Data type
|
463
|
+
# @param string value Value to be deserialized
|
464
|
+
# @return [Object] Deserialized data
|
465
|
+
def _deserialize(type, value)
|
466
|
+
case type.to_sym
|
467
|
+
when :DateTime
|
468
|
+
DateTime.parse(value)
|
469
|
+
when :Date
|
470
|
+
Date.parse(value)
|
471
|
+
when :String
|
472
|
+
value.to_s
|
473
|
+
when :Integer
|
474
|
+
value.to_i
|
475
|
+
when :Float
|
476
|
+
value.to_f
|
477
|
+
when :Boolean
|
478
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
479
|
+
true
|
480
|
+
else
|
481
|
+
false
|
482
|
+
end
|
483
|
+
when :Object
|
484
|
+
# generic object (usually a Hash), return directly
|
485
|
+
value
|
486
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
487
|
+
inner_type = Regexp.last_match[:inner_type]
|
488
|
+
value.map { |v| _deserialize(inner_type, v) }
|
489
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
490
|
+
k_type = Regexp.last_match[:k_type]
|
491
|
+
v_type = Regexp.last_match[:v_type]
|
492
|
+
{}.tap do |hash|
|
493
|
+
value.each do |k, v|
|
494
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
495
|
+
end
|
496
|
+
end
|
497
|
+
else # model
|
498
|
+
PulpRpmClient.const_get(type).build_from_hash(value)
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
# Returns the string representation of the object
|
503
|
+
# @return [String] String presentation of the object
|
504
|
+
def to_s
|
505
|
+
to_hash.to_s
|
506
|
+
end
|
507
|
+
|
508
|
+
# to_body is an alias to to_hash (backward compatibility)
|
509
|
+
# @return [Hash] Returns the object in the form of hash
|
510
|
+
def to_body
|
511
|
+
to_hash
|
512
|
+
end
|
513
|
+
|
514
|
+
# Returns the object in the form of hash
|
515
|
+
# @return [Hash] Returns the object in the form of hash
|
516
|
+
def to_hash
|
517
|
+
hash = {}
|
518
|
+
self.class.attribute_map.each_pair do |attr, param|
|
519
|
+
value = self.send(attr)
|
520
|
+
next if value.nil?
|
521
|
+
hash[param] = _to_hash(value)
|
522
|
+
end
|
523
|
+
hash
|
524
|
+
end
|
525
|
+
|
526
|
+
# Outputs non-array value in the form of hash
|
527
|
+
# For object, use to_hash. Otherwise, just return the value
|
528
|
+
# @param [Object] value Any valid value
|
529
|
+
# @return [Hash] Returns the value in the form of hash
|
530
|
+
def _to_hash(value)
|
531
|
+
if value.is_a?(Array)
|
532
|
+
value.compact.map { |v| _to_hash(v) }
|
533
|
+
elsif value.is_a?(Hash)
|
534
|
+
{}.tap do |hash|
|
535
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
536
|
+
end
|
537
|
+
elsif value.respond_to? :to_hash
|
538
|
+
value.to_hash
|
539
|
+
else
|
540
|
+
value
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|