ibm_cloud_power 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +68 -0
  3. data/LICENSE.txt +202 -0
  4. data/README.md +56 -10
  5. data/docs/CloudConnection.md +41 -0
  6. data/docs/CloudConnectionCreate.md +23 -0
  7. data/docs/CloudConnectionEndpointClassic.md +19 -0
  8. data/docs/CloudConnectionEndpointGRE.md +19 -0
  9. data/docs/CloudConnectionEndpointVPC.md +19 -0
  10. data/docs/CloudConnectionGRETunnel.md +21 -0
  11. data/docs/CloudConnectionSpeed.md +16 -0
  12. data/docs/CloudConnectionUpdate.md +27 -0
  13. data/docs/CloudConnectionVPC.md +19 -0
  14. data/docs/CloudConnectionVirtualPrivateClouds.md +17 -0
  15. data/docs/CloudConnectionVirtualPrivateCloudsVirtualPrivateClouds.md +23 -0
  16. data/docs/CloudConnections.md +17 -0
  17. data/docs/CreateDataVolume.md +6 -6
  18. data/docs/CreateImage.md +3 -3
  19. data/docs/Image.md +2 -0
  20. data/docs/ImageReference.md +2 -0
  21. data/docs/MaximumStorageAllocation.md +21 -0
  22. data/docs/MultiVolumesCreate.md +6 -4
  23. data/docs/Network.md +1 -1
  24. data/docs/NetworkPort.md +2 -0
  25. data/docs/NetworkReference.md +1 -1
  26. data/docs/PCloudCloudConnectionsApi.md +394 -0
  27. data/docs/PCloudEventsApi.md +2 -2
  28. data/docs/PCloudImagesApi.md +104 -6
  29. data/docs/PCloudPVMInstancesApi.md +60 -5
  30. data/docs/PCloudPlacementGroupsApi.md +298 -0
  31. data/docs/PCloudStorageCapacityApi.md +196 -0
  32. data/docs/PCloudVolumesApi.md +344 -0
  33. data/docs/PVMInstance.md +3 -1
  34. data/docs/PVMInstanceCreate.md +5 -3
  35. data/docs/PlacementGroup.md +23 -0
  36. data/docs/PlacementGroupCreate.md +19 -0
  37. data/docs/PlacementGroupServer.md +17 -0
  38. data/docs/PlacementGroups.md +17 -0
  39. data/docs/SAPCreate.md +1 -1
  40. data/docs/StoragePoolCapacity.md +23 -0
  41. data/docs/StoragePoolsCapacity.md +19 -0
  42. data/docs/StorageTypeCapacity.md +21 -0
  43. data/docs/StorageTypesCapacity.md +19 -0
  44. data/docs/Volume.md +2 -0
  45. data/docs/VolumeReference.md +2 -0
  46. data/docs/VolumesCloneAsyncRequest.md +1 -1
  47. data/docs/VolumesCloneCancel.md +1 -1
  48. data/docs/VolumesCloneDetail.md +1 -1
  49. data/docs/VolumesCloneExecute.md +1 -1
  50. data/lib/ibm_cloud_power.rb +24 -0
  51. data/lib/ibm_cloud_power/api/p_cloud_cloud_connections_api.rb +560 -0
  52. data/lib/ibm_cloud_power/api/p_cloud_events_api.rb +2 -2
  53. data/lib/ibm_cloud_power/api/p_cloud_images_api.rb +133 -4
  54. data/lib/ibm_cloud_power/api/p_cloud_placement_groups_api.rb +430 -0
  55. data/lib/ibm_cloud_power/api/p_cloud_pvm_instances_api.rb +82 -5
  56. data/lib/ibm_cloud_power/api/p_cloud_storage_capacity_api.rb +274 -0
  57. data/lib/ibm_cloud_power/api/p_cloud_volumes_api.rb +477 -0
  58. data/lib/ibm_cloud_power/models/cloud_connection.rb +379 -0
  59. data/lib/ibm_cloud_power/models/cloud_connection_create.rb +249 -0
  60. data/lib/ibm_cloud_power/models/cloud_connection_endpoint_classic.rb +218 -0
  61. data/lib/ibm_cloud_power/models/cloud_connection_endpoint_gre.rb +221 -0
  62. data/lib/ibm_cloud_power/models/cloud_connection_endpoint_vpc.rb +221 -0
  63. data/lib/ibm_cloud_power/models/cloud_connection_gre_tunnel.rb +239 -0
  64. data/lib/ibm_cloud_power/models/cloud_connection_speed.rb +42 -0
  65. data/lib/ibm_cloud_power/models/cloud_connection_update.rb +257 -0
  66. data/lib/ibm_cloud_power/models/cloud_connection_virtual_private_clouds.rb +216 -0
  67. data/lib/ibm_cloud_power/models/cloud_connection_virtual_private_clouds_virtual_private_clouds.rb +259 -0
  68. data/lib/ibm_cloud_power/models/cloud_connection_vpc.rb +224 -0
  69. data/lib/ibm_cloud_power/models/cloud_connections.rb +216 -0
  70. data/lib/ibm_cloud_power/models/create_data_volume.rb +17 -17
  71. data/lib/ibm_cloud_power/models/create_image.rb +3 -3
  72. data/lib/ibm_cloud_power/models/image.rb +16 -1
  73. data/lib/ibm_cloud_power/models/image_reference.rb +16 -1
  74. data/lib/ibm_cloud_power/models/maximum_storage_allocation.rb +245 -0
  75. data/lib/ibm_cloud_power/models/multi_volumes_create.rb +17 -7
  76. data/lib/ibm_cloud_power/models/network.rb +1 -1
  77. data/lib/ibm_cloud_power/models/network_port.rb +11 -1
  78. data/lib/ibm_cloud_power/models/network_reference.rb +1 -1
  79. data/lib/ibm_cloud_power/models/placement_group.rb +295 -0
  80. data/lib/ibm_cloud_power/models/placement_group_create.rb +263 -0
  81. data/lib/ibm_cloud_power/models/placement_group_server.rb +214 -0
  82. data/lib/ibm_cloud_power/models/placement_groups.rb +216 -0
  83. data/lib/ibm_cloud_power/models/pvm_instance.rb +17 -5
  84. data/lib/ibm_cloud_power/models/pvm_instance_create.rb +16 -6
  85. data/lib/ibm_cloud_power/models/pvm_instance_reference.rb +2 -2
  86. data/lib/ibm_cloud_power/models/sap_create.rb +1 -1
  87. data/lib/ibm_cloud_power/models/storage_pool_capacity.rb +245 -0
  88. data/lib/ibm_cloud_power/models/storage_pools_capacity.rb +220 -0
  89. data/lib/ibm_cloud_power/models/storage_type_capacity.rb +231 -0
  90. data/lib/ibm_cloud_power/models/storage_types_capacity.rb +220 -0
  91. data/lib/ibm_cloud_power/models/volume.rb +11 -1
  92. data/lib/ibm_cloud_power/models/volume_reference.rb +11 -1
  93. data/lib/ibm_cloud_power/models/volumes_clone_async_request.rb +1 -1
  94. data/lib/ibm_cloud_power/models/volumes_clone_cancel.rb +1 -1
  95. data/lib/ibm_cloud_power/models/volumes_clone_detail.rb +1 -1
  96. data/lib/ibm_cloud_power/models/volumes_clone_execute.rb +1 -1
  97. data/lib/ibm_cloud_power/version.rb +1 -1
  98. data/spec/api/p_cloud_cloud_connections_api_spec.rb +132 -0
  99. data/spec/api/p_cloud_placement_groups_api_spec.rb +108 -0
  100. data/spec/api/p_cloud_storage_capacity_api_spec.rb +81 -0
  101. data/spec/models/cloud_connection_create_spec.rb +59 -0
  102. data/spec/models/cloud_connection_endpoint_classic_spec.rb +47 -0
  103. data/spec/models/cloud_connection_endpoint_gre_spec.rb +47 -0
  104. data/spec/models/cloud_connection_endpoint_vpc_spec.rb +47 -0
  105. data/spec/models/cloud_connection_gre_tunnel_spec.rb +53 -0
  106. data/spec/models/cloud_connection_spec.rb +113 -0
  107. data/spec/models/cloud_connection_speed_spec.rb +35 -0
  108. data/spec/models/cloud_connection_update_spec.rb +71 -0
  109. data/spec/models/cloud_connection_virtual_private_clouds_spec.rb +41 -0
  110. data/spec/models/cloud_connection_virtual_private_clouds_virtual_private_clouds_spec.rb +59 -0
  111. data/spec/models/cloud_connection_vpc_spec.rb +47 -0
  112. data/spec/models/cloud_connections_spec.rb +41 -0
  113. data/spec/models/maximum_storage_allocation_spec.rb +53 -0
  114. data/spec/models/placement_group_create_spec.rb +51 -0
  115. data/spec/models/placement_group_server_spec.rb +41 -0
  116. data/spec/models/placement_group_spec.rb +63 -0
  117. data/spec/models/placement_groups_spec.rb +41 -0
  118. data/spec/models/storage_pool_capacity_spec.rb +59 -0
  119. data/spec/models/storage_pools_capacity_spec.rb +47 -0
  120. data/spec/models/storage_type_capacity_spec.rb +53 -0
  121. data/spec/models/storage_types_capacity_spec.rb +47 -0
  122. metadata +130 -32
