pulp_deb_client 2.3.0b1 → 2.4.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -8
  3. data/docs/ContentGenericContentsApi.md +5 -5
  4. data/docs/ContentInstallerFileIndicesApi.md +5 -5
  5. data/docs/ContentInstallerPackagesApi.md +5 -5
  6. data/docs/ContentPackageIndicesApi.md +5 -5
  7. data/docs/ContentPackageReleaseComponentsApi.md +5 -5
  8. data/docs/ContentPackagesApi.md +5 -5
  9. data/docs/ContentReleaseArchitecturesApi.md +5 -5
  10. data/docs/ContentReleaseComponentsApi.md +5 -5
  11. data/docs/ContentReleaseFilesApi.md +5 -5
  12. data/docs/ContentReleasesApi.md +5 -5
  13. data/docs/{DebBasePackage.md → DebBasePackageRead.md} +2 -2
  14. data/docs/DebDebDistributionRead.md +29 -0
  15. data/docs/DebDebPublicationRead.md +29 -0
  16. data/docs/DebDebRemote.md +7 -3
  17. data/docs/DebDebRemoteRead.md +57 -0
  18. data/docs/DebDebRepositoryRead.md +27 -0
  19. data/docs/{DebGenericContent.md → DebGenericContentRead.md} +2 -2
  20. data/docs/DebInstallerFileIndexRead.md +29 -0
  21. data/docs/DebPackageIndexRead.md +29 -0
  22. data/docs/DebPackageReleaseComponentRead.md +23 -0
  23. data/docs/DebReleaseArchitectureRead.md +23 -0
  24. data/docs/DebReleaseComponentRead.md +23 -0
  25. data/docs/DebReleaseFileRead.md +29 -0
  26. data/docs/DebReleaseRead.md +25 -0
  27. data/docs/DebVerbatimPublicationRead.md +23 -0
  28. data/docs/DistributionsAptApi.md +3 -3
  29. data/docs/InlineResponse200.md +1 -1
  30. data/docs/InlineResponse2001.md +1 -1
  31. data/docs/InlineResponse20010.md +1 -1
  32. data/docs/InlineResponse20011.md +1 -1
  33. data/docs/InlineResponse20012.md +1 -1
  34. data/docs/InlineResponse20013.md +1 -1
  35. data/docs/InlineResponse20014.md +1 -1
  36. data/docs/InlineResponse2002.md +1 -1
  37. data/docs/InlineResponse2003.md +1 -1
  38. data/docs/InlineResponse2004.md +1 -1
  39. data/docs/InlineResponse2005.md +1 -1
  40. data/docs/InlineResponse2006.md +1 -1
  41. data/docs/InlineResponse2007.md +1 -1
  42. data/docs/InlineResponse2008.md +1 -1
  43. data/docs/InlineResponse2009.md +1 -1
  44. data/docs/PublicationsAptApi.md +3 -3
  45. data/docs/PublicationsVerbatimApi.md +3 -3
  46. data/docs/RemotesAptApi.md +5 -5
  47. data/docs/RepositoriesAptApi.md +10 -10
  48. data/docs/RepositoriesDebVersionsApi.md +3 -3
  49. data/docs/RepositoryVersionRead.md +25 -0
  50. data/lib/pulp_deb_client/api/content_generic_contents_api.rb +5 -5
  51. data/lib/pulp_deb_client/api/content_installer_file_indices_api.rb +6 -6
  52. data/lib/pulp_deb_client/api/content_installer_packages_api.rb +5 -5
  53. data/lib/pulp_deb_client/api/content_package_indices_api.rb +6 -6
  54. data/lib/pulp_deb_client/api/content_package_release_components_api.rb +6 -6
  55. data/lib/pulp_deb_client/api/content_packages_api.rb +5 -5
  56. data/lib/pulp_deb_client/api/content_release_architectures_api.rb +6 -6
  57. data/lib/pulp_deb_client/api/content_release_components_api.rb +6 -6
  58. data/lib/pulp_deb_client/api/content_release_files_api.rb +6 -6
  59. data/lib/pulp_deb_client/api/content_releases_api.rb +6 -6
  60. data/lib/pulp_deb_client/api/distributions_apt_api.rb +3 -3
  61. data/lib/pulp_deb_client/api/publications_apt_api.rb +3 -3
  62. data/lib/pulp_deb_client/api/publications_verbatim_api.rb +3 -3
  63. data/lib/pulp_deb_client/api/remotes_apt_api.rb +6 -6
  64. data/lib/pulp_deb_client/api/repositories_apt_api.rb +15 -15
  65. data/lib/pulp_deb_client/api/repositories_deb_versions_api.rb +3 -3
  66. data/lib/pulp_deb_client/configuration.rb +2 -2
  67. data/lib/pulp_deb_client/models/{deb_base_package.rb → deb_base_package_read.rb} +3 -3
  68. data/lib/pulp_deb_client/models/deb_deb_distribution_read.rb +331 -0
  69. data/lib/pulp_deb_client/models/deb_deb_publication_read.rb +269 -0
  70. data/lib/pulp_deb_client/models/deb_deb_remote.rb +56 -4
  71. data/lib/pulp_deb_client/models/deb_deb_remote_read.rb +670 -0
  72. data/lib/pulp_deb_client/models/deb_deb_repository_read.rb +294 -0
  73. data/lib/pulp_deb_client/models/{deb_generic_content.rb → deb_generic_content_read.rb} +3 -3
  74. data/lib/pulp_deb_client/models/deb_installer_file_index_read.rb +341 -0
  75. data/lib/pulp_deb_client/models/deb_package_index_read.rb +341 -0
  76. data/lib/pulp_deb_client/models/deb_package_release_component_read.rb +246 -0
  77. data/lib/pulp_deb_client/models/deb_release_architecture_read.rb +265 -0
  78. data/lib/pulp_deb_client/models/deb_release_component_read.rb +265 -0
  79. data/lib/pulp_deb_client/models/deb_release_file_read.rb +342 -0
  80. data/lib/pulp_deb_client/models/deb_release_read.rb +315 -0
  81. data/lib/pulp_deb_client/models/deb_verbatim_publication_read.rb +235 -0
  82. data/lib/pulp_deb_client/models/inline_response200.rb +1 -1
  83. data/lib/pulp_deb_client/models/inline_response2001.rb +1 -1
  84. data/lib/pulp_deb_client/models/inline_response20010.rb +1 -1
  85. data/lib/pulp_deb_client/models/inline_response20011.rb +1 -1
  86. data/lib/pulp_deb_client/models/inline_response20012.rb +1 -1
  87. data/lib/pulp_deb_client/models/inline_response20013.rb +1 -1
  88. data/lib/pulp_deb_client/models/inline_response20014.rb +1 -1
  89. data/lib/pulp_deb_client/models/inline_response2002.rb +1 -1
  90. data/lib/pulp_deb_client/models/inline_response2003.rb +1 -1
  91. data/lib/pulp_deb_client/models/inline_response2004.rb +1 -1
  92. data/lib/pulp_deb_client/models/inline_response2005.rb +1 -1
  93. data/lib/pulp_deb_client/models/inline_response2006.rb +1 -1
  94. data/lib/pulp_deb_client/models/inline_response2007.rb +1 -1
  95. data/lib/pulp_deb_client/models/inline_response2008.rb +1 -1
  96. data/lib/pulp_deb_client/models/inline_response2009.rb +1 -1
  97. data/lib/pulp_deb_client/models/repository_version_read.rb +244 -0
  98. data/lib/pulp_deb_client/version.rb +1 -1
  99. data/lib/pulp_deb_client.rb +15 -2
  100. data/spec/api/content_generic_contents_api_spec.rb +2 -2
  101. data/spec/api/content_installer_file_indices_api_spec.rb +2 -2
  102. data/spec/api/content_installer_packages_api_spec.rb +2 -2
  103. data/spec/api/content_package_indices_api_spec.rb +2 -2
  104. data/spec/api/content_package_release_components_api_spec.rb +2 -2
  105. data/spec/api/content_packages_api_spec.rb +2 -2
  106. data/spec/api/content_release_architectures_api_spec.rb +2 -2
  107. data/spec/api/content_release_components_api_spec.rb +2 -2
  108. data/spec/api/content_release_files_api_spec.rb +2 -2
  109. data/spec/api/content_releases_api_spec.rb +2 -2
  110. data/spec/api/distributions_apt_api_spec.rb +1 -1
  111. data/spec/api/publications_apt_api_spec.rb +1 -1
  112. data/spec/api/publications_verbatim_api_spec.rb +1 -1
  113. data/spec/api/remotes_apt_api_spec.rb +2 -2
  114. data/spec/api/repositories_apt_api_spec.rb +6 -6
  115. data/spec/api/repositories_deb_versions_api_spec.rb +1 -1
  116. data/spec/configuration_spec.rb +3 -3
  117. data/spec/models/{deb_base_package_spec.rb → deb_base_package_read_spec.rb} +6 -6
  118. data/spec/models/deb_deb_distribution_read_spec.rb +77 -0
  119. data/spec/models/deb_deb_publication_read_spec.rb +77 -0
  120. data/spec/models/deb_deb_remote_read_spec.rb +165 -0
  121. data/spec/models/deb_deb_remote_spec.rb +12 -0
  122. data/spec/models/deb_deb_repository_read_spec.rb +71 -0
  123. data/spec/models/{deb_generic_content_spec.rb → deb_generic_content_read_spec.rb} +6 -6
  124. data/spec/models/deb_installer_file_index_read_spec.rb +77 -0
  125. data/spec/models/deb_package_index_read_spec.rb +77 -0
  126. data/spec/models/deb_package_release_component_read_spec.rb +59 -0
  127. data/spec/models/deb_release_architecture_read_spec.rb +59 -0
  128. data/spec/models/deb_release_component_read_spec.rb +59 -0
  129. data/spec/models/deb_release_file_read_spec.rb +77 -0
  130. data/spec/models/deb_release_read_spec.rb +65 -0
  131. data/spec/models/deb_verbatim_publication_read_spec.rb +59 -0
  132. data/spec/models/repository_version_read_spec.rb +65 -0
  133. metadata +62 -10
