autosde_openapi_client 1.2.12 → 1.2.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -0
  3. data/docs/AbstractCapabilityApi.md +8 -8
  4. data/docs/AbstractCapabilityResponse.md +20 -0
  5. data/docs/ServiceAbstractCapabilityValueApi.md +276 -0
  6. data/docs/ServiceAbstractCapabilityValueResponse.md +22 -0
  7. data/docs/StorageSystem.md +2 -0
  8. data/docs/StorageSystemApi.md +4 -4
  9. data/docs/StorageSystemCreate.md +2 -0
  10. data/docs/StorageSystemResponse.md +36 -0
  11. data/docs/StorageSystemUpdate.md +2 -0
  12. data/lib/autosde_openapi_client/api/abstract_capability_api.rb +6 -6
  13. data/lib/autosde_openapi_client/api/service_abstract_capability_value_api.rb +254 -0
  14. data/lib/autosde_openapi_client/api/storage_system_api.rb +3 -3
  15. data/lib/autosde_openapi_client/models/abstract_capability_response.rb +230 -0
  16. data/lib/autosde_openapi_client/models/service_abstract_capability_value_response.rb +240 -0
  17. data/lib/autosde_openapi_client/models/storage_system.rb +10 -1
  18. data/lib/autosde_openapi_client/models/storage_system_create.rb +10 -1
  19. data/lib/autosde_openapi_client/models/storage_system_response.rb +364 -0
  20. data/lib/autosde_openapi_client/models/storage_system_update.rb +10 -1
  21. data/lib/autosde_openapi_client/version.rb +2 -2
  22. data/lib/autosde_openapi_client.rb +4 -0
  23. data/spec/api/abstract_capability_api_spec.rb +2 -2
  24. data/spec/api/service_abstract_capability_value_api_spec.rb +74 -0
  25. data/spec/api/storage_system_api_spec.rb +1 -1
  26. data/spec/models/abstract_capability_response_spec.rb +40 -0
  27. data/spec/models/service_abstract_capability_value_response_spec.rb +46 -0
  28. data/spec/models/storage_system_create_spec.rb +6 -0
  29. data/spec/models/storage_system_response_spec.rb +96 -0
  30. data/spec/models/storage_system_spec.rb +6 -0
  31. data/spec/models/storage_system_update_spec.rb +6 -0
  32. metadata +18 -2
