dub 0.2.2.pre.alpha.78 → 0.2.2.pre.alpha.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ require 'faraday'
7
7
  require 'faraday/multipart'
8
8
  require 'faraday/retry'
9
9
  require 'sorbet-runtime'
10
+ require_relative 'sdk_hooks/hooks'
10
11
  require_relative 'utils/retries'
11
12
 
12
13
  module OpenApiSDK
@@ -21,8 +22,8 @@ module OpenApiSDK
21
22
  end
22
23
 
23
24
 
24
- sig { params(request: T.nilable(::OpenApiSDK::Operations::CreateFolderRequestBody)).returns(::OpenApiSDK::Operations::CreateFolderResponse) }
25
- def create(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::CreateFolderRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::CreateFolderResponse) }
26
+ def create(request, timeout_ms = nil)
26
27
  # create - Create a new folder
27
28
  # Create a new folder for the authenticated workspace.
28
29
  url, params = @sdk_configuration.get_server_details
@@ -31,21 +32,71 @@ module OpenApiSDK
31
32
  headers = {}
32
33
  req_content_type, data, form = Utils.serialize_request_body(request, :request, :json)
33
34
  headers['content-type'] = req_content_type
35
+
36
+ if form
37
+ body = Utils.encode_form(form)
38
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
39
+ body = URI.encode_www_form(data)
40
+ else
41
+ body = data
42
+ end
34
43
  headers['Accept'] = 'application/json'
35
44
  headers['user-agent'] = @sdk_configuration.user_agent
36
45
 
46
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
47
+
48
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
49
+ timeout ||= @sdk_configuration.timeout
50
+
37
51
  connection = @sdk_configuration.client
38
52
 
39
- r = connection.post(url) do |req|
40
- req.headers = headers
41
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
42
- Utils.configure_request_security(req, security) if !security.nil?
43
- if form
44
- req.body = Utils.encode_form(form)
45
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
46
- req.body = URI.encode_www_form(data)
53
+ hook_ctx = SDKHooks::HookContext.new(
54
+ base_url: base_url,
55
+ oauth2_scopes: [],
56
+ operation_id: 'createFolder',
57
+ security_source: @sdk_configuration.security_source
58
+ )
59
+
60
+ error = T.let(nil, T.nilable(StandardError))
61
+ r = T.let(nil, T.nilable(Faraday::Response))
62
+
63
+ begin
64
+ r = connection.post(url) do |req|
65
+ req.body = body
66
+ req.headers.merge!(headers)
67
+ req.options.timeout = timeout unless timeout.nil?
68
+ Utils.configure_request_security(req, security)
69
+
70
+ @sdk_configuration.hooks.before_request(
71
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
72
+ hook_ctx: hook_ctx
73
+ ),
74
+ request: req
75
+ )
76
+ end
77
+ rescue StandardError => e
78
+ error = e
79
+ ensure
80
+ if r.nil? || Utils.error_status?(r.status)
81
+ r = @sdk_configuration.hooks.after_error(
82
+ error: error,
83
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
84
+ hook_ctx: hook_ctx
85
+ ),
86
+ response: r
87
+ )
47
88
  else
48
- req.body = data
89
+ r = @sdk_configuration.hooks.after_success(
90
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
91
+ hook_ctx: hook_ctx
92
+ ),
93
+ response: r
94
+ )
95
+ end
96
+
97
+ if r.nil?
98
+ raise error if !error.nil?
99
+ raise 'no response'
49
100
  end
50
101
  end
51
102
 
@@ -110,8 +161,8 @@ module OpenApiSDK
110
161
  end
111
162
 
112
163
 
113
- sig { params(request: T.nilable(::OpenApiSDK::Operations::ListFoldersRequest)).returns(::OpenApiSDK::Operations::ListFoldersResponse) }
114
- def list(request)
164
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::ListFoldersRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::ListFoldersResponse) }
165
+ def list(request, timeout_ms = nil)
115
166
  # list - Retrieve a list of folders
