ionoscloud-dbaas-postgres 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) 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 +65 -0
  6. data/Rakefile +10 -0
  7. data/docs/README.md +163 -0
  8. data/docs/api/BackupsApi.md +232 -0
  9. data/docs/api/ClustersApi.md +540 -0
  10. data/docs/api/LogsApi.md +91 -0
  11. data/docs/api/MetadataApi.md +153 -0
  12. data/docs/api/RestoresApi.md +84 -0
  13. data/docs/models/APIVersion.md +20 -0
  14. data/docs/models/BackupLocation.md +15 -0
  15. data/docs/models/BackupMetadata.md +20 -0
  16. data/docs/models/BackupResponse.md +24 -0
  17. data/docs/models/ClusterBackup.md +26 -0
  18. data/docs/models/ClusterBackupList.md +28 -0
  19. data/docs/models/ClusterBackupListAllOf.md +22 -0
  20. data/docs/models/ClusterList.md +28 -0
  21. data/docs/models/ClusterListAllOf.md +22 -0
  22. data/docs/models/ClusterLogs.md +18 -0
  23. data/docs/models/ClusterLogsInstances.md +20 -0
  24. data/docs/models/ClusterLogsMessages.md +20 -0
  25. data/docs/models/ClusterProperties.md +40 -0
  26. data/docs/models/ClusterResponse.md +24 -0
  27. data/docs/models/Connection.md +22 -0
  28. data/docs/models/CreateClusterProperties.md +42 -0
  29. data/docs/models/CreateClusterRequest.md +20 -0
  30. data/docs/models/CreateRestoreRequest.md +20 -0
  31. data/docs/models/DBUser.md +20 -0
  32. data/docs/models/DayOfTheWeek.md +15 -0
  33. data/docs/models/ErrorMessage.md +20 -0
  34. data/docs/models/ErrorResponse.md +20 -0
  35. data/docs/models/Location.md +15 -0
  36. data/docs/models/MaintenanceWindow.md +20 -0
  37. data/docs/models/Metadata.md +30 -0
  38. data/docs/models/Pagination.md +22 -0
  39. data/docs/models/PaginationLinks.md +22 -0
  40. data/docs/models/PatchClusterProperties.md +32 -0
  41. data/docs/models/PatchClusterRequest.md +20 -0
  42. data/docs/models/PostgresVersionList.md +18 -0
  43. data/docs/models/PostgresVersionListData.md +18 -0
  44. data/docs/models/ResourceType.md +15 -0
  45. data/docs/models/State.md +15 -0
  46. data/docs/models/StorageType.md +15 -0
  47. data/docs/models/SynchronizationMode.md +15 -0
  48. data/docs/summary.md +50 -0
  49. data/git_push.sh +58 -0
  50. data/ionoscloud-dbaas-postgres.gemspec +38 -0
  51. data/lib/ionoscloud-dbaas-postgres/api/backups_api.rb +205 -0
  52. data/lib/ionoscloud-dbaas-postgres/api/clusters_api.rb +464 -0
  53. data/lib/ionoscloud-dbaas-postgres/api/logs_api.rb +102 -0
  54. data/lib/ionoscloud-dbaas-postgres/api/metadata_api.rb +136 -0
  55. data/lib/ionoscloud-dbaas-postgres/api/restores_api.rb +93 -0
  56. data/lib/ionoscloud-dbaas-postgres/api_client.rb +471 -0
  57. data/lib/ionoscloud-dbaas-postgres/api_error.rb +57 -0
  58. data/lib/ionoscloud-dbaas-postgres/configuration.rb +291 -0
  59. data/lib/ionoscloud-dbaas-postgres/models/api_version.rb +227 -0
  60. data/lib/ionoscloud-dbaas-postgres/models/backup_location.rb +36 -0
  61. data/lib/ionoscloud-dbaas-postgres/models/backup_metadata.rb +229 -0
  62. data/lib/ionoscloud-dbaas-postgres/models/backup_response.rb +247 -0
  63. data/lib/ionoscloud-dbaas-postgres/models/cluster_backup.rb +260 -0
  64. data/lib/ionoscloud-dbaas-postgres/models/cluster_backup_list.rb +305 -0
  65. data/lib/ionoscloud-dbaas-postgres/models/cluster_backup_list_all_of.rb +237 -0
  66. data/lib/ionoscloud-dbaas-postgres/models/cluster_list.rb +305 -0
  67. data/lib/ionoscloud-dbaas-postgres/models/cluster_list_all_of.rb +237 -0
  68. data/lib/ionoscloud-dbaas-postgres/models/cluster_logs.rb +219 -0
  69. data/lib/ionoscloud-dbaas-postgres/models/cluster_logs_instances.rb +228 -0
  70. data/lib/ionoscloud-dbaas-postgres/models/cluster_logs_messages.rb +227 -0
  71. data/lib/ionoscloud-dbaas-postgres/models/cluster_properties.rb +417 -0
  72. data/lib/ionoscloud-dbaas-postgres/models/cluster_response.rb +247 -0
  73. data/lib/ionoscloud-dbaas-postgres/models/connection.rb +255 -0
  74. data/lib/ionoscloud-dbaas-postgres/models/create_cluster_properties.rb +501 -0
  75. data/lib/ionoscloud-dbaas-postgres/models/create_cluster_request.rb +228 -0
  76. data/lib/ionoscloud-dbaas-postgres/models/create_restore_request.rb +235 -0
  77. data/lib/ionoscloud-dbaas-postgres/models/day_of_the_week.rb +42 -0
  78. data/lib/ionoscloud-dbaas-postgres/models/db_user.rb +239 -0
  79. data/lib/ionoscloud-dbaas-postgres/models/error_message.rb +229 -0
  80. data/lib/ionoscloud-dbaas-postgres/models/error_response.rb +228 -0
  81. data/lib/ionoscloud-dbaas-postgres/models/location.rb +41 -0
  82. data/lib/ionoscloud-dbaas-postgres/models/maintenance_window.rb +238 -0
  83. data/lib/ionoscloud-dbaas-postgres/models/metadata.rb +275 -0
  84. data/lib/ionoscloud-dbaas-postgres/models/pagination.rb +268 -0
  85. data/lib/ionoscloud-dbaas-postgres/models/pagination_links.rb +240 -0
  86. data/lib/ionoscloud-dbaas-postgres/models/patch_cluster_properties.rb +381 -0
  87. data/lib/ionoscloud-dbaas-postgres/models/patch_cluster_request.rb +228 -0
  88. data/lib/ionoscloud-dbaas-postgres/models/postgres_version_list.rb +219 -0
  89. data/lib/ionoscloud-dbaas-postgres/models/postgres_version_list_data.rb +218 -0
  90. data/lib/ionoscloud-dbaas-postgres/models/resource_type.rb +38 -0
  91. data/lib/ionoscloud-dbaas-postgres/models/state.rb +40 -0
  92. data/lib/ionoscloud-dbaas-postgres/models/storage_type.rb +37 -0
  93. data/lib/ionoscloud-dbaas-postgres/models/synchronization_mode.rb +38 -0
  94. data/lib/ionoscloud-dbaas-postgres/version.rb +15 -0
  95. data/lib/ionoscloud-dbaas-postgres.rb +79 -0
  96. data/lib/test_driver.rb +119 -0
  97. data/sonar-project.properties +12 -0
  98. data/spec/api_client_spec.rb +226 -0
  99. data/spec/configuration_spec.rb +42 -0
  100. data/spec/spec_helper.rb +111 -0
  101. metadata +190 -0
