pnap_network_api 2.1.1 → 2.2.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 +1 -0
- data/VERSION +1 -1
- data/docs/BgpIpPrefix.md +24 -0
- data/docs/BgpPeerGroup.md +6 -2
- data/docs/BgpPeerGroupCreate.md +1 -1
- data/docs/NetworkMembership.md +1 -1
- data/docs/PrivateNetworkCreate.md +1 -1
- data/docs/PublicNetwork.md +1 -1
- data/docs/PublicNetworkCreate.md +1 -1
- data/lib/pnap_network_api/api/bgp_peer_groups_api.rb +6 -6
- data/lib/pnap_network_api/api/private_networks_api.rb +6 -6
- data/lib/pnap_network_api/api/public_networks_api.rb +8 -8
- data/lib/pnap_network_api/api_client.rb +17 -14
- data/lib/pnap_network_api/api_error.rb +1 -1
- data/lib/pnap_network_api/api_model_base.rb +88 -0
- data/lib/pnap_network_api/configuration.rb +11 -1
- data/lib/pnap_network_api/models/asn_details.rb +41 -78
- data/lib/pnap_network_api/models/bgp_ip_prefix.rb +247 -0
- data/lib/pnap_network_api/models/bgp_ipv4_prefix.rb +52 -79
- data/lib/pnap_network_api/models/bgp_peer_group.rb +184 -83
- data/lib/pnap_network_api/models/bgp_peer_group_create.rb +44 -81
- data/lib/pnap_network_api/models/bgp_peer_group_patch.rb +13 -80
- data/lib/pnap_network_api/models/error.rb +21 -78
- data/lib/pnap_network_api/models/network_membership.rb +42 -79
- data/lib/pnap_network_api/models/private_network.rb +103 -80
- data/lib/pnap_network_api/models/private_network_create.rb +24 -81
- data/lib/pnap_network_api/models/private_network_modify.rb +23 -80
- data/lib/pnap_network_api/models/private_network_server.rb +31 -78
- data/lib/pnap_network_api/models/public_network.rb +84 -81
- data/lib/pnap_network_api/models/public_network_create.rb +24 -81
- data/lib/pnap_network_api/models/public_network_ip_block.rb +41 -78
- data/lib/pnap_network_api/models/public_network_ip_block_create.rb +21 -78
- data/lib/pnap_network_api/models/public_network_modify.rb +13 -80
- data/lib/pnap_network_api/version.rb +1 -2
- data/lib/pnap_network_api.rb +3 -1
- data/pnap_network_api.gemspec +6 -6
- data/spec/api/bgp_peer_groups_api_spec.rb +1 -1
- data/spec/api/private_networks_api_spec.rb +1 -1
- data/spec/api/public_networks_api_spec.rb +1 -1
- data/spec/models/asn_details_spec.rb +2 -2
- data/spec/models/bgp_ip_prefix_spec.rb +54 -0
- data/spec/models/bgp_ipv4_prefix_spec.rb +2 -2
- data/spec/models/bgp_peer_group_create_spec.rb +2 -2
- data/spec/models/bgp_peer_group_patch_spec.rb +2 -2
- data/spec/models/bgp_peer_group_spec.rb +14 -2
- data/spec/models/error_spec.rb +2 -2
- data/spec/models/network_membership_spec.rb +2 -2
- data/spec/models/private_network_create_spec.rb +2 -2
- data/spec/models/private_network_modify_spec.rb +2 -2
- data/spec/models/private_network_server_spec.rb +2 -2
- data/spec/models/private_network_spec.rb +2 -2
- data/spec/models/public_network_create_spec.rb +2 -2
- data/spec/models/public_network_ip_block_create_spec.rb +2 -2
- data/spec/models/public_network_ip_block_spec.rb +2 -2
- data/spec/models/public_network_modify_spec.rb +2 -2
- data/spec/models/public_network_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +29 -16
|
@@ -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
|
-
|
|
9
|
+
Generator version: 7.20.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ require 'time'
|
|
|
15
15
|
|
|
16
16
|
module NetworkApi
|
|
17
17
|
# Update a BGP Peer Group.
|
|
18
|
-
class BgpPeerGroupPatch
|
|
18
|
+
class BgpPeerGroupPatch < ApiModelBase
|
|
19
19
|
# The BGP Peer Group ASN.
|
|
20
20
|
attr_accessor :asn
|
|
21
21
|
|
|
@@ -34,9 +34,14 @@ module NetworkApi
|
|
|
34
34
|
}
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Returns attribute mapping this model knows about
|
|
38
|
+
def self.acceptable_attribute_map
|
|
39
|
+
attribute_map
|
|
40
|
+
end
|
|
41
|
+
|
|
37
42
|
# Returns all the JSON keys this model knows about
|
|
38
43
|
def self.acceptable_attributes
|
|
39
|
-
|
|
44
|
+
acceptable_attribute_map.values
|
|
40
45
|
end
|
|
41
46
|
|
|
42
47
|
# Attribute type mapping.
|
|
@@ -62,9 +67,10 @@ module NetworkApi
|
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
# check to see if the attribute exists and convert string to symbol for hash key
|
|
70
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
65
71
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
66
|
-
if (!
|
|
67
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::BgpPeerGroupPatch`. Please check the name to make sure it's valid. List of attributes: " +
|
|
72
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
73
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::BgpPeerGroupPatch`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
68
74
|
end
|
|
69
75
|
h[k.to_sym] = v
|
|
70
76
|
}
|
|
@@ -92,7 +98,7 @@ module NetworkApi
|
|
|
92
98
|
end
|
|
93
99
|
|
|
94
100
|
if !@password.nil? && @password.to_s.length < 8
|
|
95
|
-
invalid_properties.push('invalid value for "password", the character length must be
|
|
101
|
+
invalid_properties.push('invalid value for "password", the character length must be greater than or equal to 8.')
|
|
96
102
|
end
|
|
97
103
|
|
|
98
104
|
pattern = Regexp.new(/^[a-zA-Z0-9!@#$%^&*()\-|\[\]{}=;:<>,.]+$/)
|
|
@@ -125,7 +131,7 @@ module NetworkApi
|
|
|
125
131
|
end
|
|
126
132
|
|
|
127
133
|
if password.to_s.length < 8
|
|
128
|
-
fail ArgumentError, 'invalid value for "password", the character length must be
|
|
134
|
+
fail ArgumentError, 'invalid value for "password", the character length must be greater than or equal to 8.'
|
|
129
135
|
end
|
|
130
136
|
|
|
131
137
|
pattern = Regexp.new(/^[a-zA-Z0-9!@#$%^&*()\-|\[\]{}=;:<>,.]+$/)
|
|
@@ -181,61 +187,6 @@ module NetworkApi
|
|
|
181
187
|
new(transformed_hash)
|
|
182
188
|
end
|
|
183
189
|
|
|
184
|
-
# Deserializes the data based on type
|
|
185
|
-
# @param string type Data type
|
|
186
|
-
# @param string value Value to be deserialized
|
|
187
|
-
# @return [Object] Deserialized data
|
|
188
|
-
def self._deserialize(type, value)
|
|
189
|
-
case type.to_sym
|
|
190
|
-
when :Time
|
|
191
|
-
Time.parse(value)
|
|
192
|
-
when :Date
|
|
193
|
-
Date.parse(value)
|
|
194
|
-
when :String
|
|
195
|
-
value.to_s
|
|
196
|
-
when :Integer
|
|
197
|
-
value.to_i
|
|
198
|
-
when :Float
|
|
199
|
-
value.to_f
|
|
200
|
-
when :Boolean
|
|
201
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
202
|
-
true
|
|
203
|
-
else
|
|
204
|
-
false
|
|
205
|
-
end
|
|
206
|
-
when :Object
|
|
207
|
-
# generic object (usually a Hash), return directly
|
|
208
|
-
value
|
|
209
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
210
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
211
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
212
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
213
|
-
k_type = Regexp.last_match[:k_type]
|
|
214
|
-
v_type = Regexp.last_match[:v_type]
|
|
215
|
-
{}.tap do |hash|
|
|
216
|
-
value.each do |k, v|
|
|
217
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
else # model
|
|
221
|
-
# models (e.g. Pet) or oneOf
|
|
222
|
-
klass = NetworkApi.const_get(type)
|
|
223
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Returns the string representation of the object
|
|
228
|
-
# @return [String] String presentation of the object
|
|
229
|
-
def to_s
|
|
230
|
-
to_hash.to_s
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
# to_body is an alias to to_hash (backward compatibility)
|
|
234
|
-
# @return [Hash] Returns the object in the form of hash
|
|
235
|
-
def to_body
|
|
236
|
-
to_hash
|
|
237
|
-
end
|
|
238
|
-
|
|
239
190
|
# Returns the object in the form of hash
|
|
240
191
|
# @return [Hash] Returns the object in the form of hash
|
|
241
192
|
def to_hash
|
|
@@ -252,24 +203,6 @@ module NetworkApi
|
|
|
252
203
|
hash
|
|
253
204
|
end
|
|
254
205
|
|
|
255
|
-
# Outputs non-array value in the form of hash
|
|
256
|
-
# For object, use to_hash. Otherwise, just return the value
|
|
257
|
-
# @param [Object] value Any valid value
|
|
258
|
-
# @return [Hash] Returns the value in the form of hash
|
|
259
|
-
def _to_hash(value)
|
|
260
|
-
if value.is_a?(Array)
|
|
261
|
-
value.compact.map { |v| _to_hash(v) }
|
|
262
|
-
elsif value.is_a?(Hash)
|
|
263
|
-
{}.tap do |hash|
|
|
264
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
265
|
-
end
|
|
266
|
-
elsif value.respond_to? :to_hash
|
|
267
|
-
value.to_hash
|
|
268
|
-
else
|
|
269
|
-
value
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
206
|
end
|
|
274
207
|
|
|
275
208
|
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
|
-
|
|
9
|
+
Generator version: 7.20.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module NetworkApi
|
|
17
|
-
class Error
|
|
17
|
+
class Error < ApiModelBase
|
|
18
18
|
# The description detailing the cause of the error code.
|
|
19
19
|
attr_accessor :message
|
|
20
20
|
|
|
@@ -29,9 +29,14 @@ module NetworkApi
|
|
|
29
29
|
}
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Returns attribute mapping this model knows about
|
|
33
|
+
def self.acceptable_attribute_map
|
|
34
|
+
attribute_map
|
|
35
|
+
end
|
|
36
|
+
|
|
32
37
|
# Returns all the JSON keys this model knows about
|
|
33
38
|
def self.acceptable_attributes
|
|
34
|
-
|
|
39
|
+
acceptable_attribute_map.values
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
# Attribute type mapping.
|
|
@@ -56,9 +61,10 @@ module NetworkApi
|
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
# check to see if the attribute exists and convert string to symbol for hash key
|
|
64
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
59
65
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
60
|
-
if (!
|
|
61
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::Error`. Please check the name to make sure it's valid. List of attributes: " +
|
|
66
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::Error`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
62
68
|
end
|
|
63
69
|
h[k.to_sym] = v
|
|
64
70
|
}
|
|
@@ -96,6 +102,16 @@ module NetworkApi
|
|
|
96
102
|
true
|
|
97
103
|
end
|
|
98
104
|
|
|
105
|
+
# Custom attribute writer method with validation
|
|
106
|
+
# @param [Object] message Value to be assigned
|
|
107
|
+
def message=(message)
|
|
108
|
+
if message.nil?
|
|
109
|
+
fail ArgumentError, 'message cannot be nil'
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
@message = message
|
|
113
|
+
end
|
|
114
|
+
|
|
99
115
|
# Checks equality by comparing each attribute.
|
|
100
116
|
# @param [Object] Object to be compared
|
|
101
117
|
def ==(o)
|
|
@@ -140,61 +156,6 @@ module NetworkApi
|
|
|
140
156
|
new(transformed_hash)
|
|
141
157
|
end
|
|
142
158
|
|
|
143
|
-
# Deserializes the data based on type
|
|
144
|
-
# @param string type Data type
|
|
145
|
-
# @param string value Value to be deserialized
|
|
146
|
-
# @return [Object] Deserialized data
|
|
147
|
-
def self._deserialize(type, value)
|
|
148
|
-
case type.to_sym
|
|
149
|
-
when :Time
|
|
150
|
-
Time.parse(value)
|
|
151
|
-
when :Date
|
|
152
|
-
Date.parse(value)
|
|
153
|
-
when :String
|
|
154
|
-
value.to_s
|
|
155
|
-
when :Integer
|
|
156
|
-
value.to_i
|
|
157
|
-
when :Float
|
|
158
|
-
value.to_f
|
|
159
|
-
when :Boolean
|
|
160
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
161
|
-
true
|
|
162
|
-
else
|
|
163
|
-
false
|
|
164
|
-
end
|
|
165
|
-
when :Object
|
|
166
|
-
# generic object (usually a Hash), return directly
|
|
167
|
-
value
|
|
168
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
169
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
170
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
171
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
172
|
-
k_type = Regexp.last_match[:k_type]
|
|
173
|
-
v_type = Regexp.last_match[:v_type]
|
|
174
|
-
{}.tap do |hash|
|
|
175
|
-
value.each do |k, v|
|
|
176
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
else # model
|
|
180
|
-
# models (e.g. Pet) or oneOf
|
|
181
|
-
klass = NetworkApi.const_get(type)
|
|
182
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# Returns the string representation of the object
|
|
187
|
-
# @return [String] String presentation of the object
|
|
188
|
-
def to_s
|
|
189
|
-
to_hash.to_s
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# to_body is an alias to to_hash (backward compatibility)
|
|
193
|
-
# @return [Hash] Returns the object in the form of hash
|
|
194
|
-
def to_body
|
|
195
|
-
to_hash
|
|
196
|
-
end
|
|
197
|
-
|
|
198
159
|
# Returns the object in the form of hash
|
|
199
160
|
# @return [Hash] Returns the object in the form of hash
|
|
200
161
|
def to_hash
|
|
@@ -211,24 +172,6 @@ module NetworkApi
|
|
|
211
172
|
hash
|
|
212
173
|
end
|
|
213
174
|
|
|
214
|
-
# Outputs non-array value in the form of hash
|
|
215
|
-
# For object, use to_hash. Otherwise, just return the value
|
|
216
|
-
# @param [Object] value Any valid value
|
|
217
|
-
# @return [Hash] Returns the value in the form of hash
|
|
218
|
-
def _to_hash(value)
|
|
219
|
-
if value.is_a?(Array)
|
|
220
|
-
value.compact.map { |v| _to_hash(v) }
|
|
221
|
-
elsif value.is_a?(Hash)
|
|
222
|
-
{}.tap do |hash|
|
|
223
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
224
|
-
end
|
|
225
|
-
elsif value.respond_to? :to_hash
|
|
226
|
-
value.to_hash
|
|
227
|
-
else
|
|
228
|
-
value
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
|
|
232
175
|
end
|
|
233
176
|
|
|
234
177
|
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
|
-
|
|
9
|
+
Generator version: 7.20.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -15,11 +15,11 @@ require 'time'
|
|
|
15
15
|
|
|
16
16
|
module NetworkApi
|
|
17
17
|
# Resource details linked to the Network.
|
|
18
|
-
class NetworkMembership
|
|
18
|
+
class NetworkMembership < ApiModelBase
|
|
19
19
|
# The resource identifier.
|
|
20
20
|
attr_accessor :resource_id
|
|
21
21
|
|
|
22
|
-
# The resource's type.
|
|
22
|
+
# The resource's type. Can have one of the following values: `server`, `storage` or `virtual`.
|
|
23
23
|
attr_accessor :resource_type
|
|
24
24
|
|
|
25
25
|
# List of IPs associated to the resource.
|
|
@@ -34,9 +34,14 @@ module NetworkApi
|
|
|
34
34
|
}
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Returns attribute mapping this model knows about
|
|
38
|
+
def self.acceptable_attribute_map
|
|
39
|
+
attribute_map
|
|
40
|
+
end
|
|
41
|
+
|
|
37
42
|
# Returns all the JSON keys this model knows about
|
|
38
43
|
def self.acceptable_attributes
|
|
39
|
-
|
|
44
|
+
acceptable_attribute_map.values
|
|
40
45
|
end
|
|
41
46
|
|
|
42
47
|
# Attribute type mapping.
|
|
@@ -62,9 +67,10 @@ module NetworkApi
|
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
# check to see if the attribute exists and convert string to symbol for hash key
|
|
70
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
65
71
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
66
|
-
if (!
|
|
67
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::NetworkMembership`. Please check the name to make sure it's valid. List of attributes: " +
|
|
72
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
73
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::NetworkMembership`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
68
74
|
end
|
|
69
75
|
h[k.to_sym] = v
|
|
70
76
|
}
|
|
@@ -120,6 +126,36 @@ module NetworkApi
|
|
|
120
126
|
true
|
|
121
127
|
end
|
|
122
128
|
|
|
129
|
+
# Custom attribute writer method with validation
|
|
130
|
+
# @param [Object] resource_id Value to be assigned
|
|
131
|
+
def resource_id=(resource_id)
|
|
132
|
+
if resource_id.nil?
|
|
133
|
+
fail ArgumentError, 'resource_id cannot be nil'
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
@resource_id = resource_id
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Custom attribute writer method with validation
|
|
140
|
+
# @param [Object] resource_type Value to be assigned
|
|
141
|
+
def resource_type=(resource_type)
|
|
142
|
+
if resource_type.nil?
|
|
143
|
+
fail ArgumentError, 'resource_type cannot be nil'
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
@resource_type = resource_type
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Custom attribute writer method with validation
|
|
150
|
+
# @param [Object] ips Value to be assigned
|
|
151
|
+
def ips=(ips)
|
|
152
|
+
if ips.nil?
|
|
153
|
+
fail ArgumentError, 'ips cannot be nil'
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
@ips = ips
|
|
157
|
+
end
|
|
158
|
+
|
|
123
159
|
# Checks equality by comparing each attribute.
|
|
124
160
|
# @param [Object] Object to be compared
|
|
125
161
|
def ==(o)
|
|
@@ -165,61 +201,6 @@ module NetworkApi
|
|
|
165
201
|
new(transformed_hash)
|
|
166
202
|
end
|
|
167
203
|
|
|
168
|
-
# Deserializes the data based on type
|
|
169
|
-
# @param string type Data type
|
|
170
|
-
# @param string value Value to be deserialized
|
|
171
|
-
# @return [Object] Deserialized data
|
|
172
|
-
def self._deserialize(type, value)
|
|
173
|
-
case type.to_sym
|
|
174
|
-
when :Time
|
|
175
|
-
Time.parse(value)
|
|
176
|
-
when :Date
|
|
177
|
-
Date.parse(value)
|
|
178
|
-
when :String
|
|
179
|
-
value.to_s
|
|
180
|
-
when :Integer
|
|
181
|
-
value.to_i
|
|
182
|
-
when :Float
|
|
183
|
-
value.to_f
|
|
184
|
-
when :Boolean
|
|
185
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
186
|
-
true
|
|
187
|
-
else
|
|
188
|
-
false
|
|
189
|
-
end
|
|
190
|
-
when :Object
|
|
191
|
-
# generic object (usually a Hash), return directly
|
|
192
|
-
value
|
|
193
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
|
194
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
195
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
196
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
197
|
-
k_type = Regexp.last_match[:k_type]
|
|
198
|
-
v_type = Regexp.last_match[:v_type]
|
|
199
|
-
{}.tap do |hash|
|
|
200
|
-
value.each do |k, v|
|
|
201
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
else # model
|
|
205
|
-
# models (e.g. Pet) or oneOf
|
|
206
|
-
klass = NetworkApi.const_get(type)
|
|
207
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
# Returns the string representation of the object
|
|
212
|
-
# @return [String] String presentation of the object
|
|
213
|
-
def to_s
|
|
214
|
-
to_hash.to_s
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# to_body is an alias to to_hash (backward compatibility)
|
|
218
|
-
# @return [Hash] Returns the object in the form of hash
|
|
219
|
-
def to_body
|
|
220
|
-
to_hash
|
|
221
|
-
end
|
|
222
|
-
|
|
223
204
|
# Returns the object in the form of hash
|
|
224
205
|
# @return [Hash] Returns the object in the form of hash
|
|
225
206
|
def to_hash
|
|
@@ -236,24 +217,6 @@ module NetworkApi
|
|
|
236
217
|
hash
|
|
237
218
|
end
|
|
238
219
|
|
|
239
|
-
# Outputs non-array value in the form of hash
|
|
240
|
-
# For object, use to_hash. Otherwise, just return the value
|
|
241
|
-
# @param [Object] value Any valid value
|
|
242
|
-
# @return [Hash] Returns the value in the form of hash
|
|
243
|
-
def _to_hash(value)
|
|
244
|
-
if value.is_a?(Array)
|
|
245
|
-
value.compact.map { |v| _to_hash(v) }
|
|
246
|
-
elsif value.is_a?(Hash)
|
|
247
|
-
{}.tap do |hash|
|
|
248
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
249
|
-
end
|
|
250
|
-
elsif value.respond_to? :to_hash
|
|
251
|
-
value.to_hash
|
|
252
|
-
else
|
|
253
|
-
value
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
220
|
end
|
|
258
221
|
|
|
259
222
|
end
|