116
167
  # Retrieve a list of folders for the authenticated workspace.
117
168
  url, params = @sdk_configuration.get_server_details
@@ -122,13 +173,61 @@ module OpenApiSDK
122
173
  headers['Accept'] = 'application/json'
123
174
  headers['user-agent'] = @sdk_configuration.user_agent
124
175
 
176
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
177
+
178
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
179
+ timeout ||= @sdk_configuration.timeout
180
+
125
181
  connection = @sdk_configuration.client
126
182
 
127
- r = connection.get(url) do |req|
128
- req.headers = headers
129
- req.params = query_params
130
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
131
- Utils.configure_request_security(req, security) if !security.nil?
183
+ hook_ctx = SDKHooks::HookContext.new(
184
+ base_url: base_url,
185
+ oauth2_scopes: [],
186
+ operation_id: 'listFolders',
187
+ security_source: @sdk_configuration.security_source
188
+ )
189
+
190
+ error = T.let(nil, T.nilable(StandardError))
191
+ r = T.let(nil, T.nilable(Faraday::Response))
192
+
193
+ begin
194
+ r = connection.get(url) do |req|
195
+ req.headers.merge!(headers)
196
+ req.options.timeout = timeout unless timeout.nil?
197
+ req.params = query_params
198
+ Utils.configure_request_security(req, security)
199
+
200
+ @sdk_configuration.hooks.before_request(
201
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
202
+ hook_ctx: hook_ctx
203
+ ),
204
+ request: req
205
+ )
206
+ end
207
+ rescue StandardError => e
208
+ error = e
209
+ ensure
210
+ if r.nil? || Utils.error_status?(r.status)
211
+ r = @sdk_configuration.hooks.after_error(
212
+ error: error,
213
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
214
+ hook_ctx: hook_ctx
215
+ ),
216
+ response: r
217
+ )
218
+ else
219
+ r = @sdk_configuration.hooks.after_success(
220
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
221
+ hook_ctx: hook_ctx
222
+ ),
223
+ response: r
224
+ )
225
+ end
226
+
227
+ if r.nil?
228
+ raise error if !error.nil?
229
+ raise 'no response'
230
+ end
132
231
  end
133
232
 
134
233
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -192,8 +291,8 @@ module OpenApiSDK
192
291
  end
193
292
 
194
293
 
195
- sig { params(request: T.nilable(::OpenApiSDK::Operations::UpdateFolderRequest)).returns(::OpenApiSDK::Operations::UpdateFolderResponse) }
196
- def update(request)
294
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::UpdateFolderRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::UpdateFolderResponse) }
295
+ def update(request, timeout_ms = nil)
197
296
  # update - Update a folder
198
297
  # Update a folder in the workspace.
199
298
  url, params = @sdk_configuration.get_server_details
@@ -207,21 +306,71 @@ module OpenApiSDK
207
306
  headers = {}
208
307
  req_content_type, data, form = Utils.serialize_request_body(request, :request_body, :json)
209
308
  headers['content-type'] = req_content_type
309
+
310
+ if form
311
+ body = Utils.encode_form(form)
312
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
313
+ body = URI.encode_www_form(data)
314
+ else
315
+ body = data
316
+ end
210
317
  headers['Accept'] = 'application/json'
211
318
  headers['user-agent'] = @sdk_configuration.user_agent
212
319
 
320
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
321
+
322
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
323
+ timeout ||= @sdk_configuration.timeout
324
+
213
325
  connection = @sdk_configuration.client
214
326
 
