ionoscloud-dbaas-mongo 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +70 -0
  4. data/LICENSE +201 -0
  5. data/README.md +58 -0
  6. data/Rakefile +10 -0
  7. data/docs/api/ClustersApi.md +313 -0
  8. data/docs/api/LogsApi.md +93 -0
  9. data/docs/api/MetadataApi.md +153 -0
  10. data/docs/api/RestoresApi.md +84 -0
  11. data/docs/api/SnapshotsApi.md +83 -0
  12. data/docs/api/TemplatesApi.md +80 -0
  13. data/docs/api/UsersApi.md +321 -0
  14. data/docs/models/APIVersion.md +20 -0
  15. data/docs/models/ClusterList.md +28 -0
  16. data/docs/models/ClusterListAllOf.md +22 -0
  17. data/docs/models/ClusterLogs.md +18 -0
  18. data/docs/models/ClusterLogsInstances.md +20 -0
  19. data/docs/models/ClusterLogsMessages.md +20 -0
  20. data/docs/models/ClusterProperties.md +32 -0
  21. data/docs/models/ClusterResponse.md +24 -0
  22. data/docs/models/Connection.md +22 -0
  23. data/docs/models/CreateClusterProperties.md +30 -0
  24. data/docs/models/CreateClusterRequest.md +20 -0
  25. data/docs/models/CreateRestoreRequest.md +18 -0
  26. data/docs/models/DayOfTheWeek.md +15 -0
  27. data/docs/models/ErrorMessage.md +20 -0
  28. data/docs/models/ErrorResponse.md +20 -0
  29. data/docs/models/MaintenanceWindow.md +20 -0
  30. data/docs/models/Metadata.md +30 -0
  31. data/docs/models/Pagination.md +22 -0
  32. data/docs/models/PaginationLinks.md +22 -0
  33. data/docs/models/ResourceType.md +15 -0
  34. data/docs/models/SnapshotList.md +28 -0
  35. data/docs/models/SnapshotListAllOf.md +22 -0
  36. data/docs/models/SnapshotProperties.md +22 -0
  37. data/docs/models/SnapshotResponse.md +22 -0
  38. data/docs/models/State.md +15 -0
  39. data/docs/models/TemplateList.md +18 -0
  40. data/docs/models/TemplateListAllOf.md +18 -0
  41. data/docs/models/TemplateResponse.md +24 -0
  42. data/docs/models/User.md +22 -0
  43. data/docs/models/UserMetadata.md +24 -0
  44. data/docs/models/UserProperties.md +24 -0
  45. data/docs/models/UserRoles.md +20 -0
  46. data/docs/models/UsersList.md +22 -0
  47. data/docs/summary.md +50 -0
  48. data/git_push.sh +56 -0
  49. data/ionoscloud-dbaas-mongo.gemspec +38 -0
  50. data/lib/ionoscloud-dbaas-mongo/api/clusters_api.rb +273 -0
  51. data/lib/ionoscloud-dbaas-mongo/api/logs_api.rb +109 -0
  52. data/lib/ionoscloud-dbaas-mongo/api/metadata_api.rb +136 -0
  53. data/lib/ionoscloud-dbaas-mongo/api/restores_api.rb +93 -0
  54. data/lib/ionoscloud-dbaas-mongo/api/snapshots_api.rb +85 -0
  55. data/lib/ionoscloud-dbaas-mongo/api/templates_api.rb +79 -0
  56. data/lib/ionoscloud-dbaas-mongo/api/users_api.rb +306 -0
  57. data/lib/ionoscloud-dbaas-mongo/api_client.rb +471 -0
  58. data/lib/ionoscloud-dbaas-mongo/api_error.rb +57 -0
  59. data/lib/ionoscloud-dbaas-mongo/configuration.rb +276 -0
  60. data/lib/ionoscloud-dbaas-mongo/models/api_version.rb +243 -0
  61. data/lib/ionoscloud-dbaas-mongo/models/cluster_list.rb +353 -0
  62. data/lib/ionoscloud-dbaas-mongo/models/cluster_list_all_of.rb +261 -0
  63. data/lib/ionoscloud-dbaas-mongo/models/cluster_logs.rb +227 -0
  64. data/lib/ionoscloud-dbaas-mongo/models/cluster_logs_instances.rb +244 -0
  65. data/lib/ionoscloud-dbaas-mongo/models/cluster_logs_messages.rb +243 -0
  66. data/lib/ionoscloud-dbaas-mongo/models/cluster_properties.rb +376 -0
  67. data/lib/ionoscloud-dbaas-mongo/models/cluster_response.rb +279 -0
  68. data/lib/ionoscloud-dbaas-mongo/models/connection.rb +279 -0
  69. data/lib/ionoscloud-dbaas-mongo/models/create_cluster_properties.rb +387 -0
  70. data/lib/ionoscloud-dbaas-mongo/models/create_cluster_request.rb +244 -0
  71. data/lib/ionoscloud-dbaas-mongo/models/create_restore_request.rb +233 -0
  72. data/lib/ionoscloud-dbaas-mongo/models/day_of_the_week.rb +42 -0
  73. data/lib/ionoscloud-dbaas-mongo/models/error_message.rb +245 -0
  74. data/lib/ionoscloud-dbaas-mongo/models/error_response.rb +244 -0
  75. data/lib/ionoscloud-dbaas-mongo/models/maintenance_window.rb +254 -0
  76. data/lib/ionoscloud-dbaas-mongo/models/metadata.rb +335 -0
  77. data/lib/ionoscloud-dbaas-mongo/models/pagination.rb +292 -0
  78. data/lib/ionoscloud-dbaas-mongo/models/pagination_links.rb +264 -0
  79. data/lib/ionoscloud-dbaas-mongo/models/resource_type.rb +38 -0
  80. data/lib/ionoscloud-dbaas-mongo/models/snapshot_list.rb +353 -0
  81. data/lib/ionoscloud-dbaas-mongo/models/snapshot_list_all_of.rb +261 -0
  82. data/lib/ionoscloud-dbaas-mongo/models/snapshot_properties.rb +264 -0
  83. data/lib/ionoscloud-dbaas-mongo/models/snapshot_response.rb +262 -0
  84. data/lib/ionoscloud-dbaas-mongo/models/state.rb +40 -0
  85. data/lib/ionoscloud-dbaas-mongo/models/template_list.rb +234 -0
  86. data/lib/ionoscloud-dbaas-mongo/models/template_list_all_of.rb +226 -0
  87. data/lib/ionoscloud-dbaas-mongo/models/template_response.rb +282 -0
  88. data/lib/ionoscloud-dbaas-mongo/models/user.rb +261 -0
  89. data/lib/ionoscloud-dbaas-mongo/models/user_metadata.rb +316 -0
  90. data/lib/ionoscloud-dbaas-mongo/models/user_properties.rb +294 -0
  91. data/lib/ionoscloud-dbaas-mongo/models/user_roles.rb +278 -0
  92. data/lib/ionoscloud-dbaas-mongo/models/users_list.rb +262 -0
  93. data/lib/ionoscloud-dbaas-mongo/version.rb +15 -0
  94. data/lib/ionoscloud-dbaas-mongo.rb +79 -0
  95. data/spec/api_client_spec.rb +226 -0
  96. data/spec/configuration_spec.rb +42 -0
  97. data/spec/spec_helper.rb +111 -0
  98. metadata +189 -0