@@ -0,0 +1,240 @@
1
+ =begin
2
+ #Site Manager API
3
+
4
+ #Site Manager API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: autosde@il.ibm.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module AutosdeOpenapiClient
17
+ # TODO add description
18
+ class ServiceAbstractCapabilityValueResponse
19
+ # !!uuid of abstract_capability
20
+ attr_accessor :abstract_capability
21
+
22
+ # uuid
23
+ attr_accessor :uuid
24
+
25
+ # value
26
+ attr_accessor :value
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'abstract_capability' => :'abstract_capability',
32
+ :'uuid' => :'uuid',
33
+ :'value' => :'value'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'abstract_capability' => :'String',
46
+ :'uuid' => :'String',
47
+ :'value' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AutosdeOpenapiClient::ServiceAbstractCapabilityValueResponse` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AutosdeOpenapiClient::ServiceAbstractCapabilityValueResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'abstract_capability')
73
+ self.abstract_capability = attributes[:'abstract_capability']
74
+ end
75
+
76
+ if attributes.key?(:'uuid')
77
+ self.uuid = attributes[:'uuid']
78
+ end
79
+
80
+ if attributes.key?(:'value')
81
+ self.value = attributes[:'value']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ abstract_capability == o.abstract_capability &&
104
+ uuid == o.uuid &&
105
+ value == o.value
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Integer] Hash code
116
+ def hash
117
+ [abstract_capability, uuid, value].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def self.build_from_hash(attributes)
124
+ new.build_from_hash(attributes)
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ self.class.openapi_types.each_pair do |key, type|
133
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
134
+ self.send("#{key}=", nil)
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
139
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
140
+ end
141
+ elsif !attributes[self.class.attribute_map[key]].nil?
142
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
143
+ end
144
+ end
145
+
146
+ self
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def _deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ # models (e.g. Pet) or oneOf
187
+ klass = AutosdeOpenapiClient.const_get(type)
188
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ if value.nil?
211
+ is_nullable = self.class.openapi_nullable.include?(attr)
212
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
213
+ end
214
+
215
+ hash[param] = _to_hash(value)
216
+ end
217
+ hash
218
+ end
219
+
220
+ # Outputs non-array value in the form of hash
221
+ # For object, use to_hash. Otherwise, just return the value
222
+ # @param [Object] value Any valid value
223
+ # @return [Hash] Returns the value in the form of hash
224
+ def _to_hash(value)
225
+ if value.is_a?(Array)
226
+ value.compact.map { |v| _to_hash(v) }
227
+ elsif value.is_a?(Hash)
228
+ {}.tap do |hash|
229
+ value.each { |k, v| hash[k] = _to_hash(v) }
230
+ end
231
+ elsif value.respond_to? :to_hash
232
+ value.to_hash
233
+ else
234
+ value
235
+ end
236
+ end
237
+
238
+ end
239
+
240
+ end
@@ -22,6 +22,8 @@ module AutosdeOpenapiClient
22
22
  # component_state
23
23
  attr_accessor :component_state
24
24
 
25
+ attr_accessor :enabled_capability_values
26
+
25
27
  # management_ip
26
28
  attr_accessor :management_ip
27
29
 
@@ -69,6 +71,7 @@ module AutosdeOpenapiClient
69
71
  {
70
72
  :'auto_refresh' => :'auto_refresh',
71
73
  :'component_state' => :'component_state',
74
+ :'enabled_capability_values' => :'enabled_capability_values',
72
75
  :'management_ip' => :'management_ip',
73
76
  :'name' => :'name',
74
77
  :'status' => :'status',
@@ -89,6 +92,7 @@ module AutosdeOpenapiClient
89
92
  {
90
93
  :'auto_refresh' => :'Boolean',
91
94
  :'component_state' => :'String',
95
+ :'enabled_capability_values' => :'ServiceAbstractCapabilityValue',
92
96
  :'management_ip' => :'String',
93
97
  :'name' => :'String',
94
98
  :'status' => :'String',
@@ -130,6 +134,10 @@ module AutosdeOpenapiClient
130
134
  self.component_state = attributes[:'component_state']
131
135
  end
132
136
 
137
+ if attributes.key?(:'enabled_capability_values')
138
+ self.enabled_capability_values = attributes[:'enabled_capability_values']
139
+ end
140
+
133
141
  if attributes.key?(:'management_ip')
134
142
  self.management_ip = attributes[:'management_ip']
135
143
  end
@@ -208,6 +216,7 @@ module AutosdeOpenapiClient
208
216
  self.class == o.class &&
209
217
  auto_refresh == o.auto_refresh &&
210
218
  component_state == o.component_state &&
219
+ enabled_capability_values == o.enabled_capability_values &&
211
220
  management_ip == o.management_ip &&
212
221
  name == o.name &&
213
222
  status == o.status &&
@@ -226,7 +235,7 @@ module AutosdeOpenapiClient
226
235
  # Calculates hash code according to all attributes.
227
236
  # @return [Integer] Hash code
228
237
  def hash
229
- [auto_refresh, component_state, management_ip, name, status, storage_array, storage_family, system_type, uuid].hash
238
+ [auto_refresh, component_state, enabled_capability_values, management_ip, name, status, storage_array, storage_family, system_type, uuid].hash
230
239
  end
231
240
 
232
241
  # Builds the object from hash
@@ -28,6 +28,8 @@ module AutosdeOpenapiClient
28
28
  # component_state
29
29
  attr_accessor :component_state
30
30
 
31
+ attr_accessor :enabled_capability_values
32
+
31
33
  # initial_refresh
32
34
  attr_accessor :initial_refresh
33
35
 
@@ -97,6 +99,7 @@ module AutosdeOpenapiClient
97
99
  :'chap_name' => :'chap_name',
98
100
  :'chap_secret' => :'chap_secret',
99
101
  :'component_state' => :'component_state',
102
+ :'enabled_capability_values' => :'enabled_capability_values',
100
103
  :'initial_refresh' => :'initial_refresh',
101
104
  :'iqn' => :'iqn',
102
105
  :'management_ip' => :'management_ip',
@@ -126,6 +129,7 @@ module AutosdeOpenapiClient
126
129
  :'chap_name' => :'String',
127
130
  :'chap_secret' => :'String',
128
131
  :'component_state' => :'String',
132
+ :'enabled_capability_values' => :'ServiceAbstractCapabilityValue',
129
133
  :'initial_refresh' => :'Boolean',
130
134
  :'iqn' => :'String',
131
135
  :'management_ip' => :'String',
@@ -182,6 +186,10 @@ module AutosdeOpenapiClient
182
186
  self.component_state = attributes[:'component_state']
183
187
  end
184
188
 
189
+ if attributes.key?(:'enabled_capability_values')
190
+ self.enabled_capability_values = attributes[:'enabled_capability_values']
191
+ end
192
+
185
193
  if attributes.key?(:'initial_refresh')
186
194
  self.initial_refresh = attributes[:'initial_refresh']
187
195
  else
@@ -304,6 +312,7 @@ module AutosdeOpenapiClient
304
312
  chap_name == o.chap_name &&
305
313
  chap_secret == o.chap_secret &&
306
314
  component_state == o.component_state &&
315
+ enabled_capability_values == o.enabled_capability_values &&
307
316
  initial_refresh == o.initial_refresh &&
308
317
  iqn == o.iqn &&
309
318
  management_ip == o.management_ip &&
@@ -329,7 +338,7 @@ module AutosdeOpenapiClient
329
338
  # Calculates hash code according to all attributes.
330
339
  # @return [Integer] Hash code
331
340
  def hash
332
- [auto_refresh, chap_name, chap_secret, component_state, initial_refresh, iqn, management_ip, name, password, port_type, secondary_ip, status, storage_array, storage_driver, storage_family, system_type, user, wwpn].hash
341
+ [auto_refresh, chap_name, chap_secret, component_state, enabled_capability_values, initial_refresh, iqn, management_ip, name, password, port_type, secondary_ip, status, storage_array, storage_driver, storage_family, system_type, user, wwpn].hash
333
342
  end
334
343
 
335
344
  # Builds the object from hash
@@ -0,0 +1,364 @@
1
+ =begin
2
+ #Site Manager API
3
+
4
+ #Site Manager API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: autosde@il.ibm.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module AutosdeOpenapiClient
17
+ # TODO add description
18
+ class StorageSystemResponse
19
+ # auto_refresh
20
+ attr_accessor :auto_refresh
21
+
22
+ # component_state
23
+ attr_accessor :component_state
24
+
25
+ # enabled_capability_values
26
+ attr_accessor :enabled_capability_values
27
+
28
+ # management_ip
29
+ attr_accessor :management_ip
30
+
31
+ # name
32
+ attr_accessor :name
33
+
34
+ # status
35
+ attr_accessor :status
36
+
37
+ # storage_array
38
+ attr_accessor :storage_array
39
+
40
+ # storage_family
41
+ attr_accessor :storage_family
42
+
43
+ attr_accessor :system_type
44
+
45
+ # uuid
46
+ attr_accessor :uuid
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'auto_refresh' => :'auto_refresh',
74
+ :'component_state' => :'component_state',
75
+ :'enabled_capability_values' => :'enabled_capability_values',
76
+ :'management_ip' => :'management_ip',
77
+ :'name' => :'name',
78
+ :'status' => :'status',
79
+ :'storage_array' => :'storage_array',
80
+ :'storage_family' => :'storage_family',
81
+ :'system_type' => :'system_type',
82
+ :'uuid' => :'uuid'
83
+ }
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.openapi_types
93
+ {
94
+ :'auto_refresh' => :'Boolean',
95
+ :'component_state' => :'String',
96
+ :'enabled_capability_values' => :'Array<ServiceAbstractCapabilityValue>',
97
+ :'management_ip' => :'String',
98
+ :'name' => :'String',
99
+ :'status' => :'String',
100
+ :'storage_array' => :'String',
101
+ :'storage_family' => :'String',
102
+ :'system_type' => :'SystemType',
103
+ :'uuid' => :'String'
104
+ }
105
+ end
106
+
107
+ # List of attributes with nullable: true
108
+ def self.openapi_nullable
109
+ Set.new([
110
+ ])
111
+ end
112
+
113
+ # Initializes the object
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ def initialize(attributes = {})
116
+ if (!attributes.is_a?(Hash))
117
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AutosdeOpenapiClient::StorageSystemResponse` initialize method"
118
+ end
119
+
120
+ # check to see if the attribute exists and convert string to symbol for hash key
121
+ attributes = attributes.each_with_object({}) { |(k, v), h|
122
+ if (!self.class.attribute_map.key?(k.to_sym))
123
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AutosdeOpenapiClient::StorageSystemResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
124
+ end
125
+ h[k.to_sym] = v
126
+ }
127
+
128
+ if attributes.key?(:'auto_refresh')
129
+ self.auto_refresh = attributes[:'auto_refresh']
130
+ else
131
+ self.auto_refresh = true
132
+ end
133
+
134
+ if attributes.key?(:'component_state')
135
+ self.component_state = attributes[:'component_state']
136
+ end
137
+
138
+ if attributes.key?(:'enabled_capability_values')
139
+ if (value = attributes[:'enabled_capability_values']).is_a?(Array)
140
+ self.enabled_capability_values = value
141
+ end
142
+ end
143
+
144
+ if attributes.key?(:'management_ip')
145
+ self.management_ip = attributes[:'management_ip']
146
+ end
147
+
148
+ if attributes.key?(:'name')
149
+ self.name = attributes[:'name']
150
+ end
151
+
152
+ if attributes.key?(:'status')
153
+ self.status = attributes[:'status']
154
+ end
155
+
156
+ if attributes.key?(:'storage_array')
157
+ self.storage_array = attributes[:'storage_array']
158
+ end
159
+
160
+ if attributes.key?(:'storage_family')
161
+ self.storage_family = attributes[:'storage_family']
162
+ end
163
+
164
+ if attributes.key?(:'system_type')
165
+ self.system_type = attributes[:'system_type']
166
+ end
167
+
168
+ if attributes.key?(:'uuid')
169
+ self.uuid = attributes[:'uuid']
170
+ end
171
+ end
172
+
173
+ # Show invalid properties with the reasons. Usually used together with valid?
174
+ # @return Array for valid properties with the reasons
175
+ def list_invalid_properties
176
+ invalid_properties = Array.new
177
+ if !@component_state.nil? && @component_state.to_s.length > 32
178
+ invalid_properties.push('invalid value for "component_state", the character length must be smaller than or equal to 32.')
179
+ end
180
+
181
+ invalid_properties
182
+ end
183
+
184
+ # Check to see if the all the properties in the model are valid
185
+ # @return true if the model is valid
186
+ def valid?
187
+ component_state_validator = EnumAttributeValidator.new('String', ["PENDING_CREATION", "CREATED", "DELETED", "PENDING_DELETION", "MODIFICATION", "PENDING_MODIFICATION"])
188
+ return false unless component_state_validator.valid?(@component_state)
189
+ return false if !@component_state.nil? && @component_state.to_s.length > 32
190
+ storage_family_validator = EnumAttributeValidator.new('String', ["", "ontap_7mode", "ontap_cluster"])
191
+ return false unless storage_family_validator.valid?(@storage_family)
192
+ true
193
+ end
194
+
195
+ # Custom attribute writer method checking allowed values (enum).
196
+ # @param [Object] component_state Object to be assigned
197
+ def component_state=(component_state)
198
+ validator = EnumAttributeValidator.new('String', ["PENDING_CREATION", "CREATED", "DELETED", "PENDING_DELETION", "MODIFICATION", "PENDING_MODIFICATION"])
199
+ unless validator.valid?(component_state)
200
+ fail ArgumentError, "invalid value for \"component_state\", must be one of #{validator.allowable_values}."
201
+ end
202
+ @component_state = component_state
203
+ end
204
+
205
+ # Custom attribute writer method checking allowed values (enum).
206
+ # @param [Object] storage_family Object to be assigned
207
+ def storage_family=(storage_family)
208
+ validator = EnumAttributeValidator.new('String', ["", "ontap_7mode", "ontap_cluster"])
209
+ unless validator.valid?(storage_family)
210
+ fail ArgumentError, "invalid value for \"storage_family\", must be one of #{validator.allowable_values}."
211
+ end
212
+ @storage_family = storage_family
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ auto_refresh == o.auto_refresh &&
221
+ component_state == o.component_state &&
222
+ enabled_capability_values == o.enabled_capability_values &&
223
+ management_ip == o.management_ip &&
224
+ name == o.name &&
225
+ status == o.status &&
226
+ storage_array == o.storage_array &&
227
+ storage_family == o.storage_family &&
228
+ system_type == o.system_type &&
229
+ uuid == o.uuid
230
+ end
231
+
232
+ # @see the `==` method
233
+ # @param [Object] Object to be compared
234
+ def eql?(o)
235
+ self == o
236
+ end
237
+
238
+ # Calculates hash code according to all attributes.
239
+ # @return [Integer] Hash code
240
+ def hash
241
+ [auto_refresh, component_state, enabled_capability_values, management_ip, name, status, storage_array, storage_family, system_type, uuid].hash
242
+ end
243
+
244
+ # Builds the object from hash
245
+ # @param [Hash] attributes Model attributes in the form of hash
246
+ # @return [Object] Returns the model itself
247
+ def self.build_from_hash(attributes)
248
+ new.build_from_hash(attributes)
249
+ end
250
+
251
+ # Builds the object from hash
252
+ # @param [Hash] attributes Model attributes in the form of hash
253
+ # @return [Object] Returns the model itself
254
+ def build_from_hash(attributes)
255
+ return nil unless attributes.is_a?(Hash)
256
+ self.class.openapi_types.each_pair do |key, type|
257
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
258
+ self.send("#{key}=", nil)
259
+ elsif type =~ /\AArray<(.*)>/i
260
+ # check to ensure the input is an array given that the attribute
261
+ # is documented as an array but the input is not
262
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
263
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
264
+ end
265
+ elsif !attributes[self.class.attribute_map[key]].nil?
266
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
267
+ end
268
+ end
269
+
270
+ self
271
+ end
272
+
273
+ # Deserializes the data based on type
274
+ # @param string type Data type
275
+ # @param string value Value to be deserialized
276
+ # @return [Object] Deserialized data
277
+ def _deserialize(type, value)
278
+ case type.to_sym
279
+ when :Time
280
+ Time.parse(value)
281
+ when :Date
282
+ Date.parse(value)
283
+ when :String
284
+ value.to_s
285
+ when :Integer
286
+ value.to_i
287
+ when :Float
288
+ value.to_f
289
+ when :Boolean
290
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
291
+ true
292
+ else
293
+ false
294
+ end
295
+ when :Object
296
+ # generic object (usually a Hash), return directly
297
+ value
298
+ when /\AArray<(?<inner_type>.+)>\z/
299
+ inner_type = Regexp.last_match[:inner_type]
300
+ value.map { |v| _deserialize(inner_type, v) }
301
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
302
+ k_type = Regexp.last_match[:k_type]
303
+ v_type = Regexp.last_match[:v_type]
304
+ {}.tap do |hash|
305
+ value.each do |k, v|
306
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
307
+ end
308
+ end
309
+ else # model
310
+ # models (e.g. Pet) or oneOf
311
+ klass = AutosdeOpenapiClient.const_get(type)
312
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
313
+ end
314
+ end
315
+
316
+ # Returns the string representation of the object
317
+ # @return [String] String presentation of the object
318
+ def to_s
319
+ to_hash.to_s
320
+ end
321
+
322
+ # to_body is an alias to to_hash (backward compatibility)
323
+ # @return [Hash] Returns the object in the form of hash
324
+ def to_body
325
+ to_hash
326
+ end
327
+
328
+ # Returns the object in the form of hash
329
+ # @return [Hash] Returns the object in the form of hash
330
+ def to_hash
331
+ hash = {}
332
+ self.class.attribute_map.each_pair do |attr, param|
333
+ value = self.send(attr)
334
+ if value.nil?
335
+ is_nullable = self.class.openapi_nullable.include?(attr)
336
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
337
+ end
338
+
339
+ hash[param] = _to_hash(value)
340
+ end
341
+ hash
342
+ end
343
+
344
+ # Outputs non-array value in the form of hash
345
+ # For object, use to_hash. Otherwise, just return the value
346
+ # @param [Object] value Any valid value
347
+ # @return [Hash] Returns the value in the form of hash
348
+ def _to_hash(value)
349
+ if value.is_a?(Array)
350
+ value.compact.map { |v| _to_hash(v) }
351
+ elsif value.is_a?(Hash)
352
+ {}.tap do |hash|
353
+ value.each { |k, v| hash[k] = _to_hash(v) }
354
+ end
355
+ elsif value.respond_to? :to_hash
356
+ value.to_hash
357
+ else
358
+ value
359
+ end
360
+ end
361
+
362
+ end
363
+
364
+ end