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,471 @@
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 'json'
15
+ require 'logger'
16
+ require 'tempfile'
17
+ require 'time'
18
+ require 'typhoeus'
19
+
20
+
21
+ TooManyRequests = 429
22
+ BadGateway = 502
23
+ ServiceUnavailable = 503
24
+ GatewayTimeout = 504
25
+
26
+
27
+ module IonoscloudDbaasMongo
28
+ class ApiClient
29
+ # The Configuration object holding settings to be used in the API client.
30
+ attr_accessor :config
31
+
32
+ # Defines the headers to be used in HTTP requests of all API calls by default.
33
+ #
34
+ # @return [Hash]
35
+ attr_accessor :default_headers
36
+
37
+ # Initializes the ApiClient
38
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
39
+ def initialize(config = Configuration.default)
40
+ @config = config
41
+ @user_agent = "sdk-ruby-dbaas-mongo/v1.0.0"
42
+ @default_headers = {
43
+ 'Content-Type' => 'application/json',
44
+ 'User-Agent' => @user_agent
45
+ }
46
+ end
47
+
48
+ def self.default
49
+ @@default ||= ApiClient.new
50
+ end
51
+
52
+ # Call an API with given options.
53
+ #
54
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
55
+ # the data deserialized from response body (could be nil), response status code and response headers.
56
+ def call_api(http_method, path, opts = {})
57
+
58
+ retry_count = 0
59
+ request = build_request(http_method, path, opts)
60
+
61
+ while true
62
+ retry_count += 1
63
+ response = request.run
64
+
65
+ if @config.debugging
66
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
67
+ end
68
+
69
+ case response.code
70
+ when BadGateway, ServiceUnavailable, GatewayTimeout
71
+ backoff_time = @config.wait_time
72
+ when TooManyRequests
73
+ backoff_time = @config.wait_time
74
+ begin
75
+ backoff_time = Integer(response.headers['Retry-After'])
76
+ rescue *[ArgumentError, TypeError]
77
+ end
78
+ else
79
+ break
80
+ end
81
+
82
+ if retry_count >= @config.max_retries
83
+ if @config.debugging
84
+ @config.logger.debug "number of maximum retries exceeded #{@config.max_retries}"
85
+ end
86
+ break
87
+ end
88
+
89
+ if backoff_time > @config.max_wait_time
90
+ backoff_time = @config.max_wait_time
91
+ end
92
+
93
+ if @config.debugging
94
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
95
+ end
96
+ sleep(backoff_time)
97
+ end
98
+
99
+ unless response.success?
100
+ if response.timed_out?
101
+ fail ApiError.new('Connection timed out')
102
+ elsif response.code == 0
103
+ # Errors from libcurl will be made visible here
104
+ fail ApiError.new(:code => 0,
105
+ :message => response.return_message)
106
+ else
107
+ fail ApiError.new(:code => response.code,
108
+ :response_headers => response.headers,
109
+ :response_body => response.body),
110
+ response.status_message
111
+ end
112
+ end
113
+
114
+ if opts[:return_type]
115
+ data = deserialize(response, opts[:return_type])
116
+ else
117
+ data = nil
118
+ end
119
+ return data, response.code, response.headers
120
+ end
121
+
122
+ # Builds the HTTP request
123
+ #
124
+ # @param [String] http_method HTTP method/verb (e.g. POST)
125
+ # @param [String] path URL path (e.g. /account/new)
126
+ # @option opts [Hash] :header_params Header parameters
127
+ # @option opts [Hash] :query_params Query parameters
128
+ # @option opts [Hash] :form_params Query parameters
129
+ # @option opts [Object] :body HTTP body (JSON/XML)
130
+ # @return [Typhoeus::Request] A Typhoeus Request
131
+ def build_request(http_method, path, opts = {})
132
+ url = build_request_url(path, opts)
133
+ http_method = http_method.to_sym.downcase
134
+
135
+ header_params = @default_headers.merge(opts[:header_params] || {})
136
+ query_params = opts[:query_params] || {}
137
+ form_params = opts[:form_params] || {}
138
+
139
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
140
+
141
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
142
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
143
+
144
+ req_opts = {
145
+ :method => http_method,
146
+ :headers => header_params,
147
+ :params => query_params,
148
+ :params_encoding => @config.params_encoding,
149
+ :timeout => @config.timeout,
150
+ :ssl_verifypeer => @config.verify_ssl,
151
+ :ssl_verifyhost => _verify_ssl_host,
152
+ :sslcert => @config.cert_file,
153
+ :sslkey => @config.key_file,
154
+ :verbose => @config.debugging
155
+ }
156
+
157
+ # set custom cert, if provided
158
+ req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
159
+
160
+ if [:post, :patch, :put, :delete].include?(http_method)
161
+ req_body = build_request_body(header_params, form_params, opts[:body])
162
+ req_opts.update :body => req_body
163
+ if @config.debugging
164
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
165
+ end
166
+ end
167
+
168
+ request = Typhoeus::Request.new(url, req_opts)
169
+ download_file(request) if opts[:return_type] == 'File'
170
+ request
171
+ end
172
+
173
+ # Builds the HTTP request body
174
+ #
175
+ # @param [Hash] header_params Header parameters
176
+ # @param [Hash] form_params Query parameters
177
+ # @param [Object] body HTTP body (JSON/XML)
178
+ # @return [String] HTTP body data in the form of string
179
+ def build_request_body(header_params, form_params, body)
180
+ # http form
181
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
182
+ header_params['Content-Type'] == 'multipart/form-data'
183
+ data = {}
184
+ form_params.each do |key, value|
185
+ case value
186
+ when ::File, ::Array, nil
187
+ # let typhoeus handle File, Array and nil parameters
188
+ data[key] = value
189
+ else
190
+ data[key] = value.to_s
191
+ end
192
+ end
193
+ elsif body
194
+ data = body.is_a?(String) ? body : body.to_json
195
+ else
196
+ data = nil
197
+ end
198
+ data
199
+ end
200
+
201
+ # Save response body into a file in (the defined) temporary folder, using the filename
202
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
203
+ # The response body is written to the file in chunks in order to handle files which
204
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
205
+ # process can use.
206
+ #
207
+ # @see Configuration#temp_folder_path
208
+ def download_file(request)
209
+ tempfile = nil
210
+ encoding = nil
211
+ request.on_headers do |response|
212
+ content_disposition = response.headers['Content-Disposition']
213
+ if content_disposition && content_disposition =~ /filename=/i
214
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
215
+ prefix = sanitize_filename(filename)
216
+ else
217
+ prefix = 'download-'
218
+ end
219
+ prefix = prefix + '-' unless prefix.end_with?('-')
220
+ encoding = response.body.encoding
221
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
222
+ @tempfile = tempfile
223
+ end
224
+ request.on_body do |chunk|
225
+ chunk.force_encoding(encoding)
226
+ tempfile.write(chunk)
227
+ end
228
+ request.on_complete do |response|
229
+ if tempfile
230
+ tempfile.close
231
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
232
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
233
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
234
+ "explicitly with `tempfile.delete`"
235
+ end
236
+ end
237
+ end
238
+
239
+ # Check if the given MIME is a JSON MIME.
240
+ # JSON MIME examples:
241
+ # application/json
242
+ # application/json; charset=UTF8
243
+ # APPLICATION/JSON
244
+ # */*
245
+ # @param [String] mime MIME
246
+ # @return [Boolean] True if the MIME is application/json
247
+ def json_mime?(mime)
248
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
249
+ end
250
+
251
+ # Deserialize the response to the given return type.
252
+ #
253
+ # @param [Response] response HTTP response
254
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
255
+ def deserialize(response, return_type)
256
+ body = response.body
257
+
258
+ # handle file downloading - return the File instance processed in request callbacks
259
+ # note that response body is empty when the file is written in chunks in request on_body callback
260
+ return @tempfile if return_type == 'File'
261
+
262
+ return nil if body.nil? || body.empty?
263
+
264
+ # return response body directly for String return type
265
+ return body if return_type == 'String'
266
+
267
+ # ensuring a default content type
268
+ content_type = response.headers['Content-Type'] || 'application/json'
269
+
270
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
271
+
272
+ begin
273
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
274
+ rescue JSON::ParserError => e
275
+ if %w(String Date Time).include?(return_type)
276
+ data = body
277
+ else
278
+ raise e
279
+ end
280
+ end
281
+
282
+ convert_to_type data, return_type
283
+ end
284
+
285
+ # Convert data to the given return type.
286
+ # @param [Object] data Data to be converted
287
+ # @param [String] return_type Return type
288
+ # @return [Mixed] Data in a particular type
289
+ def convert_to_type(data, return_type)
290
+ return nil if data.nil?
291
+ case return_type
292
+ when 'String'
293
+ data.to_s
294
+ when 'Integer'
295
+ data.to_i
296
+ when 'Float'
297
+ data.to_f
298
+ when 'Boolean'
299
+ data == true
300
+ when 'Time'
301
+ # parse date time (expecting ISO 8601 format)
302
+ Time.parse data
303
+ when 'Date'
304
+ # parse date time (expecting ISO 8601 format)
305
+ Date.parse data
306
+ when 'Object'
307
+ # generic object (usually a Hash), return directly
308
+ data
309
+ when /\AArray<(.+)>\z/
310
+ # e.g. Array<Pet>
311
+ sub_type = $1
312
+ data.map { |item| convert_to_type(item, sub_type) }
313
+ when /\AHash\<String, (.+)\>\z/
314
+ # e.g. Hash<String, Integer>
315
+ sub_type = $1
316
+ {}.tap do |hash|
317
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
318
+ end
319
+ else
320
+ # models (e.g. Pet) or oneOf
321
+ klass = IonoscloudDbaasMongo.const_get(return_type)
322
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
323
+ end
324
+ end
325
+
326
+ # Sanitize filename by removing path.
327
+ # e.g. ../../sun.gif becomes sun.gif
328
+ #
329
+ # @param [String] filename the filename to be sanitized
330
+ # @return [String] the sanitized filename
331
+ def sanitize_filename(filename)
332
+ filename.gsub(/.*[\/\\]/, '')
333
+ end
334
+
335
+ def build_request_url(path, opts = {})
336
+ # Add leading and trailing slashes to path
337
+ path = "/#{path}".gsub(/\/+/, '/')
338
+ @config.base_url(opts[:operation]) + path
339
+ end
340
+
341
+ # Update hearder and query params based on authentication settings.
342
+ #
343
+ # @param [Hash] header_params Header parameters
344
+ # @param [Hash] query_params Query parameters
345
+ # @param [String] auth_names Authentication scheme name
346
+ def update_params_for_auth!(header_params, query_params, auth_names)
347
+ Array(auth_names).each do |auth_name|
348
+ auth_setting = @config.auth_settings[auth_name]
349
+ next unless auth_setting[:value]
350
+ case auth_setting[:in]
351
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
352
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
353
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
354
+ end
355
+ end
356
+ end
357
+
358
+ # Sets user agent in HTTP header
359
+ #
360
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
361
+ def user_agent=(user_agent)
362
+ @user_agent = user_agent
363
+ @default_headers['User-Agent'] = @user_agent
364
+ end
365
+
366
+ # Return Accept header based on an array of accepts provided.
367
+ # @param [Array] accepts array for Accept
368
+ # @return [String] the Accept header (e.g. application/json)
369
+ def select_header_accept(accepts)
370
+ return nil if accepts.nil? || accepts.empty?
371
+ # use JSON when present, otherwise use all of the provided
372
+ json_accept = accepts.find { |s| json_mime?(s) }
373
+ json_accept || accepts.join(',')
374
+ end
375
+
376
+ # Return Content-Type header based on an array of content types provided.
377
+ # @param [Array] content_types array for Content-Type
378
+ # @return [String] the Content-Type header (e.g. application/json)
379
+ def select_header_content_type(content_types)
380
+ # use application/json by default
381
+ return 'application/json' if content_types.nil? || content_types.empty?
382
+ # use JSON when present, otherwise use the first one
383
+ json_content_type = content_types.find { |s| json_mime?(s) }
384
+ json_content_type || content_types.first
385
+ end
386
+
387
+ # Convert object (array, hash, object, etc) to JSON string.
388
+ # @param [Object] model object to be converted into JSON string
389
+ # @return [String] JSON string representation of the object
390
+ def object_to_http_body(model)
391
+ return model if model.nil? || model.is_a?(String)
392
+ local_body = nil
393
+ if model.is_a?(Array)
394
+ local_body = model.map { |m| object_to_hash(m) }
395
+ else
396
+ local_body = object_to_hash(model)
397
+ end
398
+ local_body.to_json
399
+ end
400
+
401
+ # Convert object(non-array) to hash.
402
+ # @param [Object] obj object to be converted into JSON string
403
+ # @return [String] JSON string representation of the object
404
+ def object_to_hash(obj)
405
+ if obj.respond_to?(:to_hash)
406
+ obj.to_hash
407
+ else
408
+ obj
409
+ end
410
+ end
411
+
412
+ # Build parameter value according to the given collection format.
413
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
414
+ def build_collection_param(param, collection_format)
415
+ case collection_format
416
+ when :csv
417
+ param.join(',')
418
+ when :ssv
419
+ param.join(' ')
420
+ when :tsv
421
+ param.join("\t")
422
+ when :pipes
423
+ param.join('|')
424
+ when :multi
425
+ # return the array directly as typhoeus will handle it as expected
426
+ param
427
+ else
428
+ fail "unknown collection format: #{collection_format.inspect}"
429
+ end
430
+ end
431
+
432
+ # Execute block until it returns true
433
+ # @param [Block] _block Block to the executed.
434
+ # @param [Integer] timeout Maximum waiting time in seconds. nil means infinite waiting time.
435
+ # @param [Integer] initial_wait Initial polling interval in seconds.
436
+ # @param [Integer] scaleup Double polling interval every scaleup steps, which will be doubled.
437
+ def wait_for(timeout = 3600, initial_wait = 5, scaleup = 10, &_block)
438
+ if _block.nil?
439
+ return nil
440
+ end
441
+
442
+ wait_period = initial_wait
443
+ next_increase = Time.now.to_i + wait_period * scaleup
444
+ unless timeout.nil?
445
+ timeout = Time.now.to_i + timeout
446
+ end
447
+
448
+ while true
449
+ if yield
450
+ break
451
+ end
452
+
453
+ current_time = Time.now.to_i
454
+ if timeout && current_time > timeout
455
+ raise IonoscloudDbaasMongo::ApiError.new(message: "Timed out.")
456
+ end
457
+
458
+ if current_time > next_increase
459
+ wait_period *= 2
460
+ next_increase = Time.now.to_i + wait_period * scaleup
461
+ scaleup *= 2
462
+ end
463
+
464
+ if @config.debugging
465
+ @config.logger.info "Sleeping for #{wait_period} seconds..."
466
+ end
467
+ sleep(wait_period)
468
+ end
469
+ end
470
+ end
471
+ end
@@ -0,0 +1,57 @@
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 ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end