pnap_network_storage_api 1.3.0 → 2.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.
- checksums.yaml +4 -4
- data/README.md +14 -8
- data/VERSION +1 -1
- data/docs/StorageNetwork.md +2 -0
- data/docs/StorageNetworkCreate.md +3 -1
- data/docs/StorageNetworkVolumeCreate.md +3 -1
- data/docs/StorageNetworksApi.md +146 -76
- data/docs/TagAssignment.md +26 -0
- data/docs/TagAssignmentRequest.md +20 -0
- data/docs/Volume.md +5 -1
- data/docs/VolumeCreate.md +3 -1
- data/lib/pnap_network_storage_api/api/storage_networks_api.rb +187 -88
- data/lib/pnap_network_storage_api/api_client.rb +24 -21
- data/lib/pnap_network_storage_api/api_error.rb +2 -1
- data/lib/pnap_network_storage_api/configuration.rb +28 -9
- data/lib/pnap_network_storage_api/models/error.rb +16 -19
- data/lib/pnap_network_storage_api/models/nfs_permissions.rb +14 -19
- data/lib/pnap_network_storage_api/models/nfs_permissions_create.rb +14 -19
- data/lib/pnap_network_storage_api/models/nfs_permissions_update.rb +14 -19
- data/lib/pnap_network_storage_api/models/permissions.rb +14 -19
- data/lib/pnap_network_storage_api/models/permissions_create.rb +14 -19
- data/lib/pnap_network_storage_api/models/permissions_update.rb +14 -19
- data/lib/pnap_network_storage_api/models/status.rb +8 -4
- data/lib/pnap_network_storage_api/models/storage_network.rb +47 -20
- data/lib/pnap_network_storage_api/models/storage_network_create.rb +78 -24
- data/lib/pnap_network_storage_api/models/storage_network_update.rb +36 -22
- data/lib/pnap_network_storage_api/models/storage_network_volume_create.rb +57 -27
- data/lib/pnap_network_storage_api/models/tag_assignment.rb +311 -0
- data/lib/pnap_network_storage_api/models/tag_assignment_request.rb +233 -0
- data/lib/pnap_network_storage_api/models/volume.rb +62 -23
- data/lib/pnap_network_storage_api/models/volume_create.rb +57 -27
- data/lib/pnap_network_storage_api/models/volume_update.rb +48 -26
- data/lib/pnap_network_storage_api/version.rb +1 -1
- data/lib/pnap_network_storage_api.rb +3 -1
- data/pnap_network_storage_api.gemspec +2 -2
- data/spec/api/storage_networks_api_spec.rb +70 -15
- data/spec/models/error_spec.rb +6 -4
- data/spec/models/nfs_permissions_create_spec.rb +9 -7
- data/spec/models/nfs_permissions_spec.rb +9 -7
- data/spec/models/nfs_permissions_update_spec.rb +9 -7
- data/spec/models/permissions_create_spec.rb +5 -3
- data/spec/models/permissions_spec.rb +5 -3
- data/spec/models/permissions_update_spec.rb +5 -3
- data/spec/models/status_spec.rb +4 -2
- data/spec/models/storage_network_create_spec.rb +14 -6
- data/spec/models/storage_network_spec.rb +19 -11
- data/spec/models/storage_network_update_spec.rb +6 -4
- data/spec/models/storage_network_volume_create_spec.rb +14 -6
- data/spec/models/tag_assignment_request_spec.rb +42 -0
- data/spec/models/tag_assignment_spec.rb +64 -0
- data/spec/models/volume_create_spec.rb +20 -6
- data/spec/models/volume_spec.rb +32 -12
- data/spec/models/volume_update_spec.rb +29 -3
- data/spec/spec_helper.rb +1 -1
- metadata +20 -16
- data/spec/api_client_spec.rb +0 -226
- 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:
|
9
|
+
OpenAPI Generator version: 7.2.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -28,13 +28,17 @@ module NetworkStorageApi
|
|
28
28
|
# Capacity of Volume in GB. Currently only whole numbers and multiples of 1000GB are supported.
|
29
29
|
attr_accessor :capacity_in_gb
|
30
30
|
|
31
|
+
# Tags to set to the resource. To create a new tag or list all the existing tags that you can use, refer to [Tags API](https://developers.phoenixnap.com/docs/tags/1/overview).
|
32
|
+
attr_accessor :tags
|
33
|
+
|
31
34
|
# Attribute mapping from ruby-style variable name to JSON key.
|
32
35
|
def self.attribute_map
|
33
36
|
{
|
34
37
|
:'name' => :'name',
|
35
38
|
:'description' => :'description',
|
36
39
|
:'path_suffix' => :'pathSuffix',
|
37
|
-
:'capacity_in_gb' => :'capacityInGb'
|
40
|
+
:'capacity_in_gb' => :'capacityInGb',
|
41
|
+
:'tags' => :'tags'
|
38
42
|
}
|
39
43
|
end
|
40
44
|
|
@@ -49,7 +53,8 @@ module NetworkStorageApi
|
|
49
53
|
:'name' => :'String',
|
50
54
|
:'description' => :'String',
|
51
55
|
:'path_suffix' => :'String',
|
52
|
-
:'capacity_in_gb' => :'Integer'
|
56
|
+
:'capacity_in_gb' => :'Integer',
|
57
|
+
:'tags' => :'Array<TagAssignmentRequest>'
|
53
58
|
}
|
54
59
|
end
|
55
60
|
|
@@ -76,6 +81,8 @@ module NetworkStorageApi
|
|
76
81
|
|
77
82
|
if attributes.key?(:'name')
|
78
83
|
self.name = attributes[:'name']
|
84
|
+
else
|
85
|
+
self.name = nil
|
79
86
|
end
|
80
87
|
|
81
88
|
if attributes.key?(:'description')
|
@@ -88,12 +95,21 @@ module NetworkStorageApi
|
|
88
95
|
|
89
96
|
if attributes.key?(:'capacity_in_gb')
|
90
97
|
self.capacity_in_gb = attributes[:'capacity_in_gb']
|
98
|
+
else
|
99
|
+
self.capacity_in_gb = nil
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'tags')
|
103
|
+
if (value = attributes[:'tags']).is_a?(Array)
|
104
|
+
self.tags = value
|
105
|
+
end
|
91
106
|
end
|
92
107
|
end
|
93
108
|
|
94
109
|
# Show invalid properties with the reasons. Usually used together with valid?
|
95
110
|
# @return Array for valid properties with the reasons
|
96
111
|
def list_invalid_properties
|
112
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
97
113
|
invalid_properties = Array.new
|
98
114
|
if @name.nil?
|
99
115
|
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
@@ -107,6 +123,11 @@ module NetworkStorageApi
|
|
107
123
|
invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
|
108
124
|
end
|
109
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
|
+
|
110
131
|
if !@description.nil? && @description.to_s.length > 250
|
111
132
|
invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
|
112
133
|
end
|
@@ -138,9 +159,11 @@ module NetworkStorageApi
|
|
138
159
|
# Check to see if the all the properties in the model are valid
|
139
160
|
# @return true if the model is valid
|
140
161
|
def valid?
|
162
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
141
163
|
return false if @name.nil?
|
142
164
|
return false if @name.to_s.length > 100
|
143
165
|
return false if @name.to_s.length < 1
|
166
|
+
return false if @name !~ Regexp.new(/^(?=.*[a-zA-Z])([a-zA-Z0-9(). -])+$/)
|
144
167
|
return false if !@description.nil? && @description.to_s.length > 250
|
145
168
|
return false if !@path_suffix.nil? && @path_suffix.to_s.length > 27
|
146
169
|
return false if !@path_suffix.nil? && @path_suffix.to_s.length < 0
|
@@ -165,13 +188,22 @@ module NetworkStorageApi
|
|
165
188
|
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
|
166
189
|
end
|
167
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
|
+
|
168
196
|
@name = name
|
169
197
|
end
|
170
198
|
|
171
199
|
# Custom attribute writer method with validation
|
172
200
|
# @param [Object] description Value to be assigned
|
173
201
|
def description=(description)
|
174
|
-
if
|
202
|
+
if description.nil?
|
203
|
+
fail ArgumentError, 'description cannot be nil'
|
204
|
+
end
|
205
|
+
|
206
|
+
if description.to_s.length > 250
|
175
207
|
fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
|
176
208
|
end
|
177
209
|
|
@@ -181,16 +213,20 @@ module NetworkStorageApi
|
|
181
213
|
# Custom attribute writer method with validation
|
182
214
|
# @param [Object] path_suffix Value to be assigned
|
183
215
|
def path_suffix=(path_suffix)
|
184
|
-
if
|
216
|
+
if path_suffix.nil?
|
217
|
+
fail ArgumentError, 'path_suffix cannot be nil'
|
218
|
+
end
|
219
|
+
|
220
|
+
if path_suffix.to_s.length > 27
|
185
221
|
fail ArgumentError, 'invalid value for "path_suffix", the character length must be smaller than or equal to 27.'
|
186
222
|
end
|
187
223
|
|
188
|
-
if
|
224
|
+
if path_suffix.to_s.length < 0
|
189
225
|
fail ArgumentError, 'invalid value for "path_suffix", the character length must be great than or equal to 0.'
|
190
226
|
end
|
191
227
|
|
192
228
|
pattern = Regexp.new(/^(\/[\w-]+)+$|^$/)
|
193
|
-
if
|
229
|
+
if path_suffix !~ pattern
|
194
230
|
fail ArgumentError, "invalid value for \"path_suffix\", must conform to the pattern #{pattern}."
|
195
231
|
end
|
196
232
|
|
@@ -219,7 +255,8 @@ module NetworkStorageApi
|
|
219
255
|
name == o.name &&
|
220
256
|
description == o.description &&
|
221
257
|
path_suffix == o.path_suffix &&
|
222
|
-
capacity_in_gb == o.capacity_in_gb
|
258
|
+
capacity_in_gb == o.capacity_in_gb &&
|
259
|
+
tags == o.tags
|
223
260
|
end
|
224
261
|
|
225
262
|
# @see the `==` method
|
@@ -231,44 +268,37 @@ module NetworkStorageApi
|
|
231
268
|
# Calculates hash code according to all attributes.
|
232
269
|
# @return [Integer] Hash code
|
233
270
|
def hash
|
234
|
-
[name, description, path_suffix, capacity_in_gb].hash
|
271
|
+
[name, description, path_suffix, capacity_in_gb, tags].hash
|
235
272
|
end
|
236
273
|
|
237
274
|
# Builds the object from hash
|
238
275
|
# @param [Hash] attributes Model attributes in the form of hash
|
239
276
|
# @return [Object] Returns the model itself
|
240
277
|
def self.build_from_hash(attributes)
|
241
|
-
new.build_from_hash(attributes)
|
242
|
-
end
|
243
|
-
|
244
|
-
# Builds the object from hash
|
245
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
246
|
-
# @return [Object] Returns the model itself
|
247
|
-
def build_from_hash(attributes)
|
248
278
|
return nil unless attributes.is_a?(Hash)
|
249
279
|
attributes = attributes.transform_keys(&:to_sym)
|
250
|
-
|
251
|
-
|
252
|
-
|
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
|
253
284
|
elsif type =~ /\AArray<(.*)>/i
|
254
285
|
# check to ensure the input is an array given that the attribute
|
255
286
|
# is documented as an array but the input is not
|
256
|
-
if attributes[
|
257
|
-
|
287
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
288
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
258
289
|
end
|
259
|
-
elsif !attributes[
|
260
|
-
|
290
|
+
elsif !attributes[attribute_map[key]].nil?
|
291
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
261
292
|
end
|
262
293
|
end
|
263
|
-
|
264
|
-
self
|
294
|
+
new(transformed_hash)
|
265
295
|
end
|
266
296
|
|
267
297
|
# Deserializes the data based on type
|
268
298
|
# @param string type Data type
|
269
299
|
# @param string value Value to be deserialized
|
270
300
|
# @return [Object] Deserialized data
|
271
|
-
def _deserialize(type, value)
|
301
|
+
def self._deserialize(type, value)
|
272
302
|
case type.to_sym
|
273
303
|
when :Time
|
274
304
|
Time.parse(value)
|
@@ -303,7 +333,7 @@ module NetworkStorageApi
|
|
303
333
|
else # model
|
304
334
|
# models (e.g. Pet) or oneOf
|
305
335
|
klass = NetworkStorageApi.const_get(type)
|
306
|
-
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)
|
307
337
|
end
|
308
338
|
end
|
309
339
|
|
@@ -0,0 +1,311 @@
|
|
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: 7.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module NetworkStorageApi
|
17
|
+
# Tag assigned to resource.
|
18
|
+
class TagAssignment
|
19
|
+
# The unique id of the tag.
|
20
|
+
attr_accessor :id
|
21
|
+
|
22
|
+
# The name of the tag.
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
# The value of the tag assigned to the resource.
|
26
|
+
attr_accessor :value
|
27
|
+
|
28
|
+
# Whether or not to show the tag as part of billing and invoices
|
29
|
+
attr_accessor :is_billing_tag
|
30
|
+
|
31
|
+
# Who the tag was created by.
|
32
|
+
attr_accessor :created_by
|
33
|
+
|
34
|
+
class EnumAttributeValidator
|
35
|
+
attr_reader :datatype
|
36
|
+
attr_reader :allowable_values
|
37
|
+
|
38
|
+
def initialize(datatype, allowable_values)
|
39
|
+
@allowable_values = allowable_values.map do |value|
|
40
|
+
case datatype.to_s
|
41
|
+
when /Integer/i
|
42
|
+
value.to_i
|
43
|
+
when /Float/i
|
44
|
+
value.to_f
|
45
|
+
else
|
46
|
+
value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid?(value)
|
52
|
+
!value || allowable_values.include?(value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
57
|
+
def self.attribute_map
|
58
|
+
{
|
59
|
+
:'id' => :'id',
|
60
|
+
:'name' => :'name',
|
61
|
+
:'value' => :'value',
|
62
|
+
:'is_billing_tag' => :'isBillingTag',
|
63
|
+
:'created_by' => :'createdBy'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns all the JSON keys this model knows about
|
68
|
+
def self.acceptable_attributes
|
69
|
+
attribute_map.values
|
70
|
+
end
|
71
|
+
|
72
|
+
# Attribute type mapping.
|
73
|
+
def self.openapi_types
|
74
|
+
{
|
75
|
+
:'id' => :'String',
|
76
|
+
:'name' => :'String',
|
77
|
+
:'value' => :'String',
|
78
|
+
:'is_billing_tag' => :'Boolean',
|
79
|
+
:'created_by' => :'String'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# List of attributes with nullable: true
|
84
|
+
def self.openapi_nullable
|
85
|
+
Set.new([
|
86
|
+
])
|
87
|
+
end
|
88
|
+
|
89
|
+
# Initializes the object
|
90
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
91
|
+
def initialize(attributes = {})
|
92
|
+
if (!attributes.is_a?(Hash))
|
93
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkStorageApi::TagAssignment` initialize method"
|
94
|
+
end
|
95
|
+
|
96
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
97
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
98
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
99
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkStorageApi::TagAssignment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
100
|
+
end
|
101
|
+
h[k.to_sym] = v
|
102
|
+
}
|
103
|
+
|
104
|
+
if attributes.key?(:'id')
|
105
|
+
self.id = attributes[:'id']
|
106
|
+
else
|
107
|
+
self.id = nil
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'name')
|
111
|
+
self.name = attributes[:'name']
|
112
|
+
else
|
113
|
+
self.name = nil
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'value')
|
117
|
+
self.value = attributes[:'value']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'is_billing_tag')
|
121
|
+
self.is_billing_tag = attributes[:'is_billing_tag']
|
122
|
+
else
|
123
|
+
self.is_billing_tag = nil
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.key?(:'created_by')
|
127
|
+
self.created_by = attributes[:'created_by']
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
132
|
+
# @return Array for valid properties with the reasons
|
133
|
+
def list_invalid_properties
|
134
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
135
|
+
invalid_properties = Array.new
|
136
|
+
if @id.nil?
|
137
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
138
|
+
end
|
139
|
+
|
140
|
+
if @name.nil?
|
141
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
142
|
+
end
|
143
|
+
|
144
|
+
if @is_billing_tag.nil?
|
145
|
+
invalid_properties.push('invalid value for "is_billing_tag", is_billing_tag cannot be nil.')
|
146
|
+
end
|
147
|
+
|
148
|
+
invalid_properties
|
149
|
+
end
|
150
|
+
|
151
|
+
# Check to see if the all the properties in the model are valid
|
152
|
+
# @return true if the model is valid
|
153
|
+
def valid?
|
154
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
155
|
+
return false if @id.nil?
|
156
|
+
return false if @name.nil?
|
157
|
+
return false if @is_billing_tag.nil?
|
158
|
+
created_by_validator = EnumAttributeValidator.new('String', ["USER", "SYSTEM"])
|
159
|
+
return false unless created_by_validator.valid?(@created_by)
|
160
|
+
true
|
161
|
+
end
|
162
|
+
|
163
|
+
# Custom attribute writer method checking allowed values (enum).
|
164
|
+
# @param [Object] created_by Object to be assigned
|
165
|
+
def created_by=(created_by)
|
166
|
+
validator = EnumAttributeValidator.new('String', ["USER", "SYSTEM"])
|
167
|
+
unless validator.valid?(created_by)
|
168
|
+
fail ArgumentError, "invalid value for \"created_by\", must be one of #{validator.allowable_values}."
|
169
|
+
end
|
170
|
+
@created_by = created_by
|
171
|
+
end
|
172
|
+
|
173
|
+
# Checks equality by comparing each attribute.
|
174
|
+
# @param [Object] Object to be compared
|
175
|
+
def ==(o)
|
176
|
+
return true if self.equal?(o)
|
177
|
+
self.class == o.class &&
|
178
|
+
id == o.id &&
|
179
|
+
name == o.name &&
|
180
|
+
value == o.value &&
|
181
|
+
is_billing_tag == o.is_billing_tag &&
|
182
|
+
created_by == o.created_by
|
183
|
+
end
|
184
|
+
|
185
|
+
# @see the `==` method
|
186
|
+
# @param [Object] Object to be compared
|
187
|
+
def eql?(o)
|
188
|
+
self == o
|
189
|
+
end
|
190
|
+
|
191
|
+
# Calculates hash code according to all attributes.
|
192
|
+
# @return [Integer] Hash code
|
193
|
+
def hash
|
194
|
+
[id, name, value, is_billing_tag, created_by].hash
|
195
|
+
end
|
196
|
+
|
197
|
+
# Builds the object from hash
|
198
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
199
|
+
# @return [Object] Returns the model itself
|
200
|
+
def self.build_from_hash(attributes)
|
201
|
+
return nil unless attributes.is_a?(Hash)
|
202
|
+
attributes = attributes.transform_keys(&:to_sym)
|
203
|
+
transformed_hash = {}
|
204
|
+
openapi_types.each_pair do |key, type|
|
205
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
206
|
+
transformed_hash["#{key}"] = nil
|
207
|
+
elsif type =~ /\AArray<(.*)>/i
|
208
|
+
# check to ensure the input is an array given that the attribute
|
209
|
+
# is documented as an array but the input is not
|
210
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
211
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
212
|
+
end
|
213
|
+
elsif !attributes[attribute_map[key]].nil?
|
214
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
215
|
+
end
|
216
|
+
end
|
217
|
+
new(transformed_hash)
|
218
|
+
end
|
219
|
+
|
220
|
+
# Deserializes the data based on type
|
221
|
+
# @param string type Data type
|
222
|
+
# @param string value Value to be deserialized
|
223
|
+
# @return [Object] Deserialized data
|
224
|
+
def self._deserialize(type, value)
|
225
|
+
case type.to_sym
|
226
|
+
when :Time
|
227
|
+
Time.parse(value)
|
228
|
+
when :Date
|
229
|
+
Date.parse(value)
|
230
|
+
when :String
|
231
|
+
value.to_s
|
232
|
+
when :Integer
|
233
|
+
value.to_i
|
234
|
+
when :Float
|
235
|
+
value.to_f
|
236
|
+
when :Boolean
|
237
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
238
|
+
true
|
239
|
+
else
|
240
|
+
false
|
241
|
+
end
|
242
|
+
when :Object
|
243
|
+
# generic object (usually a Hash), return directly
|
244
|
+
value
|
245
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
246
|
+
inner_type = Regexp.last_match[:inner_type]
|
247
|
+
value.map { |v| _deserialize(inner_type, v) }
|
248
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
249
|
+
k_type = Regexp.last_match[:k_type]
|
250
|
+
v_type = Regexp.last_match[:v_type]
|
251
|
+
{}.tap do |hash|
|
252
|
+
value.each do |k, v|
|
253
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
else # model
|
257
|
+
# models (e.g. Pet) or oneOf
|
258
|
+
klass = NetworkStorageApi.const_get(type)
|
259
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Returns the string representation of the object
|
264
|
+
# @return [String] String presentation of the object
|
265
|
+
def to_s
|
266
|
+
to_hash.to_s
|
267
|
+
end
|
268
|
+
|
269
|
+
# to_body is an alias to to_hash (backward compatibility)
|
270
|
+
# @return [Hash] Returns the object in the form of hash
|
271
|
+
def to_body
|
272
|
+
to_hash
|
273
|
+
end
|
274
|
+
|
275
|
+
# Returns the object in the form of hash
|
276
|
+
# @return [Hash] Returns the object in the form of hash
|
277
|
+
def to_hash
|
278
|
+
hash = {}
|
279
|
+
self.class.attribute_map.each_pair do |attr, param|
|
280
|
+
value = self.send(attr)
|
281
|
+
if value.nil?
|
282
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
283
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
284
|
+
end
|
285
|
+
|
286
|
+
hash[param] = _to_hash(value)
|
287
|
+
end
|
288
|
+
hash
|
289
|
+
end
|
290
|
+
|
291
|
+
# Outputs non-array value in the form of hash
|
292
|
+
# For object, use to_hash. Otherwise, just return the value
|
293
|
+
# @param [Object] value Any valid value
|
294
|
+
# @return [Hash] Returns the value in the form of hash
|
295
|
+
def _to_hash(value)
|
296
|
+
if value.is_a?(Array)
|
297
|
+
value.compact.map { |v| _to_hash(v) }
|
298
|
+
elsif value.is_a?(Hash)
|
299
|
+
{}.tap do |hash|
|
300
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
301
|
+
end
|
302
|
+
elsif value.respond_to? :to_hash
|
303
|
+
value.to_hash
|
304
|
+
else
|
305
|
+
value
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|