pulp_2to3_migration_client 0.3.0b1.dev01595360000

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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +114 -0
  4. data/Rakefile +10 -0
  5. data/docs/AsyncOperationResponse.md +17 -0
  6. data/docs/InlineResponse200.md +23 -0
  7. data/docs/InlineResponse2001.md +23 -0
  8. data/docs/InlineResponse2002.md +23 -0
  9. data/docs/MigrationPlanRun.md +19 -0
  10. data/docs/MigrationPlansApi.md +295 -0
  11. data/docs/Pulp2contentApi.md +154 -0
  12. data/docs/Pulp2repositoriesApi.md +140 -0
  13. data/docs/Pulp2to3MigrationMigrationPlan.md +21 -0
  14. data/docs/Pulp2to3MigrationPulp2Content.md +33 -0
  15. data/docs/Pulp2to3MigrationPulp2Repository.md +39 -0
  16. data/git_push.sh +58 -0
  17. data/lib/pulp_2to3_migration_client.rb +50 -0
  18. data/lib/pulp_2to3_migration_client/api/migration_plans_api.rb +355 -0
  19. data/lib/pulp_2to3_migration_client/api/pulp2content_api.rb +194 -0
  20. data/lib/pulp_2to3_migration_client/api/pulp2repositories_api.rb +173 -0
  21. data/lib/pulp_2to3_migration_client/api_client.rb +402 -0
  22. data/lib/pulp_2to3_migration_client/api_error.rb +57 -0
  23. data/lib/pulp_2to3_migration_client/configuration.rb +243 -0
  24. data/lib/pulp_2to3_migration_client/models/async_operation_response.rb +212 -0
  25. data/lib/pulp_2to3_migration_client/models/inline_response200.rb +247 -0
  26. data/lib/pulp_2to3_migration_client/models/inline_response2001.rb +247 -0
  27. data/lib/pulp_2to3_migration_client/models/inline_response2002.rb +247 -0
  28. data/lib/pulp_2to3_migration_client/models/migration_plan_run.rb +221 -0
  29. data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_migration_plan.rb +231 -0
  30. data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_pulp2_content.rb +393 -0
  31. data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_pulp2_repository.rb +444 -0
  32. data/lib/pulp_2to3_migration_client/version.rb +15 -0
  33. data/pulp_2to3_migration_client.gemspec +39 -0
  34. data/spec/api/migration_plans_api_spec.rb +102 -0
  35. data/spec/api/pulp2content_api_spec.rb +76 -0
  36. data/spec/api/pulp2repositories_api_spec.rb +69 -0
  37. data/spec/api_client_spec.rb +188 -0
  38. data/spec/configuration_spec.rb +42 -0
  39. data/spec/models/async_operation_response_spec.rb +41 -0
  40. data/spec/models/inline_response2001_spec.rb +59 -0
  41. data/spec/models/inline_response2002_spec.rb +59 -0
  42. data/spec/models/inline_response200_spec.rb +59 -0
  43. data/spec/models/migration_plan_run_spec.rb +47 -0
  44. data/spec/models/pulp2to3_migration_migration_plan_spec.rb +53 -0
  45. data/spec/models/pulp2to3_migration_pulp2_content_spec.rb +89 -0
  46. data/spec/models/pulp2to3_migration_pulp2_repository_spec.rb +107 -0
  47. data/spec/spec_helper.rb +111 -0
  48. metadata +157 -0
