zest 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +185 -0
  4. data/Rakefile +8 -0
  5. data/api.json +1 -0
  6. data/config.json +6 -0
  7. data/docs/Artifact.md +17 -0
  8. data/docs/AsyncOperationResponse.md +8 -0
  9. data/docs/Distribution.md +16 -0
  10. data/docs/FileContent.md +12 -0
  11. data/docs/FilePublisher.md +14 -0
  12. data/docs/FileRemote.md +23 -0
  13. data/docs/InlineResponse200.md +11 -0
  14. data/docs/InlineResponse2001.md +11 -0
  15. data/docs/InlineResponse20010.md +11 -0
  16. data/docs/InlineResponse2002.md +11 -0
  17. data/docs/InlineResponse2003.md +11 -0
  18. data/docs/InlineResponse2004.md +11 -0
  19. data/docs/InlineResponse2005.md +11 -0
  20. data/docs/InlineResponse2006.md +11 -0
  21. data/docs/InlineResponse2007.md +11 -0
  22. data/docs/InlineResponse2008.md +11 -0
  23. data/docs/InlineResponse2009.md +11 -0
  24. data/docs/ProgressReport.md +13 -0
  25. data/docs/Publication.md +13 -0
  26. data/docs/PulpApi.md +3056 -0
  27. data/docs/Repository.md +13 -0
  28. data/docs/RepositoryPublishURL.md +9 -0
  29. data/docs/RepositorySyncURL.md +9 -0
  30. data/docs/RepositoryVersion.md +17 -0
  31. data/docs/RepositoryVersionCreate.md +10 -0
  32. data/docs/Task.md +21 -0
  33. data/docs/User.md +11 -0
  34. data/docs/Worker.md +13 -0
  35. data/git_push.sh +55 -0
  36. data/katello_pulp_api-0.0.1.gem +0 -0
  37. data/katello_pulp_api.gemspec +46 -0
  38. data/lib/katello_pulp_api.rb +67 -0
  39. data/lib/katello_pulp_api/api/pulp_api.rb +3277 -0
  40. data/lib/katello_pulp_api/api_client.rb +389 -0
  41. data/lib/katello_pulp_api/api_error.rb +38 -0
  42. data/lib/katello_pulp_api/configuration.rb +209 -0
  43. data/lib/katello_pulp_api/models/artifact.rb +278 -0
  44. data/lib/katello_pulp_api/models/async_operation_response.rb +194 -0
  45. data/lib/katello_pulp_api/models/distribution.rb +350 -0
  46. data/lib/katello_pulp_api/models/file_content.rb +272 -0
  47. data/lib/katello_pulp_api/models/file_publisher.rb +306 -0
  48. data/lib/katello_pulp_api/models/file_remote.rb +452 -0
  49. data/lib/katello_pulp_api/models/inline_response_200.rb +227 -0
  50. data/lib/katello_pulp_api/models/inline_response_200_1.rb +227 -0
  51. data/lib/katello_pulp_api/models/inline_response_200_10.rb +227 -0
  52. data/lib/katello_pulp_api/models/inline_response_200_2.rb +227 -0
  53. data/lib/katello_pulp_api/models/inline_response_200_3.rb +227 -0
  54. data/lib/katello_pulp_api/models/inline_response_200_4.rb +227 -0
  55. data/lib/katello_pulp_api/models/inline_response_200_5.rb +227 -0
  56. data/lib/katello_pulp_api/models/inline_response_200_6.rb +227 -0
  57. data/lib/katello_pulp_api/models/inline_response_200_7.rb +227 -0
  58. data/lib/katello_pulp_api/models/inline_response_200_8.rb +227 -0
  59. data/lib/katello_pulp_api/models/inline_response_200_9.rb +227 -0
  60. data/lib/katello_pulp_api/models/progress_report.rb +271 -0
  61. data/lib/katello_pulp_api/models/publication.rb +249 -0
  62. data/lib/katello_pulp_api/models/repository.rb +260 -0
  63. data/lib/katello_pulp_api/models/repository_publish_url.rb +199 -0
  64. data/lib/katello_pulp_api/models/repository_sync_url.rb +206 -0
  65. data/lib/katello_pulp_api/models/repository_version.rb +277 -0
  66. data/lib/katello_pulp_api/models/repository_version_create.rb +223 -0
  67. data/lib/katello_pulp_api/models/task.rb +363 -0
  68. data/lib/katello_pulp_api/models/user.rb +284 -0
  69. data/lib/katello_pulp_api/models/worker.rb +254 -0
  70. data/lib/katello_pulp_api/version.rb +15 -0
  71. data/lib/zest.rb +67 -0
  72. data/lib/zest/api/pulp_api.rb +3277 -0
  73. data/lib/zest/api_client.rb +389 -0
  74. data/lib/zest/api_error.rb +38 -0
  75. data/lib/zest/configuration.rb +209 -0
  76. data/lib/zest/models/artifact.rb +278 -0
  77. data/lib/zest/models/async_operation_response.rb +194 -0
  78. data/lib/zest/models/distribution.rb +350 -0
  79. data/lib/zest/models/file_content.rb +272 -0
  80. data/lib/zest/models/file_publisher.rb +306 -0
  81. data/lib/zest/models/file_remote.rb +452 -0
  82. data/lib/zest/models/inline_response_200.rb +227 -0
  83. data/lib/zest/models/inline_response_200_1.rb +227 -0
  84. data/lib/zest/models/inline_response_200_10.rb +227 -0
  85. data/lib/zest/models/inline_response_200_2.rb +227 -0
  86. data/lib/zest/models/inline_response_200_3.rb +227 -0
  87. data/lib/zest/models/inline_response_200_4.rb +227 -0
  88. data/lib/zest/models/inline_response_200_5.rb +227 -0
  89. data/lib/zest/models/inline_response_200_6.rb +227 -0
  90. data/lib/zest/models/inline_response_200_7.rb +227 -0
  91. data/lib/zest/models/inline_response_200_8.rb +227 -0
  92. data/lib/zest/models/inline_response_200_9.rb +227 -0
  93. data/lib/zest/models/progress_report.rb +271 -0
  94. data/lib/zest/models/publication.rb +249 -0
  95. data/lib/zest/models/repository.rb +260 -0
  96. data/lib/zest/models/repository_publish_url.rb +199 -0
  97. data/lib/zest/models/repository_sync_url.rb +206 -0
  98. data/lib/zest/models/repository_version.rb +277 -0
  99. data/lib/zest/models/repository_version_create.rb +223 -0
  100. data/lib/zest/models/task.rb +363 -0
  101. data/lib/zest/models/user.rb +284 -0
  102. data/lib/zest/models/worker.rb +254 -0
  103. data/lib/zest/version.rb +15 -0
  104. data/spec/api/pulp_api_spec.rb +784 -0
  105. data/spec/api_client_spec.rb +226 -0
  106. data/spec/configuration_spec.rb +42 -0
  107. data/spec/models/artifact_spec.rb +96 -0
  108. data/spec/models/async_operation_response_spec.rb +42 -0
  109. data/spec/models/distribution_spec.rb +90 -0
  110. data/spec/models/file_content_spec.rb +66 -0
  111. data/spec/models/file_publisher_spec.rb +78 -0
  112. data/spec/models/file_remote_spec.rb +136 -0
  113. data/spec/models/inline_response_200_10_spec.rb +60 -0
  114. data/spec/models/inline_response_200_1_spec.rb +60 -0
  115. data/spec/models/inline_response_200_2_spec.rb +60 -0
  116. data/spec/models/inline_response_200_3_spec.rb +60 -0
  117. data/spec/models/inline_response_200_4_spec.rb +60 -0
  118. data/spec/models/inline_response_200_5_spec.rb +60 -0
  119. data/spec/models/inline_response_200_6_spec.rb +60 -0
  120. data/spec/models/inline_response_200_7_spec.rb +60 -0
  121. data/spec/models/inline_response_200_8_spec.rb +60 -0
  122. data/spec/models/inline_response_200_9_spec.rb +60 -0
  123. data/spec/models/inline_response_200_spec.rb +60 -0
  124. data/spec/models/progress_report_spec.rb +72 -0
  125. data/spec/models/publication_spec.rb +72 -0
  126. data/spec/models/repository_publish_url_spec.rb +48 -0
  127. data/spec/models/repository_spec.rb +72 -0
  128. data/spec/models/repository_sync_url_spec.rb +48 -0
  129. data/spec/models/repository_version_create_spec.rb +54 -0
  130. data/spec/models/repository_version_spec.rb +96 -0
  131. data/spec/models/task_spec.rb +120 -0
  132. data/spec/models/user_spec.rb +60 -0
  133. data/spec/models/worker_spec.rb +72 -0
  134. data/spec/spec_helper.rb +111 -0
  135. data/zest.gemspec +46 -0
  136. metadata +391 -0