@@ -0,0 +1,376 @@
1
+ =begin
2
+ #IONOS DBaaS MongoDB REST API
3
+
4
+ #With IONOS Cloud Database as a Service, you have the ability to quickly set up and manage a MongoDB database. You can also delete clusters, manage backups and users via the API. MongoDB is an open source, cross-platform, document-oriented database program. Classified as a NoSQL database program, it uses JSON-like documents with optional schemas. The MongoDB API allows you to create additional database clusters or modify existing ones. Both tools, the Data Center Designer (DCD) and the API use the same concepts consistently and are well suited for smooth and intuitive use.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module IonoscloudDbaasMongo
17
+ # Properties of a database cluster.
18
+ class ClusterProperties
19
+
20
+ # The name of your cluster.
21
+ attr_accessor :display_name
22
+
23
+
24
+ # The MongoDB version of your cluster.
25
+ attr_accessor :mongo_db_version
26
+
27
+
28
+ # The physical location where the cluster will be created. This is the location where all your instances will be located. This property is immutable.
29
+ attr_accessor :location
30
+
31
+
32
+ # The total number of instances in the cluster (one primary and n-1 secondaries).
33
+ attr_accessor :instances
34
+
35
+
36
+ attr_accessor :connections
37
+
38
+
39
+ attr_accessor :maintenance_window
40
+
41
+
42
+ # The unique ID of the template, which specifies the number of cores, storage size, and memory.
43
+ attr_accessor :template_id
44
+
45
+
46
+ # The connection string for your cluster.
47
+ attr_accessor :connection_string
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+
53
+ :'display_name' => :'displayName',
54
+
55
+ :'mongo_db_version' => :'mongoDBVersion',
56
+
57
+ :'location' => :'location',
58
+
59
+ :'instances' => :'instances',
60
+
61
+ :'connections' => :'connections',
62
+
63
+ :'maintenance_window' => :'maintenanceWindow',
64
+
65
+ :'template_id' => :'templateID',
66
+
67
+ :'connection_string' => :'connectionString'
68
+ }
69
+ end
70
+
71
+ # Returns all the JSON keys this model knows about
72
+ def self.acceptable_attributes
73
+ attribute_map.values
74
+ end
75
+
76
+ # Attribute type mapping.
77
+ def self.openapi_types
78
+ {
79
+
80
+ :'display_name' => :'String',
81
+
82
+ :'mongo_db_version' => :'String',
83
+
84
+ :'location' => :'String',
85
+
86
+ :'instances' => :'Integer',
87
+
88
+ :'connections' => :'Array<Connection>',
89
+
90
+ :'maintenance_window' => :'MaintenanceWindow',
91
+
92
+ :'template_id' => :'String',
93
+
94
+ :'connection_string' => :'String'
95
+ }
96
+ end
97
+
98
+ # List of attributes with nullable: true
99
+ def self.openapi_nullable
100
+ Set.new([
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ ])
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ if (!attributes.is_a?(Hash))
116
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasMongo::ClusterProperties` initialize method"
117
+ end
118
+
119
+ # check to see if the attribute exists and convert string to symbol for hash key
120
+ attributes = attributes.each_with_object({}) { |(k, v), h|
121
+ if (!self.class.attribute_map.key?(k.to_sym))
122
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasMongo::ClusterProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
123
+ end
124
+ h[k.to_sym] = v
125
+ }
126
+
127
+
128
+ if attributes.key?(:'display_name')
129
+ self.display_name = attributes[:'display_name']
130
+ end
131
+
132
+
133
+ if attributes.key?(:'mongo_db_version')
134
+ self.mongo_db_version = attributes[:'mongo_db_version']
135
+ end
136
+
137
+
138
+ if attributes.key?(:'location')
139
+ self.location = attributes[:'location']
140
+ end
141
+
142
+
143
+ if attributes.key?(:'instances')
144
+ self.instances = attributes[:'instances']
145
+ end
146
+
147
+
148
+ if attributes.key?(:'connections') && (value = attributes[:'connections']).is_a?(Array)
149
+ self.connections = value
150
+ end
151
+
152
+
153
+ if attributes.key?(:'maintenance_window')
154
+ self.maintenance_window = attributes[:'maintenance_window']
155
+ end
156
+
157
+
158
+ if attributes.key?(:'template_id')
159
+ self.template_id = attributes[:'template_id']
160
+ end
161
+
162
+
163
+ if attributes.key?(:'connection_string')
164
+ self.connection_string = attributes[:'connection_string']
165
+ end
166
+ end
167
+
168
+ # Show invalid properties with the reasons. Usually used together with valid?
169
+ # @return Array for valid properties with the reasons
170
+ def list_invalid_properties
171
+ invalid_properties = Array.new
172
+
173
+
174
+
175
+
176
+
177
+ if !@connections.nil? && @connections.length > 1
178
+ invalid_properties.push('invalid value for "connections", number of items must be less than or equal to 1.')
179
+ end
180
+
181
+ if !@connections.nil? && @connections.length < 1
182
+ invalid_properties.push('invalid value for "connections", number of items must be greater than or equal to 1.')
183
+ end
184
+
185
+
186
+
187
+
188
+ invalid_properties
189
+ end
190
+
191
+ # Check to see if the all the properties in the model are valid
192
+ # @return true if the model is valid
193
+ def valid?
194
+
195
+
196
+
197
+
198
+
199
+ return false if !@connections.nil? && @connections.length > 1
200
+ return false if !@connections.nil? && @connections.length < 1
201
+
202
+
203
+
204
+ true
205
+ end
206
+
207
+
208
+
209
+
210
+
211
+
212
+ # Custom attribute writer method with validation
213
+ # @param [Object] connections Value to be assigned
214
+ def connections=(connections)
215
+ if !connections.nil? && connections.length > 1
216
+ fail ArgumentError, 'invalid value for "connections", number of items must be less than or equal to 1.'
217
+ end
218
+
219
+ if !connections.nil? && connections.length < 1
220
+ fail ArgumentError, 'invalid value for "connections", number of items must be greater than or equal to 1.'
221
+ end
222
+
223
+ @connections = connections
224
+ end
225
+
226
+
227
+
228
+
229
+ # Checks equality by comparing each attribute.
230
+ # @param [Object] Object to be compared
231
+ def ==(o)
232
+ return true if self.equal?(o)
233
+ self.class == o.class &&
234
+ display_name == o.display_name &&
235
+ mongo_db_version == o.mongo_db_version &&
236
+ location == o.location &&
237
+ instances == o.instances &&
238
+ connections == o.connections &&
239
+ maintenance_window == o.maintenance_window &&
240
+ template_id == o.template_id &&
241
+ connection_string == o.connection_string
242
+ end
243
+
244
+ # @see the `==` method
245
+ # @param [Object] Object to be compared
246
+ def eql?(o)
247
+ self == o
248
+ end
249
+
250
+ # Calculates hash code according to all attributes.
251
+ # @return [Integer] Hash code
252
+ def hash
253
+ [display_name, mongo_db_version, location, instances, connections, maintenance_window, template_id, connection_string].hash
254
+ end
255
+
256
+ # Builds the object from hash
257
+ # @param [Hash] attributes Model attributes in the form of hash
258
+ # @return [Object] Returns the model itself
259
+ def self.build_from_hash(attributes)
260
+ new.build_from_hash(attributes)
261
+ end
262
+
263
+ # Builds the object from hash
264
+ # @param [Hash] attributes Model attributes in the form of hash
265
+ # @return [Object] Returns the model itself
266
+ def build_from_hash(attributes)
267
+ return nil unless attributes.is_a?(Hash)
268
+ self.class.openapi_types.each_pair do |key, type|
269
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
270
+ self.send("#{key}=", nil)
271
+ elsif type =~ /\AArray<(.*)>/i
272
+ # check to ensure the input is an array given that the attribute
273
+ # is documented as an array but the input is not
274
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
275
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
276
+ end
277
+ elsif !attributes[self.class.attribute_map[key]].nil?
278
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
279
+ end
280
+ end
281
+
282
+ self
283
+ end
284
+
285
+ # Deserializes the data based on type
286
+ # @param string type Data type
287
+ # @param string value Value to be deserialized
288
+ # @return [Object] Deserialized data
289
+ def _deserialize(type, value)
290
+ case type.to_sym
291
+ when :Time
292
+ Time.parse(value)
293
+ when :Date
294
+ Date.parse(value)
295
+ when :String
296
+ value.to_s
297
+ when :Integer
298
+ value.to_i
299
+ when :Float
300
+ value.to_f
301
+ when :Boolean
302
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
303
+ true
304
+ else
305
+ false
306
+ end
307
+ when :Object
308
+ # generic object (usually a Hash), return directly
309
+ value
310
+ when /\AArray<(?<inner_type>.+)>\z/
311
+ inner_type = Regexp.last_match[:inner_type]
312
+ value.map { |v| _deserialize(inner_type, v) }
313
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
314
+ k_type = Regexp.last_match[:k_type]
315
+ v_type = Regexp.last_match[:v_type]
316
+ {}.tap do |hash|
317
+ value.each do |k, v|
318
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
319
+ end
320
+ end
321
+ else # model
322
+ # models (e.g. Pet) or oneOf
323
+ klass = IonoscloudDbaasMongo.const_get(type)
324
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
325
+ end
326
+ end
327
+
328
+ # Returns the string representation of the object
329
+ # @return [String] String presentation of the object
330
+ def to_s
331
+ to_hash.to_s
332
+ end
333
+
334
+ # to_body is an alias to to_hash (backward compatibility)
335
+ # @return [Hash] Returns the object in the form of hash
336
+ def to_body
337
+ to_hash
338
+ end
339
+
340
+ # Returns the object in the form of hash
341
+ # @return [Hash] Returns the object in the form of hash
342
+ def to_hash
343
+ hash = {}
344
+ self.class.attribute_map.each_pair do |attr, param|
345
+ value = self.send(attr)
346
+ if value.nil?
347
+ is_nullable = self.class.openapi_nullable.include?(attr)
348
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
349
+ end
350
+
351
+ hash[param] = _to_hash(value)
352
+ end
353
+ hash
354
+ end
355
+
356
+ # Outputs non-array value in the form of hash
357
+ # For object, use to_hash. Otherwise, just return the value
358
+ # @param [Object] value Any valid value
359
+ # @return [Hash] Returns the value in the form of hash
360
+ def _to_hash(value)
361
+ if value.is_a?(Array)
362
+ value.compact.map { |v| _to_hash(v) }
363
+ elsif value.is_a?(Hash)
364
+ {}.tap do |hash|
365
+ value.each { |k, v| hash[k] = _to_hash(v) }
366
+ end
367
+ elsif value.respond_to? :to_hash
368
+ value.to_hash
369
+ else
370
+ value
371
+ end
372
+ end
373
+
374
+ end
375
+
376
+ end
@@ -0,0 +1,279 @@
1
+ =begin
2
+ #IONOS DBaaS MongoDB REST API
3
+
4
+ #With IONOS Cloud Database as a Service, you have the ability to quickly set up and manage a MongoDB database. You can also delete clusters, manage backups and users via the API. MongoDB is an open source, cross-platform, document-oriented database program. Classified as a NoSQL database program, it uses JSON-like documents with optional schemas. The MongoDB API allows you to create additional database clusters or modify existing ones. Both tools, the Data Center Designer (DCD) and the API use the same concepts consistently and are well suited for smooth and intuitive use.
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module IonoscloudDbaasMongo
17
+ # A database cluster.
18
+ class ClusterResponse
19
+
20
+ attr_accessor :type
21
+
22
+
23
+ # The unique ID of the resource.
24
+ attr_accessor :id
25
+
26
+
27
+ attr_accessor :metadata
28
+
29
+
30
+ attr_accessor :properties
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+
36
+ :'type' => :'type',
37
+
38
+ :'id' => :'id',
39
+
40
+ :'metadata' => :'metadata',
41
+
42
+ :'properties' => :'properties'
43
+ }
44
+ end
45
+
46
+ # Returns all the JSON keys this model knows about
47
+ def self.acceptable_attributes
48
+ attribute_map.values
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+
55
+ :'type' => :'ResourceType',
56
+
57
+ :'id' => :'String',
58
+
59
+ :'metadata' => :'Metadata',
60
+
61
+ :'properties' => :'ClusterProperties'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+
69
+
70
+
71
+
72
+ ])
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ if (!attributes.is_a?(Hash))
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasMongo::ClusterResponse` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!self.class.attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasMongo::ClusterResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+
91
+ if attributes.key?(:'type')
92
+ self.type = attributes[:'type']
93
+ end
94
+
95
+
96
+ if attributes.key?(:'id')
97
+ self.id = attributes[:'id']
98
+ end
99
+
100
+
101
+ if attributes.key?(:'metadata')
102
+ self.metadata = attributes[:'metadata']
103
+ end
104
+
105
+
106
+ if attributes.key?(:'properties')
107
+ self.properties = attributes[:'properties']
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
+
116
+
117
+
118
+
119
+ invalid_properties
120
+ end
121
+
122
+ # Check to see if the all the properties in the model are valid
123
+ # @return true if the model is valid
124
+ def valid?
125
+
126
+
127
+
128
+
129
+ true
130
+ end
131
+
132
+
133
+
134
+
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(o)
139
+ return true if self.equal?(o)
140
+ self.class == o.class &&
141
+ type == o.type &&
142
+ id == o.id &&
143
+ metadata == o.metadata &&
144
+ properties == o.properties
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(o)
150
+ self == o
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [type, id, metadata, properties].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ new.build_from_hash(attributes)
164
+ end
165
+
166
+ # Builds the object from hash
167
+ # @param [Hash] attributes Model attributes in the form of hash
168
+ # @return [Object] Returns the model itself
169
+ def build_from_hash(attributes)
170
+ return nil unless attributes.is_a?(Hash)
171
+ self.class.openapi_types.each_pair do |key, type|
172
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
173
+ self.send("#{key}=", nil)
174
+ elsif type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
178
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
179
+ end
180
+ elsif !attributes[self.class.attribute_map[key]].nil?
181
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
182
+ end
183
+ end
184
+
185
+ self
186
+ end
187
+
188
+ # Deserializes the data based on type
189
+ # @param string type Data type
190
+ # @param string value Value to be deserialized
191
+ # @return [Object] Deserialized data
192
+ def _deserialize(type, value)
193
+ case type.to_sym
194
+ when :Time
195
+ Time.parse(value)
196
+ when :Date
197
+ Date.parse(value)
198
+ when :String
199
+ value.to_s
200
+ when :Integer
201
+ value.to_i
202
+ when :Float
203
+ value.to_f
204
+ when :Boolean
205
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
206
+ true
207
+ else
208
+ false
209
+ end
210
+ when :Object
211
+ # generic object (usually a Hash), return directly
212
+ value
213
+ when /\AArray<(?<inner_type>.+)>\z/
214
+ inner_type = Regexp.last_match[:inner_type]
215
+ value.map { |v| _deserialize(inner_type, v) }
216
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
217
+ k_type = Regexp.last_match[:k_type]
218
+ v_type = Regexp.last_match[:v_type]
219
+ {}.tap do |hash|
220
+ value.each do |k, v|
221
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
222
+ end
223
+ end
224
+ else # model
225
+ # models (e.g. Pet) or oneOf
226
+ klass = IonoscloudDbaasMongo.const_get(type)
227
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
228
+ end
229
+ end
230
+
231
+ # Returns the string representation of the object
232
+ # @return [String] String presentation of the object
233
+ def to_s
234
+ to_hash.to_s
235
+ end
236
+
237
+ # to_body is an alias to to_hash (backward compatibility)
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_body
240
+ to_hash
241
+ end
242
+
243
+ # Returns the object in the form of hash
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_hash
246
+ hash = {}
247
+ self.class.attribute_map.each_pair do |attr, param|
248
+ value = self.send(attr)
249
+ if value.nil?
250
+ is_nullable = self.class.openapi_nullable.include?(attr)
251
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
252
+ end
253
+
254
+ hash[param] = _to_hash(value)
255
+ end
256
+ hash
257
+ end
258
+
259
+ # Outputs non-array value in the form of hash
260
+ # For object, use to_hash. Otherwise, just return the value
261
+ # @param [Object] value Any valid value
262
+ # @return [Hash] Returns the value in the form of hash
263
+ def _to_hash(value)
264
+ if value.is_a?(Array)
265
+ value.compact.map { |v| _to_hash(v) }
266
+ elsif value.is_a?(Hash)
267
+ {}.tap do |hash|
268
+ value.each { |k, v| hash[k] = _to_hash(v) }
269
+ end
270
+ elsif value.respond_to? :to_hash
271
+ value.to_hash
272
+ else
273
+ value
274
+ end
275
+ end
276
+
277
+ end
278
+
279
+ end