pulp_rpm_client 3.0.0b4 → 3.0.0b5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -6
  3. data/docs/Addon.md +27 -0
  4. data/docs/Artifact.md +35 -0
  5. data/docs/Checksum.md +19 -0
  6. data/docs/ContentAdvisoriesApi.md +12 -6
  7. data/docs/ContentPackagesApi.md +12 -6
  8. data/docs/DistributionTree.md +53 -0
  9. data/docs/DistributionTreesDistributionTreesApi.md +179 -0
  10. data/docs/DistributionsRpmApi.md +14 -8
  11. data/docs/Image.md +23 -0
  12. data/docs/InlineResponse200.md +3 -3
  13. data/docs/InlineResponse2001.md +3 -3
  14. data/docs/InlineResponse2002.md +4 -4
  15. data/docs/InlineResponse2003.md +4 -4
  16. data/docs/InlineResponse2004.md +4 -4
  17. data/docs/InlineResponse2005.md +23 -0
  18. data/docs/InlineResponse2006.md +23 -0
  19. data/docs/Package.md +10 -8
  20. data/docs/PublicationsRpmApi.md +14 -8
  21. data/docs/RemotesRpmApi.md +14 -8
  22. data/docs/RepoMetadataFile.md +31 -0
  23. data/docs/RepoMetadataFilesRepoMetadataFilesApi.md +179 -0
  24. data/docs/Variant.md +37 -0
  25. data/git_push.sh +10 -7
  26. data/lib/pulp_rpm_client/api/content_advisories_api.rb +15 -9
  27. data/lib/pulp_rpm_client/api/content_packages_api.rb +15 -9
  28. data/lib/pulp_rpm_client/api/distribution_trees_distribution_trees_api.rb +212 -0
  29. data/lib/pulp_rpm_client/api/distributions_rpm_api.rb +21 -15
  30. data/lib/pulp_rpm_client/api/publications_rpm_api.rb +19 -13
  31. data/lib/pulp_rpm_client/api/remotes_rpm_api.rb +22 -16
  32. data/lib/pulp_rpm_client/api/repo_metadata_files_repo_metadata_files_api.rb +212 -0
  33. data/lib/pulp_rpm_client/api/rpm_copy_api.rb +2 -2
  34. data/lib/pulp_rpm_client/api/rpm_upload_api.rb +2 -2
  35. data/lib/pulp_rpm_client/api_client.rb +77 -62
  36. data/lib/pulp_rpm_client/api_error.rb +1 -1
  37. data/lib/pulp_rpm_client/configuration.rb +13 -21
  38. data/lib/pulp_rpm_client/models/addon.rb +372 -0
  39. data/lib/pulp_rpm_client/models/artifact.rb +376 -0
  40. data/lib/pulp_rpm_client/models/async_operation_response.rb +1 -1
  41. data/lib/pulp_rpm_client/models/checksum.rb +255 -0
  42. data/lib/pulp_rpm_client/models/distribution_tree.rb +660 -0
  43. data/lib/pulp_rpm_client/models/image.rb +303 -0
  44. data/lib/pulp_rpm_client/models/inline_response200.rb +11 -11
  45. data/lib/pulp_rpm_client/models/inline_response2001.rb +11 -11
  46. data/lib/pulp_rpm_client/models/inline_response2002.rb +12 -12
  47. data/lib/pulp_rpm_client/models/inline_response2003.rb +12 -12
  48. data/lib/pulp_rpm_client/models/inline_response2004.rb +12 -12
  49. data/lib/pulp_rpm_client/models/inline_response2005.rb +235 -0
  50. data/lib/pulp_rpm_client/models/inline_response2006.rb +235 -0
  51. data/lib/pulp_rpm_client/models/package.rb +69 -40
  52. data/lib/pulp_rpm_client/models/repo_metadata_file.rb +381 -0
  53. data/lib/pulp_rpm_client/models/repository_sync_url.rb +1 -1
  54. data/lib/pulp_rpm_client/models/rpm_distribution.rb +1 -1
  55. data/lib/pulp_rpm_client/models/rpm_publication.rb +1 -1
  56. data/lib/pulp_rpm_client/models/rpm_remote.rb +1 -1
  57. data/lib/pulp_rpm_client/models/update_record.rb +1 -1
  58. data/lib/pulp_rpm_client/models/variant.rb +542 -0
  59. data/lib/pulp_rpm_client/version.rb +2 -2
  60. data/lib/pulp_rpm_client.rb +12 -1
  61. data/pulp_rpm_client.gemspec +3 -9
  62. data/spec/api/content_advisories_api_spec.rb +5 -3
  63. data/spec/api/content_packages_api_spec.rb +5 -3
  64. data/spec/api/distribution_trees_distribution_trees_api_spec.rb +74 -0
  65. data/spec/api/distributions_rpm_api_spec.rb +6 -4
  66. data/spec/api/publications_rpm_api_spec.rb +6 -4
  67. data/spec/api/remotes_rpm_api_spec.rb +6 -4
  68. data/spec/api/repo_metadata_files_repo_metadata_files_api_spec.rb +74 -0
  69. data/spec/api/rpm_copy_api_spec.rb +1 -1
  70. data/spec/api/rpm_upload_api_spec.rb +1 -1
  71. data/spec/api_client_spec.rb +1 -39
  72. data/spec/configuration_spec.rb +1 -1
  73. data/spec/models/addon_spec.rb +71 -0
  74. data/spec/models/artifact_spec.rb +95 -0
  75. data/spec/models/async_operation_response_spec.rb +1 -1
  76. data/spec/models/checksum_spec.rb +47 -0
  77. data/spec/models/distribution_tree_spec.rb +149 -0
  78. data/spec/models/image_spec.rb +59 -0
  79. data/spec/models/inline_response2001_spec.rb +4 -4
  80. data/spec/models/inline_response2002_spec.rb +4 -4
  81. data/spec/models/inline_response2003_spec.rb +4 -4
  82. data/spec/models/inline_response2004_spec.rb +4 -4
  83. data/spec/models/inline_response2005_spec.rb +59 -0
  84. data/spec/models/inline_response2006_spec.rb +59 -0
  85. data/spec/models/inline_response200_spec.rb +4 -4
  86. data/spec/models/package_spec.rb +16 -10
  87. data/spec/models/repo_metadata_file_spec.rb +83 -0
  88. data/spec/models/repository_sync_url_spec.rb +1 -1
  89. data/spec/models/rpm_distribution_spec.rb +1 -1
  90. data/spec/models/rpm_publication_spec.rb +1 -1
  91. data/spec/models/rpm_remote_spec.rb +1 -1
  92. data/spec/models/update_record_spec.rb +1 -1
  93. data/spec/models/variant_spec.rb +101 -0
  94. data/spec/spec_helper.rb +1 -1
  95. metadata +50 -133
  96. data/Gemfile.lock +0 -79
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v3
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.0.0
9
+ OpenAPI Generator version: 4.1.3-SNAPSHOT
10
10
 
