pnap_network_storage_api 1.4.0 → 2.0.1

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -9
  3. data/VERSION +1 -1
  4. data/docs/StorageNetwork.md +2 -0
  5. data/docs/StorageNetworksApi.md +77 -87
  6. data/docs/Volume.md +2 -0
  7. data/lib/pnap_network_storage_api/api/storage_networks_api.rb +120 -100
  8. data/lib/pnap_network_storage_api/api_client.rb +26 -23
  9. data/lib/pnap_network_storage_api/api_error.rb +2 -1
  10. data/lib/pnap_network_storage_api/configuration.rb +28 -9
  11. data/lib/pnap_network_storage_api/models/error.rb +16 -19
  12. data/lib/pnap_network_storage_api/models/nfs_permissions.rb +14 -19
  13. data/lib/pnap_network_storage_api/models/nfs_permissions_create.rb +14 -19
  14. data/lib/pnap_network_storage_api/models/nfs_permissions_update.rb +14 -19
  15. data/lib/pnap_network_storage_api/models/permissions.rb +14 -19
  16. data/lib/pnap_network_storage_api/models/permissions_create.rb +14 -19
  17. data/lib/pnap_network_storage_api/models/permissions_update.rb +14 -19
  18. data/lib/pnap_network_storage_api/models/status.rb +8 -4
  19. data/lib/pnap_network_storage_api/models/storage_network.rb +47 -20
  20. data/lib/pnap_network_storage_api/models/storage_network_create.rb +42 -22
  21. data/lib/pnap_network_storage_api/models/storage_network_update.rb +36 -22
  22. data/lib/pnap_network_storage_api/models/storage_network_volume_create.rb +41 -23
  23. data/lib/pnap_network_storage_api/models/tag_assignment.rb +20 -19
  24. data/lib/pnap_network_storage_api/models/tag_assignment_request.rb +16 -19
  25. data/lib/pnap_network_storage_api/models/volume.rb +47 -20
  26. data/lib/pnap_network_storage_api/models/volume_create.rb +41 -23
  27. data/lib/pnap_network_storage_api/models/volume_update.rb +48 -26
  28. data/lib/pnap_network_storage_api/version.rb +1 -1
  29. data/lib/pnap_network_storage_api.rb +1 -1
  30. data/pnap_network_storage_api.gemspec +2 -2
  31. data/spec/api/storage_networks_api_spec.rb +70 -15
  32. data/spec/models/error_spec.rb +6 -4
  33. data/spec/models/nfs_permissions_create_spec.rb +9 -7
  34. data/spec/models/nfs_permissions_spec.rb +9 -7
  35. data/spec/models/nfs_permissions_update_spec.rb +9 -7
  36. data/spec/models/permissions_create_spec.rb +5 -3
  37. data/spec/models/permissions_spec.rb +5 -3
  38. data/spec/models/permissions_update_spec.rb +5 -3
  39. data/spec/models/status_spec.rb +4 -2
  40. data/spec/models/storage_network_create_spec.rb +14 -6
  41. data/spec/models/storage_network_spec.rb +19 -11
  42. data/spec/models/storage_network_update_spec.rb +6 -4
  43. data/spec/models/storage_network_volume_create_spec.rb +14 -6
  44. data/spec/models/tag_assignment_request_spec.rb +6 -4
  45. data/spec/models/tag_assignment_spec.rb +9 -7
  46. data/spec/models/volume_create_spec.rb +20 -6
  47. data/spec/models/volume_spec.rb +32 -12
  48. data/spec/models/volume_update_spec.rb +29 -3
  49. data/spec/spec_helper.rb +1 -1
  50. metadata +14 -18
  51. data/spec/api_client_spec.rb +0 -226
  52. data/spec/configuration_spec.rb +0 -42
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -17,8 +17,13 @@ module NetworkStorageApi
17
17
  class Status
18
18
  READY = "READY".freeze
19
19
  BUSY = "BUSY".freeze
20
+ DELETING = "DELETING".freeze
20
21
  ERROR = "ERROR".freeze
21
22
 
23
+ def self.all_vars
24
+ @all_vars ||= [READY, BUSY, DELETING, ERROR].freeze
25
+ end
26
+
22
27
  # Builds the enum from string
23
28
  # @param [String] The enum value in the form of the string
24
29
  # @return [String] The enum value
