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,276 @@
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
+ module IonoscloudDbaasMongo
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines Tokens used with Token authentications.
37
+ #
38
+ # @return [String]
39
+ attr_accessor :token
40
+
41
+ # Defines Token prefixes used with Token authentications.
42
+ # Default to 'Bearer'.
43
+ #
44
+ # @return [String]
45
+ attr_accessor :token_prefix
46
+
47
+ # Defines the username used with HTTP basic authentication.
48
+ #
49
+ # @return [String]
50
+ attr_accessor :username
51
+
52
+ # Defines the password used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :password
56
+
57
+ # Defines the access token (Bearer) used with OAuth2.
58
+ attr_accessor :access_token
59
+
60
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
61
+ # details will be logged with `logger.debug` (see the `logger` attribute).
62
+ # Default to false.
63
+ #
64
+ # @return [true, false]
65
+ attr_accessor :debugging
66
+
67
+ # Defines the logger used for debugging.
68
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
69
+ #
70
+ # @return [#debug]
71
+ attr_accessor :logger
72
+
73
+ # Defines the temporary folder to store downloaded files
74
+ # (for API endpoints that have file response).
75
+ # Default to use `Tempfile`.
76
+ #
77
+ # @return [String]
78
+ attr_accessor :temp_folder_path
79
+
80
+ # The time limit for HTTP request in seconds.
81
+ # Default to 0 (never times out).
82
+ attr_accessor :timeout
83
+
84
+ # Set this to false to skip client side validation in the operation.
85
+ # Default to true.
86
+ # @return [true, false]
87
+ attr_accessor :client_side_validation
88
+
89
+ ### TLS/SSL setting
90
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
91
+ # Default to true.
92
+ #
93
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
94
+ #
95
+ # @return [true, false]
96
+ attr_accessor :verify_ssl
97
+
98
+ ### TLS/SSL setting
99
+ # Set this to false to skip verifying SSL host name
100
+ # Default to true.
101
+ #
102
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
103
+ #
104
+ # @return [true, false]
105
+ attr_accessor :verify_ssl_host
106
+
107
+ ### TLS/SSL setting
108
+ # Set this to customize the certificate file to verify the peer.
109
+ #
110
+ # @return [String] the path to the certificate file
111
+ #
112
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
113
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
114
+ attr_accessor :ssl_ca_cert
115
+
116
+ ### TLS/SSL setting
117
+ # Client certificate file (for client certificate)
118
+ attr_accessor :cert_file
119
+
120
+ ### TLS/SSL setting
121
+ # Client private key file (for client certificate)
122
+ attr_accessor :key_file
123
+
124
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
125
+ # Default to nil.
126
+ #
127
+ # @see The params_encoding option of Ethon. Related source code:
128
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
129
+ attr_accessor :params_encoding
130
+
131
+ attr_accessor :inject_format
132
+
133
+ attr_accessor :force_ending_format
134
+
135
+ attr_accessor :max_retries
136
+
137
+ attr_accessor :wait_time
138
+
139
+ attr_accessor :max_wait_time
140
+
141
+ def initialize
142
+ @scheme = 'https'
143
+ @host = 'api.ionos.com'
144
+ @base_path = '/databases/mongodb'
145
+ @server_index = 0
146
+ @server_operation_index = {}
147
+ @server_variables = {}
148
+ @server_operation_variables = {}
149
+ @token = nil
150
+ @token_prefix = 'Bearer'
151
+ @timeout = 0
152
+ @client_side_validation = true
153
+ @verify_ssl = true
154
+ @verify_ssl_host = true
155
+ @params_encoding = nil
156
+ @cert_file = nil
157
+ @key_file = nil
158
+ @debugging = false
159
+ @inject_format = false
160
+ @force_ending_format = false
161
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
162
+ @max_retries = 3
163
+ @wait_time = 0.1
164
+ @max_wait_time = 2
165
+
166
+ yield(self) if block_given?
167
+ end
168
+
169
+ # The default Configuration object.
170
+ def self.default
171
+ @@default ||= Configuration.new
172
+ end
173
+
174
+ def configure
175
+ yield(self) if block_given?
176
+ end
177
+
178
+ def scheme=(scheme)
179
+ # remove :// from scheme
180
+ @scheme = scheme.sub(/:\/\//, '')
181
+ end
182
+
183
+ def host=(host)
184
+ # remove http(s):// and anything after a slash
185
+ @host = host.sub(/https?:\/\//, '').split('/').first
186
+ end
187
+
188
+ def base_path=(base_path)
189
+ # Add leading and trailing slashes to base_path
190
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
191
+ @base_path = '' if @base_path == '/'
192
+ end
193
+
194
+ # Returns base URL for specified operation based on server settings
195
+ def base_url(operation = nil)
196
+ index = server_operation_index.fetch(operation, server_index)
197
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
198
+
199
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
200
+ end
201
+
202
+ # Gets Basic Auth token string
203
+ def basic_auth_token
204
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
205
+ end
206
+
207
+ # Returns Auth Settings hash for api client.
208
+ def auth_settings
209
+ {
210
+ 'basicAuth' =>
211
+ {
212
+ type: 'basic',
213
+ in: 'header',
214
+ key: 'Authorization',
215
+ value: basic_auth_token
216
+ },
217
+ 'tokenAuth' =>
218
+ {
219
+ type: 'token',
220
+ in: 'header',
221
+ key: 'Authorization',
222
+ value: token.nil? ? nil : "#{token_prefix} #{token}"
223
+ },
224
+ }
225
+ end
226
+
227
+ # Returns an array of Server setting
228
+ def server_settings
229
+ [
230
+ {
231
+ url: "https://api.ionos.com/databases/mongodb",
232
+ description: "Production",
233
+ }
234
+ ]
235
+ end
236
+
237
+ def operation_server_settings
238
+ {
239
+ }
240
+ end
241
+
242
+ # Returns URL based on server settings
243
+ #
244
+ # @param index array index of the server settings
245
+ # @param variables hash of variable and the corresponding value
246
+ def server_url(index, variables = {}, servers = nil)
247
+ servers = server_settings if servers == nil
248
+
249
+ # check array index out of bound
250
+ if (index < 0 || index >= servers.size)
251
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
252
+ end
253
+
254
+ server = servers[index]
255
+ url = server[:url]
256
+
257
+ return url unless server.key? :variables
258
+
259
+ # go through variable and assign a value
260
+ server[:variables].each do |name, variable|
261
+ if variables.key?(name)
262
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
263
+ url.gsub! "{" + name.to_s + "}", variables[name]
264
+ else
265
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
266
+ end
267
+ else
268
+ # use default value
269
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
270
+ end
271
+ end
272
+
273
+ url
274
+ end
275
+ end
276
+ end
@@ -0,0 +1,243 @@
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
+ class APIVersion
18
+
19
+ attr_accessor :name
20
+
21
+
22
+ attr_accessor :swagger_url
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+
28
+ :'name' => :'name',
29
+
30
+ :'swagger_url' => :'swaggerUrl'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+
43
+ :'name' => :'String',
44
+
45
+ :'swagger_url' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+
53
+
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 `IonoscloudDbaasMongo::APIVersion` 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 `IonoscloudDbaasMongo::APIVersion`. 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
+
73
+ if attributes.key?(:'name')
74
+ self.name = attributes[:'name']
75
+ end
76
+
77
+
78
+ if attributes.key?(:'swagger_url')
79
+ self.swagger_url = attributes[:'swagger_url']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+
88
+
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
+
96
+
97
+ true
98
+ end
99
+
100
+
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ name == o.name &&
108
+ swagger_url == o.swagger_url
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [name, swagger_url].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
137
+ self.send("#{key}=", nil)
138
+ elsif type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ # models (e.g. Pet) or oneOf
190
+ klass = IonoscloudDbaasMongo.const_get(type)
191
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
192
+ end
193
+ end
194
+
195
+ # Returns the string representation of the object
196
+ # @return [String] String presentation of the object
197
+ def to_s
198
+ to_hash.to_s
199
+ end
200
+
201
+ # to_body is an alias to to_hash (backward compatibility)
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_body
204
+ to_hash
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = self.send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to? :to_hash
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+
241
+ end
242
+
243
+ end