11
11
  =end
12
12
 
@@ -14,20 +14,20 @@ require 'date'
14
14
 
15
15
  module PulpRpmClient
16
16
  class InlineResponse2004
17
+ attr_accessor :count
18
+
17
19
  attr_accessor :_next
18
20
 
19
21
  attr_accessor :previous
20
22
 
21
- attr_accessor :count
22
-
23
23
  attr_accessor :results
24
24
 
25
25
  # Attribute mapping from ruby-style variable name to JSON key.
26
26
  def self.attribute_map
27
27
  {
28
+ :'count' => :'count',
28
29
  :'_next' => :'next',
29
30
  :'previous' => :'previous',
30
- :'count' => :'count',
31
31
  :'results' => :'results'
32
32
  }
33
33
  end
@@ -35,10 +35,10 @@ module PulpRpmClient
35
35
  # Attribute type mapping.
36
36
  def self.openapi_types
37
37
  {
38
+ :'count' => :'Integer',
38
39
  :'_next' => :'String',
39
40
  :'previous' => :'String',
40
- :'count' => :'Integer',
41
- :'results' => :'Array<RpmRemote>'
41
+ :'results' => :'Array<RpmPublication>'
42
42
  }
43
43
  end
44
44
 
@@ -57,6 +57,10 @@ module PulpRpmClient
57
57
  h[k.to_sym] = v
58
58
  }
59
59
 
60
+ if attributes.key?(:'count')
61
+ self.count = attributes[:'count']
62
+ end
63
+
60
64
  if attributes.key?(:'_next')
