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,227 @@
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 ClusterLogsMessages
18
+ attr_accessor :time
19
+
20
+ attr_accessor :message
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'time' => :'time',
26
+ :'message' => :'message'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'time' => :'Time',
39
+ :'message' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasPostgres::ClusterLogsMessages` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasPostgres::ClusterLogsMessages`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'time')
65
+ self.time = attributes[:'time']
66
+ end
67
+
68
+ if attributes.key?(:'message')
69
+ self.message = attributes[:'message']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ time == o.time &&
92
+ message == o.message
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [time, message].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ new.build_from_hash(attributes)
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ self.class.openapi_types.each_pair do |key, type|
120
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
121
+ self.send("#{key}=", nil)
122
+ elsif type =~ /\AArray<(.*)>/i
123
+ # check to ensure the input is an array given that the attribute
124
+ # is documented as an array but the input is not
125
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
126
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
127
+ end
128
+ elsif !attributes[self.class.attribute_map[key]].nil?
129
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
130
+ end
131
+ end
132
+
133
+ self
134
+ end
135
+
136
+ # Deserializes the data based on type
137
+ # @param string type Data type
138
+ # @param string value Value to be deserialized
139
+ # @return [Object] Deserialized data
140
+ def _deserialize(type, value)
141
+ case type.to_sym
142
+ when :Time
143
+ Time.parse(value)
144
+ when :Date
145
+ Date.parse(value)
146
+ when :String
147
+ value.to_s
148
+ when :Integer
149
+ value.to_i
150
+ when :Float
151
+ value.to_f
152
+ when :Boolean
153
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
+ true
155
+ else
156
+ false
157
+ end
158
+ when :Object
159
+ # generic object (usually a Hash), return directly
160
+ value
161
+ when /\AArray<(?<inner_type>.+)>\z/
162
+ inner_type = Regexp.last_match[:inner_type]
163
+ value.map { |v| _deserialize(inner_type, v) }
164
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165
+ k_type = Regexp.last_match[:k_type]
166
+ v_type = Regexp.last_match[:v_type]
167
+ {}.tap do |hash|
168
+ value.each do |k, v|
169
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170
+ end
171
+ end
172
+ else # model
173
+ # models (e.g. Pet) or oneOf
174
+ klass = IonoscloudDbaasPostgres.const_get(type)
175
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
176
+ end
177
+ end
178
+
179
+ # Returns the string representation of the object
180
+ # @return [String] String presentation of the object
181
+ def to_s
182
+ to_hash.to_s
183
+ end
184
+
185
+ # to_body is an alias to to_hash (backward compatibility)
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_body
188
+ to_hash
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = self.send(attr)
197
+ if value.nil?
198
+ is_nullable = self.class.openapi_nullable.include?(attr)
199
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
200
+ end
201
+
202
+ hash[param] = _to_hash(value)
203
+ end
204
+ hash
205
+ end
206
+
207
+ # Outputs non-array value in the form of hash
208
+ # For object, use to_hash. Otherwise, just return the value
209
+ # @param [Object] value Any valid value
210
+ # @return [Hash] Returns the value in the form of hash
211
+ def _to_hash(value)
212
+ if value.is_a?(Array)
213
+ value.compact.map { |v| _to_hash(v) }
214
+ elsif value.is_a?(Hash)
215
+ {}.tap do |hash|
216
+ value.each { |k, v| hash[k] = _to_hash(v) }
217
+ end
218
+ elsif value.respond_to? :to_hash
219
+ value.to_hash
220
+ else
221
+ value
222
+ end
223
+ end
224
+
225
+ end
226
+
227
+ end
@@ -0,0 +1,417 @@
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
+ # Properties of a database cluster
18
+ class ClusterProperties
19
+ # The friendly name of your cluster.
20
+ attr_accessor :display_name
21
+
22
+ # The PostgreSQL version of your cluster.
23
+ attr_accessor :postgres_version
24
+
25
+ attr_accessor :location
26
+
27
+ attr_accessor :backup_location
28
+
29
+ # The total number of instances in the cluster (one master and n-1 standbys).
30
+ attr_accessor :instances
31
+
32
+ # The amount of memory per instance in megabytes. Has to be a multiple of 1024.
33
+ attr_accessor :ram
34
+
35
+ # The number of CPU cores per instance.
36
+ attr_accessor :cores
37
+
38
+ # The amount of storage per instance in megabytes.
39
+ attr_accessor :storage_size
40
+
41
+ attr_accessor :storage_type
42
+
43
+ attr_accessor :connections
44
+
45
+ attr_accessor :maintenance_window
46
+
47
+ attr_accessor :synchronization_mode
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'display_name' => :'displayName',
53
+ :'postgres_version' => :'postgresVersion',
54
+ :'location' => :'location',
55
+ :'backup_location' => :'backupLocation',
56
+ :'instances' => :'instances',
57
+ :'ram' => :'ram',
58
+ :'cores' => :'cores',
59
+ :'storage_size' => :'storageSize',
60
+ :'storage_type' => :'storageType',
61
+ :'connections' => :'connections',
62
+ :'maintenance_window' => :'maintenanceWindow',
63
+ :'synchronization_mode' => :'synchronizationMode'
64
+ }
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'display_name' => :'String',
76
+ :'postgres_version' => :'String',
77
+ :'location' => :'Location',
78
+ :'backup_location' => :'BackupLocation',
79
+ :'instances' => :'Integer',
80
+ :'ram' => :'Integer',
81
+ :'cores' => :'Integer',
82
+ :'storage_size' => :'Integer',
83
+ :'storage_type' => :'StorageType',
84
+ :'connections' => :'Array<Connection>',
85
+ :'maintenance_window' => :'MaintenanceWindow',
86
+ :'synchronization_mode' => :'SynchronizationMode'
87
+ }
88
+ end
89
+
90
+ # List of attributes with nullable: true
91
+ def self.openapi_nullable
92
+ Set.new([
93
+ ])
94
+ end
95
+
96
+ # Initializes the object
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ def initialize(attributes = {})
99
+ if (!attributes.is_a?(Hash))
100
+ fail ArgumentError, "The input argument (attributes) must be a hash in `IonoscloudDbaasPostgres::ClusterProperties` initialize method"
101
+ end
102
+
103
+ # check to see if the attribute exists and convert string to symbol for hash key
104
+ attributes = attributes.each_with_object({}) { |(k, v), h|
105
+ if (!self.class.attribute_map.key?(k.to_sym))
106
+ fail ArgumentError, "`#{k}` is not a valid attribute in `IonoscloudDbaasPostgres::ClusterProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
107
+ end
108
+ h[k.to_sym] = v
109
+ }
110
+
111
+ if attributes.key?(:'display_name')
112
+ self.display_name = attributes[:'display_name']
113
+ end
114
+
115
+ if attributes.key?(:'postgres_version')
116
+ self.postgres_version = attributes[:'postgres_version']
117
+ end
118
+
119
+ if attributes.key?(:'location')
120
+ self.location = attributes[:'location']
121
+ end
122
+
123
+ if attributes.key?(:'backup_location')
124
+ self.backup_location = attributes[:'backup_location']
125
+ end
126
+
127
+ if attributes.key?(:'instances')
128
+ self.instances = attributes[:'instances']
129
+ end
130
+
131
+ if attributes.key?(:'ram')
132
+ self.ram = attributes[:'ram']
133
+ end
134
+
135
+ if attributes.key?(:'cores')
136
+ self.cores = attributes[:'cores']
137
+ end
138
+
139
+ if attributes.key?(:'storage_size')
140
+ self.storage_size = attributes[:'storage_size']
141
+ end
142
+
143
+ if attributes.key?(:'storage_type')
144
+ self.storage_type = attributes[:'storage_type']
145
+ end
146
+
147
+ if attributes.key?(:'connections') && (value = attributes[:'connections']).is_a?(Array)
148
+ self.connections = value
149
+ end
150
+
151
+ if attributes.key?(:'maintenance_window')
152
+ self.maintenance_window = attributes[:'maintenance_window']
153
+ end
154
+
155
+ if attributes.key?(:'synchronization_mode')
156
+ self.synchronization_mode = attributes[:'synchronization_mode']
157
+ end
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def list_invalid_properties
163
+ invalid_properties = Array.new
164
+ if !@instances.nil? && @instances > 5
165
+ invalid_properties.push('invalid value for "instances", must be smaller than or equal to 5.')
166
+ end
167
+
168
+ if !@instances.nil? && @instances < 1
169
+ invalid_properties.push('invalid value for "instances", must be greater than or equal to 1.')
170
+ end
171
+
172
+ if !@ram.nil? && @ram < 2048
173
+ invalid_properties.push('invalid value for "ram", must be greater than or equal to 2048.')
174
+ end
175
+
176
+ if !@cores.nil? && @cores < 1
177
+ invalid_properties.push('invalid value for "cores", must be greater than or equal to 1.')
178
+ end
179
+
180
+ if !@storage_size.nil? && @storage_size < 2048
181
+ invalid_properties.push('invalid value for "storage_size", must be greater than or equal to 2048.')
182
+ end
183
+
184
+ if !@connections.nil? && @connections.length > 1
185
+ invalid_properties.push('invalid value for "connections", number of items must be less than or equal to 1.')
186
+ end
187
+
188
+ if !@connections.nil? && @connections.length < 1
189
+ invalid_properties.push('invalid value for "connections", number of items must be greater than or equal to 1.')
190
+ end
191
+
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ return false if !@instances.nil? && @instances > 5
199
+ return false if !@instances.nil? && @instances < 1
200
+ return false if !@ram.nil? && @ram < 2048
201
+ return false if !@cores.nil? && @cores < 1
202
+ return false if !@storage_size.nil? && @storage_size < 2048
203
+ return false if !@connections.nil? && @connections.length > 1
204
+ return false if !@connections.nil? && @connections.length < 1
205
+ true
206
+ end
207
+
208
+ # Custom attribute writer method with validation
209
+ # @param [Object] instances Value to be assigned
210
+ def instances=(instances)
211
+ if !instances.nil? && instances > 5
212
+ fail ArgumentError, 'invalid value for "instances", must be smaller than or equal to 5.'
213
+ end
214
+
215
+ if !instances.nil? && instances < 1
216
+ fail ArgumentError, 'invalid value for "instances", must be greater than or equal to 1.'
217
+ end
218
+
219
+ @instances = instances
220
+ end
221
+
222
+ # Custom attribute writer method with validation
223
+ # @param [Object] ram Value to be assigned
224
+ def ram=(ram)
225
+ if !ram.nil? && ram < 2048
226
+ fail ArgumentError, 'invalid value for "ram", must be greater than or equal to 2048.'
227
+ end
228
+
229
+ @ram = ram
230
+ end
231
+
232
+ # Custom attribute writer method with validation
233
+ # @param [Object] cores Value to be assigned
234
+ def cores=(cores)
235
+ if !cores.nil? && cores < 1
236
+ fail ArgumentError, 'invalid value for "cores", must be greater than or equal to 1.'
237
+ end
238
+
239
+ @cores = cores
240
+ end
241
+
242
+ # Custom attribute writer method with validation
243
+ # @param [Object] storage_size Value to be assigned
244
+ def storage_size=(storage_size)
245
+ if !storage_size.nil? && storage_size < 2048
246
+ fail ArgumentError, 'invalid value for "storage_size", must be greater than or equal to 2048.'
247
+ end
248
+
249
+ @storage_size = storage_size
250
+ end
251
+
252
+ # Custom attribute writer method with validation
253
+ # @param [Object] connections Value to be assigned
254
+ def connections=(connections)
255
+ if !connections.nil? && connections.length > 1
256
+ fail ArgumentError, 'invalid value for "connections", number of items must be less than or equal to 1.'
257
+ end
258
+
259
+ if !connections.nil? && connections.length < 1
260
+ fail ArgumentError, 'invalid value for "connections", number of items must be greater than or equal to 1.'
261
+ end
262
+
263
+ @connections = connections
264
+ end
265
+
266
+ # Checks equality by comparing each attribute.
267
+ # @param [Object] Object to be compared
268
+ def ==(o)
269
+ return true if self.equal?(o)
270
+ self.class == o.class &&
271
+ display_name == o.display_name &&
272
+ postgres_version == o.postgres_version &&
273
+ location == o.location &&
274
+ backup_location == o.backup_location &&
275
+ instances == o.instances &&
276
+ ram == o.ram &&
277
+ cores == o.cores &&
278
+ storage_size == o.storage_size &&
279
+ storage_type == o.storage_type &&
280
+ connections == o.connections &&
281
+ maintenance_window == o.maintenance_window &&
282
+ synchronization_mode == o.synchronization_mode
283
+ end
284
+
285
+ # @see the `==` method
286
+ # @param [Object] Object to be compared
287
+ def eql?(o)
288
+ self == o
289
+ end
290
+
291
+ # Calculates hash code according to all attributes.
292
+ # @return [Integer] Hash code
293
+ def hash
294
+ [display_name, postgres_version, location, backup_location, instances, ram, cores, storage_size, storage_type, connections, maintenance_window, synchronization_mode].hash
295
+ end
296
+
297
+ # Builds the object from hash
298
+ # @param [Hash] attributes Model attributes in the form of hash
299
+ # @return [Object] Returns the model itself
300
+ def self.build_from_hash(attributes)
301
+ new.build_from_hash(attributes)
302
+ end
303
+
304
+ # Builds the object from hash
305
+ # @param [Hash] attributes Model attributes in the form of hash
306
+ # @return [Object] Returns the model itself
307
+ def build_from_hash(attributes)
308
+ return nil unless attributes.is_a?(Hash)
309
+ self.class.openapi_types.each_pair do |key, type|
310
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
311
+ self.send("#{key}=", nil)
312
+ elsif type =~ /\AArray<(.*)>/i
313
+ # check to ensure the input is an array given that the attribute
314
+ # is documented as an array but the input is not
315
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
316
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
317
+ end
318
+ elsif !attributes[self.class.attribute_map[key]].nil?
319
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
320
+ end
321
+ end
322
+
323
+ self
324
+ end
325
+
326
+ # Deserializes the data based on type
327
+ # @param string type Data type
328
+ # @param string value Value to be deserialized
329
+ # @return [Object] Deserialized data
330
+ def _deserialize(type, value)
331
+ case type.to_sym
332
+ when :Time
333
+ Time.parse(value)
334
+ when :Date
335
+ Date.parse(value)
336
+ when :String
337
+ value.to_s
338
+ when :Integer
339
+ value.to_i
340
+ when :Float
341
+ value.to_f
342
+ when :Boolean
343
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
344
+ true
345
+ else
346
+ false
347
+ end
348
+ when :Object
349
+ # generic object (usually a Hash), return directly
350
+ value
351
+ when /\AArray<(?<inner_type>.+)>\z/
352
+ inner_type = Regexp.last_match[:inner_type]
353
+ value.map { |v| _deserialize(inner_type, v) }
354
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
355
+ k_type = Regexp.last_match[:k_type]
356
+ v_type = Regexp.last_match[:v_type]
357
+ {}.tap do |hash|
358
+ value.each do |k, v|
359
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
360
+ end
361
+ end
362
+ else # model
363
+ # models (e.g. Pet) or oneOf
364
+ klass = IonoscloudDbaasPostgres.const_get(type)
365
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
366
+ end
367
+ end
368
+
369
+ # Returns the string representation of the object
370
+ # @return [String] String presentation of the object
371
+ def to_s
372
+ to_hash.to_s
373
+ end
374
+
375
+ # to_body is an alias to to_hash (backward compatibility)
376
+ # @return [Hash] Returns the object in the form of hash
377
+ def to_body
378
+ to_hash
379
+ end
380
+
381
+ # Returns the object in the form of hash
382
+ # @return [Hash] Returns the object in the form of hash
383
+ def to_hash
384
+ hash = {}
385
+ self.class.attribute_map.each_pair do |attr, param|
386
+ value = self.send(attr)
387
+ if value.nil?
388
+ is_nullable = self.class.openapi_nullable.include?(attr)
389
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
390
+ end
391
+
392
+ hash[param] = _to_hash(value)
393
+ end
394
+ hash
395
+ end
396
+
397
+ # Outputs non-array value in the form of hash
398
+ # For object, use to_hash. Otherwise, just return the value
399
+ # @param [Object] value Any valid value
400
+ # @return [Hash] Returns the value in the form of hash
401
+ def _to_hash(value)
402
+ if value.is_a?(Array)
403
+ value.compact.map { |v| _to_hash(v) }
404
+ elsif value.is_a?(Hash)
405
+ {}.tap do |hash|
406
+ value.each { |k, v| hash[k] = _to_hash(v) }
407
+ end
408
+ elsif value.respond_to? :to_hash
409
+ value.to_hash
410
+ else
411
+ value
412
+ end
413
+ end
414
+
415
+ end
416
+
417
+ end