pnap_network_storage_api 1.0.0

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