215
- r = connection.patch(url) do |req|
216
- req.headers = headers
217
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
218
- Utils.configure_request_security(req, security) if !security.nil?
219
- if form
220
- req.body = Utils.encode_form(form)
221
- elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
222
- req.body = URI.encode_www_form(data)
327
+ hook_ctx = SDKHooks::HookContext.new(
328
+ base_url: base_url,
329
+ oauth2_scopes: [],
330
+ operation_id: 'updateFolder',
331
+ security_source: @sdk_configuration.security_source
332
+ )
333
+
334
+ error = T.let(nil, T.nilable(StandardError))
335
+ r = T.let(nil, T.nilable(Faraday::Response))
336
+
337
+ begin
338
+ r = connection.patch(url) do |req|
339
+ req.body = body
340
+ req.headers.merge!(headers)
341
+ req.options.timeout = timeout unless timeout.nil?
342
+ Utils.configure_request_security(req, security)
343
+
344
+ @sdk_configuration.hooks.before_request(
345
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
346
+ hook_ctx: hook_ctx
347
+ ),
348
+ request: req
349
+ )
350
+ end
351
+ rescue StandardError => e
352
+ error = e
353
+ ensure
354
+ if r.nil? || Utils.error_status?(r.status)
355
+ r = @sdk_configuration.hooks.after_error(
356
+ error: error,
357
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
358
+ hook_ctx: hook_ctx
359
+ ),
360
+ response: r
361
+ )
223
362
  else
224
- req.body = data
363
+ r = @sdk_configuration.hooks.after_success(
364
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
365
+ hook_ctx: hook_ctx
366
+ ),
367
+ response: r
368
+ )
369
+ end
370
+
371
+ if r.nil?
372
+ raise error if !error.nil?
373
+ raise 'no response'
225
374
  end
226
375
  end
227
376
 
@@ -286,8 +435,8 @@ module OpenApiSDK
286
435
  end
287
436
 
288
437
 
289
- sig { params(request: T.nilable(::OpenApiSDK::Operations::DeleteFolderRequest)).returns(::OpenApiSDK::Operations::DeleteFolderResponse) }
290
- def delete(request)
438
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::DeleteFolderRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::DeleteFolderResponse) }
439
+ def delete(request, timeout_ms = nil)
291
440
  # delete - Delete a folder
292
441
  # Delete a folder from the workspace. All existing links will still work, but they will no longer be associated with this folder.
293
442
  url, params = @sdk_configuration.get_server_details
@@ -302,12 +451,60 @@ module OpenApiSDK
302
451
  headers['Accept'] = 'application/json'
303
452
  headers['user-agent'] = @sdk_configuration.user_agent
304
453
 
454
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
455
+
456
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
457
+ timeout ||= @sdk_configuration.timeout
458
+
305
459
  connection = @sdk_configuration.client
306
460
 
307
- r = connection.delete(url) do |req|
308
- req.headers = headers
309
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
310
- Utils.configure_request_security(req, security) if !security.nil?
461
+ hook_ctx = SDKHooks::HookContext.new(
462
+ base_url: base_url,
463
+ oauth2_scopes: [],
464
+ operation_id: 'deleteFolder',
465
+ security_source: @sdk_configuration.security_source
466
+ )
467
+
468
+ error = T.let(nil, T.nilable(StandardError))
469
+ r = T.let(nil, T.nilable(Faraday::Response))
470
+
471
+ begin
472
+ r = connection.delete(url) do |req|
473
+ req.headers.merge!(headers)
474
+ req.options.timeout = timeout unless timeout.nil?
475
+ Utils.configure_request_security(req, security)
476
+
477
+ @sdk_configuration.hooks.before_request(
478
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
479
+ hook_ctx: hook_ctx
480
+ ),
481
+ request: req
482
+ )
483
+ end
484
+ rescue StandardError => e
485
+ error = e
486
+ ensure
487
+ if r.nil? || Utils.error_status?(r.status)
488
+ r = @sdk_configuration.hooks.after_error(
489
+ error: error,
490
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
491
+ hook_ctx: hook_ctx
492
+ ),
493
+ response: r
494
+ )
495
+ else
496
+ r = @sdk_configuration.hooks.after_success(
497
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
498
+ hook_ctx: hook_ctx
499
+ ),
500
+ response: r
501
+ )
502
+ end
503
+
504
+ if r.nil?
505
+ raise error if !error.nil?
506
+ raise 'no response'
507
+ end
311
508
  end
312
509
 
313
510
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')