@@ -30,9 +35,8 @@ module NetworkStorageApi
30
35
  # @param [String] The enum value in the form of the string
31
36
  # @return [String] The enum value
32
37
  def build_from_hash(value)
33
- constantValues = Status.constants.select { |c| Status::const_get(c) == value }
34
- raise "Invalid ENUM value #{value} for class #Status" if constantValues.empty?
35
- value
38
+ return value if Status.all_vars.include?(value)
39
+ raise "Invalid ENUM value #{value} for class #Status"
36
40
  end
37
41
  end
38
42
  end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -39,9 +39,34 @@ module NetworkStorageApi
39
39
  # Date and time when this storage network was created.
40
40
  attr_accessor :created_on
41
41
 
42
+ # Date and time of the initial request for storage network deletion.
43
+ attr_accessor :delete_requested_on
44
+
42
45
  # Volume for a storage network.
43
46
  attr_accessor :volumes
44
47
 
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
45
70
  # Attribute mapping from ruby-style variable name to JSON key.
46
71
  def self.attribute_map
47
72
  {
@@ -53,6 +78,7 @@ module NetworkStorageApi
53
78
  :'network_id' => :'networkId',
54
79
  :'ips' => :'ips',
55
80
  :'created_on' => :'createdOn',
81
+ :'delete_requested_on' => :'deleteRequestedOn',
56
82
  :'volumes' => :'volumes'
57
83
  }
58
84
  end
@@ -73,6 +99,7 @@ module NetworkStorageApi
73
99
  :'network_id' => :'String',
74
100
  :'ips' => :'Array<String>',
75
101
  :'created_on' => :'Time',
102
+ :'delete_requested_on' => :'Time',
76
103
  :'volumes' => :'Array<Volume>'
77
104
  }
78
105
  end
@@ -132,6 +159,10 @@ module NetworkStorageApi
132
159
  self.created_on = attributes[:'created_on']
133
160
  end
134
161
 
162
+ if attributes.key?(:'delete_requested_on')
163
+ self.delete_requested_on = attributes[:'delete_requested_on']
164
+ end
165
+
135
166
  if attributes.key?(:'volumes')
136
167
  if (value = attributes[:'volumes']).is_a?(Array)
137
168
  self.volumes = value
@@ -142,6 +173,7 @@ module NetworkStorageApi
142
173
  # Show invalid properties with the reasons. Usually used together with valid?
143
174
  # @return Array for valid properties with the reasons
144
175
  def list_invalid_properties
176
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
145
177
  invalid_properties = Array.new
146
178
  invalid_properties
147
179
  end
@@ -149,6 +181,7 @@ module NetworkStorageApi
149
181
  # Check to see if the all the properties in the model are valid
150
182
  # @return true if the model is valid
151
183
  def valid?
184
+ warn '[DEPRECATED] the `valid?` method is obsolete'
152
185
  true
153
186
  end
154
187
 
@@ -165,6 +198,7 @@ module NetworkStorageApi
165
198
  network_id == o.network_id &&
166
199
  ips == o.ips &&
167
200
  created_on == o.created_on &&
201
+ delete_requested_on == o.delete_requested_on &&
168
202
  volumes == o.volumes
169
203
  end
170
204
 
@@ -177,44 +211,37 @@ module NetworkStorageApi
177
211
  # Calculates hash code according to all attributes.
178
212
  # @return [Integer] Hash code
179
213
  def hash
180
- [id, name, description, status, location, network_id, ips, created_on, volumes].hash
214
+ [id, name, description, status, location, network_id, ips, created_on, delete_requested_on, volumes].hash
181
215
  end
182
216
 
183
217
  # Builds the object from hash
184
218
  # @param [Hash] attributes Model attributes in the form of hash
185
219
  # @return [Object] Returns the model itself
186
220
  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
221
  return nil unless attributes.is_a?(Hash)
195
222
  attributes = attributes.transform_keys(&:to_sym)
196
- self.class.openapi_types.each_pair do |key, type|
197
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
- self.send("#{key}=", nil)
223
+ transformed_hash = {}
224
+ openapi_types.each_pair do |key, type|
225
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = nil
199
227
  elsif type =~ /\AArray<(.*)>/i
200
228
  # check to ensure the input is an array given that the attribute
201
229
  # is documented as an array but the input is not
