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
@@ -20,7 +20,7 @@ module IbmCloudPower
20
20
  # Network Name
21
21
  attr_accessor :name
22
22
 
23
- # Type of Network {pub-vlan, vlan, vxlan}
23
+ # Type of Network {vlan, pub-vlan}
24
24
  attr_accessor :type
25
25
 
26
26
  # VLAN ID
@@ -29,6 +29,9 @@ module IbmCloudPower
29
29
  # The ip address of this port
30
30
  attr_accessor :ip_address
31
31
 
32
+ # The external ip address (for pub-vlan networks)
33
+ attr_accessor :external_ip
34
+
32
35
  attr_accessor :pvm_instance
33
36
 
34
37
  # Link to port resource
@@ -42,6 +45,7 @@ module IbmCloudPower
42
45
  :'status' => :'status',
43
46
  :'mac_address' => :'macAddress',
44
47
  :'ip_address' => :'ipAddress',
48
+ :'external_ip' => :'externalIP',
45
49
  :'pvm_instance' => :'pvmInstance',
46
50
  :'href' => :'href'
47
51
  }
@@ -55,6 +59,7 @@ module IbmCloudPower
55
59
  :'status' => :'String',
56
60
  :'mac_address' => :'String',
57
61
  :'ip_address' => :'String',
62
+ :'external_ip' => :'String',
58
63
  :'pvm_instance' => :'NetworkPortPvmInstance',
59
64
  :'href' => :'String'
60
65
  }
@@ -101,6 +106,10 @@ module IbmCloudPower
101
106
  self.ip_address = attributes[:'ip_address']
102
107
  end
103
108
 
109
+ if attributes.key?(:'external_ip')
110
+ self.external_ip = attributes[:'external_ip']
111
+ end
112
+
104
113
  if attributes.key?(:'pvm_instance')
105
114
  self.pvm_instance = attributes[:'pvm_instance']
106
115
  end
@@ -158,6 +167,7 @@ module IbmCloudPower
158
167
  status == o.status &&
159
168
  mac_address == o.mac_address &&
160
169
  ip_address == o.ip_address &&
170
+ external_ip == o.external_ip &&
161
171
  pvm_instance == o.pvm_instance &&
162
172
  href == o.href
163
173
  end
@@ -171,7 +181,7 @@ module IbmCloudPower
171
181
  # Calculates hash code according to all attributes.
172
182
  # @return [Integer] Hash code
173
183
  def hash
174
- [port_id, description, status, mac_address, ip_address, pvm_instance, href].hash
184
+ [port_id, description, status, mac_address, ip_address, external_ip, pvm_instance, href].hash
175
185
  end
176
186
 
177
187
  # Builds the object from hash
@@ -23,7 +23,7 @@ module IbmCloudPower
23
23
  # VLAN ID
24
24
  attr_accessor :vlan_id
25
25
 
26
- # Type of Network {pub-vlan, vlan, vxlan}
26
+ # Type of Network {vlan, pub-vlan}
27
27
  attr_accessor :type
28
28
 
29
29
  # MTU Jumbo Network enabled
