pulpcore_client 3.118.0 → 3.119.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -4
  3. data/docs/ArtifactDistributionResponse.md +20 -20
  4. data/docs/ContentguardsApi.md +4 -4
  5. data/docs/ContentguardsEnvvarHeaderApi.md +810 -0
  6. data/docs/EnvVarHeaderContentGuard.md +24 -0
  7. data/docs/EnvVarHeaderContentGuardResponse.md +32 -0
  8. data/docs/PaginatedEnvVarHeaderContentGuardResponseList.md +24 -0
  9. data/docs/PatchedEnvVarHeaderContentGuard.md +24 -0
  10. data/docs/Purge.md +1 -1
  11. data/lib/pulpcore_client/api/contentguards_api.rb +6 -6
  12. data/lib/pulpcore_client/api/contentguards_envvar_header_api.rb +799 -0
  13. data/lib/pulpcore_client/models/artifact_distribution_response.rb +90 -90
  14. data/lib/pulpcore_client/models/env_var_header_content_guard.rb +340 -0
  15. data/lib/pulpcore_client/models/env_var_header_content_guard_response.rb +307 -0
  16. data/lib/pulpcore_client/models/paginated_env_var_header_content_guard_response_list.rb +257 -0
  17. data/lib/pulpcore_client/models/patched_env_var_header_content_guard.rb +319 -0
  18. data/lib/pulpcore_client/models/purge.rb +1 -1
  19. data/lib/pulpcore_client/version.rb +1 -1
  20. data/lib/pulpcore_client.rb +5 -0
  21. data/spec/api/contentguards_api_spec.rb +2 -2
  22. data/spec/api/contentguards_envvar_header_api_spec.rb +192 -0
  23. data/spec/models/artifact_distribution_response_spec.rb +13 -13
  24. data/spec/models/env_var_header_content_guard_response_spec.rb +78 -0
  25. data/spec/models/env_var_header_content_guard_spec.rb +54 -0
  26. data/spec/models/paginated_env_var_header_content_guard_response_list_spec.rb +54 -0
  27. data/spec/models/patched_env_var_header_content_guard_spec.rb +54 -0
  28. metadata +22 -2
@@ -16,59 +16,59 @@ require 'time'
16
16
  module PulpcoreClient
17
17
  # A serializer for ArtifactDistribution.
18
18
  class ArtifactDistributionResponse
19
- # Timestamp of creation.
20
- attr_accessor :pulp_created
19
+ # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
20
+ attr_accessor :base_path
21
21
 
22
- # Timestamp since when the distributed content served by this distribution has not changed. If equals to `null`, no guarantee is provided about content changes.
23
- attr_accessor :no_content_change_since
22
+ # The Pulp Resource Name (PRN).
23
+ attr_accessor :prn
24
24
 
25
- # RepositoryVersion to be served
26
- attr_accessor :repository_version
25
+ # Whether this distribution should be shown in the content app.
26
+ attr_accessor :hidden
27
+
28
+ attr_accessor :pulp_href
27
29
 
28
30
  # The URL for accessing the publication as defined by this distribution.
29
31
  attr_accessor :base_url
30
32
 
33
+ # An optional content-guard.
34
+ attr_accessor :content_guard
35
+
31
36
  # A unique name. Ex, `rawhide` and `stable`.
32
37
  attr_accessor :name
33
38
 
34
- # The Pulp Resource Name (PRN) of the associated optional content guard.
35
- attr_accessor :content_guard_prn
39
+ attr_accessor :pulp_labels
40
+
41
+ # Timestamp of creation.
42
+ attr_accessor :pulp_created
36
43
 
37
44
  # Timestamp of the last time this resource was updated. Note: for immutable resources - like content, repository versions, and publication - pulp_created and pulp_last_updated dates will be the same.
38
45
  attr_accessor :pulp_last_updated
39
46
 