202
- if attributes[self.class.attribute_map[key]].is_a?(Array)
203
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
230
+ if attributes[attribute_map[key]].is_a?(Array)
231
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
204
232
  end
205
- elsif !attributes[self.class.attribute_map[key]].nil?
206
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
233
+ elsif !attributes[attribute_map[key]].nil?
234
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
207
235
  end
208
236
  end
209
-
210
- self
237
+ new(transformed_hash)
211
238
  end
212
239
 
213
240
  # Deserializes the data based on type
214
241
  # @param string type Data type
215
242
  # @param string value Value to be deserialized
216
243
  # @return [Object] Deserialized data
217
- def _deserialize(type, value)
244
+ def self._deserialize(type, value)
218
245
  case type.to_sym
219
246
  when :Time
220
247
  Time.parse(value)
@@ -249,7 +276,7 @@ module NetworkStorageApi
249
276
  else # model
250
277
  # models (e.g. Pet) or oneOf
251
278
  klass = NetworkStorageApi.const_get(type)
252
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
279
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
280
  end
254
281
  end
255
282
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -81,6 +81,8 @@ module NetworkStorageApi
81
81
 
82
82
  if attributes.key?(:'name')
83
83
  self.name = attributes[:'name']
84
+ else
85
+ self.name = nil
84
86
  end
85
87
 
86
88
  if attributes.key?(:'description')
@@ -89,12 +91,16 @@ module NetworkStorageApi
89
91
 
90
92
  if attributes.key?(:'location')
91
93
  self.location = attributes[:'location']
94
+ else
95
+ self.location = nil
92
96
  end
93
97
 
94
98
  if attributes.key?(:'volumes')
95
99
  if (value = attributes[:'volumes']).is_a?(Array)
96
100
  self.volumes = value
97
101
  end
102
+ else
103
+ self.volumes = nil
98
104
  end
99
105
 
100
106
  if attributes.key?(:'client_vlan')
@@ -105,6 +111,7 @@ module NetworkStorageApi
105
111
  # Show invalid properties with the reasons. Usually used together with valid?
106
112
  # @return Array for valid properties with the reasons
107
113
  def list_invalid_properties
114
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
115
  invalid_properties = Array.new
109
116
  if @name.nil?
110
117
  invalid_properties.push('invalid value for "name", name cannot be nil.')
@@ -118,6 +125,11 @@ module NetworkStorageApi
118
125
  invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
119
126
  end
120
127
 
128
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
129
+ if @name !~ pattern
130
+ invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
131
+ end
132
+
121
133
  if !@description.nil? && @description.to_s.length > 250
122
134
  invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
123
135
  end
@@ -152,9 +164,11 @@ module NetworkStorageApi
152
164
  # Check to see if the all the properties in the model are valid
153
165
  # @return true if the model is valid
154
166
  def valid?
167
+ warn '[DEPRECATED] the `valid?` method is obsolete'
155
168
  return false if @name.nil?
156
169
  return false if @name.to_s.length > 100
157
170
  return false if @name.to_s.length < 1
171
+ return false if @name !~ Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
158
172
  return false if !@description.nil? && @description.to_s.length > 250
159
173
  return false if @location.nil?
160
174
  return false if @volumes.nil?
@@ -180,13 +194,22 @@ module NetworkStorageApi
180
194
  fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
181
195
  end
182
196
 
197
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
198
+ if name !~ pattern
199
+ fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
200
+ end
201
+
183
202
  @name = name
184
203
  end
185
204
 
186
205
  # Custom attribute writer method with validation
187
206
  # @param [Object] description Value to be assigned
188
207
  def description=(description)
189
- if !description.nil? && description.to_s.length > 250
208
+ if description.nil?
209
+ fail ArgumentError, 'description cannot be nil'
210
+ end
211
+
212
+ if description.to_s.length > 250
190
213
  fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
191
214
  end
192
215
 
@@ -214,11 +237,15 @@ module NetworkStorageApi
214
237
  # Custom attribute writer method with validation
215
238
  # @param [Object] client_vlan Value to be assigned
216
239
  def client_vlan=(client_vlan)
217
- if !client_vlan.nil? && client_vlan > 4094
240
+ if client_vlan.nil?
241
+ fail ArgumentError, 'client_vlan cannot be nil'
242
+ end
243
+
244
+ if client_vlan > 4094
218
245
  fail ArgumentError, 'invalid value for "client_vlan", must be smaller than or equal to 4094.'