@@ -0,0 +1,295 @@
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
+ class PlacementGroup
17
+ # The id of the Placement Group
18
+ attr_accessor :id
19
+
20
+ # The name of the Placement Group
21
+ attr_accessor :name
22
+
23
+ # The Placement Group Policy
24
+ attr_accessor :policy
25
+
26
+ # The List of PVM Instance IDs associated with the Placement Group
27
+ attr_accessor :members
28
+
29
+ class EnumAttributeValidator
30
+ attr_reader :datatype
31
+ attr_reader :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'id' => :'id',
55
+ :'name' => :'name',
56
+ :'policy' => :'policy',
57
+ :'members' => :'members'
58
+ }
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'id' => :'String',
65
+ :'name' => :'String',
66
+ :'policy' => :'String',
67
+ :'members' => :'Array<String>'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudPower::PlacementGroup` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudPower::PlacementGroup`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'id')
93
+ self.id = attributes[:'id']
94
+ end
95
+
96
+ if attributes.key?(:'name')
97
+ self.name = attributes[:'name']
98
+ end
99
+
100
+ if attributes.key?(:'policy')
101
+ self.policy = attributes[:'policy']
102
+ end
103
+
104
+ if attributes.key?(:'members')
105
+ if (value = attributes[:'members']).is_a?(Array)
106
+ self.members = value
107
+ end
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ if @id.nil?
116
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
117
+ end
118
+
119
+ if @name.nil?
120
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
121
+ end
122
+
123
+ if @policy.nil?
124
+ invalid_properties.push('invalid value for "policy", policy cannot be nil.')
125
+ end
126
+
127
+ if @members.nil?
128
+ invalid_properties.push('invalid value for "members", members cannot be nil.')
129
+ end
130
+
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ return false if @id.nil?
138
+ return false if @name.nil?
139
+ return false if @policy.nil?
140
+ policy_validator = EnumAttributeValidator.new('String', ["affinity", "anti-affinity"])
141
+ return false unless policy_validator.valid?(@policy)
142
+ return false if @members.nil?
143
+ true
144
+ end
145
+
146
+ # Custom attribute writer method checking allowed values (enum).
147
+ # @param [Object] policy Object to be assigned
148
+ def policy=(policy)
149
+ validator = EnumAttributeValidator.new('String', ["affinity", "anti-affinity"])
150
+ unless validator.valid?(policy)
151
+ fail ArgumentError, "invalid value for \"policy\", must be one of #{validator.allowable_values}."
152
+ end
153
+ @policy = policy
154
+ end
155
+
156
+ # Checks equality by comparing each attribute.
157
+ # @param [Object] Object to be compared
158
+ def ==(o)
159
+ return true if self.equal?(o)
160
+ self.class == o.class &&
161
+ id == o.id &&
162
+ name == o.name &&
163
+ policy == o.policy &&
164
+ members == o.members
165
+ end
166
+
167
+ # @see the `==` method
168
+ # @param [Object] Object to be compared
169
+ def eql?(o)
170
+ self == o
171
+ end
172
+
173
+ # Calculates hash code according to all attributes.
174
+ # @return [Integer] Hash code
175
+ def hash
176
+ [id, name, policy, members].hash
177
+ end
178
+
179
+ # Builds the object from hash
180
+ # @param [Hash] attributes Model attributes in the form of hash
181
+ # @return [Object] Returns the model itself
182
+ def self.build_from_hash(attributes)
183
+ new.build_from_hash(attributes)
184
+ end
185
+
186
+ # Builds the object from hash
187
+ # @param [Hash] attributes Model attributes in the form of hash
188
+ # @return [Object] Returns the model itself
189
+ def build_from_hash(attributes)
190
+ return nil unless attributes.is_a?(Hash)
191
+ self.class.openapi_types.each_pair do |key, type|
192
+ if type =~ /\AArray<(.*)>/i
193
+ # check to ensure the input is an array given that the attribute
194
+ # is documented as an array but the input is not
195
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
196
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
197
+ end
198
+ elsif !attributes[self.class.attribute_map[key]].nil?
199
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
200
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
201
+ self.send("#{key}=", nil)
202
+ end
203
+ end
204
+
205
+ self
206
+ end
207
+
208
+ # Deserializes the data based on type
209
+ # @param string type Data type
210
+ # @param string value Value to be deserialized
211
+ # @return [Object] Deserialized data
212
+ def _deserialize(type, value)
213
+ case type.to_sym
214
+ when :DateTime
215
+ DateTime.parse(value)
216
+ when :Date
217
+ Date.parse(value)
218
+ when :String
219
+ value.to_s
220
+ when :Integer
221
+ value.to_i
222
+ when :Float
223
+ value.to_f
224
+ when :Boolean
225
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
226
+ true
227
+ else
228
+ false
229
+ end
230
+ when :Object
231
+ # generic object (usually a Hash), return directly
232
+ value
233
+ when /\AArray<(?<inner_type>.+)>\z/
234
+ inner_type = Regexp.last_match[:inner_type]
235
+ value.map { |v| _deserialize(inner_type, v) }
236
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
237
+ k_type = Regexp.last_match[:k_type]
238
+ v_type = Regexp.last_match[:v_type]
239
+ {}.tap do |hash|
240
+ value.each do |k, v|
241
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
242
+ end
243
+ end
244
+ else # model
245
+ IbmCloudPower.const_get(type).build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ if value.nil?
268
+ is_nullable = self.class.openapi_nullable.include?(attr)
269
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
270
+ end
271
+
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ # Outputs non-array value in the form of hash
278
+ # For object, use to_hash. Otherwise, just return the value
279
+ # @param [Object] value Any valid value
280
+ # @return [Hash] Returns the value in the form of hash
281
+ def _to_hash(value)
282
+ if value.is_a?(Array)
283
+ value.compact.map { |v| _to_hash(v) }
284
+ elsif value.is_a?(Hash)
285
+ {}.tap do |hash|
286
+ value.each { |k, v| hash[k] = _to_hash(v) }
287
+ end
288
+ elsif value.respond_to? :to_hash
289
+ value.to_hash
290
+ else
291
+ value
292
+ end
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,263 @@
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
+ class PlacementGroupCreate
17
+ # The name of the Placement Group
18
+ attr_accessor :name
19
+
20
+ # The Placement Group Policy
21
+ attr_accessor :policy
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'name' => :'name',
49
+ :'policy' => :'policy'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'name' => :'String',
57
+ :'policy' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IbmCloudPower::PlacementGroupCreate` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IbmCloudPower::PlacementGroupCreate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'name')
83
+ self.name = attributes[:'name']
84
+ end
85
+
86
+ if attributes.key?(:'policy')
87
+ self.policy = attributes[:'policy']
88
+ end
89
+ end
90
+
91
+ # Show invalid properties with the reasons. Usually used together with valid?
92
+ # @return Array for valid properties with the reasons
93
+ def list_invalid_properties
94
+ invalid_properties = Array.new
95
+ if @name.nil?
96
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
97
+ end
98
+
99
+ if @policy.nil?
100
+ invalid_properties.push('invalid value for "policy", policy cannot be nil.')
101
+ end
102
+
103
+ invalid_properties
104
+ end
105
+
106
+ # Check to see if the all the properties in the model are valid
107
+ # @return true if the model is valid
108
+ def valid?
109
+ return false if @name.nil?
110
+ return false if @policy.nil?
111
+ policy_validator = EnumAttributeValidator.new('String', ["affinity", "anti-affinity"])
112
+ return false unless policy_validator.valid?(@policy)
113
+ true
114
+ end
115
+
116
+ # Custom attribute writer method checking allowed values (enum).
117
+ # @param [Object] policy Object to be assigned
118
+ def policy=(policy)
119
+ validator = EnumAttributeValidator.new('String', ["affinity", "anti-affinity"])
120
+ unless validator.valid?(policy)
121
+ fail ArgumentError, "invalid value for \"policy\", must be one of #{validator.allowable_values}."
122
+ end
123
+ @policy = policy
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ name == o.name &&
132
+ policy == o.policy
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(o)
138
+ self == o
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Integer] Hash code
143
+ def hash
144
+ [name, policy].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def self.build_from_hash(attributes)
151
+ new.build_from_hash(attributes)
152
+ end
153
+
154
+ # Builds the object from hash
155
+ # @param [Hash] attributes Model attributes in the form of hash
156
+ # @return [Object] Returns the model itself
157
+ def build_from_hash(attributes)
158
+ return nil unless attributes.is_a?(Hash)
159
+ self.class.openapi_types.each_pair do |key, type|
160
+ if type =~ /\AArray<(.*)>/i
161
+ # check to ensure the input is an array given that the attribute
162
+ # is documented as an array but the input is not
163
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
164
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
165
+ end
166
+ elsif !attributes[self.class.attribute_map[key]].nil?
167
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
168
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
169
+ self.send("#{key}=", nil)
170
+ end
171
+ end
172
+
173
+ self
174
+ end
175
+
176
+ # Deserializes the data based on type
177
+ # @param string type Data type
178
+ # @param string value Value to be deserialized
179
+ # @return [Object] Deserialized data
180
+ def _deserialize(type, value)
181
+ case type.to_sym
182
+ when :DateTime
183
+ DateTime.parse(value)
184
+ when :Date
185
+ Date.parse(value)
186
+ when :String
187
+ value.to_s
188
+ when :Integer
189
+ value.to_i
190
+ when :Float
191
+ value.to_f
192
+ when :Boolean
193
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
+ true
195
+ else
196
+ false
197
+ end
198
+ when :Object
199
+ # generic object (usually a Hash), return directly
200
+ value
201
+ when /\AArray<(?<inner_type>.+)>\z/
202
+ inner_type = Regexp.last_match[:inner_type]
203
+ value.map { |v| _deserialize(inner_type, v) }
204
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
+ k_type = Regexp.last_match[:k_type]
206
+ v_type = Regexp.last_match[:v_type]
207
+ {}.tap do |hash|
208
+ value.each do |k, v|
209
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
+ end
211
+ end
212
+ else # model
213
+ IbmCloudPower.const_get(type).build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ if value.nil?
236
+ is_nullable = self.class.openapi_nullable.include?(attr)
237
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
238
+ end
239
+
240
+ hash[param] = _to_hash(value)
241
+ end
242
+ hash
243
+ end
244
+
245
+ # Outputs non-array value in the form of hash
246
+ # For object, use to_hash. Otherwise, just return the value
247
+ # @param [Object] value Any valid value
248
+ # @return [Hash] Returns the value in the form of hash
249
+ def _to_hash(value)
250
+ if value.is_a?(Array)
251
+ value.compact.map { |v| _to_hash(v) }
252
+ elsif value.is_a?(Hash)
253
+ {}.tap do |hash|
254
+ value.each { |k, v| hash[k] = _to_hash(v) }
255
+ end
256
+ elsif value.respond_to? :to_hash
257
+ value.to_hash
258
+ else
259
+ value
260
+ end
261
+ end
262
+ end
263
+ end