@@ -56,10 +56,10 @@ module IbmCloudPower
56
56
  # Indicates if the server is allowed to migrate between hosts
57
57
  attr_accessor :migratable
58
58
 
59
- # Cloud init user defined data
59
+ # Cloud-init user-defined data. The user-defined data is made available to the VM instance as a config drive.
60
60
  attr_accessor :user_data
61
61
 
62
- # Storage type for server deployment
62
+ # Storage type for server deployment. Only valid when you deploy one of the IBM supplied **stock** images. Storage type for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage type the image was created in
63
63
  attr_accessor :storage_type
64
64
 
65
65
  attr_accessor :software_licenses
@@ -68,6 +68,9 @@ module IbmCloudPower
68
68
 
69
69
  attr_accessor :virtual_cores
70
70
 
71
+ # The placement group for the server
72
+ attr_accessor :placement_group
73
+
71
74
  class EnumAttributeValidator
72
75
  attr_reader :datatype
73
76
  attr_reader :allowable_values
@@ -111,7 +114,8 @@ module IbmCloudPower
111
114
  :'storage_type' => :'storageType',
112
115
  :'software_licenses' => :'softwareLicenses',
113
116
  :'pin_policy' => :'pinPolicy',
114
- :'virtual_cores' => :'virtualCores'
117
+ :'virtual_cores' => :'virtualCores',
118
+ :'placement_group' => :'placementGroup'
115
119
  }