219
246
  end
220
247
 
221
- if !client_vlan.nil? && client_vlan < 2
248
+ if client_vlan < 2
222
249
  fail ArgumentError, 'invalid value for "client_vlan", must be greater than or equal to 2.'
223
250
  end
224
251
 
@@ -253,37 +280,30 @@ module NetworkStorageApi
253
280
  # @param [Hash] attributes Model attributes in the form of hash
254
281
  # @return [Object] Returns the model itself
255
282
  def self.build_from_hash(attributes)
256
- new.build_from_hash(attributes)
257
- end
258
-
259
- # Builds the object from hash
260
- # @param [Hash] attributes Model attributes in the form of hash
261
- # @return [Object] Returns the model itself
262
- def build_from_hash(attributes)
263
283
  return nil unless attributes.is_a?(Hash)
264
284
  attributes = attributes.transform_keys(&:to_sym)
265
- self.class.openapi_types.each_pair do |key, type|
266
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
267
- self.send("#{key}=", nil)
285
+ transformed_hash = {}
286
+ openapi_types.each_pair do |key, type|
287
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
288
+ transformed_hash["#{key}"] = nil
268
289
  elsif type =~ /\AArray<(.*)>/i
269
290
  # check to ensure the input is an array given that the attribute
270
291
  # is documented as an array but the input is not
271
- if attributes[self.class.attribute_map[key]].is_a?(Array)
272
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
292
+ if attributes[attribute_map[key]].is_a?(Array)
293
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
273
294
  end
274
- elsif !attributes[self.class.attribute_map[key]].nil?
275
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
295
+ elsif !attributes[attribute_map[key]].nil?
296
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
276
297
  end
277
298
  end
278
-
279
- self
299
+ new(transformed_hash)
280
300
  end
281
301
 
282
302
  # Deserializes the data based on type
283
303
  # @param string type Data type
284
304
  # @param string value Value to be deserialized
285
305
  # @return [Object] Deserialized data
286
- def _deserialize(type, value)
306
+ def self._deserialize(type, value)
287
307
  case type.to_sym
288
308
  when :Time
289
309
  Time.parse(value)
@@ -318,7 +338,7 @@ module NetworkStorageApi
318
338
  else # model
319
339
  # models (e.g. Pet) or oneOf
320
340
  klass = NetworkStorageApi.const_get(type)
321
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
341
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
322
342
  end
323
343
  end
324
344
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -76,6 +76,7 @@ module NetworkStorageApi
76
76
  # Show invalid properties with the reasons. Usually used together with valid?
77
77
  # @return Array for valid properties with the reasons
78
78
  def list_invalid_properties
79
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
79
80
  invalid_properties = Array.new
80
81
  if !@name.nil? && @name.to_s.length > 100
81
82
  invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
@@ -85,6 +86,11 @@ module NetworkStorageApi
85
86
  invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
86
87
  end
87
88
 
89
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
90
+ if !@name.nil? && @name !~ pattern
91
+ invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
92
+ end
93
+
88
94
  if !@description.nil? && @description.to_s.length > 250
89
95
  invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
90
96
  end
@@ -95,8 +101,10 @@ module NetworkStorageApi
95
101
  # Check to see if the all the properties in the model are valid
96
102
  # @return true if the model is valid
97
103
  def valid?
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
105
  return false if !@name.nil? && @name.to_s.length > 100
99
106
  return false if !@name.nil? && @name.to_s.length < 1
107
+ return false if !@name.nil? && @name !~ Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
100
108
  return false if !@description.nil? && @description.to_s.length > 250
101
109
  true
102
110
  end
@@ -104,21 +112,34 @@ module NetworkStorageApi
104
112
  # Custom attribute writer method with validation
105
113
  # @param [Object] name Value to be assigned
106
114
  def name=(name)
107
- if !name.nil? && name.to_s.length > 100
115
+ if name.nil?
116
+ fail ArgumentError, 'name cannot be nil'
117
+ end
118
+
119
+ if name.to_s.length > 100
108
120
  fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
109
121
  end
110
122
 
111
- if !name.nil? && name.to_s.length < 1
123
+ if name.to_s.length < 1
112
124
  fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
113
125
  end
114
126
 
127
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
128
+ if name !~ pattern
129
+ fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
130
+ end
131
+
115
132
  @name = name
116
133
  end
117
134
 