@@ -0,0 +1,231 @@
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 Pulp2to3MigrationClient
16
+ class Pulp2to3MigrationMigrationPlan
17
+ attr_accessor :pulp_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :pulp_created
21
+
22
+ # Migration Plan in JSON format
23
+ attr_accessor :plan
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'pulp_href' => :'pulp_href',
29
+ :'pulp_created' => :'pulp_created',
30
+ :'plan' => :'plan'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'pulp_href' => :'String',
38
+ :'pulp_created' => :'DateTime',
39
+ :'plan' => :'Object'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Pulp2to3MigrationClient::Pulp2to3MigrationMigrationPlan` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Pulp2to3MigrationClient::Pulp2to3MigrationMigrationPlan`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'pulp_href')
65
+ self.pulp_href = attributes[:'pulp_href']
66
+ end
67
+
68
+ if attributes.key?(:'pulp_created')
69
+ self.pulp_created = attributes[:'pulp_created']
70
+ end
71
+
72
+ if attributes.key?(:'plan')
73
+ self.plan = attributes[:'plan']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ if @plan.nil?
82
+ invalid_properties.push('invalid value for "plan", plan cannot be nil.')
83
+ end
84
+
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ return false if @plan.nil?
92
+ true
93
+ end
94
+
95
+ # Checks equality by comparing each attribute.
96
+ # @param [Object] Object to be compared
97
+ def ==(o)
98
+ return true if self.equal?(o)
99
+ self.class == o.class &&
100
+ pulp_href == o.pulp_href &&
101
+ pulp_created == o.pulp_created &&
102
+ plan == o.plan
103
+ end
104
+
105
+ # @see the `==` method
106
+ # @param [Object] Object to be compared
107
+ def eql?(o)
108
+ self == o
109
+ end
110
+
111
+ # Calculates hash code according to all attributes.
112
+ # @return [Integer] Hash code
113
+ def hash
114
+ [pulp_href, pulp_created, plan].hash
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def self.build_from_hash(attributes)
121
+ new.build_from_hash(attributes)
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ self.class.openapi_types.each_pair do |key, type|
130
+ if type =~ /\AArray<(.*)>/i
131
+ # check to ensure the input is an array given that the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ Pulp2to3MigrationClient.const_get(type).build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+ end
231
+ end
@@ -0,0 +1,393 @@
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 Pulp2to3MigrationClient
16
+ class Pulp2to3MigrationPulp2Content
17
+ attr_accessor :pulp_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :pulp_created
21
+
22
+ attr_accessor :pulp2_id
23
+
24
+ attr_accessor :pulp2_content_type_id
25
+
26
+ attr_accessor :pulp2_last_updated
27
+
28
+ attr_accessor :pulp2_storage_path
29
+
30
+ attr_accessor :downloaded
31
+
32
+ attr_accessor :pulp3_content
33
+
34
+ # Get pulp3_repository_version href from pulp2repo if available
35
+ attr_accessor :pulp3_repository_version
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'pulp_href' => :'pulp_href',
41
+ :'pulp_created' => :'pulp_created',
42
+ :'pulp2_id' => :'pulp2_id',
43
+ :'pulp2_content_type_id' => :'pulp2_content_type_id',
44
+ :'pulp2_last_updated' => :'pulp2_last_updated',
45
+ :'pulp2_storage_path' => :'pulp2_storage_path',
46
+ :'downloaded' => :'downloaded',
47
+ :'pulp3_content' => :'pulp3_content',
48
+ :'pulp3_repository_version' => :'pulp3_repository_version'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'pulp_href' => :'String',
56
+ :'pulp_created' => :'DateTime',
57
+ :'pulp2_id' => :'String',
58
+ :'pulp2_content_type_id' => :'String',
59
+ :'pulp2_last_updated' => :'Integer',
60
+ :'pulp2_storage_path' => :'String',
61
+ :'downloaded' => :'Boolean',
62
+ :'pulp3_content' => :'String',
63
+ :'pulp3_repository_version' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ :'pulp3_content',
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Pulp2to3MigrationClient::Pulp2to3MigrationPulp2Content` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Pulp2to3MigrationClient::Pulp2to3MigrationPulp2Content`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'pulp_href')
90
+ self.pulp_href = attributes[:'pulp_href']
91
+ end
92
+
93
+ if attributes.key?(:'pulp_created')
94
+ self.pulp_created = attributes[:'pulp_created']
95
+ end
96
+
97
+ if attributes.key?(:'pulp2_id')
98
+ self.pulp2_id = attributes[:'pulp2_id']
99
+ end
100
+
101
+ if attributes.key?(:'pulp2_content_type_id')
102
+ self.pulp2_content_type_id = attributes[:'pulp2_content_type_id']
103
+ end
104
+
105
+ if attributes.key?(:'pulp2_last_updated')
106
+ self.pulp2_last_updated = attributes[:'pulp2_last_updated']
107
+ end
108
+
109
+ if attributes.key?(:'pulp2_storage_path')
110
+ self.pulp2_storage_path = attributes[:'pulp2_storage_path']
111
+ end
112
+
113
+ if attributes.key?(:'downloaded')
114
+ self.downloaded = attributes[:'downloaded']
115
+ else
116
+ self.downloaded = false
117
+ end
118
+
119
+ if attributes.key?(:'pulp3_content')
120
+ self.pulp3_content = attributes[:'pulp3_content']
121
+ end
122
+
123
+ if attributes.key?(:'pulp3_repository_version')
124
+ self.pulp3_repository_version = attributes[:'pulp3_repository_version']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ invalid_properties = Array.new
132
+ if @pulp2_id.nil?
133
+ invalid_properties.push('invalid value for "pulp2_id", pulp2_id cannot be nil.')
134
+ end
135
+
136
+ if @pulp2_id.to_s.length > 255
137
+ invalid_properties.push('invalid value for "pulp2_id", the character length must be smaller than or equal to 255.')
138
+ end
139
+
140
+ if @pulp2_id.to_s.length < 1
141
+ invalid_properties.push('invalid value for "pulp2_id", the character length must be great than or equal to 1.')
142
+ end
143
+
144
+ if @pulp2_content_type_id.nil?
145
+ invalid_properties.push('invalid value for "pulp2_content_type_id", pulp2_content_type_id cannot be nil.')
146
+ end
147
+
148
+ if @pulp2_content_type_id.to_s.length > 255
149
+ invalid_properties.push('invalid value for "pulp2_content_type_id", the character length must be smaller than or equal to 255.')
150
+ end
151
+
152
+ if @pulp2_content_type_id.to_s.length < 1
153
+ invalid_properties.push('invalid value for "pulp2_content_type_id", the character length must be great than or equal to 1.')
154
+ end
155
+
156
+ if @pulp2_last_updated.nil?
157
+ invalid_properties.push('invalid value for "pulp2_last_updated", pulp2_last_updated cannot be nil.')
158
+ end
159
+
160
+ if @pulp2_storage_path.nil?
161
+ invalid_properties.push('invalid value for "pulp2_storage_path", pulp2_storage_path cannot be nil.')
162
+ end
163
+
164
+ if @pulp2_storage_path.to_s.length < 1
165
+ invalid_properties.push('invalid value for "pulp2_storage_path", the character length must be great than or equal to 1.')
166
+ end
167
+
168
+ if !@pulp3_repository_version.nil? && @pulp3_repository_version.to_s.length < 1
169
+ invalid_properties.push('invalid value for "pulp3_repository_version", the character length must be great than or equal to 1.')
170
+ end
171
+
172
+ invalid_properties
173
+ end
174
+
175
+ # Check to see if the all the properties in the model are valid
176
+ # @return true if the model is valid
177
+ def valid?
178
+ return false if @pulp2_id.nil?
179
+ return false if @pulp2_id.to_s.length > 255
180
+ return false if @pulp2_id.to_s.length < 1
181
+ return false if @pulp2_content_type_id.nil?
182
+ return false if @pulp2_content_type_id.to_s.length > 255
183
+ return false if @pulp2_content_type_id.to_s.length < 1
184
+ return false if @pulp2_last_updated.nil?
185
+ return false if @pulp2_storage_path.nil?
186
+ return false if @pulp2_storage_path.to_s.length < 1
187
+ return false if !@pulp3_repository_version.nil? && @pulp3_repository_version.to_s.length < 1
188
+ true
189
+ end
190
+
191
+ # Custom attribute writer method with validation
192
+ # @param [Object] pulp2_id Value to be assigned
193
+ def pulp2_id=(pulp2_id)
194
+ if pulp2_id.nil?
195
+ fail ArgumentError, 'pulp2_id cannot be nil'
196
+ end
197
+
198
+ if pulp2_id.to_s.length > 255
199
+ fail ArgumentError, 'invalid value for "pulp2_id", the character length must be smaller than or equal to 255.'
200
+ end
201
+
202
+ if pulp2_id.to_s.length < 1
203
+ fail ArgumentError, 'invalid value for "pulp2_id", the character length must be great than or equal to 1.'
204
+ end
205
+
206
+ @pulp2_id = pulp2_id
207
+ end
208
+
209
+ # Custom attribute writer method with validation
210
+ # @param [Object] pulp2_content_type_id Value to be assigned
211
+ def pulp2_content_type_id=(pulp2_content_type_id)
212
+ if pulp2_content_type_id.nil?
213
+ fail ArgumentError, 'pulp2_content_type_id cannot be nil'
214
+ end
215
+
216
+ if pulp2_content_type_id.to_s.length > 255
217
+ fail ArgumentError, 'invalid value for "pulp2_content_type_id", the character length must be smaller than or equal to 255.'
218
+ end
219
+
220
+ if pulp2_content_type_id.to_s.length < 1
221
+ fail ArgumentError, 'invalid value for "pulp2_content_type_id", the character length must be great than or equal to 1.'
222
+ end
223
+
224
+ @pulp2_content_type_id = pulp2_content_type_id
225
+ end
226
+
227
+ # Custom attribute writer method with validation
228
+ # @param [Object] pulp2_storage_path Value to be assigned
229
+ def pulp2_storage_path=(pulp2_storage_path)
230
+ if pulp2_storage_path.nil?
231
+ fail ArgumentError, 'pulp2_storage_path cannot be nil'
232
+ end
233
+
234
+ if pulp2_storage_path.to_s.length < 1
235
+ fail ArgumentError, 'invalid value for "pulp2_storage_path", the character length must be great than or equal to 1.'
236
+ end
237
+
238
+ @pulp2_storage_path = pulp2_storage_path
239
+ end
240
+
241
+ # Custom attribute writer method with validation
242
+ # @param [Object] pulp3_repository_version Value to be assigned
243
+ def pulp3_repository_version=(pulp3_repository_version)
244
+ if !pulp3_repository_version.nil? && pulp3_repository_version.to_s.length < 1
245
+ fail ArgumentError, 'invalid value for "pulp3_repository_version", the character length must be great than or equal to 1.'
246
+ end
247
+
248
+ @pulp3_repository_version = pulp3_repository_version
249
+ end
250
+
251
+ # Checks equality by comparing each attribute.
252
+ # @param [Object] Object to be compared
253
+ def ==(o)
254
+ return true if self.equal?(o)
255
+ self.class == o.class &&
256
+ pulp_href == o.pulp_href &&
257
+ pulp_created == o.pulp_created &&
258
+ pulp2_id == o.pulp2_id &&
259
+ pulp2_content_type_id == o.pulp2_content_type_id &&
260
+ pulp2_last_updated == o.pulp2_last_updated &&
261
+ pulp2_storage_path == o.pulp2_storage_path &&
262
+ downloaded == o.downloaded &&
263
+ pulp3_content == o.pulp3_content &&
264
+ pulp3_repository_version == o.pulp3_repository_version
265
+ end
266
+
267
+ # @see the `==` method
268
+ # @param [Object] Object to be compared
269
+ def eql?(o)
270
+ self == o
271
+ end
272
+
273
+ # Calculates hash code according to all attributes.
274
+ # @return [Integer] Hash code
275
+ def hash
276
+ [pulp_href, pulp_created, pulp2_id, pulp2_content_type_id, pulp2_last_updated, pulp2_storage_path, downloaded, pulp3_content, pulp3_repository_version].hash
277
+ end
278
+
279
+ # Builds the object from hash
280
+ # @param [Hash] attributes Model attributes in the form of hash
281
+ # @return [Object] Returns the model itself
282
+ def self.build_from_hash(attributes)
283
+ new.build_from_hash(attributes)
284
+ end
285
+
286
+ # Builds the object from hash
287
+ # @param [Hash] attributes Model attributes in the form of hash
288
+ # @return [Object] Returns the model itself
289
+ def build_from_hash(attributes)
290
+ return nil unless attributes.is_a?(Hash)
291
+ self.class.openapi_types.each_pair do |key, type|
292
+ if type =~ /\AArray<(.*)>/i
293
+ # check to ensure the input is an array given that the attribute
294
+ # is documented as an array but the input is not
295
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
296
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
297
+ end
298
+ elsif !attributes[self.class.attribute_map[key]].nil?
299
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
300
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
301
+ end
302
+
303
+ self
304
+ end
305
+
306
+ # Deserializes the data based on type
307
+ # @param string type Data type
308
+ # @param string value Value to be deserialized
309
+ # @return [Object] Deserialized data
310
+ def _deserialize(type, value)
311
+ case type.to_sym
312
+ when :DateTime
313
+ DateTime.parse(value)
314
+ when :Date
315
+ Date.parse(value)
316
+ when :String
317
+ value.to_s
318
+ when :Integer
319
+ value.to_i
320
+ when :Float
321
+ value.to_f
322
+ when :Boolean
323
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
324
+ true
325
+ else
326
+ false
327
+ end
328
+ when :Object
329
+ # generic object (usually a Hash), return directly
330
+ value
331
+ when /\AArray<(?<inner_type>.+)>\z/
332
+ inner_type = Regexp.last_match[:inner_type]
333
+ value.map { |v| _deserialize(inner_type, v) }
334
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
335
+ k_type = Regexp.last_match[:k_type]
336
+ v_type = Regexp.last_match[:v_type]
337
+ {}.tap do |hash|
338
+ value.each do |k, v|
339
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
340
+ end
341
+ end
342
+ else # model
343
+ Pulp2to3MigrationClient.const_get(type).build_from_hash(value)
344
+ end
345
+ end
346
+
347
+ # Returns the string representation of the object
348
+ # @return [String] String presentation of the object
349
+ def to_s
350
+ to_hash.to_s
351
+ end
352
+
353
+ # to_body is an alias to to_hash (backward compatibility)
354
+ # @return [Hash] Returns the object in the form of hash
355
+ def to_body
356
+ to_hash
357
+ end
358
+
359
+ # Returns the object in the form of hash
360
+ # @return [Hash] Returns the object in the form of hash
361
+ def to_hash
362
+ hash = {}
363
+ self.class.attribute_map.each_pair do |attr, param|
364
+ value = self.send(attr)
365
+ if value.nil?
366
+ is_nullable = self.class.openapi_nullable.include?(attr)
367
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
368
+ end
369
+
370
+ hash[param] = _to_hash(value)
371
+ end
372
+ hash
373
+ end
374
+
375
+ # Outputs non-array value in the form of hash
376
+ # For object, use to_hash. Otherwise, just return the value
377
+ # @param [Object] value Any valid value
378
+ # @return [Hash] Returns the value in the form of hash
379
+ def _to_hash(value)
380
+ if value.is_a?(Array)
381
+ value.compact.map { |v| _to_hash(v) }
382
+ elsif value.is_a?(Hash)
383
+ {}.tap do |hash|
384
+ value.each { |k, v| hash[k] = _to_hash(v) }
385
+ end
386
+ elsif value.respond_to? :to_hash
387
+ value.to_hash
388
+ else
389
+ value
390
+ end
391
+ end
392
+ end
393
+ end