pnap_network_storage_api 1.0.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 (45) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +158 -0
  4. data/Rakefile +10 -0
  5. data/VERSION +1 -0
  6. data/docs/Error.md +20 -0
  7. data/docs/NfsPermissions.md +26 -0
  8. data/docs/Permissions.md +18 -0
  9. data/docs/Status.md +15 -0
  10. data/docs/StorageNetwork.md +34 -0
  11. data/docs/StorageNetworkCreate.md +24 -0
  12. data/docs/StorageNetworkUpdate.md +20 -0
  13. data/docs/StorageNetworksApi.md +506 -0
  14. data/docs/Volume.md +36 -0
  15. data/docs/VolumeCreate.md +24 -0
  16. data/lib/pnap_network_storage_api/api/storage_networks_api.rb +474 -0
  17. data/lib/pnap_network_storage_api/api_client.rb +392 -0
  18. data/lib/pnap_network_storage_api/api_error.rb +57 -0
  19. data/lib/pnap_network_storage_api/configuration.rb +278 -0
  20. data/lib/pnap_network_storage_api/models/error.rb +236 -0
  21. data/lib/pnap_network_storage_api/models/nfs_permissions.rb +270 -0
  22. data/lib/pnap_network_storage_api/models/permissions.rb +219 -0
  23. data/lib/pnap_network_storage_api/models/status.rb +38 -0
  24. data/lib/pnap_network_storage_api/models/storage_network.rb +303 -0
  25. data/lib/pnap_network_storage_api/models/storage_network_create.rb +338 -0
  26. data/lib/pnap_network_storage_api/models/storage_network_update.rb +269 -0
  27. data/lib/pnap_network_storage_api/models/volume.rb +307 -0
  28. data/lib/pnap_network_storage_api/models/volume_create.rb +357 -0
  29. data/lib/pnap_network_storage_api/version.rb +19 -0
  30. data/lib/pnap_network_storage_api.rb +49 -0
  31. data/pnap_network_storage_api.gemspec +39 -0
  32. data/spec/api/storage_networks_api_spec.rb +121 -0
  33. data/spec/api_client_spec.rb +226 -0
  34. data/spec/configuration_spec.rb +42 -0
  35. data/spec/models/error_spec.rb +40 -0
  36. data/spec/models/nfs_permissions_spec.rb +58 -0
  37. data/spec/models/permissions_spec.rb +34 -0
  38. data/spec/models/status_spec.rb +28 -0
  39. data/spec/models/storage_network_create_spec.rb +52 -0
  40. data/spec/models/storage_network_spec.rb +82 -0
  41. data/spec/models/storage_network_update_spec.rb +40 -0
  42. data/spec/models/volume_create_spec.rb +52 -0
  43. data/spec/models/volume_spec.rb +88 -0
  44. data/spec/spec_helper.rb +111 -0
  45. metadata +140 -0
