pulp_file_client 0.1.0b1

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 (58) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +127 -0
  5. data/Rakefile +10 -0
  6. data/docs/AsyncOperationResponse.md +17 -0
  7. data/docs/ContentFilesApi.md +184 -0
  8. data/docs/DistributionsFileApi.md +352 -0
  9. data/docs/FileContent.md +37 -0
  10. data/docs/FileDistribution.md +29 -0
  11. data/docs/FilePublication.md +31 -0
  12. data/docs/FileRemote.md +45 -0
  13. data/docs/InlineResponse200.md +23 -0
  14. data/docs/InlineResponse2001.md +23 -0
  15. data/docs/InlineResponse2002.md +23 -0
  16. data/docs/InlineResponse2003.md +23 -0
  17. data/docs/PublicationsFileApi.md +229 -0
  18. data/docs/RemotesFileApi.md +411 -0
  19. data/docs/RepositorySyncURL.md +19 -0
  20. data/git_push.sh +55 -0
  21. data/lib/pulp_file_client/api/content_files_api.rb +225 -0
  22. data/lib/pulp_file_client/api/distributions_file_api.rb +430 -0
  23. data/lib/pulp_file_client/api/publications_file_api.rb +273 -0
  24. data/lib/pulp_file_client/api/remotes_file_api.rb +504 -0
  25. data/lib/pulp_file_client/api_client.rb +387 -0
  26. data/lib/pulp_file_client/api_error.rb +57 -0
  27. data/lib/pulp_file_client/configuration.rb +251 -0
  28. data/lib/pulp_file_client/models/async_operation_response.rb +202 -0
  29. data/lib/pulp_file_client/models/file_content.rb +429 -0
  30. data/lib/pulp_file_client/models/file_distribution.rb +337 -0
  31. data/lib/pulp_file_client/models/file_publication.rb +297 -0
  32. data/lib/pulp_file_client/models/file_remote.rb +539 -0
  33. data/lib/pulp_file_client/models/inline_response200.rb +235 -0
  34. data/lib/pulp_file_client/models/inline_response2001.rb +235 -0
  35. data/lib/pulp_file_client/models/inline_response2002.rb +235 -0
  36. data/lib/pulp_file_client/models/inline_response2003.rb +235 -0
  37. data/lib/pulp_file_client/models/repository_sync_url.rb +214 -0
  38. data/lib/pulp_file_client/version.rb +15 -0
  39. data/lib/pulp_file_client.rb +53 -0
  40. data/pulp_file_client.gemspec +45 -0
  41. data/spec/api/content_files_api_spec.rb +77 -0
  42. data/spec/api/distributions_file_api_spec.rb +116 -0
  43. data/spec/api/publications_file_api_spec.rb +85 -0
  44. data/spec/api/remotes_file_api_spec.rb +130 -0
  45. data/spec/api_client_spec.rb +226 -0
  46. data/spec/configuration_spec.rb +42 -0
  47. data/spec/models/async_operation_response_spec.rb +41 -0
  48. data/spec/models/file_content_spec.rb +101 -0
  49. data/spec/models/file_distribution_spec.rb +77 -0
  50. data/spec/models/file_publication_spec.rb +83 -0
  51. data/spec/models/file_remote_spec.rb +129 -0
  52. data/spec/models/inline_response2001_spec.rb +59 -0
  53. data/spec/models/inline_response2002_spec.rb +59 -0
  54. data/spec/models/inline_response2003_spec.rb +59 -0
  55. data/spec/models/inline_response200_spec.rb +59 -0
  56. data/spec/models/repository_sync_url_spec.rb +47 -0
  57. data/spec/spec_helper.rb +111 -0
  58. metadata +297 -0