61
65
  self._next = attributes[:'_next']
62
66
  end
@@ -65,10 +69,6 @@ module PulpRpmClient
65
69
  self.previous = attributes[:'previous']
66
70
  end
67
71
 
68
- if attributes.key?(:'count')
69
- self.count = attributes[:'count']
70
- end
71
-
72
72
  if attributes.key?(:'results')
73
73
  if (value = attributes[:'results']).is_a?(Array)
74
74
  self.results = value
@@ -104,9 +104,9 @@ module PulpRpmClient
104
104
  def ==(o)
105
105
  return true if self.equal?(o)
106
106
  self.class == o.class &&
107
+ count == o.count &&
107
108
  _next == o._next &&
108
109
  previous == o.previous &&
109
- count == o.count &&
110
110
  results == o.results
111
111
  end
112
112
 
@@ -119,7 +119,7 @@ module PulpRpmClient
119
119
  # Calculates hash code according to all attributes.
120
120
  # @return [Integer] Hash code
121
121
  def hash
122
- [_next, previous, count, results].hash
122
+ [count, _next, previous, results].hash
123
123
  end
124
124
 
125
125
  # Builds the object from hash
@@ -0,0 +1,235 @@
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.1.3-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpRpmClient
16
+ class InlineResponse2005
17
+ attr_accessor :count
18
+
19
+ attr_accessor :_next
20
+
21
+ attr_accessor :previous
22
+
23
+ attr_accessor :results
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'count' => :'count',
29
+ :'_next' => :'next',
30
+ :'previous' => :'previous',
31
+ :'results' => :'results'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'count' => :'Integer',
39
+ :'_next' => :'String',
40
+ :'previous' => :'String',
41
+ :'results' => :'Array<RpmRemote>'
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 `PulpRpmClient::InlineResponse2005` 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 `PulpRpmClient::InlineResponse2005`. 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?(:'count')
61
+ self.count = attributes[:'count']
62
+ end
63
+
64
+ if attributes.key?(:'_next')
65
+ self._next = attributes[:'_next']
66
+ end
67
+
68
+ if attributes.key?(:'previous')
69
+ self.previous = attributes[:'previous']
70
+ end
71
+
72
+ if attributes.key?(:'results')
73
+ if (value = attributes[:'results']).is_a?(Array)
74
+ self.results = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ if @count.nil?
84
+ invalid_properties.push('invalid value for "count", count cannot be nil.')
85
+ end
86
+
87
+ if @results.nil?
88
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if @count.nil?
98
+ return false if @results.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ count == o.count &&
108
+ _next == o._next &&
109
+ previous == o.previous &&
110
+ results == o.results
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [count, _next, previous, results].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ PulpRpmClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,235 @@
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.1.3-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PulpRpmClient
16
+ class InlineResponse2006
17
+ attr_accessor :count
18
+
19
+ attr_accessor :_next
20
+
21
+ attr_accessor :previous
22
+
23
+ attr_accessor :results
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'count' => :'count',
29
+ :'_next' => :'next',
30
+ :'previous' => :'previous',
31
+ :'results' => :'results'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'count' => :'Integer',
39
+ :'_next' => :'String',
40
+ :'previous' => :'String',
41
+ :'results' => :'Array<RepoMetadataFile>'
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 `PulpRpmClient::InlineResponse2006` 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 `PulpRpmClient::InlineResponse2006`. 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?(:'count')
61
+ self.count = attributes[:'count']
62
+ end
63
+
64
+ if attributes.key?(:'_next')
65
+ self._next = attributes[:'_next']
66
+ end
67
+
68
+ if attributes.key?(:'previous')
69
+ self.previous = attributes[:'previous']
70
+ end
71
+
72
+ if attributes.key?(:'results')
73
+ if (value = attributes[:'results']).is_a?(Array)
74
+ self.results = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ if @count.nil?
84
+ invalid_properties.push('invalid value for "count", count cannot be nil.')
85
+ end
86
+
87
+ if @results.nil?
88
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
89
+ end
90
+
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ return false if @count.nil?
98
+ return false if @results.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ count == o.count &&
108
+ _next == o._next &&
109
+ previous == o.previous &&
110
+ results == o.results
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [count, _next, previous, results].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ PulpRpmClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ next if value.nil?
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end