@@ -0,0 +1,265 @@
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 PulpDebClient
16
+ class DebReleaseArchitectureRead
17
+ attr_accessor :pulp_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :pulp_created
21
+
22
+ # Name of the architecture.
23
+ attr_accessor :architecture
24
+
25
+ # Release this architecture is contained in.
26
+ attr_accessor :release
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'pulp_href' => :'pulp_href',
32
+ :'pulp_created' => :'pulp_created',
33
+ :'architecture' => :'architecture',
34
+ :'release' => :'release'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'pulp_href' => :'String',
42
+ :'pulp_created' => :'DateTime',
43
+ :'architecture' => :'String',
44
+ :'release' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDebClient::DebReleaseArchitectureRead` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDebClient::DebReleaseArchitectureRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'pulp_href')
70
+ self.pulp_href = attributes[:'pulp_href']
71
+ end
72
+
73
+ if attributes.key?(:'pulp_created')
74
+ self.pulp_created = attributes[:'pulp_created']
75
+ end
76
+
77
+ if attributes.key?(:'architecture')
78
+ self.architecture = attributes[:'architecture']
79
+ end
80
+
81
+ if attributes.key?(:'release')
82
+ self.release = attributes[:'release']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @architecture.nil?
91
+ invalid_properties.push('invalid value for "architecture", architecture cannot be nil.')
92
+ end
93
+
94
+ if @architecture.to_s.length < 1
95
+ invalid_properties.push('invalid value for "architecture", the character length must be great than or equal to 1.')
96
+ end
97
+
98
+ if @release.nil?
99
+ invalid_properties.push('invalid value for "release", release cannot be nil.')
100
+ end
101
+
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ return false if @architecture.nil?
109
+ return false if @architecture.to_s.length < 1
110
+ return false if @release.nil?
111
+ true
112
+ end
113
+
114
+ # Custom attribute writer method with validation
115
+ # @param [Object] architecture Value to be assigned
116
+ def architecture=(architecture)
117
+ if architecture.nil?
118
+ fail ArgumentError, 'architecture cannot be nil'
119
+ end
120
+
121
+ if architecture.to_s.length < 1
122
+ fail ArgumentError, 'invalid value for "architecture", the character length must be great than or equal to 1.'
123
+ end
124
+
125
+ @architecture = architecture
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ pulp_href == o.pulp_href &&
134
+ pulp_created == o.pulp_created &&
135
+ architecture == o.architecture &&
136
+ release == o.release
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [pulp_href, pulp_created, architecture, release].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ new.build_from_hash(attributes)
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ self.class.openapi_types.each_pair do |key, type|
164
+ if type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
168
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
169
+ end
170
+ elsif !attributes[self.class.attribute_map[key]].nil?
171
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
172
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def _deserialize(type, value)
183
+ case type.to_sym
184
+ when :DateTime
185
+ DateTime.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ PulpDebClient.const_get(type).build_from_hash(value)
216
+ end
217
+ end
218
+
219
+ # Returns the string representation of the object
220
+ # @return [String] String presentation of the object
221
+ def to_s
222
+ to_hash.to_s
223
+ end
224
+
225
+ # to_body is an alias to to_hash (backward compatibility)
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_body
228
+ to_hash
229
+ end
230
+
231
+ # Returns the object in the form of hash
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_hash
234
+ hash = {}
235
+ self.class.attribute_map.each_pair do |attr, param|
236
+ value = self.send(attr)
237
+ if value.nil?
238
+ is_nullable = self.class.openapi_nullable.include?(attr)
239
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
+ end
241
+
242
+ hash[param] = _to_hash(value)
243
+ end
244
+ hash
245
+ end
246
+
247
+ # Outputs non-array value in the form of hash
248
+ # For object, use to_hash. Otherwise, just return the value
249
+ # @param [Object] value Any valid value
250
+ # @return [Hash] Returns the value in the form of hash
251
+ def _to_hash(value)
252
+ if value.is_a?(Array)
253
+ value.compact.map { |v| _to_hash(v) }
254
+ elsif value.is_a?(Hash)
255
+ {}.tap do |hash|
256
+ value.each { |k, v| hash[k] = _to_hash(v) }
257
+ end
258
+ elsif value.respond_to? :to_hash
259
+ value.to_hash
260
+ else
261
+ value
262
+ end
263
+ end
264
+ end
265
+ end
@@ -0,0 +1,265 @@
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 PulpDebClient
16
+ class DebReleaseComponentRead
17
+ attr_accessor :pulp_href
18
+
19
+ # Timestamp of creation.
20
+ attr_accessor :pulp_created
21
+
22
+ # Name of the component.
23
+ attr_accessor :component
24
+
25
+ # Release this component is contained in.
26
+ attr_accessor :release
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'pulp_href' => :'pulp_href',
32
+ :'pulp_created' => :'pulp_created',
33
+ :'component' => :'component',
34
+ :'release' => :'release'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'pulp_href' => :'String',
42
+ :'pulp_created' => :'DateTime',
43
+ :'component' => :'String',
44
+ :'release' => :'String'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDebClient::DebReleaseComponentRead` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDebClient::DebReleaseComponentRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'pulp_href')
70
+ self.pulp_href = attributes[:'pulp_href']
71
+ end
72
+
73
+ if attributes.key?(:'pulp_created')
74
+ self.pulp_created = attributes[:'pulp_created']
75
+ end
76
+
77
+ if attributes.key?(:'component')
78
+ self.component = attributes[:'component']
79
+ end
80
+
81
+ if attributes.key?(:'release')
82
+ self.release = attributes[:'release']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @component.nil?
91
+ invalid_properties.push('invalid value for "component", component cannot be nil.')
92
+ end
93
+
94
+ if @component.to_s.length < 1
95
+ invalid_properties.push('invalid value for "component", the character length must be great than or equal to 1.')
96
+ end
97
+
98
+ if @release.nil?
99
+ invalid_properties.push('invalid value for "release", release cannot be nil.')
100
+ end
101
+
102
+ invalid_properties
103
+ end
104
+
105
+ # Check to see if the all the properties in the model are valid
106
+ # @return true if the model is valid
107
+ def valid?
108
+ return false if @component.nil?
109
+ return false if @component.to_s.length < 1
110
+ return false if @release.nil?
111
+ true
112
+ end
113
+
114
+ # Custom attribute writer method with validation
115
+ # @param [Object] component Value to be assigned
116
+ def component=(component)
117
+ if component.nil?
118
+ fail ArgumentError, 'component cannot be nil'
119
+ end
120
+
121
+ if component.to_s.length < 1
122
+ fail ArgumentError, 'invalid value for "component", the character length must be great than or equal to 1.'
123
+ end
124
+
125
+ @component = component
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ pulp_href == o.pulp_href &&
134
+ pulp_created == o.pulp_created &&
135
+ component == o.component &&
136
+ release == o.release
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [pulp_href, pulp_created, component, release].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ new.build_from_hash(attributes)
156
+ end
157
+
158
+ # Builds the object from hash
159
+ # @param [Hash] attributes Model attributes in the form of hash
160
+ # @return [Object] Returns the model itself
161
+ def build_from_hash(attributes)
162
+ return nil unless attributes.is_a?(Hash)
163
+ self.class.openapi_types.each_pair do |key, type|
164
+ if type =~ /\AArray<(.*)>/i
165
+ # check to ensure the input is an array given that the attribute
166
+ # is documented as an array but the input is not
167
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
168
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
169
+ end
170
+ elsif !attributes[self.class.attribute_map[key]].nil?
171
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
172
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def _deserialize(type, value)
183
+ case type.to_sym
184
+ when :DateTime
185
+ DateTime.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ PulpDebClient.const_get(type).build_from_hash(value)
216
+ end
217
+ end
218
+
219
+ # Returns the string representation of the object
220
+ # @return [String] String presentation of the object
221
+ def to_s
222
+ to_hash.to_s
223
+ end
224
+
225
+ # to_body is an alias to to_hash (backward compatibility)
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_body
228
+ to_hash
229
+ end
230
+
231
+ # Returns the object in the form of hash
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_hash
234
+ hash = {}
235
+ self.class.attribute_map.each_pair do |attr, param|
236
+ value = self.send(attr)
237
+ if value.nil?
238
+ is_nullable = self.class.openapi_nullable.include?(attr)
239
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
+ end
241
+
242
+ hash[param] = _to_hash(value)
243
+ end
244
+ hash
245
+ end
246
+
247
+ # Outputs non-array value in the form of hash
248
+ # For object, use to_hash. Otherwise, just return the value
249
+ # @param [Object] value Any valid value
250
+ # @return [Hash] Returns the value in the form of hash
251
+ def _to_hash(value)
252
+ if value.is_a?(Array)
253
+ value.compact.map { |v| _to_hash(v) }
254
+ elsif value.is_a?(Hash)
255
+ {}.tap do |hash|
256
+ value.each { |k, v| hash[k] = _to_hash(v) }
257
+ end
258
+ elsif value.respond_to? :to_hash
259
+ value.to_hash
260
+ else
261
+ value
262
+ end
263
+ end
264
+ end
265
+ end