@@ -0,0 +1,303 @@
1
+ =begin
2
+ #Network Storage API
3
+
4
+ #Create, list, edit, and delete storage networks with the Network Storage API. Use storage networks to expand storage capacity on a private network. <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/bare-metal-cloud-storage' target='_blank'>here</a> </span> <br> <b>All URLs are relative to (https://api.phoenixnap.com/network-storage/v1/)</b>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module NetworkStorageApi
17
+ # Storage network.
18
+ class StorageNetwork
19
+ # Storage network ID.
20
+ attr_accessor :id
21
+
22
+ # Storage network friendly name.
23
+ attr_accessor :name
24
+
25
+ # Storage network description.
26
+ attr_accessor :description
27
+
28
+ attr_accessor :status
29
+
30
+ # Location of storage network. Currently this field should be set to `PHX` or `ASH`.
31
+ attr_accessor :location
32
+
33
+ # Id of network the storage belongs to.
34
+ attr_accessor :network_id
35
+
36
+ # IP of the storage network.
37
+ attr_accessor :ips
38
+
39
+ # Date and time when this storage network was created.
40
+ attr_accessor :created_on
41
+
42
+ # Volume for a storage network.
43
+ attr_accessor :volumes
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'id' => :'id',
49
+ :'name' => :'name',
50
+ :'description' => :'description',
51
+ :'status' => :'status',
52
+ :'location' => :'location',
53
+ :'network_id' => :'networkId',
54
+ :'ips' => :'ips',
55
+ :'created_on' => :'createdOn',
56
+ :'volumes' => :'volumes'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'id' => :'String',
69
+ :'name' => :'String',
70
+ :'description' => :'String',
71
+ :'status' => :'Status',
72
+ :'location' => :'String',
73
+ :'network_id' => :'String',
74
+ :'ips' => :'Array<String>',
75
+ :'created_on' => :'Time',
76
+ :'volumes' => :'Array<Volume>'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkStorageApi::StorageNetwork` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkStorageApi::StorageNetwork`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'id')
102
+ self.id = attributes[:'id']
103
+ end
104
+
105
+ if attributes.key?(:'name')
106
+ self.name = attributes[:'name']
107
+ end
108
+
109
+ if attributes.key?(:'description')
110
+ self.description = attributes[:'description']
111
+ end
112
+
113
+ if attributes.key?(:'status')
114
+ self.status = attributes[:'status']
115
+ end
116
+
117
+ if attributes.key?(:'location')
118
+ self.location = attributes[:'location']
119
+ end
120
+
121
+ if attributes.key?(:'network_id')
122
+ self.network_id = attributes[:'network_id']
123
+ end
124
+
125
+ if attributes.key?(:'ips')
126
+ if (value = attributes[:'ips']).is_a?(Array)
127
+ self.ips = value
128
+ end
129
+ end
130
+
131
+ if attributes.key?(:'created_on')
132
+ self.created_on = attributes[:'created_on']
133
+ end
134
+
135
+ if attributes.key?(:'volumes')
136
+ if (value = attributes[:'volumes']).is_a?(Array)
137
+ self.volumes = value
138
+ end
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ invalid_properties = Array.new
146
+ invalid_properties
147
+ end
148
+
149
+ # Check to see if the all the properties in the model are valid
150
+ # @return true if the model is valid
151
+ def valid?
152
+ true
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
+ id == o.id &&
161
+ name == o.name &&
162
+ description == o.description &&
163
+ status == o.status &&
164
+ location == o.location &&
165
+ network_id == o.network_id &&
166
+ ips == o.ips &&
167
+ created_on == o.created_on &&
168
+ volumes == o.volumes
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [id, name, description, status, location, network_id, ips, created_on, volumes].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ self.class.openapi_types.each_pair do |key, type|
196
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
197
+ self.send("#{key}=", nil)
198
+ elsif type =~ /\AArray<(.*)>/i
199
+ # check to ensure the input is an array given that the attribute
200
+ # is documented as an array but the input is not
201
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
202
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
203
+ end
204
+ elsif !attributes[self.class.attribute_map[key]].nil?
205
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
206
+ end
207
+ end
208
+
209
+ self
210
+ end
211
+
212
+ # Deserializes the data based on type
213
+ # @param string type Data type
214
+ # @param string value Value to be deserialized
215
+ # @return [Object] Deserialized data
216
+ def _deserialize(type, value)
217
+ case type.to_sym
218
+ when :Time
219
+ Time.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :Boolean
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ # models (e.g. Pet) or oneOf
250
+ klass = NetworkStorageApi.const_get(type)
251
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
252
+ end
253
+ end
254
+
255
+ # Returns the string representation of the object
256
+ # @return [String] String presentation of the object
257
+ def to_s
258
+ to_hash.to_s
259
+ end
260
+
261
+ # to_body is an alias to to_hash (backward compatibility)
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_body
264
+ to_hash
265
+ end
266
+
267
+ # Returns the object in the form of hash
268
+ # @return [Hash] Returns the object in the form of hash
269
+ def to_hash
270
+ hash = {}
271
+ self.class.attribute_map.each_pair do |attr, param|
272
+ value = self.send(attr)
273
+ if value.nil?
274
+ is_nullable = self.class.openapi_nullable.include?(attr)
275
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
276
+ end
277
+
278
+ hash[param] = _to_hash(value)
279
+ end
280
+ hash
281
+ end
282
+
283
+ # Outputs non-array value in the form of hash
284
+ # For object, use to_hash. Otherwise, just return the value
285
+ # @param [Object] value Any valid value
286
+ # @return [Hash] Returns the value in the form of hash
287
+ def _to_hash(value)
288
+ if value.is_a?(Array)
289
+ value.compact.map { |v| _to_hash(v) }
290
+ elsif value.is_a?(Hash)
291
+ {}.tap do |hash|
292
+ value.each { |k, v| hash[k] = _to_hash(v) }
293
+ end
294
+ elsif value.respond_to? :to_hash
295
+ value.to_hash
296
+ else
297
+ value
298
+ end
299
+ end
300
+
301
+ end
302
+
303
+ end
@@ -0,0 +1,338 @@
1
+ =begin
2
+ #Network Storage API
3
+
4
+ #Create, list, edit, and delete storage networks with the Network Storage API. Use storage networks to expand storage capacity on a private network. <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/bare-metal-cloud-storage' target='_blank'>here</a> </span> <br> <b>All URLs are relative to (https://api.phoenixnap.com/network-storage/v1/)</b>
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module NetworkStorageApi
17
+ # Create Storage Network.
18
+ class StorageNetworkCreate
19
+ # Storage network friendly name.
20
+ attr_accessor :name
21
+
22
+ # Storage network description.
23
+ attr_accessor :description
24
+
25
+ # Location of storage network. Currently this field should be set to `PHX`.
26
+ attr_accessor :location
27
+
28
+ # Volume to be created alongside storage. Currently only 1 volume is supported.
29
+ attr_accessor :volumes
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
+ :'location' => :'location',
37
+ :'volumes' => :'volumes'
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
+ :'location' => :'String',
52
+ :'volumes' => :'Array<VolumeCreate>'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkStorageApi::StorageNetworkCreate` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkStorageApi::StorageNetworkCreate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'name')
78
+ self.name = attributes[:'name']
79
+ end
80
+
81
+ if attributes.key?(:'description')
82
+ self.description = attributes[:'description']
83
+ end
84
+
85
+ if attributes.key?(:'location')
86
+ self.location = attributes[:'location']
87
+ end
88
+
89
+ if attributes.key?(:'volumes')
90
+ if (value = attributes[:'volumes']).is_a?(Array)
91
+ self.volumes = value
92
+ end
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @name.nil?
101
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
102
+ end
103
+
104
+ if @name.to_s.length > 100
105
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
106
+ end
107
+
108
+ if @name.to_s.length < 1
109
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
110
+ end
111
+
112
+ if !@description.nil? && @description.to_s.length > 250
113
+ invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
114
+ end
115
+
116
+ if @location.nil?
117
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
118
+ end
119
+
120
+ if @volumes.nil?
121
+ invalid_properties.push('invalid value for "volumes", volumes cannot be nil.')
122
+ end
123
+
124
+ if @volumes.length > 1
125
+ invalid_properties.push('invalid value for "volumes", number of items must be less than or equal to 1.')
126
+ end
127
+
128
+ if @volumes.length < 1
129
+ invalid_properties.push('invalid value for "volumes", number of items must be greater than or equal to 1.')
130
+ end
131
+
132
+ invalid_properties
133
+ end
134
+
135
+ # Check to see if the all the properties in the model are valid
136
+ # @return true if the model is valid
137
+ def valid?
138
+ return false if @name.nil?
139
+ return false if @name.to_s.length > 100
140
+ return false if @name.to_s.length < 1
141
+ return false if !@description.nil? && @description.to_s.length > 250
142
+ return false if @location.nil?
143
+ return false if @volumes.nil?
144
+ return false if @volumes.length > 1
145
+ return false if @volumes.length < 1
146
+ true
147
+ end
148
+
149
+ # Custom attribute writer method with validation
150
+ # @param [Object] name Value to be assigned
151
+ def name=(name)
152
+ if name.nil?
153
+ fail ArgumentError, 'name cannot be nil'
154
+ end
155
+
156
+ if name.to_s.length > 100
157
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
158
+ end
159
+
160
+ if name.to_s.length < 1
161
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
162
+ end
163
+
164
+ @name = name
165
+ end
166
+
167
+ # Custom attribute writer method with validation
168
+ # @param [Object] description Value to be assigned
169
+ def description=(description)
170
+ if !description.nil? && description.to_s.length > 250
171
+ fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
172
+ end
173
+
174
+ @description = description
175
+ end
176
+
177
+ # Custom attribute writer method with validation
178
+ # @param [Object] volumes Value to be assigned
179
+ def volumes=(volumes)
180
+ if volumes.nil?
181
+ fail ArgumentError, 'volumes cannot be nil'
182
+ end
183
+
184
+ if volumes.length > 1
185
+ fail ArgumentError, 'invalid value for "volumes", number of items must be less than or equal to 1.'
186
+ end
187
+
188
+ if volumes.length < 1
189
+ fail ArgumentError, 'invalid value for "volumes", number of items must be greater than or equal to 1.'
190
+ end
191
+
192
+ @volumes = volumes
193
+ end
194
+
195
+ # Checks equality by comparing each attribute.
196
+ # @param [Object] Object to be compared
197
+ def ==(o)
198
+ return true if self.equal?(o)
199
+ self.class == o.class &&
200
+ name == o.name &&
201
+ description == o.description &&
202
+ location == o.location &&
203
+ volumes == o.volumes
204
+ end
205
+
206
+ # @see the `==` method
207
+ # @param [Object] Object to be compared
208
+ def eql?(o)
209
+ self == o
210
+ end
211
+
212
+ # Calculates hash code according to all attributes.
213
+ # @return [Integer] Hash code
214
+ def hash
215
+ [name, description, location, volumes].hash
216
+ end
217
+
218
+ # Builds the object from hash
219
+ # @param [Hash] attributes Model attributes in the form of hash
220
+ # @return [Object] Returns the model itself
221
+ def self.build_from_hash(attributes)
222
+ new.build_from_hash(attributes)
223
+ end
224
+
225
+ # Builds the object from hash
226
+ # @param [Hash] attributes Model attributes in the form of hash
227
+ # @return [Object] Returns the model itself
228
+ def build_from_hash(attributes)
229
+ return nil unless attributes.is_a?(Hash)
230
+ self.class.openapi_types.each_pair do |key, type|
231
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
232
+ self.send("#{key}=", nil)
233
+ elsif type =~ /\AArray<(.*)>/i
234
+ # check to ensure the input is an array given that the attribute
235
+ # is documented as an array but the input is not
236
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
237
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
238
+ end
239
+ elsif !attributes[self.class.attribute_map[key]].nil?
240
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
241
+ end
242
+ end
243
+
244
+ self
245
+ end
246
+
247
+ # Deserializes the data based on type
248
+ # @param string type Data type
249
+ # @param string value Value to be deserialized
250
+ # @return [Object] Deserialized data
251
+ def _deserialize(type, value)
252
+ case type.to_sym
253
+ when :Time
254
+ Time.parse(value)
255
+ when :Date
256
+ Date.parse(value)
257
+ when :String
258
+ value.to_s
259
+ when :Integer
260
+ value.to_i
261
+ when :Float
262
+ value.to_f
263
+ when :Boolean
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ # models (e.g. Pet) or oneOf
285
+ klass = NetworkStorageApi.const_get(type)
286
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
287
+ end
288
+ end
289
+
290
+ # Returns the string representation of the object
291
+ # @return [String] String presentation of the object
292
+ def to_s
293
+ to_hash.to_s
294
+ end
295
+
296
+ # to_body is an alias to to_hash (backward compatibility)
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_body
299
+ to_hash
300
+ end
301
+
302
+ # Returns the object in the form of hash
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_hash
305
+ hash = {}
306
+ self.class.attribute_map.each_pair do |attr, param|
307
+ value = self.send(attr)
308
+ if value.nil?
309
+ is_nullable = self.class.openapi_nullable.include?(attr)
310
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
311
+ end
312
+
313
+ hash[param] = _to_hash(value)
314
+ end
315
+ hash
316
+ end
317
+
318
+ # Outputs non-array value in the form of hash
319
+ # For object, use to_hash. Otherwise, just return the value
320
+ # @param [Object] value Any valid value
321
+ # @return [Hash] Returns the value in the form of hash
322
+ def _to_hash(value)
323
+ if value.is_a?(Array)
324
+ value.compact.map { |v| _to_hash(v) }
325
+ elsif value.is_a?(Hash)
326
+ {}.tap do |hash|
327
+ value.each { |k, v| hash[k] = _to_hash(v) }
328
+ end
329
+ elsif value.respond_to? :to_hash
330
+ value.to_hash
331
+ else
332
+ value
333
+ end
334
+ end
335
+
336
+ end
337
+
338
+ end