pulp_gem_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +160 -0
  4. data/Rakefile +10 -0
  5. data/docs/AsyncOperationResponse.md +17 -0
  6. data/docs/ContentGemApi.md +210 -0
  7. data/docs/ContentSummaryResponse.md +21 -0
  8. data/docs/DistributionsGemApi.md +382 -0
  9. data/docs/GemGemContent.md +21 -0
  10. data/docs/GemGemContentResponse.md +35 -0
  11. data/docs/GemGemDistribution.md +31 -0
  12. data/docs/GemGemDistributionResponse.md +37 -0
  13. data/docs/GemGemPublication.md +19 -0
  14. data/docs/GemGemPublicationResponse.md +23 -0
  15. data/docs/GemGemRemote.md +63 -0
  16. data/docs/GemGemRemoteResponse.md +61 -0
  17. data/docs/GemGemRemoteResponseHiddenFields.md +19 -0
  18. data/docs/GemGemRepository.md +25 -0
  19. data/docs/GemGemRepositoryResponse.md +33 -0
  20. data/docs/PaginatedRepositoryVersionResponseList.md +23 -0
  21. data/docs/PaginatedgemGemContentResponseList.md +23 -0
  22. data/docs/PaginatedgemGemDistributionResponseList.md +23 -0
  23. data/docs/PaginatedgemGemPublicationResponseList.md +23 -0
  24. data/docs/PaginatedgemGemRemoteResponseList.md +23 -0
  25. data/docs/PaginatedgemGemRepositoryResponseList.md +23 -0
  26. data/docs/PatchedgemGemDistribution.md +31 -0
  27. data/docs/PatchedgemGemRemote.md +63 -0
  28. data/docs/PatchedgemGemRepository.md +25 -0
  29. data/docs/PolicyEnum.md +16 -0
  30. data/docs/PublicationsGemApi.md +263 -0
  31. data/docs/RemotesGemApi.md +380 -0
  32. data/docs/Repair.md +17 -0
  33. data/docs/RepositoriesGemApi.md +502 -0
  34. data/docs/RepositoriesGemVersionsApi.md +273 -0
  35. data/docs/RepositoryAddRemoveContent.md +21 -0
  36. data/docs/RepositorySyncURL.md +19 -0
  37. data/docs/RepositoryVersionResponse.md +27 -0
  38. data/lib/pulp_gem_client/api/content_gem_api.rb +259 -0
  39. data/lib/pulp_gem_client/api/distributions_gem_api.rb +476 -0
  40. data/lib/pulp_gem_client/api/publications_gem_api.rb +325 -0
  41. data/lib/pulp_gem_client/api/remotes_gem_api.rb +473 -0
  42. data/lib/pulp_gem_client/api/repositories_gem_api.rb +628 -0
  43. data/lib/pulp_gem_client/api/repositories_gem_versions_api.rb +346 -0
  44. data/lib/pulp_gem_client/api_client.rb +403 -0
  45. data/lib/pulp_gem_client/api_error.rb +57 -0
  46. data/lib/pulp_gem_client/configuration.rb +251 -0
  47. data/lib/pulp_gem_client/models/async_operation_response.rb +213 -0
  48. data/lib/pulp_gem_client/models/content_summary_response.rb +246 -0
  49. data/lib/pulp_gem_client/models/gem_gem_content.rb +228 -0
  50. data/lib/pulp_gem_client/models/gem_gem_content_response.rb +303 -0
  51. data/lib/pulp_gem_client/models/gem_gem_distribution.rb +333 -0
  52. data/lib/pulp_gem_client/models/gem_gem_distribution_response.rb +324 -0
  53. data/lib/pulp_gem_client/models/gem_gem_publication.rb +217 -0
  54. data/lib/pulp_gem_client/models/gem_gem_publication_response.rb +236 -0
  55. data/lib/pulp_gem_client/models/gem_gem_remote.rb +704 -0
  56. data/lib/pulp_gem_client/models/gem_gem_remote_response.rb +532 -0
  57. data/lib/pulp_gem_client/models/gem_gem_remote_response_hidden_fields.rb +215 -0
  58. data/lib/pulp_gem_client/models/gem_gem_repository.rb +306 -0
  59. data/lib/pulp_gem_client/models/gem_gem_repository_response.rb +309 -0
  60. data/lib/pulp_gem_client/models/paginated_repository_version_response_list.rb +237 -0
  61. data/lib/pulp_gem_client/models/paginatedgem_gem_content_response_list.rb +237 -0
  62. data/lib/pulp_gem_client/models/paginatedgem_gem_distribution_response_list.rb +237 -0
  63. data/lib/pulp_gem_client/models/paginatedgem_gem_publication_response_list.rb +237 -0
  64. data/lib/pulp_gem_client/models/paginatedgem_gem_remote_response_list.rb +237 -0
  65. data/lib/pulp_gem_client/models/paginatedgem_gem_repository_response_list.rb +237 -0
  66. data/lib/pulp_gem_client/models/patchedgem_gem_distribution.rb +315 -0
  67. data/lib/pulp_gem_client/models/patchedgem_gem_remote.rb +686 -0
  68. data/lib/pulp_gem_client/models/patchedgem_gem_repository.rb +297 -0
  69. data/lib/pulp_gem_client/models/policy_enum.rb +37 -0
  70. data/lib/pulp_gem_client/models/repair.rb +209 -0
  71. data/lib/pulp_gem_client/models/repository_add_remove_content.rb +232 -0
  72. data/lib/pulp_gem_client/models/repository_sync_url.rb +220 -0
  73. data/lib/pulp_gem_client/models/repository_version_response.rb +255 -0
  74. data/lib/pulp_gem_client/version.rb +15 -0
  75. data/lib/pulp_gem_client.rb +72 -0
  76. data/pulp_gem_client.gemspec +39 -0
  77. data/spec/api/content_gem_api_spec.rb +88 -0
  78. data/spec/api/distributions_gem_api_spec.rb +130 -0
  79. data/spec/api/publications_gem_api_spec.rb +101 -0
  80. data/spec/api/remotes_gem_api_spec.rb +129 -0
  81. data/spec/api/repositories_gem_api_spec.rb +160 -0
  82. data/spec/api/repositories_gem_versions_api_spec.rb +105 -0
  83. data/spec/api_client_spec.rb +188 -0
  84. data/spec/configuration_spec.rb +42 -0
  85. data/spec/models/async_operation_response_spec.rb +41 -0
  86. data/spec/models/content_summary_response_spec.rb +53 -0
  87. data/spec/models/gem_gem_content_response_spec.rb +95 -0
  88. data/spec/models/gem_gem_content_spec.rb +53 -0
  89. data/spec/models/gem_gem_distribution_response_spec.rb +101 -0
  90. data/spec/models/gem_gem_distribution_spec.rb +83 -0
  91. data/spec/models/gem_gem_publication_response_spec.rb +59 -0
  92. data/spec/models/gem_gem_publication_spec.rb +47 -0
  93. data/spec/models/gem_gem_remote_response_hidden_fields_spec.rb +47 -0
  94. data/spec/models/gem_gem_remote_response_spec.rb +173 -0
  95. data/spec/models/gem_gem_remote_spec.rb +179 -0
  96. data/spec/models/gem_gem_repository_response_spec.rb +89 -0
  97. data/spec/models/gem_gem_repository_spec.rb +65 -0
  98. data/spec/models/paginated_repository_version_response_list_spec.rb +59 -0
  99. data/spec/models/paginatedgem_gem_content_response_list_spec.rb +59 -0
  100. data/spec/models/paginatedgem_gem_distribution_response_list_spec.rb +59 -0
  101. data/spec/models/paginatedgem_gem_publication_response_list_spec.rb +59 -0
  102. data/spec/models/paginatedgem_gem_remote_response_list_spec.rb +59 -0
  103. data/spec/models/paginatedgem_gem_repository_response_list_spec.rb +59 -0
  104. data/spec/models/patchedgem_gem_distribution_spec.rb +83 -0
  105. data/spec/models/patchedgem_gem_remote_spec.rb +179 -0
  106. data/spec/models/patchedgem_gem_repository_spec.rb +65 -0
  107. data/spec/models/policy_enum_spec.rb +35 -0
  108. data/spec/models/repair_spec.rb +41 -0
  109. data/spec/models/repository_add_remove_content_spec.rb +53 -0
  110. data/spec/models/repository_sync_url_spec.rb +47 -0
  111. data/spec/models/repository_version_response_spec.rb +71 -0
  112. data/spec/spec_helper.rb +111 -0
  113. metadata +250 -0