@@ -0,0 +1,284 @@
1
+ =begin
2
+ #Pulp3 API
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module KatelloPulpApi
16
+
17
+ class User
18
+ attr_accessor :_href
19
+
20
+ # Timestamp of creation.
21
+ attr_accessor :_created
22
+
23
+ # Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
24
+ attr_accessor :username
25
+
26
+ # Password
27
+ attr_accessor :password
28
+
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'_href' => :'_href',
34
+ :'_created' => :'_created',
35
+ :'username' => :'username',
36
+ :'password' => :'password'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'_href' => :'String',
44
+ :'_created' => :'DateTime',
45
+ :'username' => :'String',
46
+ :'password' => :'String'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
57
+
58
+ if attributes.has_key?(:'_href')
59
+ self._href = attributes[:'_href']
60
+ end
61
+
62
+ if attributes.has_key?(:'_created')
63
+ self._created = attributes[:'_created']
64
+ end
65
+
66
+ if attributes.has_key?(:'username')
67
+ self.username = attributes[:'username']
68
+ end
69
+
70
+ if attributes.has_key?(:'password')
71
+ self.password = attributes[:'password']
72
+ end
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ if @username.nil?
81
+ invalid_properties.push("invalid value for 'username', username cannot be nil.")
82
+ end
83
+
84
+ if @username.to_s.length > 150
85
+ invalid_properties.push("invalid value for 'username', the character length must be smaller than or equal to 150.")
86
+ end
87
+
88
+ if @username.to_s.length < 1
89
+ invalid_properties.push("invalid value for 'username', the character length must be great than or equal to 1.")
90
+ end
91
+
92
+ if @username !~ Regexp.new(/^[\\w.@+-]+$/)
93
+ invalid_properties.push("invalid value for 'username', must conform to the pattern /^[\\w.@+-]+$/.")
94
+ end
95
+
96
+ if @password.nil?
97
+ invalid_properties.push("invalid value for 'password', password cannot be nil.")
98
+ end
99
+
100
+ if @password.to_s.length < 1
101
+ invalid_properties.push("invalid value for 'password', the character length must be great than or equal to 1.")
102
+ end
103
+
104
+ return invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ return false if @username.nil?
111
+ return false if @username.to_s.length > 150
112
+ return false if @username.to_s.length < 1
113
+ return false if @username !~ Regexp.new(/^[\\w.@+-]+$/)
114
+ return false if @password.nil?
115
+ return false if @password.to_s.length < 1
116
+ return true
117
+ end
118
+
119
+ # Custom attribute writer method with validation
120
+ # @param [Object] username Value to be assigned
121
+ def username=(username)
122
+ if username.nil?
123
+ fail ArgumentError, "username cannot be nil"
124
+ end
125
+
126
+ if username.to_s.length > 150
127
+ fail ArgumentError, "invalid value for 'username', the character length must be smaller than or equal to 150."
128
+ end
129
+
130
+ if username.to_s.length < 1
131
+ fail ArgumentError, "invalid value for 'username', the character length must be great than or equal to 1."
132
+ end
133
+
134
+ if username !~ Regexp.new(/^[\\w.@+-]+$/)
135
+ fail ArgumentError, "invalid value for 'username', must conform to the pattern /^[\\w.@+-]+$/."
136
+ end
137
+
138
+ @username = username
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] password Value to be assigned
143
+ def password=(password)
144
+ if password.nil?
145
+ fail ArgumentError, "password cannot be nil"
146
+ end
147
+
148
+ if password.to_s.length < 1
149
+ fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 1."
150
+ end
151
+
152
+ @password = password
153
+ end
154
+
155
+ # Checks equality by comparing each attribute.
156
+ # @param [Object] Object to be compared
157
+ def ==(o)
158
+ return true if self.equal?(o)
159
+ self.class == o.class &&
160
+ _href == o._href &&
161
+ _created == o._created &&
162
+ username == o.username &&
163
+ password == o.password
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Fixnum] Hash code
174
+ def hash
175
+ [_href, _created, username, password].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ self.class.swagger_types.each_pair do |key, type|
184
+ if type =~ /\AArray<(.*)>/i
185
+ # check to ensure the input is an array given that the the attribute
186
+ # is documented as an array but the input is not
187
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
188
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
189
+ end
190
+ elsif !attributes[self.class.attribute_map[key]].nil?
191
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
192
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
193
+ end
194
+
195
+ self
196
+ end
197
+
198
+ # Deserializes the data based on type
199
+ # @param string type Data type
200
+ # @param string value Value to be deserialized
201
+ # @return [Object] Deserialized data
202
+ def _deserialize(type, value)
203
+ case type.to_sym
204
+ when :DateTime
205
+ DateTime.parse(value)
206
+ when :Date
207
+ Date.parse(value)
208
+ when :String
209
+ value.to_s
210
+ when :Integer
211
+ value.to_i
212
+ when :Float
213
+ value.to_f
214
+ when :BOOLEAN
215
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
+ true
217
+ else
218
+ false
219
+ end
220
+ when :Object
221
+ # generic object (usually a Hash), return directly
222
+ value
223
+ when /\AArray<(?<inner_type>.+)>\z/
224
+ inner_type = Regexp.last_match[:inner_type]
225
+ value.map { |v| _deserialize(inner_type, v) }
226
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
+ k_type = Regexp.last_match[:k_type]
228
+ v_type = Regexp.last_match[:v_type]
229
+ {}.tap do |hash|
230
+ value.each do |k, v|
231
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
+ end
233
+ end
234
+ else # model
235
+ temp_model = KatelloPulpApi.const_get(type).new
236
+ temp_model.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ next if value.nil?
259
+ hash[param] = _to_hash(value)
260
+ end
261
+ hash
262
+ end
263
+
264
+ # Outputs non-array value in the form of hash
265
+ # For object, use to_hash. Otherwise, just return the value
266
+ # @param [Object] value Any valid value
267
+ # @return [Hash] Returns the value in the form of hash
268
+ def _to_hash(value)
269
+ if value.is_a?(Array)
270
+ value.compact.map{ |v| _to_hash(v) }
271
+ elsif value.is_a?(Hash)
272
+ {}.tap do |hash|
273
+ value.each { |k, v| hash[k] = _to_hash(v) }
274
+ end
275
+ elsif value.respond_to? :to_hash
276
+ value.to_hash
277
+ else
278
+ value
279
+ end
280
+ end
281
+
282
+ end
283
+
284
+ end
@@ -0,0 +1,254 @@
1
+ =begin
2
+ #Pulp3 API
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module KatelloPulpApi
16
+
17
+ class Worker
18
+ attr_accessor :_href
19
+
20
+ # Timestamp of creation.
21
+ attr_accessor :_created
22
+
23
+ # The name of the worker.
24
+ attr_accessor :name
25
+
26
+ # Timestamp of the last time the worker talked to the service.
27
+ attr_accessor :last_heartbeat
28
+
29
+ # True if the worker is considered online, otherwise False
30
+ attr_accessor :online
31
+
32
+ # True if the worker is considerd missing, otherwise False
33
+ attr_accessor :missing
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'_href' => :'_href',
40
+ :'_created' => :'_created',
41
+ :'name' => :'name',
42
+ :'last_heartbeat' => :'last_heartbeat',
43
+ :'online' => :'online',
44
+ :'missing' => :'missing'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.swagger_types
50
+ {
51
+ :'_href' => :'String',
52
+ :'_created' => :'DateTime',
53
+ :'name' => :'String',
54
+ :'last_heartbeat' => :'DateTime',
55
+ :'online' => :'BOOLEAN',
56
+ :'missing' => :'BOOLEAN'
57
+ }
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ return unless attributes.is_a?(Hash)
64
+
65
+ # convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
67
+
68
+ if attributes.has_key?(:'_href')
69
+ self._href = attributes[:'_href']
70
+ end
71
+
72
+ if attributes.has_key?(:'_created')
73
+ self._created = attributes[:'_created']
74
+ end
75
+
76
+ if attributes.has_key?(:'name')
77
+ self.name = attributes[:'name']
78
+ end
79
+
80
+ if attributes.has_key?(:'last_heartbeat')
81
+ self.last_heartbeat = attributes[:'last_heartbeat']
82
+ end
83
+
84
+ if attributes.has_key?(:'online')
85
+ self.online = attributes[:'online']
86
+ end
87
+
88
+ if attributes.has_key?(:'missing')
89
+ self.missing = attributes[:'missing']
90
+ end
91
+
92
+ end
93
+
94
+ # Show invalid properties with the reasons. Usually used together with valid?
95
+ # @return Array for valid properties with the reasons
96
+ def list_invalid_properties
97
+ invalid_properties = Array.new
98
+ if !@name.nil? && @name.to_s.length < 1
99
+ invalid_properties.push("invalid value for 'name', the character length must be great than or equal to 1.")
100
+ end
101
+
102
+ return 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 !@name.nil? && @name.to_s.length < 1
109
+ return true
110
+ end
111
+
112
+ # Custom attribute writer method with validation
113
+ # @param [Object] name Value to be assigned
114
+ def name=(name)
115
+
116
+ if !name.nil? && name.to_s.length < 1
117
+ fail ArgumentError, "invalid value for 'name', the character length must be great than or equal to 1."
118
+ end
119
+
120
+ @name = name
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ _href == o._href &&
129
+ _created == o._created &&
130
+ name == o.name &&
131
+ last_heartbeat == o.last_heartbeat &&
132
+ online == o.online &&
133
+ missing == o.missing
134
+ end
135
+
136
+ # @see the `==` method
137
+ # @param [Object] Object to be compared
138
+ def eql?(o)
139
+ self == o
140
+ end
141
+
142
+ # Calculates hash code according to all attributes.
143
+ # @return [Fixnum] Hash code
144
+ def hash
145
+ [_href, _created, name, last_heartbeat, online, missing].hash
146
+ end
147
+
148
+ # Builds the object from hash
149
+ # @param [Hash] attributes Model attributes in the form of hash
150
+ # @return [Object] Returns the model itself
151
+ def build_from_hash(attributes)
152
+ return nil unless attributes.is_a?(Hash)
153
+ self.class.swagger_types.each_pair do |key, type|
154
+ if type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :DateTime
175
+ DateTime.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :BOOLEAN
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ temp_model = KatelloPulpApi.const_get(type).new
206
+ temp_model.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ next if value.nil?
229
+ hash[param] = _to_hash(value)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map{ |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+
252
+ end
253
+
254
+ end