40
- # An optional content-guard.
41
- attr_accessor :content_guard
42
-
43
- # Whether this distribution should be shown in the content app.
44
- attr_accessor :hidden
45
-
46
- # The Pulp Resource Name (PRN).
47
- attr_accessor :prn
48
-
49
- attr_accessor :pulp_href
47
+ # RepositoryVersion to be served
48
+ attr_accessor :repository_version
50
49
 
51
- # The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")
52
- attr_accessor :base_path
50
+ # Timestamp since when the distributed content served by this distribution has not changed. If equals to `null`, no guarantee is provided about content changes.
51
+ attr_accessor :no_content_change_since
53
52
 
54
- attr_accessor :pulp_labels
53
+ # The Pulp Resource Name (PRN) of the associated optional content guard.
54
+ attr_accessor :content_guard_prn
55
55
 
56
56
  # Attribute mapping from ruby-style variable name to JSON key.
57
57
  def self.attribute_map
58
58
  {
59
- :'pulp_created' => :'pulp_created',
60
- :'no_content_change_since' => :'no_content_change_since',
61
- :'repository_version' => :'repository_version',
59
+ :'base_path' => :'base_path',
60
+ :'prn' => :'prn',
61
+ :'hidden' => :'hidden',
62
+ :'pulp_href' => :'pulp_href',
62
63
  :'base_url' => :'base_url',
64
+ :'content_guard' => :'content_guard',
63
65
  :'name' => :'name',
64
- :'content_guard_prn' => :'content_guard_prn',
66
+ :'pulp_labels' => :'pulp_labels',
67
+ :'pulp_created' => :'pulp_created',
65
68
  :'pulp_last_updated' => :'pulp_last_updated',
66
- :'content_guard' => :'content_guard',
67
- :'hidden' => :'hidden',
68
- :'prn' => :'prn',
69
- :'pulp_href' => :'pulp_href',
70
- :'base_path' => :'base_path',
71
- :'pulp_labels' => :'pulp_labels'
69
+ :'repository_version' => :'repository_version',
70
+ :'no_content_change_since' => :'no_content_change_since',
71
+ :'content_guard_prn' => :'content_guard_prn'
72
72
  }
73
73
  end
74
74
 
@@ -80,27 +80,27 @@ module PulpcoreClient
80
80
  # Attribute type mapping.
81
81
  def self.openapi_types
82
82
  {
83
- :'pulp_created' => :'Time',
84
- :'no_content_change_since' => :'String',
85
- :'repository_version' => :'String',
83
+ :'base_path' => :'String',
84
+ :'prn' => :'String',
85
+ :'hidden' => :'Boolean',
86
+ :'pulp_href' => :'String',
86
87
  :'base_url' => :'String',
88
+ :'content_guard' => :'String',
87
89
  :'name' => :'String',
88
- :'content_guard_prn' => :'String',
90
+ :'pulp_labels' => :'Hash<String, String>',
91
+ :'pulp_created' => :'Time',
89
92
  :'pulp_last_updated' => :'Time',
90
- :'content_guard' => :'String',
91
- :'hidden' => :'Boolean',
92
- :'prn' => :'String',
93
- :'pulp_href' => :'String',
94
- :'base_path' => :'String',
95
- :'pulp_labels' => :'Hash<String, String>'
93
+ :'repository_version' => :'String',
94
+ :'no_content_change_since' => :'String',
95
+ :'content_guard_prn' => :'String'
96
96
  }
97
97
  end
98
98
 
99
99
  # List of attributes with nullable: true
100
100
  def self.openapi_nullable
101
101
  Set.new([
102
- :'repository_version',
103
102
  :'content_guard',
103
+ :'repository_version',
104
104
  ])
105
105
  end
106
106
 
@@ -119,64 +119,64 @@ module PulpcoreClient
119
119
  h[k.to_sym] = v
120
120
  }
121
121
 
122
- if attributes.key?(:'pulp_created')
123
- self.pulp_created = attributes[:'pulp_created']
122
+ if attributes.key?(:'base_path')
123
+ self.base_path = attributes[:'base_path']
124
+ else
125
+ self.base_path = nil
124
126
  end