118
135
  # Custom attribute writer method with validation
119
136
  # @param [Object] description Value to be assigned
120
137
  def description=(description)
121
- if !description.nil? && description.to_s.length > 250
138
+ if description.nil?
139
+ fail ArgumentError, 'description cannot be nil'
140
+ end
141
+
142
+ if description.to_s.length > 250
122
143
  fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
123
144
  end
124
145
 
@@ -150,37 +171,30 @@ module NetworkStorageApi
150
171
  # @param [Hash] attributes Model attributes in the form of hash
151
172
  # @return [Object] Returns the model itself
152
173
  def self.build_from_hash(attributes)
153
- new.build_from_hash(attributes)
154
- end
155
-
156
- # Builds the object from hash
157
- # @param [Hash] attributes Model attributes in the form of hash
158
- # @return [Object] Returns the model itself
159
- def build_from_hash(attributes)
160
174
  return nil unless attributes.is_a?(Hash)
161
175
  attributes = attributes.transform_keys(&:to_sym)
162
- self.class.openapi_types.each_pair do |key, type|
163
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
164
- self.send("#{key}=", nil)
176
+ transformed_hash = {}
177
+ openapi_types.each_pair do |key, type|
178
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
179
+ transformed_hash["#{key}"] = nil
165
180
  elsif type =~ /\AArray<(.*)>/i
166
181
  # check to ensure the input is an array given that the attribute
167
182
  # is documented as an array but the input is not
168
- if attributes[self.class.attribute_map[key]].is_a?(Array)
169
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
+ if attributes[attribute_map[key]].is_a?(Array)
184
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
170
185
  end
171
- elsif !attributes[self.class.attribute_map[key]].nil?
172
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
+ elsif !attributes[attribute_map[key]].nil?
187
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
173
188
  end
174
189
  end
175
-
176
- self
190
+ new(transformed_hash)
177
191
  end
178
192
 
179
193
  # Deserializes the data based on type
180
194
  # @param string type Data type
181
195
  # @param string value Value to be deserialized
182
196
  # @return [Object] Deserialized data
183
- def _deserialize(type, value)
197
+ def self._deserialize(type, value)
184
198
  case type.to_sym
185
199
  when :Time
186
200
  Time.parse(value)
@@ -215,7 +229,7 @@ module NetworkStorageApi
215
229
  else # model
216
230
  # models (e.g. Pet) or oneOf
217
231
  klass = NetworkStorageApi.const_get(type)
218
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
233
  end
220
234
  end
221
235
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -81,6 +81,8 @@ module NetworkStorageApi
81
81
 
82
82
  if attributes.key?(:'name')
83
83
  self.name = attributes[:'name']
84
+ else
85
+ self.name = nil
84
86
  end
85
87
 
86
88
  if attributes.key?(:'description')
@@ -93,6 +95,8 @@ module NetworkStorageApi
93
95
 
94
96
  if attributes.key?(:'capacity_in_gb')
95
97
  self.capacity_in_gb = attributes[:'capacity_in_gb']
98
+ else
99
+ self.capacity_in_gb = nil
96
100
  end
97
101
 
98
102
  if attributes.key?(:'tags')
@@ -105,6 +109,7 @@ module NetworkStorageApi
105
109
  # Show invalid properties with the reasons. Usually used together with valid?
106
110
  # @return Array for valid properties with the reasons
107
111
  def list_invalid_properties
112
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
113
  invalid_properties = Array.new
109
114
  if @name.nil?
110
115
  invalid_properties.push('invalid value for "name", name cannot be nil.')
@@ -118,6 +123,11 @@ module NetworkStorageApi
118
123
  invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
119
124
  end
120
125
 
126
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
127
+ if @name !~ pattern
128
+ invalid_properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.")
129
+ end
130
+
121
131
  if !@description.nil? && @description.to_s.length > 250
122
132
  invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
123
133
  end
@@ -149,9 +159,11 @@ module NetworkStorageApi
149
159
  # Check to see if the all the properties in the model are valid
150
160
  # @return true if the model is valid
151
161
  def valid?
162
+ warn '[DEPRECATED] the `valid?` method is obsolete'
152
163
  return false if @name.nil?
153
164
  return false if @name.to_s.length > 100
154
165
  return false if @name.to_s.length < 1
166
+ return false if @name !~ Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
155
167
  return false if !@description.nil? && @description.to_s.length > 250