@@ -0,0 +1,41 @@
1
+ =begin
2
+ #IONOS DBaaS REST API
3
+
4
+ #An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.
5
+
6
+ The version of the OpenAPI document: 0.0.1
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 IonoscloudDbaasPostgres
17
+ class Location
18
+ DE_FRA = "de/fra".freeze
19
+ DE_TXL = "de/txl".freeze
20
+ GB_LHR = "gb/lhr".freeze
21
+ ES_VIT = "es/vit".freeze
22
+ US_EWR = "us/ewr".freeze
23
+ US_LAS = "us/las".freeze
24
+
25
+ # Builds the enum from string
26
+ # @param [String] The enum value in the form of the string
27
+ # @return [String] The enum value
28
+ def self.build_from_hash(value)
29
+ new.build_from_hash(value)
30
+ end
31
+
32
+ # Builds the enum from string
33
+ # @param [String] The enum value in the form of the string
34
+ # @return [String] The enum value
35
+ def build_from_hash(value)
36
+ constantValues = Location.constants.select { |c| Location::const_get(c) == value }
37
+ raise "Invalid ENUM value #{value} for class #Location" if constantValues.empty?
38
+ value
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,238 @@
1
+ =begin
2
+ #IONOS DBaaS REST API
3
+
4
+ #An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.
5
+
6
+ The version of the OpenAPI document: 0.0.1
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 IonoscloudDbaasPostgres
17
+ # A weekly 4 hour-long window, during which maintenance might occur
18
+ class MaintenanceWindow
19
+ attr_accessor :time
20
+
21
+ attr_accessor :day_of_the_week
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'time' => :'time',
27
+ :'day_of_the_week' => :'dayOfTheWeek'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'time' => :'String',
40
+ :'day_of_the_week' => :'DayOfTheWeek'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasPostgres::MaintenanceWindow` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasPostgres::MaintenanceWindow`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'time')
66
+ self.time = attributes[:'time']
67
+ end
68
+
69
+ if attributes.key?(:'day_of_the_week')
70
+ self.day_of_the_week = attributes[:'day_of_the_week']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ if @time.nil?
79
+ invalid_properties.push('invalid value for "time", time cannot be nil.')
80
+ end
81
+
82
+ if @day_of_the_week.nil?
83
+ invalid_properties.push('invalid value for "day_of_the_week", day_of_the_week cannot be nil.')
84
+ end
85
+
86
+ invalid_properties
87
+ end
88
+
89
+ # Check to see if the all the properties in the model are valid
90
+ # @return true if the model is valid
91
+ def valid?
92
+ return false if @time.nil?
93
+ return false if @day_of_the_week.nil?
94
+ true
95
+ end
96
+
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
99
+ def ==(o)
100
+ return true if self.equal?(o)
101
+ self.class == o.class &&
102
+ time == o.time &&
103
+ day_of_the_week == o.day_of_the_week
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [time, day_of_the_week].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ new.build_from_hash(attributes)
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ self.class.openapi_types.each_pair do |key, type|
131
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
132
+ self.send("#{key}=", nil)
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
137
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
138
+ end
139
+ elsif !attributes[self.class.attribute_map[key]].nil?
140
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
141
+ end
142
+ end
143
+
144
+ self
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def _deserialize(type, value)
152
+ case type.to_sym
153
+ when :Time
154
+ Time.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :Boolean
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ # models (e.g. Pet) or oneOf
185
+ klass = IonoscloudDbaasPostgres.const_get(type)
186
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
213
+ hash[param] = _to_hash(value)
214
+ end
215
+ hash
216
+ end
217
+
218
+ # Outputs non-array value in the form of hash
219
+ # For object, use to_hash. Otherwise, just return the value
220
+ # @param [Object] value Any valid value
221
+ # @return [Hash] Returns the value in the form of hash
222
+ def _to_hash(value)
223
+ if value.is_a?(Array)
224
+ value.compact.map { |v| _to_hash(v) }
225
+ elsif value.is_a?(Hash)
226
+ {}.tap do |hash|
227
+ value.each { |k, v| hash[k] = _to_hash(v) }
228
+ end
229
+ elsif value.respond_to? :to_hash
230
+ value.to_hash
231
+ else
232
+ value
233
+ end
234
+ end
235
+
236
+ end
237
+
238
+ end
@@ -0,0 +1,275 @@
1
+ =begin
2
+ #IONOS DBaaS REST API
3
+
4
+ #An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.
5
+
6
+ The version of the OpenAPI document: 0.0.1
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 IonoscloudDbaasPostgres
17
+ # Metadata of the resource
18
+ class Metadata
19
+ # The ISO 8601 creation timestamp.
20
+ attr_accessor :created_date
21
+
22
+ attr_accessor :created_by
23
+
24
+ attr_accessor :created_by_user_id
25
+
26
+ # The ISO 8601 modified timestamp.
27
+ attr_accessor :last_modified_date
28
+
29
+ attr_accessor :last_modified_by
30
+
31
+ attr_accessor :last_modified_by_user_id
32
+
33
+ attr_accessor :state
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'created_date' => :'createdDate',
39
+ :'created_by' => :'createdBy',
40
+ :'created_by_user_id' => :'createdByUserId',
41
+ :'last_modified_date' => :'lastModifiedDate',
42
+ :'last_modified_by' => :'lastModifiedBy',
43
+ :'last_modified_by_user_id' => :'lastModifiedByUserId',
44
+ :'state' => :'state'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'created_date' => :'Time',
57
+ :'created_by' => :'String',
58
+ :'created_by_user_id' => :'String',
59
+ :'last_modified_date' => :'Time',
60
+ :'last_modified_by' => :'String',
61
+ :'last_modified_by_user_id' => :'String',
62
+ :'state' => :'State'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ ])
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ if (!attributes.is_a?(Hash))
76
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasPostgres::Metadata` initialize method"
77
+ end
78
+
79
+ # check to see if the attribute exists and convert string to symbol for hash key
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!self.class.attribute_map.key?(k.to_sym))
82
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasPostgres::Metadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
83
+ end
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:'created_date')
88
+ self.created_date = attributes[:'created_date']
89
+ end
90
+
91
+ if attributes.key?(:'created_by')
92
+ self.created_by = attributes[:'created_by']
93
+ end
94
+
95
+ if attributes.key?(:'created_by_user_id')
96
+ self.created_by_user_id = attributes[:'created_by_user_id']
97
+ end
98
+
99
+ if attributes.key?(:'last_modified_date')
100
+ self.last_modified_date = attributes[:'last_modified_date']
101
+ end
102
+
103
+ if attributes.key?(:'last_modified_by')
104
+ self.last_modified_by = attributes[:'last_modified_by']
105
+ end
106
+
107
+ if attributes.key?(:'last_modified_by_user_id')
108
+ self.last_modified_by_user_id = attributes[:'last_modified_by_user_id']
109
+ end
110
+
111
+ if attributes.key?(:'state')
112
+ self.state = attributes[:'state']
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ invalid_properties = Array.new
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ true
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ created_date == o.created_date &&
135
+ created_by == o.created_by &&
136
+ created_by_user_id == o.created_by_user_id &&
137
+ last_modified_date == o.last_modified_date &&
138
+ last_modified_by == o.last_modified_by &&
139
+ last_modified_by_user_id == o.last_modified_by_user_id &&
140
+ state == o.state
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Integer] Hash code
151
+ def hash
152
+ [created_date, created_by, created_by_user_id, last_modified_date, last_modified_by, last_modified_by_user_id, state].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ new.build_from_hash(attributes)
160
+ end
161
+
162
+ # Builds the object from hash
163
+ # @param [Hash] attributes Model attributes in the form of hash
164
+ # @return [Object] Returns the model itself
165
+ def build_from_hash(attributes)
166
+ return nil unless attributes.is_a?(Hash)
167
+ self.class.openapi_types.each_pair do |key, type|
168
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
169
+ self.send("#{key}=", nil)
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
174
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
175
+ end
176
+ elsif !attributes[self.class.attribute_map[key]].nil?
177
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
178
+ end
179
+ end
180
+
181
+ self
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def _deserialize(type, value)
189
+ case type.to_sym
190
+ when :Time
191
+ Time.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ # models (e.g. Pet) or oneOf
222
+ klass = IonoscloudDbaasPostgres.const_get(type)
223
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.openapi_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end
272
+
273
+ end
274
+
275
+ end