125
127
 
126
- if attributes.key?(:'no_content_change_since')
127
- self.no_content_change_since = attributes[:'no_content_change_since']
128
+ if attributes.key?(:'prn')
129
+ self.prn = attributes[:'prn']
128
130
  end
129
131
 
130
- if attributes.key?(:'repository_version')
131
- self.repository_version = attributes[:'repository_version']
132
+ if attributes.key?(:'hidden')
133
+ self.hidden = attributes[:'hidden']
134
+ else
135
+ self.hidden = false
136
+ end
137
+
138
+ if attributes.key?(:'pulp_href')
139
+ self.pulp_href = attributes[:'pulp_href']
132
140
  end
133
141
 
134
142
  if attributes.key?(:'base_url')
135
143
  self.base_url = attributes[:'base_url']
136
144
  end
137
145
 
146
+ if attributes.key?(:'content_guard')
147
+ self.content_guard = attributes[:'content_guard']
148
+ end
149
+
138
150
  if attributes.key?(:'name')
139
151
  self.name = attributes[:'name']
140
152
  else
141
153
  self.name = nil
142
154
  end
143
155
 
144
- if attributes.key?(:'content_guard_prn')
145
- self.content_guard_prn = attributes[:'content_guard_prn']
146
- end
147
-
148
- if attributes.key?(:'pulp_last_updated')
149
- self.pulp_last_updated = attributes[:'pulp_last_updated']
150
- end
151
-
152
- if attributes.key?(:'content_guard')
153
- self.content_guard = attributes[:'content_guard']
156
+ if attributes.key?(:'pulp_labels')
157
+ if (value = attributes[:'pulp_labels']).is_a?(Hash)
158
+ self.pulp_labels = value
159
+ end
154
160
  end
155
161
 
156
- if attributes.key?(:'hidden')
157
- self.hidden = attributes[:'hidden']
158
- else
159
- self.hidden = false
162
+ if attributes.key?(:'pulp_created')
163
+ self.pulp_created = attributes[:'pulp_created']
160
164
  end
161
165
 
162
- if attributes.key?(:'prn')
163
- self.prn = attributes[:'prn']
166
+ if attributes.key?(:'pulp_last_updated')
167
+ self.pulp_last_updated = attributes[:'pulp_last_updated']
164
168
  end
165
169
 
166
- if attributes.key?(:'pulp_href')
167
- self.pulp_href = attributes[:'pulp_href']
170
+ if attributes.key?(:'repository_version')
171
+ self.repository_version = attributes[:'repository_version']
168
172
  end
169
173
 
170
- if attributes.key?(:'base_path')
171
- self.base_path = attributes[:'base_path']
172
- else
173
- self.base_path = nil
174
+ if attributes.key?(:'no_content_change_since')
175
+ self.no_content_change_since = attributes[:'no_content_change_since']
174
176
  end
175
177
 
176
- if attributes.key?(:'pulp_labels')
177
- if (value = attributes[:'pulp_labels']).is_a?(Hash)
178
- self.pulp_labels = value
179
- end
178
+ if attributes.key?(:'content_guard_prn')
179
+ self.content_guard_prn = attributes[:'content_guard_prn']
180
180
  end
181
181
  end
182
182
 
@@ -185,14 +185,14 @@ module PulpcoreClient
185
185
  def list_invalid_properties
186
186
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
187
187
  invalid_properties = Array.new
188
- if @name.nil?
189
- invalid_properties.push('invalid value for "name", name cannot be nil.')
190
- end
191
-
192
188
  if @base_path.nil?
193
189
  invalid_properties.push('invalid value for "base_path", base_path cannot be nil.')
194
190
  end
195
191
 
192
+ if @name.nil?
193
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
194
+ end
195
+
196
196
  invalid_properties
197
197
  end
198
198
 