156
168
  return false if !@path_suffix.nil? && @path_suffix.to_s.length > 27
157
169
  return false if !@path_suffix.nil? && @path_suffix.to_s.length < 0
@@ -176,13 +188,22 @@ module NetworkStorageApi
176
188
  fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
177
189
  end
178
190
 
191
+ pattern = Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
192
+ if name !~ pattern
193
+ fail ArgumentError, "invalid value for \"name\", must conform to the pattern #{pattern}."
194
+ end
195
+
179
196
  @name = name
180
197
  end
181
198
 
182
199
  # Custom attribute writer method with validation
183
200
  # @param [Object] description Value to be assigned
184
201
  def description=(description)
185
- if !description.nil? && description.to_s.length > 250
202
+ if description.nil?
203
+ fail ArgumentError, 'description cannot be nil'
204
+ end
205
+
206
+ if description.to_s.length > 250
186
207
  fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
187
208
  end
188
209
 
@@ -192,16 +213,20 @@ module NetworkStorageApi
192
213
  # Custom attribute writer method with validation
193
214
  # @param [Object] path_suffix Value to be assigned
194
215
  def path_suffix=(path_suffix)
195
- if !path_suffix.nil? && path_suffix.to_s.length > 27
216
+ if path_suffix.nil?
217
+ fail ArgumentError, 'path_suffix cannot be nil'
218
+ end
219
+
220
+ if path_suffix.to_s.length > 27
196
221
  fail ArgumentError, 'invalid value for "path_suffix", the character length must be smaller than or equal to 27.'
197
222
  end
198
223
 
199
- if !path_suffix.nil? && path_suffix.to_s.length < 0
224
+ if path_suffix.to_s.length < 0
200
225
  fail ArgumentError, 'invalid value for "path_suffix", the character length must be great than or equal to 0.'
201
226
  end
202
227
 
203
228
  pattern = Regexp.new(/^(\/[\w-]+)+$|^$/)
204
- if !path_suffix.nil? && path_suffix !~ pattern
229
+ if path_suffix !~ pattern
205
230
  fail ArgumentError, "invalid value for \"path_suffix\", must conform to the pattern #{pattern}."
206
231
  end
207
232
 
@@ -250,37 +275,30 @@ module NetworkStorageApi
250
275
  # @param [Hash] attributes Model attributes in the form of hash
251
276
  # @return [Object] Returns the model itself
252
277
  def self.build_from_hash(attributes)
253
- new.build_from_hash(attributes)
254
- end
255
-
256
- # Builds the object from hash
257
- # @param [Hash] attributes Model attributes in the form of hash
258
- # @return [Object] Returns the model itself
259
- def build_from_hash(attributes)
260
278
  return nil unless attributes.is_a?(Hash)
261
279
  attributes = attributes.transform_keys(&:to_sym)
262
- self.class.openapi_types.each_pair do |key, type|
263
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
264
- self.send("#{key}=", nil)
280
+ transformed_hash = {}
281
+ openapi_types.each_pair do |key, type|
282
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
283
+ transformed_hash["#{key}"] = nil
265
284
  elsif type =~ /\AArray<(.*)>/i
266
285
  # check to ensure the input is an array given that the attribute
267
286
  # is documented as an array but the input is not
268
- if attributes[self.class.attribute_map[key]].is_a?(Array)
269
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
287
+ if attributes[attribute_map[key]].is_a?(Array)
288
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
270
289
  end
271
- elsif !attributes[self.class.attribute_map[key]].nil?
272
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
290
+ elsif !attributes[attribute_map[key]].nil?
291
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
273
292
  end
274
293
  end
275
-
276
- self
294
+ new(transformed_hash)
277
295
  end
278
296
 
279
297
  # Deserializes the data based on type
280
298
  # @param string type Data type
281
299
  # @param string value Value to be deserialized
282
300
  # @return [Object] Deserialized data
283
- def _deserialize(type, value)
301
+ def self._deserialize(type, value)
284
302
  case type.to_sym
285
303
  when :Time
286
304
  Time.parse(value)
@@ -315,7 +333,7 @@ module NetworkStorageApi
315
333
  else # model
316
334
  # models (e.g. Pet) or oneOf
317
335
  klass = NetworkStorageApi.const_get(type)
318
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
336
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
319
337
  end
320
338
  end
321
339