pnap_network_api 1.0.0 → 1.1.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 +18 -5
- data/VERSION +1 -1
- data/docs/NetworkMembership.md +22 -0
- data/docs/PrivateNetwork.md +7 -1
- data/docs/PublicNetwork.md +34 -0
- data/docs/PublicNetworkCreate.md +24 -0
- data/docs/PublicNetworkIpBlock.md +18 -0
- data/docs/PublicNetworkMembership.md +22 -0
- data/docs/PublicNetworkModify.md +20 -0
- data/docs/PublicNetworksApi.md +510 -0
- data/lib/pnap_network_api/api/private_networks_api.rb +1 -1
- data/lib/pnap_network_api/api/public_networks_api.rb +481 -0
- data/lib/pnap_network_api/api_client.rb +1 -1
- data/lib/pnap_network_api/api_error.rb +1 -1
- data/lib/pnap_network_api/configuration.rb +1 -1
- data/lib/pnap_network_api/models/error.rb +1 -1
- data/lib/pnap_network_api/models/network_membership.rb +257 -0
- data/lib/pnap_network_api/models/private_network.rb +95 -5
- data/lib/pnap_network_api/models/private_network_create.rb +44 -1
- data/lib/pnap_network_api/models/private_network_modify.rb +44 -1
- data/lib/pnap_network_api/models/private_network_server.rb +1 -1
- data/lib/pnap_network_api/models/public_network.rb +387 -0
- data/lib/pnap_network_api/models/public_network_create.rb +320 -0
- data/lib/pnap_network_api/models/public_network_ip_block.rb +225 -0
- data/lib/pnap_network_api/models/public_network_membership.rb +257 -0
- data/lib/pnap_network_api/models/public_network_modify.rb +269 -0
- data/lib/pnap_network_api/version.rb +1 -1
- data/lib/pnap_network_api.rb +7 -1
- data/pnap_network_api.gemspec +2 -2
- data/spec/api/public_networks_api_spec.rb +122 -0
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/network_membership_spec.rb +46 -0
- data/spec/models/public_network_create_spec.rb +52 -0
- data/spec/models/public_network_ip_block_spec.rb +34 -0
- data/spec/models/public_network_membership_spec.rb +46 -0
- data/spec/models/public_network_modify_spec.rb +40 -0
- data/spec/models/public_network_spec.rb +76 -0
- data/spec/spec_helper.rb +1 -1
- metadata +34 -6
@@ -0,0 +1,387 @@
|
|
1
|
+
=begin
|
2
|
+
#Networks API
|
3
|
+
|
4
|
+
#Create, list, edit and delete public/private networks with the Network API. Use public networks to place multiple servers on the same network or VLAN. Assign new servers with IP addresses from the same CIDR range. Use private networks to avoid unnecessary egress data charges. Model your networks according to your business needs.<br> <br> <span class='pnap-api-knowledge-base-link'> Helpful knowledge base articles are available for <a href='https://phoenixnap.com/kb/bmc-server-management-via-api#multi-private-backend-network-api' target='_blank'>multi-private backend networks</a> and <a href='https://phoenixnap.com/kb/bmc-server-management-via-api#ftoc-heading-15' target='_blank'>public networks</a>. </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/networks/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 NetworkApi
|
17
|
+
# Public Network details.
|
18
|
+
class PublicNetwork
|
19
|
+
# The public network identifier.
|
20
|
+
attr_accessor :id
|
21
|
+
|
22
|
+
# The VLAN of this public network.
|
23
|
+
attr_accessor :vlan_id
|
24
|
+
|
25
|
+
# A list of resources that are members of this public network.
|
26
|
+
attr_accessor :memberships
|
27
|
+
|
28
|
+
# The friendly name of this public network.
|
29
|
+
attr_accessor :name
|
30
|
+
|
31
|
+
# The location of this public network. Supported values are `PHX`, `ASH`, `SGP`, `NLD`, `CHI`, `SEA` and `AUS`.
|
32
|
+
attr_accessor :location
|
33
|
+
|
34
|
+
# The description of this public network.
|
35
|
+
attr_accessor :description
|
36
|
+
|
37
|
+
# The status of the public network. Can have one of the following values: `BUSY` or `READY`.
|
38
|
+
attr_accessor :status
|
39
|
+
|
40
|
+
# Date and time when this public network was created.
|
41
|
+
attr_accessor :created_on
|
42
|
+
|
43
|
+
# A list of IP Blocks that are associated with this public network.
|
44
|
+
attr_accessor :ip_blocks
|
45
|
+
|
46
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
47
|
+
def self.attribute_map
|
48
|
+
{
|
49
|
+
:'id' => :'id',
|
50
|
+
:'vlan_id' => :'vlanId',
|
51
|
+
:'memberships' => :'memberships',
|
52
|
+
:'name' => :'name',
|
53
|
+
:'location' => :'location',
|
54
|
+
:'description' => :'description',
|
55
|
+
:'status' => :'status',
|
56
|
+
:'created_on' => :'createdOn',
|
57
|
+
:'ip_blocks' => :'ipBlocks'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns all the JSON keys this model knows about
|
62
|
+
def self.acceptable_attributes
|
63
|
+
attribute_map.values
|
64
|
+
end
|
65
|
+
|
66
|
+
# Attribute type mapping.
|
67
|
+
def self.openapi_types
|
68
|
+
{
|
69
|
+
:'id' => :'String',
|
70
|
+
:'vlan_id' => :'Integer',
|
71
|
+
:'memberships' => :'Array<NetworkMembership>',
|
72
|
+
:'name' => :'String',
|
73
|
+
:'location' => :'String',
|
74
|
+
:'description' => :'String',
|
75
|
+
:'status' => :'String',
|
76
|
+
:'created_on' => :'Time',
|
77
|
+
:'ip_blocks' => :'Array<PublicNetworkIpBlock>'
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
# List of attributes with nullable: true
|
82
|
+
def self.openapi_nullable
|
83
|
+
Set.new([
|
84
|
+
])
|
85
|
+
end
|
86
|
+
|
87
|
+
# Initializes the object
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
+
def initialize(attributes = {})
|
90
|
+
if (!attributes.is_a?(Hash))
|
91
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkApi::PublicNetwork` initialize method"
|
92
|
+
end
|
93
|
+
|
94
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
95
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
96
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
97
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkApi::PublicNetwork`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
98
|
+
end
|
99
|
+
h[k.to_sym] = v
|
100
|
+
}
|
101
|
+
|
102
|
+
if attributes.key?(:'id')
|
103
|
+
self.id = attributes[:'id']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'vlan_id')
|
107
|
+
self.vlan_id = attributes[:'vlan_id']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'memberships')
|
111
|
+
if (value = attributes[:'memberships']).is_a?(Array)
|
112
|
+
self.memberships = value
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'name')
|
117
|
+
self.name = attributes[:'name']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'location')
|
121
|
+
self.location = attributes[:'location']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'description')
|
125
|
+
self.description = attributes[:'description']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'status')
|
129
|
+
self.status = attributes[:'status']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'created_on')
|
133
|
+
self.created_on = attributes[:'created_on']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'ip_blocks')
|
137
|
+
if (value = attributes[:'ip_blocks']).is_a?(Array)
|
138
|
+
self.ip_blocks = value
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
144
|
+
# @return Array for valid properties with the reasons
|
145
|
+
def list_invalid_properties
|
146
|
+
invalid_properties = Array.new
|
147
|
+
if @id.nil?
|
148
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
149
|
+
end
|
150
|
+
|
151
|
+
if @vlan_id.nil?
|
152
|
+
invalid_properties.push('invalid value for "vlan_id", vlan_id cannot be nil.')
|
153
|
+
end
|
154
|
+
|
155
|
+
if @memberships.nil?
|
156
|
+
invalid_properties.push('invalid value for "memberships", memberships cannot be nil.')
|
157
|
+
end
|
158
|
+
|
159
|
+
if @name.nil?
|
160
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
161
|
+
end
|
162
|
+
|
163
|
+
if @name.to_s.length > 100
|
164
|
+
invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
|
165
|
+
end
|
166
|
+
|
167
|
+
if @name.to_s.length < 1
|
168
|
+
invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
|
169
|
+
end
|
170
|
+
|
171
|
+
if @location.nil?
|
172
|
+
invalid_properties.push('invalid value for "location", location cannot be nil.')
|
173
|
+
end
|
174
|
+
|
175
|
+
if !@description.nil? && @description.to_s.length > 250
|
176
|
+
invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 250.')
|
177
|
+
end
|
178
|
+
|
179
|
+
if @status.nil?
|
180
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
181
|
+
end
|
182
|
+
|
183
|
+
if @created_on.nil?
|
184
|
+
invalid_properties.push('invalid value for "created_on", created_on cannot be nil.')
|
185
|
+
end
|
186
|
+
|
187
|
+
if @ip_blocks.nil?
|
188
|
+
invalid_properties.push('invalid value for "ip_blocks", ip_blocks cannot be nil.')
|
189
|
+
end
|
190
|
+
|
191
|
+
invalid_properties
|
192
|
+
end
|
193
|
+
|
194
|
+
# Check to see if the all the properties in the model are valid
|
195
|
+
# @return true if the model is valid
|
196
|
+
def valid?
|
197
|
+
return false if @id.nil?
|
198
|
+
return false if @vlan_id.nil?
|
199
|
+
return false if @memberships.nil?
|
200
|
+
return false if @name.nil?
|
201
|
+
return false if @name.to_s.length > 100
|
202
|
+
return false if @name.to_s.length < 1
|
203
|
+
return false if @location.nil?
|
204
|
+
return false if !@description.nil? && @description.to_s.length > 250
|
205
|
+
return false if @status.nil?
|
206
|
+
return false if @created_on.nil?
|
207
|
+
return false if @ip_blocks.nil?
|
208
|
+
true
|
209
|
+
end
|
210
|
+
|
211
|
+
# Custom attribute writer method with validation
|
212
|
+
# @param [Object] name Value to be assigned
|
213
|
+
def name=(name)
|
214
|
+
if name.nil?
|
215
|
+
fail ArgumentError, 'name cannot be nil'
|
216
|
+
end
|
217
|
+
|
218
|
+
if name.to_s.length > 100
|
219
|
+
fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
|
220
|
+
end
|
221
|
+
|
222
|
+
if name.to_s.length < 1
|
223
|
+
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
|
224
|
+
end
|
225
|
+
|
226
|
+
@name = name
|
227
|
+
end
|
228
|
+
|
229
|
+
# Custom attribute writer method with validation
|
230
|
+
# @param [Object] description Value to be assigned
|
231
|
+
def description=(description)
|
232
|
+
if !description.nil? && description.to_s.length > 250
|
233
|
+
fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
|
234
|
+
end
|
235
|
+
|
236
|
+
@description = description
|
237
|
+
end
|
238
|
+
|
239
|
+
# Checks equality by comparing each attribute.
|
240
|
+
# @param [Object] Object to be compared
|
241
|
+
def ==(o)
|
242
|
+
return true if self.equal?(o)
|
243
|
+
self.class == o.class &&
|
244
|
+
id == o.id &&
|
245
|
+
vlan_id == o.vlan_id &&
|
246
|
+
memberships == o.memberships &&
|
247
|
+
name == o.name &&
|
248
|
+
location == o.location &&
|
249
|
+
description == o.description &&
|
250
|
+
status == o.status &&
|
251
|
+
created_on == o.created_on &&
|
252
|
+
ip_blocks == o.ip_blocks
|
253
|
+
end
|
254
|
+
|
255
|
+
# @see the `==` method
|
256
|
+
# @param [Object] Object to be compared
|
257
|
+
def eql?(o)
|
258
|
+
self == o
|
259
|
+
end
|
260
|
+
|
261
|
+
# Calculates hash code according to all attributes.
|
262
|
+
# @return [Integer] Hash code
|
263
|
+
def hash
|
264
|
+
[id, vlan_id, memberships, name, location, description, status, created_on, ip_blocks].hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Builds the object from hash
|
268
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
269
|
+
# @return [Object] Returns the model itself
|
270
|
+
def self.build_from_hash(attributes)
|
271
|
+
new.build_from_hash(attributes)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Builds the object from hash
|
275
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
276
|
+
# @return [Object] Returns the model itself
|
277
|
+
def build_from_hash(attributes)
|
278
|
+
return nil unless attributes.is_a?(Hash)
|
279
|
+
self.class.openapi_types.each_pair do |key, type|
|
280
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
281
|
+
self.send("#{key}=", nil)
|
282
|
+
elsif type =~ /\AArray<(.*)>/i
|
283
|
+
# check to ensure the input is an array given that the attribute
|
284
|
+
# is documented as an array but the input is not
|
285
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
286
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
287
|
+
end
|
288
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
289
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
self
|
294
|
+
end
|
295
|
+
|
296
|
+
# Deserializes the data based on type
|
297
|
+
# @param string type Data type
|
298
|
+
# @param string value Value to be deserialized
|
299
|
+
# @return [Object] Deserialized data
|
300
|
+
def _deserialize(type, value)
|
301
|
+
case type.to_sym
|
302
|
+
when :Time
|
303
|
+
Time.parse(value)
|
304
|
+
when :Date
|
305
|
+
Date.parse(value)
|
306
|
+
when :String
|
307
|
+
value.to_s
|
308
|
+
when :Integer
|
309
|
+
value.to_i
|
310
|
+
when :Float
|
311
|
+
value.to_f
|
312
|
+
when :Boolean
|
313
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
314
|
+
true
|
315
|
+
else
|
316
|
+
false
|
317
|
+
end
|
318
|
+
when :Object
|
319
|
+
# generic object (usually a Hash), return directly
|
320
|
+
value
|
321
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
322
|
+
inner_type = Regexp.last_match[:inner_type]
|
323
|
+
value.map { |v| _deserialize(inner_type, v) }
|
324
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
325
|
+
k_type = Regexp.last_match[:k_type]
|
326
|
+
v_type = Regexp.last_match[:v_type]
|
327
|
+
{}.tap do |hash|
|
328
|
+
value.each do |k, v|
|
329
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
else # model
|
333
|
+
# models (e.g. Pet) or oneOf
|
334
|
+
klass = NetworkApi.const_get(type)
|
335
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
# Returns the string representation of the object
|
340
|
+
# @return [String] String presentation of the object
|
341
|
+
def to_s
|
342
|
+
to_hash.to_s
|
343
|
+
end
|
344
|
+
|
345
|
+
# to_body is an alias to to_hash (backward compatibility)
|
346
|
+
# @return [Hash] Returns the object in the form of hash
|
347
|
+
def to_body
|
348
|
+
to_hash
|
349
|
+
end
|
350
|
+
|
351
|
+
# Returns the object in the form of hash
|
352
|
+
# @return [Hash] Returns the object in the form of hash
|
353
|
+
def to_hash
|
354
|
+
hash = {}
|
355
|
+
self.class.attribute_map.each_pair do |attr, param|
|
356
|
+
value = self.send(attr)
|
357
|
+
if value.nil?
|
358
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
359
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
360
|
+
end
|
361
|
+
|
362
|
+
hash[param] = _to_hash(value)
|
363
|
+
end
|
364
|
+
hash
|
365
|
+
end
|
366
|
+
|
367
|
+
# Outputs non-array value in the form of hash
|
368
|
+
# For object, use to_hash. Otherwise, just return the value
|
369
|
+
# @param [Object] value Any valid value
|
370
|
+
# @return [Hash] Returns the value in the form of hash
|
371
|
+
def _to_hash(value)
|
372
|
+
if value.is_a?(Array)
|
373
|
+
value.compact.map { |v| _to_hash(v) }
|
374
|
+
elsif value.is_a?(Hash)
|
375
|
+
{}.tap do |hash|
|
376
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
377
|
+
end
|
378
|
+
elsif value.respond_to? :to_hash
|
379
|
+
value.to_hash
|
380
|
+
else
|
381
|
+
value
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
end
|
386
|
+
|
387
|
+
end
|
@@ -0,0 +1,320 @@
|
|
1
|
+
=begin
|
2
|
+
#Networks API
|
3
|
+
|
4
|
+
#Create, list, edit and delete public/private networks with the Network API. Use public networks to place multiple servers on the same network or VLAN. Assign new servers with IP addresses from the same CIDR range. Use private networks to avoid unnecessary egress data charges. Model your networks according to your business needs.<br> <br> <span class='pnap-api-knowledge-base-link'> Helpful knowledge base articles are available for <a href='https://phoenixnap.com/kb/bmc-server-management-via-api#multi-private-backend-network-api' target='_blank'>multi-private backend networks</a> and <a href='https://phoenixnap.com/kb/bmc-server-management-via-api#ftoc-heading-15' target='_blank'>public networks</a>. </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/networks/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 NetworkApi
|
17
|
+
# Details of Public Network to be created.
|
18
|
+
class PublicNetworkCreate
|
19
|
+
# The friendly name of this public network. This name should be unique.
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
# The description of this public network.
|
23
|
+
attr_accessor :description
|
24
|
+
|
25
|
+
# The location of this public network. Supported values are `PHX`, `ASH`, `SGP`, `NLD`, `CHI`, `SEA` and `AUS`.
|
26
|
+
attr_accessor :location
|
27
|
+
|
28
|
+
# A list of IP Blocks that will be associated with this public network.
|
29
|
+
attr_accessor :ip_blocks
|
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
|
+
:'ip_blocks' => :'ipBlocks'
|
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
|
+
:'ip_blocks' => :'Array<PublicNetworkIpBlock>'
|
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 `NetworkApi::PublicNetworkCreate` 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 `NetworkApi::PublicNetworkCreate`. 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?(:'ip_blocks')
|
90
|
+
if (value = attributes[:'ip_blocks']).is_a?(Array)
|
91
|
+
self.ip_blocks = 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 !@ip_blocks.nil? && @ip_blocks.length > 10
|
121
|
+
invalid_properties.push('invalid value for "ip_blocks", number of items must be less than or equal to 10.')
|
122
|
+
end
|
123
|
+
|
124
|
+
invalid_properties
|
125
|
+
end
|
126
|
+
|
127
|
+
# Check to see if the all the properties in the model are valid
|
128
|
+
# @return true if the model is valid
|
129
|
+
def valid?
|
130
|
+
return false if @name.nil?
|
131
|
+
return false if @name.to_s.length > 100
|
132
|
+
return false if @name.to_s.length < 1
|
133
|
+
return false if !@description.nil? && @description.to_s.length > 250
|
134
|
+
return false if @location.nil?
|
135
|
+
return false if !@ip_blocks.nil? && @ip_blocks.length > 10
|
136
|
+
true
|
137
|
+
end
|
138
|
+
|
139
|
+
# Custom attribute writer method with validation
|
140
|
+
# @param [Object] name Value to be assigned
|
141
|
+
def name=(name)
|
142
|
+
if name.nil?
|
143
|
+
fail ArgumentError, 'name cannot be nil'
|
144
|
+
end
|
145
|
+
|
146
|
+
if name.to_s.length > 100
|
147
|
+
fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 100.'
|
148
|
+
end
|
149
|
+
|
150
|
+
if name.to_s.length < 1
|
151
|
+
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
|
152
|
+
end
|
153
|
+
|
154
|
+
@name = name
|
155
|
+
end
|
156
|
+
|
157
|
+
# Custom attribute writer method with validation
|
158
|
+
# @param [Object] description Value to be assigned
|
159
|
+
def description=(description)
|
160
|
+
if !description.nil? && description.to_s.length > 250
|
161
|
+
fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 250.'
|
162
|
+
end
|
163
|
+
|
164
|
+
@description = description
|
165
|
+
end
|
166
|
+
|
167
|
+
# Custom attribute writer method with validation
|
168
|
+
# @param [Object] ip_blocks Value to be assigned
|
169
|
+
def ip_blocks=(ip_blocks)
|
170
|
+
if !ip_blocks.nil? && ip_blocks.length > 10
|
171
|
+
fail ArgumentError, 'invalid value for "ip_blocks", number of items must be less than or equal to 10.'
|
172
|
+
end
|
173
|
+
|
174
|
+
@ip_blocks = ip_blocks
|
175
|
+
end
|
176
|
+
|
177
|
+
# Checks equality by comparing each attribute.
|
178
|
+
# @param [Object] Object to be compared
|
179
|
+
def ==(o)
|
180
|
+
return true if self.equal?(o)
|
181
|
+
self.class == o.class &&
|
182
|
+
name == o.name &&
|
183
|
+
description == o.description &&
|
184
|
+
location == o.location &&
|
185
|
+
ip_blocks == o.ip_blocks
|
186
|
+
end
|
187
|
+
|
188
|
+
# @see the `==` method
|
189
|
+
# @param [Object] Object to be compared
|
190
|
+
def eql?(o)
|
191
|
+
self == o
|
192
|
+
end
|
193
|
+
|
194
|
+
# Calculates hash code according to all attributes.
|
195
|
+
# @return [Integer] Hash code
|
196
|
+
def hash
|
197
|
+
[name, description, location, ip_blocks].hash
|
198
|
+
end
|
199
|
+
|
200
|
+
# Builds the object from hash
|
201
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
202
|
+
# @return [Object] Returns the model itself
|
203
|
+
def self.build_from_hash(attributes)
|
204
|
+
new.build_from_hash(attributes)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Builds the object from hash
|
208
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
209
|
+
# @return [Object] Returns the model itself
|
210
|
+
def build_from_hash(attributes)
|
211
|
+
return nil unless attributes.is_a?(Hash)
|
212
|
+
self.class.openapi_types.each_pair do |key, type|
|
213
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
214
|
+
self.send("#{key}=", nil)
|
215
|
+
elsif type =~ /\AArray<(.*)>/i
|
216
|
+
# check to ensure the input is an array given that the attribute
|
217
|
+
# is documented as an array but the input is not
|
218
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
219
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
220
|
+
end
|
221
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
222
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
self
|
227
|
+
end
|
228
|
+
|
229
|
+
# Deserializes the data based on type
|
230
|
+
# @param string type Data type
|
231
|
+
# @param string value Value to be deserialized
|
232
|
+
# @return [Object] Deserialized data
|
233
|
+
def _deserialize(type, value)
|
234
|
+
case type.to_sym
|
235
|
+
when :Time
|
236
|
+
Time.parse(value)
|
237
|
+
when :Date
|
238
|
+
Date.parse(value)
|
239
|
+
when :String
|
240
|
+
value.to_s
|
241
|
+
when :Integer
|
242
|
+
value.to_i
|
243
|
+
when :Float
|
244
|
+
value.to_f
|
245
|
+
when :Boolean
|
246
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
247
|
+
true
|
248
|
+
else
|
249
|
+
false
|
250
|
+
end
|
251
|
+
when :Object
|
252
|
+
# generic object (usually a Hash), return directly
|
253
|
+
value
|
254
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
255
|
+
inner_type = Regexp.last_match[:inner_type]
|
256
|
+
value.map { |v| _deserialize(inner_type, v) }
|
257
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
258
|
+
k_type = Regexp.last_match[:k_type]
|
259
|
+
v_type = Regexp.last_match[:v_type]
|
260
|
+
{}.tap do |hash|
|
261
|
+
value.each do |k, v|
|
262
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
else # model
|
266
|
+
# models (e.g. Pet) or oneOf
|
267
|
+
klass = NetworkApi.const_get(type)
|
268
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# Returns the string representation of the object
|
273
|
+
# @return [String] String presentation of the object
|
274
|
+
def to_s
|
275
|
+
to_hash.to_s
|
276
|
+
end
|
277
|
+
|
278
|
+
# to_body is an alias to to_hash (backward compatibility)
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
280
|
+
def to_body
|
281
|
+
to_hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns the object in the form of hash
|
285
|
+
# @return [Hash] Returns the object in the form of hash
|
286
|
+
def to_hash
|
287
|
+
hash = {}
|
288
|
+
self.class.attribute_map.each_pair do |attr, param|
|
289
|
+
value = self.send(attr)
|
290
|
+
if value.nil?
|
291
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
292
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
293
|
+
end
|
294
|
+
|
295
|
+
hash[param] = _to_hash(value)
|
296
|
+
end
|
297
|
+
hash
|
298
|
+
end
|
299
|
+
|
300
|
+
# Outputs non-array value in the form of hash
|
301
|
+
# For object, use to_hash. Otherwise, just return the value
|
302
|
+
# @param [Object] value Any valid value
|
303
|
+
# @return [Hash] Returns the value in the form of hash
|
304
|
+
def _to_hash(value)
|
305
|
+
if value.is_a?(Array)
|
306
|
+
value.compact.map { |v| _to_hash(v) }
|
307
|
+
elsif value.is_a?(Hash)
|
308
|
+
{}.tap do |hash|
|
309
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
310
|
+
end
|
311
|
+
elsif value.respond_to? :to_hash
|
312
|
+
value.to_hash
|
313
|
+
else
|
314
|
+
value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|