@@ -0,0 +1,337 @@
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.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpFileClient
16
+ class FileDistribution
17
+ attr_accessor :_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :_created
21
+
22
+ # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
23
+ attr_accessor :base_path
24
+
25
+ # The URL for accessing the publication as defined by this distribution.
26
+ attr_accessor :base_url
27
+
28
+ # An optional content-guard.
29
+ attr_accessor :content_guard
30
+
31
+ # A unique name. Ex, `rawhide` and `stable`.
32
+ attr_accessor :name
33
+
34
+ # Publication to be served
35
+ attr_accessor :publication
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'_href' => :'_href',
41
+ :'_created' => :'_created',
42
+ :'base_path' => :'base_path',
43
+ :'base_url' => :'base_url',
44
+ :'content_guard' => :'content_guard',
45
+ :'name' => :'name',
46
+ :'publication' => :'publication'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'_href' => :'String',
54
+ :'_created' => :'DateTime',
55
+ :'base_path' => :'String',
56
+ :'base_url' => :'String',
57
+ :'content_guard' => :'String',
58
+ :'name' => :'String',
59
+ :'publication' => :'String'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpFileClient::FileDistribution` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpFileClient::FileDistribution`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'_href')
79
+ self._href = attributes[:'_href']
80
+ end
81
+
82
+ if attributes.key?(:'_created')
83
+ self._created = attributes[:'_created']
84
+ end
85
+
86
+ if attributes.key?(:'base_path')
87
+ self.base_path = attributes[:'base_path']
88
+ end
89
+
90
+ if attributes.key?(:'base_url')
91
+ self.base_url = attributes[:'base_url']
92
+ end
93
+
94
+ if attributes.key?(:'content_guard')
95
+ self.content_guard = attributes[:'content_guard']
96
+ end
97
+
98
+ if attributes.key?(:'name')
99
+ self.name = attributes[:'name']
100
+ end
101
+
102
+ if attributes.key?(:'publication')
103
+ self.publication = attributes[:'publication']
104
+ end
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ invalid_properties = Array.new
111
+ if @base_path.nil?
112
+ invalid_properties.push('invalid value for "base_path", base_path cannot be nil.')
113
+ end
114
+
115
+ if @base_path.to_s.length > 255
116
+ invalid_properties.push('invalid value for "base_path", the character length must be smaller than or equal to 255.')
117
+ end
118
+
119
+ if @base_path.to_s.length < 1
120
+ invalid_properties.push('invalid value for "base_path", the character length must be great than or equal to 1.')
121
+ end
122
+
123
+ if !@base_url.nil? && @base_url.to_s.length < 1
124
+ invalid_properties.push('invalid value for "base_url", the character length must be great than or equal to 1.')
125
+ end
126
+
127
+ if @name.nil?
128
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
129
+ end
130
+
131
+ if @name.to_s.length > 255
132
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 255.')
133
+ end
134
+
135
+ if @name.to_s.length < 1
136
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
137
+ end
138
+
139
+ invalid_properties
140
+ end
141
+
142
+ # Check to see if the all the properties in the model are valid
143
+ # @return true if the model is valid
144
+ def valid?
145
+ return false if @base_path.nil?
146
+ return false if @base_path.to_s.length > 255
147
+ return false if @base_path.to_s.length < 1
148
+ return false if !@base_url.nil? && @base_url.to_s.length < 1
149
+ return false if @name.nil?
150
+ return false if @name.to_s.length > 255
151
+ return false if @name.to_s.length < 1
152
+ true
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] base_path Value to be assigned
157
+ def base_path=(base_path)
158
+ if base_path.nil?
159
+ fail ArgumentError, 'base_path cannot be nil'
160
+ end
161
+
162
+ if base_path.to_s.length > 255
163
+ fail ArgumentError, 'invalid value for "base_path", the character length must be smaller than or equal to 255.'
164
+ end
165
+
166
+ if base_path.to_s.length < 1
167
+ fail ArgumentError, 'invalid value for "base_path", the character length must be great than or equal to 1.'
168
+ end
169
+
170
+ @base_path = base_path
171
+ end
172
+
173
+ # Custom attribute writer method with validation
174
+ # @param [Object] base_url Value to be assigned
175
+ def base_url=(base_url)
176
+ if !base_url.nil? && base_url.to_s.length < 1
177
+ fail ArgumentError, 'invalid value for "base_url", the character length must be great than or equal to 1.'
178
+ end
179
+
180
+ @base_url = base_url
181
+ end
182
+
183
+ # Custom attribute writer method with validation
184
+ # @param [Object] name Value to be assigned
185
+ def name=(name)
186
+ if name.nil?
187
+ fail ArgumentError, 'name cannot be nil'
188
+ end
189
+
190
+ if name.to_s.length > 255
191
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.'
192
+ end
193
+
194
+ if name.to_s.length < 1
195
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
196
+ end
197
+
198
+ @name = name
199
+ end
200
+
201
+ # Checks equality by comparing each attribute.
202
+ # @param [Object] Object to be compared
203
+ def ==(o)
204
+ return true if self.equal?(o)
205
+ self.class == o.class &&
206
+ _href == o._href &&
207
+ _created == o._created &&
208
+ base_path == o.base_path &&
209
+ base_url == o.base_url &&
210
+ content_guard == o.content_guard &&
211
+ name == o.name &&
212
+ publication == o.publication
213
+ end
214
+
215
+ # @see the `==` method
216
+ # @param [Object] Object to be compared
217
+ def eql?(o)
218
+ self == o
219
+ end
220
+
221
+ # Calculates hash code according to all attributes.
222
+ # @return [Integer] Hash code
223
+ def hash
224
+ [_href, _created, base_path, base_url, content_guard, name, publication].hash
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def self.build_from_hash(attributes)
231
+ new.build_from_hash(attributes)
232
+ end
233
+
234
+ # Builds the object from hash
235
+ # @param [Hash] attributes Model attributes in the form of hash
236
+ # @return [Object] Returns the model itself
237
+ def build_from_hash(attributes)
238
+ return nil unless attributes.is_a?(Hash)
239
+ self.class.openapi_types.each_pair do |key, type|
240
+ if type =~ /\AArray<(.*)>/i
241
+ # check to ensure the input is an array given that the attribute
242
+ # is documented as an array but the input is not
243
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
244
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
245
+ end
246
+ elsif !attributes[self.class.attribute_map[key]].nil?
247
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
248
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
249
+ end
250
+
251
+ self
252
+ end
253
+
254
+ # Deserializes the data based on type
255
+ # @param string type Data type
256
+ # @param string value Value to be deserialized
257
+ # @return [Object] Deserialized data
258
+ def _deserialize(type, value)
259
+ case type.to_sym
260
+ when :DateTime
261
+ DateTime.parse(value)
262
+ when :Date
263
+ Date.parse(value)
264
+ when :String
265
+ value.to_s
266
+ when :Integer
267
+ value.to_i
268
+ when :Float
269
+ value.to_f
270
+ when :Boolean
271
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
272
+ true
273
+ else
274
+ false
275
+ end
276
+ when :Object
277
+ # generic object (usually a Hash), return directly
278
+ value
279
+ when /\AArray<(?<inner_type>.+)>\z/
280
+ inner_type = Regexp.last_match[:inner_type]
281
+ value.map { |v| _deserialize(inner_type, v) }
282
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
283
+ k_type = Regexp.last_match[:k_type]
284
+ v_type = Regexp.last_match[:v_type]
285
+ {}.tap do |hash|
286
+ value.each do |k, v|
287
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
288
+ end
289
+ end
290
+ else # model
291
+ PulpFileClient.const_get(type).build_from_hash(value)
292
+ end
293
+ end
294
+
295
+ # Returns the string representation of the object
296
+ # @return [String] String presentation of the object
297
+ def to_s
298
+ to_hash.to_s
299
+ end
300
+
301
+ # to_body is an alias to to_hash (backward compatibility)
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_body
304
+ to_hash
305
+ end
306
+
307
+ # Returns the object in the form of hash
308
+ # @return [Hash] Returns the object in the form of hash
309
+ def to_hash
310
+ hash = {}
311
+ self.class.attribute_map.each_pair do |attr, param|
312
+ value = self.send(attr)
313
+ next if value.nil?
314
+ hash[param] = _to_hash(value)
315
+ end
316
+ hash
317
+ end
318
+
319
+ # Outputs non-array value in the form of hash
320
+ # For object, use to_hash. Otherwise, just return the value
321
+ # @param [Object] value Any valid value
322
+ # @return [Hash] Returns the value in the form of hash
323
+ def _to_hash(value)
324
+ if value.is_a?(Array)
325
+ value.compact.map { |v| _to_hash(v) }
326
+ elsif value.is_a?(Hash)
327
+ {}.tap do |hash|
328
+ value.each { |k, v| hash[k] = _to_hash(v) }
329
+ end
330
+ elsif value.respond_to? :to_hash
331
+ value.to_hash
332
+ else
333
+ value
334
+ end
335
+ end
336
+ end
337
+ end
@@ -0,0 +1,297 @@
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.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpFileClient
16
+ class FilePublication
17
+ attr_accessor :_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :_created
21
+
22
+ attr_accessor :_type
23
+
24
+ attr_accessor :publisher
25
+
26
+ attr_accessor :repository_version
27
+
28
+ # A URI of the repository to be published.
29
+ attr_accessor :repository
30
+
31
+ # This publication is currently hosted as defined by these distributions.
32
+ attr_accessor :distributions
33
+
34
+ # Filename to use for manifest file containing metadata for all the files.
35
+ attr_accessor :manifest
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'_href' => :'_href',
41
+ :'_created' => :'_created',
42
+ :'_type' => :'_type',
43
+ :'publisher' => :'publisher',
44
+ :'repository_version' => :'repository_version',
45
+ :'repository' => :'repository',
46
+ :'distributions' => :'distributions',
47
+ :'manifest' => :'manifest'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'_href' => :'String',
55
+ :'_created' => :'DateTime',
56
+ :'_type' => :'String',
57
+ :'publisher' => :'String',
58
+ :'repository_version' => :'String',
59
+ :'repository' => :'String',
60
+ :'distributions' => :'Array<String>',
61
+ :'manifest' => :'String'
62
+ }
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpFileClient::FilePublication` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpFileClient::FilePublication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'_href')
81
+ self._href = attributes[:'_href']
82
+ end
83
+
84
+ if attributes.key?(:'_created')
85
+ self._created = attributes[:'_created']
86
+ end
87
+
88
+ if attributes.key?(:'_type')
89
+ self._type = attributes[:'_type']
90
+ end
91
+
92
+ if attributes.key?(:'publisher')
93
+ self.publisher = attributes[:'publisher']
94
+ end
95
+
96
+ if attributes.key?(:'repository_version')
97
+ self.repository_version = attributes[:'repository_version']
98
+ end
99
+
100
+ if attributes.key?(:'repository')
101
+ self.repository = attributes[:'repository']
102
+ end
103
+
104
+ if attributes.key?(:'distributions')
105
+ if (value = attributes[:'distributions']).is_a?(Array)
106
+ self.distributions = value
107
+ end
108
+ end
109
+
110
+ if attributes.key?(:'manifest')
111
+ self.manifest = attributes[:'manifest']
112
+ else
113
+ self.manifest = 'PULP_MANIFEST'
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ invalid_properties = Array.new
121
+ if !@_type.nil? && @_type.to_s.length < 1
122
+ invalid_properties.push('invalid value for "_type", the character length must be great than or equal to 1.')
123
+ end
124
+
125
+ if !@manifest.nil? && @manifest.to_s.length < 1
126
+ invalid_properties.push('invalid value for "manifest", the character length must be great than or equal to 1.')
127
+ end
128
+
129
+ 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 !@_type.nil? && @_type.to_s.length < 1
136
+ return false if !@manifest.nil? && @manifest.to_s.length < 1
137
+ true
138
+ end
139
+
140
+ # Custom attribute writer method with validation
141
+ # @param [Object] _type Value to be assigned
142
+ def _type=(_type)
143
+ if !_type.nil? && _type.to_s.length < 1
144
+ fail ArgumentError, 'invalid value for "_type", the character length must be great than or equal to 1.'
145
+ end
146
+
147
+ @_type = _type
148
+ end
149
+
150
+ # Custom attribute writer method with validation
151
+ # @param [Object] manifest Value to be assigned
152
+ def manifest=(manifest)
153
+ if !manifest.nil? && manifest.to_s.length < 1
154
+ fail ArgumentError, 'invalid value for "manifest", the character length must be great than or equal to 1.'
155
+ end
156
+
157
+ @manifest = manifest
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ _href == o._href &&
166
+ _created == o._created &&
167
+ _type == o._type &&
168
+ publisher == o.publisher &&
169
+ repository_version == o.repository_version &&
170
+ repository == o.repository &&
171
+ distributions == o.distributions &&
172
+ manifest == o.manifest
173
+ end
174
+
175
+ # @see the `==` method
176
+ # @param [Object] Object to be compared
177
+ def eql?(o)
178
+ self == o
179
+ end
180
+
181
+ # Calculates hash code according to all attributes.
182
+ # @return [Integer] Hash code
183
+ def hash
184
+ [_href, _created, _type, publisher, repository_version, repository, distributions, manifest].hash
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def self.build_from_hash(attributes)
191
+ new.build_from_hash(attributes)
192
+ end
193
+
194
+ # Builds the object from hash
195
+ # @param [Hash] attributes Model attributes in the form of hash
196
+ # @return [Object] Returns the model itself
197
+ def build_from_hash(attributes)
198
+ return nil unless attributes.is_a?(Hash)
199
+ self.class.openapi_types.each_pair do |key, type|
200
+ if type =~ /\AArray<(.*)>/i
201
+ # check to ensure the input is an array given that the attribute
202
+ # is documented as an array but the input is not
203
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
204
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
205
+ end
206
+ elsif !attributes[self.class.attribute_map[key]].nil?
207
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
208
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
209
+ end
210
+
211
+ self
212
+ end
213
+
214
+ # Deserializes the data based on type
215
+ # @param string type Data type
216
+ # @param string value Value to be deserialized
217
+ # @return [Object] Deserialized data
218
+ def _deserialize(type, value)
219
+ case type.to_sym
220
+ when :DateTime
221
+ DateTime.parse(value)
222
+ when :Date
223
+ Date.parse(value)
224
+ when :String
225
+ value.to_s
226
+ when :Integer
227
+ value.to_i
228
+ when :Float
229
+ value.to_f
230
+ when :Boolean
231
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
232
+ true
233
+ else
234
+ false
235
+ end
236
+ when :Object
237
+ # generic object (usually a Hash), return directly
238
+ value
239
+ when /\AArray<(?<inner_type>.+)>\z/
240
+ inner_type = Regexp.last_match[:inner_type]
241
+ value.map { |v| _deserialize(inner_type, v) }
242
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
243
+ k_type = Regexp.last_match[:k_type]
244
+ v_type = Regexp.last_match[:v_type]
245
+ {}.tap do |hash|
246
+ value.each do |k, v|
247
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
248
+ end
249
+ end
250
+ else # model
251
+ PulpFileClient.const_get(type).build_from_hash(value)
252
+ end
253
+ end
254
+
255
+ # Returns the string representation of the object
256
+ # @return [String] String presentation of the object
257
+ def to_s
258
+ to_hash.to_s
259
+ end
260
+
261
+ # to_body is an alias to to_hash (backward compatibility)
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_body
264
+ to_hash
265
+ end
266
+
267
+ # Returns the object in the form of hash
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_hash
270
+ hash = {}
271
+ self.class.attribute_map.each_pair do |attr, param|
272
+ value = self.send(attr)
273
+ next if value.nil?
274
+ hash[param] = _to_hash(value)
275
+ end
276
+ hash
277
+ end
278
+
279
+ # Outputs non-array value in the form of hash
280
+ # For object, use to_hash. Otherwise, just return the value
281
+ # @param [Object] value Any valid value
282
+ # @return [Hash] Returns the value in the form of hash
283
+ def _to_hash(value)
284
+ if value.is_a?(Array)
285
+ value.compact.map { |v| _to_hash(v) }
286
+ elsif value.is_a?(Hash)
287
+ {}.tap do |hash|
288
+ value.each { |k, v| hash[k] = _to_hash(v) }
289
+ end
290
+ elsif value.respond_to? :to_hash
291
+ value.to_hash
292
+ else
293
+ value
294
+ end
295
+ end
296
+ end
297
+ end