@@ -0,0 +1,324 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpGemClient
16
+ # A Serializer for GemDistribution.
17
+ class GemGemDistributionResponse
18
+ attr_accessor :pulp_href
19
+
20
+ # Timestamp of creation.
21
+ attr_accessor :pulp_created
22
+
23
+ # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
24
+ attr_accessor :base_path
25
+
26
+ # The URL for accessing the publication as defined by this distribution.
27
+ attr_accessor :base_url
28
+
29
+ # An optional content-guard.
30
+ attr_accessor :content_guard
31
+
32
+ # Whether this distribution should be shown in the content app.
33
+ attr_accessor :hidden
34
+
35
+ attr_accessor :pulp_labels
36
+
37
+ # A unique name. Ex, `rawhide` and `stable`.
38
+ attr_accessor :name
39
+
40
+ # The latest RepositoryVersion for this Repository will be served.
41
+ attr_accessor :repository
42
+
43
+ # Publication to be served
44
+ attr_accessor :publication
45
+
46
+ # Remote that can be used to fetch content when using pull-through caching.
47
+ attr_accessor :remote
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'pulp_href' => :'pulp_href',
53
+ :'pulp_created' => :'pulp_created',
54
+ :'base_path' => :'base_path',
55
+ :'base_url' => :'base_url',
56
+ :'content_guard' => :'content_guard',
57
+ :'hidden' => :'hidden',
58
+ :'pulp_labels' => :'pulp_labels',
59
+ :'name' => :'name',
60
+ :'repository' => :'repository',
61
+ :'publication' => :'publication',
62
+ :'remote' => :'remote'
63
+ }
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'pulp_href' => :'String',
70
+ :'pulp_created' => :'DateTime',
71
+ :'base_path' => :'String',
72
+ :'base_url' => :'String',
73
+ :'content_guard' => :'String',
74
+ :'hidden' => :'Boolean',
75
+ :'pulp_labels' => :'Hash<String, String>',
76
+ :'name' => :'String',
77
+ :'repository' => :'String',
78
+ :'publication' => :'String',
79
+ :'remote' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ :'content_guard',
87
+ :'repository',
88
+ :'publication',
89
+ :'remote'
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpGemClient::GemGemDistributionResponse` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpGemClient::GemGemDistributionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'pulp_href')
109
+ self.pulp_href = attributes[:'pulp_href']
110
+ end
111
+
112
+ if attributes.key?(:'pulp_created')
113
+ self.pulp_created = attributes[:'pulp_created']
114
+ end
115
+
116
+ if attributes.key?(:'base_path')
117
+ self.base_path = attributes[:'base_path']
118
+ end
119
+
120
+ if attributes.key?(:'base_url')
121
+ self.base_url = attributes[:'base_url']
122
+ end
123
+
124
+ if attributes.key?(:'content_guard')
125
+ self.content_guard = attributes[:'content_guard']
126
+ end
127
+
128
+ if attributes.key?(:'hidden')
129
+ self.hidden = attributes[:'hidden']
130
+ else
131
+ self.hidden = false
132
+ end
133
+
134
+ if attributes.key?(:'pulp_labels')
135
+ if (value = attributes[:'pulp_labels']).is_a?(Hash)
136
+ self.pulp_labels = value
137
+ end
138
+ end
139
+
140
+ if attributes.key?(:'name')
141
+ self.name = attributes[:'name']
142
+ end
143
+
144
+ if attributes.key?(:'repository')
145
+ self.repository = attributes[:'repository']
146
+ end
147
+
148
+ if attributes.key?(:'publication')
149
+ self.publication = attributes[:'publication']
150
+ end
151
+
152
+ if attributes.key?(:'remote')
153
+ self.remote = attributes[:'remote']
154
+ end
155
+ end
156
+
157
+ # Show invalid properties with the reasons. Usually used together with valid?
158
+ # @return Array for valid properties with the reasons
159
+ def list_invalid_properties
160
+ invalid_properties = Array.new
161
+ if @base_path.nil?
162
+ invalid_properties.push('invalid value for "base_path", base_path cannot be nil.')
163
+ end
164
+
165
+ if @name.nil?
166
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
167
+ end
168
+
169
+ invalid_properties
170
+ end
171
+
172
+ # Check to see if the all the properties in the model are valid
173
+ # @return true if the model is valid
174
+ def valid?
175
+ return false if @base_path.nil?
176
+ return false if @name.nil?
177
+ true
178
+ end
179
+
180
+ # Checks equality by comparing each attribute.
181
+ # @param [Object] Object to be compared
182
+ def ==(o)
183
+ return true if self.equal?(o)
184
+ self.class == o.class &&
185
+ pulp_href == o.pulp_href &&
186
+ pulp_created == o.pulp_created &&
187
+ base_path == o.base_path &&
188
+ base_url == o.base_url &&
189
+ content_guard == o.content_guard &&
190
+ hidden == o.hidden &&
191
+ pulp_labels == o.pulp_labels &&
192
+ name == o.name &&
193
+ repository == o.repository &&
194
+ publication == o.publication &&
195
+ remote == o.remote
196
+ end
197
+
198
+ # @see the `==` method
199
+ # @param [Object] Object to be compared
200
+ def eql?(o)
201
+ self == o
202
+ end
203
+
204
+ # Calculates hash code according to all attributes.
205
+ # @return [Integer] Hash code
206
+ def hash
207
+ [pulp_href, pulp_created, base_path, base_url, content_guard, hidden, pulp_labels, name, repository, publication, remote].hash
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def self.build_from_hash(attributes)
214
+ new.build_from_hash(attributes)
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def build_from_hash(attributes)
221
+ return nil unless attributes.is_a?(Hash)
222
+ self.class.openapi_types.each_pair do |key, type|
223
+ if type =~ /\AArray<(.*)>/i
224
+ # check to ensure the input is an array given that the attribute
225
+ # is documented as an array but the input is not
226
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
227
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
228
+ end
229
+ elsif !attributes[self.class.attribute_map[key]].nil?
230
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
231
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
232
+ end
233
+
234
+ self
235
+ end
236
+
237
+ # Deserializes the data based on type
238
+ # @param string type Data type
239
+ # @param string value Value to be deserialized
240
+ # @return [Object] Deserialized data
241
+ def _deserialize(type, value)
242
+ case type.to_sym
243
+ when :DateTime
244
+ DateTime.parse(value)
245
+ when :Date
246
+ Date.parse(value)
247
+ when :String
248
+ value.to_s
249
+ when :Integer
250
+ value.to_i
251
+ when :Float
252
+ value.to_f
253
+ when :Boolean
254
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
255
+ true
256
+ else
257
+ false
258
+ end
259
+ when :Object
260
+ # generic object (usually a Hash), return directly
261
+ value
262
+ when /\AArray<(?<inner_type>.+)>\z/
263
+ inner_type = Regexp.last_match[:inner_type]
264
+ value.map { |v| _deserialize(inner_type, v) }
265
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
266
+ k_type = Regexp.last_match[:k_type]
267
+ v_type = Regexp.last_match[:v_type]
268
+ {}.tap do |hash|
269
+ value.each do |k, v|
270
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
271
+ end
272
+ end
273
+ else # model
274
+ PulpGemClient.const_get(type).build_from_hash(value)
275
+ end
276
+ end
277
+
278
+ # Returns the string representation of the object
279
+ # @return [String] String presentation of the object
280
+ def to_s
281
+ to_hash.to_s
282
+ end
283
+
284
+ # to_body is an alias to to_hash (backward compatibility)
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_body
287
+ to_hash
288
+ end
289
+
290
+ # Returns the object in the form of hash
291
+ # @return [Hash] Returns the object in the form of hash
292
+ def to_hash
293
+ hash = {}
294
+ self.class.attribute_map.each_pair do |attr, param|
295
+ value = self.send(attr)
296
+ if value.nil?
297
+ is_nullable = self.class.openapi_nullable.include?(attr)
298
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
299
+ end
300
+
301
+ hash[param] = _to_hash(value)
302
+ end
303
+ hash
304
+ end
305
+
306
+ # Outputs non-array value in the form of hash
307
+ # For object, use to_hash. Otherwise, just return the value
308
+ # @param [Object] value Any valid value
309
+ # @return [Hash] Returns the value in the form of hash
310
+ def _to_hash(value)
311
+ if value.is_a?(Array)
312
+ value.compact.map { |v| _to_hash(v) }
313
+ elsif value.is_a?(Hash)
314
+ {}.tap do |hash|
315
+ value.each { |k, v| hash[k] = _to_hash(v) }
316
+ end
317
+ elsif value.respond_to? :to_hash
318
+ value.to_hash
319
+ else
320
+ value
321
+ end
322
+ end
323
+ end
324
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpGemClient
16
+ # A Serializer for GemPublication.
17
+ class GemGemPublication
18
+ attr_accessor :repository_version
19
+
20
+ # A URI of the repository to be published.
21
+ attr_accessor :repository
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'repository_version' => :'repository_version',
27
+ :'repository' => :'repository'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'repository_version' => :'String',
35
+ :'repository' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpGemClient::GemGemPublication` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpGemClient::GemGemPublication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'repository_version')
61
+ self.repository_version = attributes[:'repository_version']
62
+ end
63
+
64
+ if attributes.key?(:'repository')
65
+ self.repository = attributes[:'repository']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ repository_version == o.repository_version &&
88
+ repository == o.repository
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [repository_version, repository].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ PulpGemClient.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end