116
120
  end
117
121
 
@@ -136,7 +140,8 @@ module IbmCloudPower
136
140
  :'storage_type' => :'String',
137
141
  :'software_licenses' => :'SoftwareLicenses',
138
142
  :'pin_policy' => :'PinPolicy',
139
- :'virtual_cores' => :'VirtualCores'
143
+ :'virtual_cores' => :'VirtualCores',
144
+ :'placement_group' => :'String'
140
145
  }
141
146
  end
142
147
 
@@ -250,6 +255,10 @@ module IbmCloudPower
250
255
  if attributes.key?(:'virtual_cores')
251
256
  self.virtual_cores = attributes[:'virtual_cores']
252
257
  end
258
+
259
+ if attributes.key?(:'placement_group')
260
+ self.placement_group = attributes[:'placement_group']
261
+ end
253
262
  end
254
263
 
255
264
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -349,7 +358,8 @@ module IbmCloudPower
349
358
  storage_type == o.storage_type &&
350
359
  software_licenses == o.software_licenses &&
351
360
  pin_policy == o.pin_policy &&
352
- virtual_cores == o.virtual_cores
361
+ virtual_cores == o.virtual_cores &&
362
+ placement_group == o.placement_group
353
363
  end
354
364
 
355
365
  # @see the `==` method
@@ -361,7 +371,7 @@ module IbmCloudPower
361
371
  # Calculates hash code according to all attributes.
362
372
  # @return [Integer] Hash code
363
373
  def hash