@@ -200,8 +200,8 @@ module PulpcoreClient
200
200
  # @return true if the model is valid
201
201
  def valid?
202
202
  warn '[DEPRECATED] the `valid?` method is obsolete'
203
- return false if @name.nil?
204
203
  return false if @base_path.nil?
204
+ return false if @name.nil?
205
205
  true
206
206
  end
207
207
 
@@ -210,19 +210,19 @@ module PulpcoreClient
210
210
  def ==(o)
211
211
  return true if self.equal?(o)
212
212
  self.class == o.class &&
213
- pulp_created == o.pulp_created &&
214
- no_content_change_since == o.no_content_change_since &&
215
- repository_version == o.repository_version &&
213
+ base_path == o.base_path &&
214
+ prn == o.prn &&
215
+ hidden == o.hidden &&
216
+ pulp_href == o.pulp_href &&
216
217
  base_url == o.base_url &&
218
+ content_guard == o.content_guard &&
217
219
  name == o.name &&
218
- content_guard_prn == o.content_guard_prn &&
220
+ pulp_labels == o.pulp_labels &&
221
+ pulp_created == o.pulp_created &&
219
222
  pulp_last_updated == o.pulp_last_updated &&
220
- content_guard == o.content_guard &&
221
- hidden == o.hidden &&
222
- prn == o.prn &&
223
- pulp_href == o.pulp_href &&
224
- base_path == o.base_path &&
225
- pulp_labels == o.pulp_labels
223
+ repository_version == o.repository_version &&
224
+ no_content_change_since == o.no_content_change_since &&
225
+ content_guard_prn == o.content_guard_prn
226
226
  end
227
227
 
228
228
  # @see the `==` method
@@ -234,7 +234,7 @@ module PulpcoreClient
234
234
  # Calculates hash code according to all attributes.
235
235
  # @return [Integer] Hash code
236
236
  def hash
237
- [pulp_created, no_content_change_since, repository_version, base_url, name, content_guard_prn, pulp_last_updated, content_guard, hidden, prn, pulp_href, base_path, pulp_labels].hash
237
+ [base_path, prn, hidden, pulp_href, base_url, content_guard, name, pulp_labels, pulp_created, pulp_last_updated, repository_version, no_content_change_since, content_guard_prn].hash
238
238
  end
239
239
 
240
240
  # Builds the object from hash
