pnap_network_storage_api 1.2.0 → 1.4.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/VERSION +1 -1
  4. data/docs/NfsPermissionsCreate.md +26 -0
  5. data/docs/NfsPermissionsUpdate.md +26 -0
  6. data/docs/PermissionsCreate.md +18 -0
  7. data/docs/PermissionsUpdate.md +18 -0
  8. data/docs/StorageNetworkCreate.md +4 -2
  9. data/docs/StorageNetworkVolumeCreate.md +26 -0
  10. data/docs/StorageNetworksApi.md +85 -5
  11. data/docs/TagAssignment.md +26 -0
  12. data/docs/TagAssignmentRequest.md +20 -0
  13. data/docs/Volume.md +3 -1
  14. data/docs/VolumeCreate.md +5 -1
  15. data/docs/VolumeUpdate.md +3 -1
  16. data/lib/pnap_network_storage_api/api/storage_networks_api.rb +79 -0
  17. data/lib/pnap_network_storage_api/models/nfs_permissions_create.rb +271 -0
  18. data/lib/pnap_network_storage_api/models/nfs_permissions_update.rb +271 -0
  19. data/lib/pnap_network_storage_api/models/permissions_create.rb +220 -0
  20. data/lib/pnap_network_storage_api/models/permissions_update.rb +220 -0
  21. data/lib/pnap_network_storage_api/models/storage_network_create.rb +38 -4
  22. data/lib/pnap_network_storage_api/models/storage_network_volume_create.rb +370 -0
  23. data/lib/pnap_network_storage_api/models/tag_assignment.rb +310 -0
  24. data/lib/pnap_network_storage_api/models/tag_assignment_request.rb +236 -0
  25. data/lib/pnap_network_storage_api/models/volume.rb +16 -4
  26. data/lib/pnap_network_storage_api/models/volume_create.rb +25 -4
  27. data/lib/pnap_network_storage_api/models/volume_update.rb +13 -4
  28. data/lib/pnap_network_storage_api.rb +7 -0
  29. data/spec/models/nfs_permissions_create_spec.rb +58 -0
  30. data/spec/models/nfs_permissions_update_spec.rb +58 -0
  31. data/spec/models/permissions_create_spec.rb +34 -0
  32. data/spec/models/permissions_update_spec.rb +34 -0
  33. data/spec/models/storage_network_volume_create_spec.rb +52 -0
  34. data/spec/models/tag_assignment_request_spec.rb +40 -0
  35. data/spec/models/tag_assignment_spec.rb +62 -0
  36. metadata +35 -7
@@ -0,0 +1,220 @@
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: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module NetworkStorageApi
17
+ # Update permissions for a volume.
18
+ class PermissionsCreate
19
+ attr_accessor :nfs
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'nfs' => :'nfs'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'nfs' => :'NfsPermissionsCreate'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkStorageApi::PermissionsCreate` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkStorageApi::PermissionsCreate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'nfs')
62
+ self.nfs = attributes[:'nfs']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ nfs == o.nfs
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [nfs].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = NetworkStorageApi.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -0,0 +1,220 @@
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: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module NetworkStorageApi
17
+ # Update permissions for a volume.
18
+ class PermissionsUpdate
19
+ attr_accessor :nfs
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'nfs' => :'nfs'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'nfs' => :'NfsPermissionsUpdate'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `NetworkStorageApi::PermissionsUpdate` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `NetworkStorageApi::PermissionsUpdate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'nfs')
62
+ self.nfs = attributes[:'nfs']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ nfs == o.nfs
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [nfs].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ self.class.openapi_types.each_pair do |key, type|
113
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
+ self.send("#{key}=", nil)
115
+ elsif type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = NetworkStorageApi.const_get(type)
168
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
@@ -28,13 +28,17 @@ module NetworkStorageApi
28
28
  # Volume to be created alongside storage. Currently only 1 volume is supported.
29
29
  attr_accessor :volumes
30
30
 
31
+ # Custom Client VLAN that the Storage Network will be set to.
32
+ attr_accessor :client_vlan
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
  :'location' => :'location',
37
- :'volumes' => :'volumes'
40
+ :'volumes' => :'volumes',
41
+ :'client_vlan' => :'clientVlan'
38
42
  }
39
43
  end
40
44
 
@@ -49,7 +53,8 @@ module NetworkStorageApi
49
53
  :'name' => :'String',
50
54
  :'description' => :'String',
51
55
  :'location' => :'String',
52
- :'volumes' => :'Array<VolumeCreate>'
56
+ :'volumes' => :'Array<StorageNetworkVolumeCreate>',
57
+ :'client_vlan' => :'Integer'
53
58
  }
54
59
  end
55
60
 
@@ -91,6 +96,10 @@ module NetworkStorageApi
91
96
  self.volumes = value
92
97
  end
93
98
  end
99
+
100
+ if attributes.key?(:'client_vlan')
101
+ self.client_vlan = attributes[:'client_vlan']
102
+ end
94
103
  end
95
104
 
96
105
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -129,6 +138,14 @@ module NetworkStorageApi
129
138
  invalid_properties.push('invalid value for "volumes", number of items must be greater than or equal to 1.')
130
139
  end
131
140
 
141
+ if !@client_vlan.nil? && @client_vlan > 4094
142
+ invalid_properties.push('invalid value for "client_vlan", must be smaller than or equal to 4094.')
143
+ end
144
+
145
+ if !@client_vlan.nil? && @client_vlan < 2
146
+ invalid_properties.push('invalid value for "client_vlan", must be greater than or equal to 2.')
147
+ end
148
+
132
149
  invalid_properties
133
150
  end
134
151
 
@@ -143,6 +160,8 @@ module NetworkStorageApi
143
160
  return false if @volumes.nil?
144
161
  return false if @volumes.length > 1
145
162
  return false if @volumes.length < 1
163
+ return false if !@client_vlan.nil? && @client_vlan > 4094
164
+ return false if !@client_vlan.nil? && @client_vlan < 2
146
165
  true
147
166
  end
148
167
 
@@ -192,6 +211,20 @@ module NetworkStorageApi
192
211
  @volumes = volumes
193
212
  end
194
213
 
214
+ # Custom attribute writer method with validation
215
+ # @param [Object] client_vlan Value to be assigned
216
+ def client_vlan=(client_vlan)
217
+ if !client_vlan.nil? && client_vlan > 4094
218
+ fail ArgumentError, 'invalid value for "client_vlan", must be smaller than or equal to 4094.'
219
+ end
220
+
221
+ if !client_vlan.nil? && client_vlan < 2
222
+ fail ArgumentError, 'invalid value for "client_vlan", must be greater than or equal to 2.'
223
+ end
224
+
225
+ @client_vlan = client_vlan
226
+ end
227
+
195
228
  # Checks equality by comparing each attribute.
196
229
  # @param [Object] Object to be compared
197
230
  def ==(o)
@@ -200,7 +233,8 @@ module NetworkStorageApi
200
233
  name == o.name &&
201
234
  description == o.description &&
202
235
  location == o.location &&
203
- volumes == o.volumes
236
+ volumes == o.volumes &&
237
+ client_vlan == o.client_vlan
204
238
  end
205
239
 
206
240
  # @see the `==` method
@@ -212,7 +246,7 @@ module NetworkStorageApi
212
246
  # Calculates hash code according to all attributes.
213
247
  # @return [Integer] Hash code
214
248
  def hash
215
- [name, description, location, volumes].hash
249
+ [name, description, location, volumes, client_vlan].hash
216
250
  end
217
251
 
218
252
  # Builds the object from hash