364
- [server_name, replicants, replicant_naming_scheme, replicant_affinity_policy, image_id, processors, proc_type, memory, network_i_ds, networks, volume_i_ds, key_pair_name, sys_type, migratable, user_data, storage_type, software_licenses, pin_policy, virtual_cores].hash
374
+ [server_name, replicants, replicant_naming_scheme, replicant_affinity_policy, image_id, processors, proc_type, memory, network_i_ds, networks, volume_i_ds, key_pair_name, sys_type, migratable, user_data, storage_type, software_licenses, pin_policy, virtual_cores, placement_group].hash
365
375
  end
366
376
 
367
377
  # Builds the object from hash
@@ -380,7 +380,7 @@ module IbmCloudPower
380
380
  return false if @image_id.nil?
381
381
  return false if @processors.nil?
382
382
  return false if @proc_type.nil?
383
- proc_type_validator = EnumAttributeValidator.new('String', ["dedicated", "shared", "capped"])
383
+ proc_type_validator = EnumAttributeValidator.new('String', ["dedicated", "shared", "capped", ""])
384
384
  return false unless proc_type_validator.valid?(@proc_type)
385
385
  return false if @memory.nil?
386
386
  return false if @disk_size.nil?
@@ -393,7 +393,7 @@ module IbmCloudPower
393
393
  # Custom attribute writer method checking allowed values (enum).
394
394
  # @param [Object] proc_type Object to be assigned
395
395
  def proc_type=(proc_type)
396
- validator = EnumAttributeValidator.new('String', ["dedicated", "shared", "capped"])
396
+ validator = EnumAttributeValidator.new('String', ["dedicated", "shared", "capped", ""])
397
397
  unless validator.valid?(proc_type)
398
398
  fail ArgumentError, "invalid value for \"proc_type\", must be one of #{validator.allowable_values}."
399
399
  end
@@ -34,7 +34,7 @@ module IbmCloudPower
34
34
  # The name of the SSH Key to provide to the server for authenticating
35
35
  attr_accessor :ssh_key_name
36
36
 
37
- # Cloud init user defined data
37
+ # Cloud-init user-defined data. The user-defined data is made available to the VM instance as a config drive.
38
38
  attr_accessor :user_data
39
39
 
40
40
  attr_accessor :pin_policy