@@ -0,0 +1,340 @@
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
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PulpcoreClient
17
+ # A serializer for EnvVarHeaderContentGuard. The guard expects the request header named ``header_name`` to carry a Base64-encoded UTF-8 representation of the secret. The plaintext secret is read from ``env_var`` on the server at request time and is never stored in or returned by the API.
18
+ class EnvVarHeaderContentGuard
19
+ # The unique name.
20
+ attr_accessor :name
21
+
22
+ # An optional description.
23
+ attr_accessor :description
24
+
25
+ # The header name the guard will check on.
26
+ attr_accessor :header_name
27
+
28
+ # Name of a content-app environment variable holding the expected secret (plaintext UTF-8). Must be listed in ENVVAR_HEADER_CONTENT_GUARD_ALLOWED_VARS. The request header must send that value Base64-encoded. The value is never stored in or returned by the API.
29
+ attr_accessor :env_var
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'name' => :'name',
35
+ :'description' => :'description',
36
+ :'header_name' => :'header_name',
37
+ :'env_var' => :'env_var'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'name' => :'String',
50
+ :'description' => :'String',
51
+ :'header_name' => :'String',
52
+ :'env_var' => :'String'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ :'description',
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::EnvVarHeaderContentGuard` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::EnvVarHeaderContentGuard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'name')
79
+ self.name = attributes[:'name']
80
+ else
81
+ self.name = nil
82
+ end
83
+
84
+ if attributes.key?(:'description')
85
+ self.description = attributes[:'description']
86
+ end
87
+
88
+ if attributes.key?(:'header_name')
89
+ self.header_name = attributes[:'header_name']
90
+ else
91
+ self.header_name = nil
92
+ end
93
+
94
+ if attributes.key?(:'env_var')
95
+ self.env_var = attributes[:'env_var']
96
+ else
97
+ self.env_var = nil
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
105
+ invalid_properties = Array.new
106
+ if @name.nil?
107
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
108
+ end
109
+
110
+ if @name.to_s.length < 1
111
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
112
+ end
113
+
114
+ if !@description.nil? && @description.to_s.length < 1
115
+ invalid_properties.push('invalid value for "description", the character length must be great than or equal to 1.')
116
+ end
117
+
118
+ if @header_name.nil?
119
+ invalid_properties.push('invalid value for "header_name", header_name cannot be nil.')
120
+ end
121
+
122
+ if @header_name.to_s.length < 1
123
+ invalid_properties.push('invalid value for "header_name", the character length must be great than or equal to 1.')
124
+ end
125
+
126
+ if @env_var.nil?
127
+ invalid_properties.push('invalid value for "env_var", env_var cannot be nil.')
128
+ end
129
+
130
+ if @env_var.to_s.length < 1
131
+ invalid_properties.push('invalid value for "env_var", the character length must be great than or equal to 1.')
132
+ end
133
+
134
+ invalid_properties
135
+ end
136
+
137
+ # Check to see if the all the properties in the model are valid
138
+ # @return true if the model is valid
139
+ def valid?
140
+ warn '[DEPRECATED] the `valid?` method is obsolete'
141
+ return false if @name.nil?
142
+ return false if @name.to_s.length < 1
143
+ return false if !@description.nil? && @description.to_s.length < 1
144
+ return false if @header_name.nil?
145
+ return false if @header_name.to_s.length < 1
146
+ return false if @env_var.nil?
147
+ return false if @env_var.to_s.length < 1
148
+ true
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] name Value to be assigned
153
+ def name=(name)
154
+ if name.nil?
155
+ fail ArgumentError, 'name cannot be nil'
156
+ end
157
+
158
+ if name.to_s.length < 1
159
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
160
+ end
161
+
162
+ @name = name
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] description Value to be assigned
167
+ def description=(description)
168
+ if !description.nil? && description.to_s.length < 1
169
+ fail ArgumentError, 'invalid value for "description", the character length must be great than or equal to 1.'
170
+ end
171
+
172
+ @description = description
173
+ end
174
+
175
+ # Custom attribute writer method with validation
176
+ # @param [Object] header_name Value to be assigned
177
+ def header_name=(header_name)
178
+ if header_name.nil?
179
+ fail ArgumentError, 'header_name cannot be nil'
180
+ end
181
+
182
+ if header_name.to_s.length < 1
183
+ fail ArgumentError, 'invalid value for "header_name", the character length must be great than or equal to 1.'
184
+ end
185
+
186
+ @header_name = header_name
187
+ end
188
+
189
+ # Custom attribute writer method with validation
190
+ # @param [Object] env_var Value to be assigned
191
+ def env_var=(env_var)
192
+ if env_var.nil?
193
+ fail ArgumentError, 'env_var cannot be nil'
194
+ end
195
+
196
+ if env_var.to_s.length < 1
197
+ fail ArgumentError, 'invalid value for "env_var", the character length must be great than or equal to 1.'
198
+ end
199
+
200
+ @env_var = env_var
201
+ end
202
+
203
+ # Checks equality by comparing each attribute.
204
+ # @param [Object] Object to be compared
205
+ def ==(o)
206
+ return true if self.equal?(o)
207
+ self.class == o.class &&
208
+ name == o.name &&
209
+ description == o.description &&
210
+ header_name == o.header_name &&
211
+ env_var == o.env_var
212
+ end
213
+
214
+ # @see the `==` method
215
+ # @param [Object] Object to be compared
216
+ def eql?(o)
217
+ self == o
218
+ end
219
+
220
+ # Calculates hash code according to all attributes.
221
+ # @return [Integer] Hash code
222
+ def hash
223
+ [name, description, header_name, env_var].hash
224
+ end
225
+
226
+ # Builds the object from hash
227
+ # @param [Hash] attributes Model attributes in the form of hash
228
+ # @return [Object] Returns the model itself
229
+ def self.build_from_hash(attributes)
230
+ return nil unless attributes.is_a?(Hash)
231
+ attributes = attributes.transform_keys(&:to_sym)
232
+ transformed_hash = {}
233
+ openapi_types.each_pair do |key, type|
234
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
235
+ transformed_hash["#{key}"] = nil
236
+ elsif type =~ /\AArray<(.*)>/i
237
+ # check to ensure the input is an array given that the attribute
238
+ # is documented as an array but the input is not
239
+ if attributes[attribute_map[key]].is_a?(Array)
240
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
241
+ end
242
+ elsif !attributes[attribute_map[key]].nil?
243
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
244
+ end
245
+ end
246
+ new(transformed_hash)
247
+ end
248
+
249
+ # Deserializes the data based on type
250
+ # @param string type Data type
251
+ # @param string value Value to be deserialized
252
+ # @return [Object] Deserialized data
253
+ def self._deserialize(type, value)
254
+ case type.to_sym
255
+ when :Time
256
+ Time.parse(value)
257
+ when :Date
258
+ Date.parse(value)
259
+ when :String
260
+ value.to_s
261
+ when :Integer
262
+ value.to_i
263
+ when :Float
264
+ value.to_f
265
+ when :Boolean
266
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
267
+ true
268
+ else
269
+ false
270
+ end
271
+ when :Object
272
+ # generic object (usually a Hash), return directly
273
+ value
274
+ when /\AArray<(?<inner_type>.+)>\z/
275
+ inner_type = Regexp.last_match[:inner_type]
276
+ value.map { |v| _deserialize(inner_type, v) }
277
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
278
+ k_type = Regexp.last_match[:k_type]
279
+ v_type = Regexp.last_match[:v_type]
280
+ {}.tap do |hash|
281
+ value.each do |k, v|
282
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
283
+ end
284
+ end
285
+ else # model
286
+ # models (e.g. Pet) or oneOf
287
+ klass = PulpcoreClient.const_get(type)
288
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
289
+ end
290
+ end
291
+
292
+ # Returns the string representation of the object
293
+ # @return [String] String presentation of the object
294
+ def to_s
295
+ to_hash.to_s
296
+ end
297
+
298
+ # to_body is an alias to to_hash (backward compatibility)
299
+ # @return [Hash] Returns the object in the form of hash
300
+ def to_body
301
+ to_hash
302
+ end
303
+
304
+ # Returns the object in the form of hash
305
+ # @return [Hash] Returns the object in the form of hash
306
+ def to_hash
307
+ hash = {}
308
+ self.class.attribute_map.each_pair do |attr, param|
309
+ value = self.send(attr)
310
+ if value.nil?
311
+ is_nullable = self.class.openapi_nullable.include?(attr)
312
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
313
+ end
314
+
315
+ hash[param] = _to_hash(value)
316
+ end
317
+ hash
318
+ end
319
+
320
+ # Outputs non-array value in the form of hash
321
+ # For object, use to_hash. Otherwise, just return the value
322
+ # @param [Object] value Any valid value
323
+ # @return [Hash] Returns the value in the form of hash
324
+ def _to_hash(value)
325
+ if value.is_a?(Array)
326
+ value.compact.map { |v| _to_hash(v) }
327
+ elsif value.is_a?(Hash)
328
+ {}.tap do |hash|
329
+ value.each { |k, v| hash[k] = _to_hash(v) }
330
+ end
331
+ elsif value.respond_to? :to_hash
332
+ value.to_hash
333
+ else
334
+ value
335
+ end
336
+ end
337
+
338
+ end
339
+
340
+ end