@@ -0,0 +1,245 @@
1
+ =begin
2
+ #Power Cloud API
3
+
4
+ #IBM Power Cloud API for Power Hardware / Infrastructure
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: kylej@us.ibm.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IbmCloudPower
16
+ # Storage pool capacity
17
+ class StoragePoolCapacity
18
+ # Pool name
19
+ attr_accessor :pool_name
20
+
21
+ # Storage type of the storage pool
22
+ attr_accessor :storage_type
23
+
24
+ # Maximum allocation storage size (GB)
25
+ attr_accessor :max_allocation_size
26
+
27
+ # Total pool capacity (GB)
28
+ attr_accessor :total_capacity
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'pool_name' => :'poolName',
34
+ :'storage_type' => :'storageType',
35
+ :'max_allocation_size' => :'maxAllocationSize',
36
+ :'total_capacity' => :'totalCapacity'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'pool_name' => :'String',
44
+ :'storage_type' => :'String',
45
+ :'max_allocation_size' => :'Integer',
46
+ :'total_capacity' => :'Integer'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudPower::StoragePoolCapacity` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudPower::StoragePoolCapacity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'pool_name')
72
+ self.pool_name = attributes[:'pool_name']
73
+ end
74
+
75
+ if attributes.key?(:'storage_type')
76
+ self.storage_type = attributes[:'storage_type']
77
+ end
78
+
79
+ if attributes.key?(:'max_allocation_size')
80
+ self.max_allocation_size = attributes[:'max_allocation_size']
81
+ end
82
+
83
+ if attributes.key?(:'total_capacity')
84
+ self.total_capacity = attributes[:'total_capacity']
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ if @max_allocation_size.nil?
93
+ invalid_properties.push('invalid value for "max_allocation_size", max_allocation_size cannot be nil.')
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ return false if @max_allocation_size.nil?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ pool_name == o.pool_name &&
112
+ storage_type == o.storage_type &&
113
+ max_allocation_size == o.max_allocation_size &&
114
+ total_capacity == o.total_capacity
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [pool_name, storage_type, max_allocation_size, total_capacity].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.openapi_types.each_pair do |key, type|
142
+ if type =~ /\AArray<(.*)>/i
143
+ # check to ensure the input is an array given that the attribute
144
+ # is documented as an array but the input is not
145
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
146
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
147
+ end
148
+ elsif !attributes[self.class.attribute_map[key]].nil?
149
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
150
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
151
+ self.send("#{key}=", nil)
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :DateTime
165
+ DateTime.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ IbmCloudPower.const_get(type).build_from_hash(value)
196
+ end
197
+ end
198
+
199
+ # Returns the string representation of the object
200
+ # @return [String] String presentation of the object
201
+ def to_s
202
+ to_hash.to_s
203
+ end
204
+
205
+ # to_body is an alias to to_hash (backward compatibility)
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_body
208
+ to_hash
209
+ end
210
+
211
+ # Returns the object in the form of hash
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_hash
214
+ hash = {}
215
+ self.class.attribute_map.each_pair do |attr, param|
216
+ value = self.send(attr)
217
+ if value.nil?
218
+ is_nullable = self.class.openapi_nullable.include?(attr)
219
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
220
+ end
221
+
222
+ hash[param] = _to_hash(value)
223
+ end
224
+ hash
225
+ end
226
+
227
+ # Outputs non-array value in the form of hash
228
+ # For object, use to_hash. Otherwise, just return the value
229
+ # @param [Object] value Any valid value
230
+ # @return [Hash] Returns the value in the form of hash
231
+ def _to_hash(value)
232
+ if value.is_a?(Array)
233
+ value.compact.map { |v| _to_hash(v) }
234
+ elsif value.is_a?(Hash)
235
+ {}.tap do |hash|
236
+ value.each { |k, v| hash[k] = _to_hash(v) }
237
+ end
238
+ elsif value.respond_to? :to_hash
239
+ value.to_hash
240
+ else
241
+ value
242
+ end
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,220 @@
1
+ =begin
2
+ #Power Cloud API
3
+
4
+ #IBM Power Cloud API for Power Hardware / Infrastructure
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: kylej@us.ibm.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module IbmCloudPower
16
+ # Storage capacity for all storage pools
17
+ class StoragePoolsCapacity
18
+ attr_accessor :maximum_storage_allocation
19
+
20
+ attr_accessor :storage_pools_capacity
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'maximum_storage_allocation' => :'maximumStorageAllocation',
26
+ :'storage_pools_capacity' => :'storagePoolsCapacity'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'maximum_storage_allocation' => :'MaximumStorageAllocation',
34
+ :'storage_pools_capacity' => :'Array<StoragePoolCapacity>'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudPower::StoragePoolsCapacity` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudPower::StoragePoolsCapacity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'maximum_storage_allocation')
60
+ self.maximum_storage_allocation = attributes[:'maximum_storage_allocation']
61
+ end
62
+
63
+ if attributes.key?(:'storage_pools_capacity')
64
+ if (value = attributes[:'storage_pools_capacity']).is_a?(Array)
65
+ self.storage_pools_capacity = value
66
+ end
67
+ end
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(o)
86
+ return true if self.equal?(o)
87
+ self.class == o.class &&
88
+ maximum_storage_allocation == o.maximum_storage_allocation &&
89
+ storage_pools_capacity == o.storage_pools_capacity
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(o)
95
+ self == o
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Integer] Hash code
100
+ def hash
101
+ [maximum_storage_allocation, storage_pools_capacity].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ new.build_from_hash(attributes)
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ self.class.openapi_types.each_pair do |key, type|
117
+ if type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
121
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
122
+ end
123
+ elsif !attributes[self.class.attribute_map[key]].nil?
124
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
125
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
126
+ self.send("#{key}=", nil)
127
+ end
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :DateTime
140
+ DateTime.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :Boolean
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ IbmCloudPower.const_get(type).build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ if value.nil?
193
+ is_nullable = self.class.openapi_nullable.include?(attr)
194
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
195
+ end
196
+
197
+ hash[param] = _to_hash(value)
198
+ end
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to? :to_hash
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+ end
220
+ end