dub 0.2.2.pre.alpha.77 → 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::CreateDomainRequestBody)).returns(::OpenApiSDK::Operations::CreateDomainResponse) }
25
- def create(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::CreateDomainRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::CreateDomainResponse) }
26
+ def create(request, timeout_ms = nil)
26
27
  # create - Create a domain
27
28
  # Create a domain 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: 'createDomain',
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::ListDomainsRequest)).returns(::OpenApiSDK::Operations::ListDomainsResponse) }
114
- def list(request)
164
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::ListDomainsRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::ListDomainsResponse) }
165
+ def list(request, timeout_ms = nil)
115
166
  # list - Retrieve a list of domains
116
167
  # Retrieve a list of domains associated with 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: 'listDomains',
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::UpdateDomainRequest)).returns(::OpenApiSDK::Operations::UpdateDomainResponse) }
196
- def update(request)
294
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::UpdateDomainRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::UpdateDomainResponse) }
295
+ def update(request, timeout_ms = nil)
197
296
  # update - Update a domain
198
297
  # Update a domain for the authenticated 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: 'updateDomain',
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::DeleteDomainRequest)).returns(::OpenApiSDK::Operations::DeleteDomainResponse) }
290
- def delete(request)
438
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::DeleteDomainRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::DeleteDomainResponse) }
439
+ def delete(request, timeout_ms = nil)
291
440
  # delete - Delete a domain
292
441
  # Delete a domain from a workspace. It cannot be undone. This will also delete all the links associated with the domain.
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: 'deleteDomain',
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')
@@ -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,6 +22,7 @@ module OpenApiSDK
21
22
  params(
22
23
  client: T.nilable(Faraday::Connection),
23
24
  retry_config: T.nilable(::OpenApiSDK::Utils::RetryConfig),
25
+ timeout_ms: T.nilable(Integer),
24
26
  security: T.nilable(::OpenApiSDK::Shared::Security),
25
27
  security_source: T.nilable(T.proc.returns(::OpenApiSDK::Shared::Security)),
26
28
  server_idx: T.nilable(Integer),
@@ -28,23 +30,27 @@ module OpenApiSDK
28
30
  url_params: T.nilable(T::Hash[Symbol, String])
29
31
  ).void
30
32
  end
31
- def initialize(client: nil, retry_config: nil, security: nil, security_source: nil, server_idx: nil, server_url: nil, url_params: nil)
33
+ def initialize(client: nil, retry_config: nil, timeout_ms: nil, security: nil, security_source: nil, server_idx: nil, server_url: nil, url_params: nil)
32
34
  ## Instantiates the SDK configuring it with the provided parameters.
33
35
  # @param [T.nilable(Faraday::Connection)] client The faraday HTTP client to use for all operations
34
36
  # @param [T.nilable(::OpenApiSDK::Utils::RetryConfig)] retry_config The retry configuration to use for all operations
37
+ # @param [T.nilable(Integer)] timeout_ms Request timeout in milliseconds for all operations
35
38
  # @param [T.nilable(::OpenApiSDK::Shared::Security)] security: The security details required for authentication
36
39
  # @param [T.proc.returns(T.nilable(::OpenApiSDK::Shared::Security))] security_source: A function that returns security details required for authentication
37
40
  # @param [T.nilable(::Integer)] server_idx The index of the server to use for all operations
38
41
  # @param [T.nilable(::String)] server_url The server URL to use for all operations
39
42
  # @param [T.nilable(::Hash<::Symbol, ::String>)] url_params Parameters to optionally template the server URL with
40
43
 
41
- if client.nil?
42
- client = Faraday.new(request: {
43
- params_encoder: Faraday::FlatParamsEncoder
44
- }) do |f|
45
- f.request :multipart, {}
46
- # f.response :logger
47
- end
44
+ connection_options = {
45
+ request: {
46
+ params_encoder: Faraday::FlatParamsEncoder
47
+ }
48
+ }
49
+ connection_options[:request][:timeout] = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
50
+
51
+ client ||= Faraday.new(**connection_options) do |f|
52
+ f.request :multipart, {}
53
+ # f.response :logger, nil, { headers: true, bodies: true, errors: true }
48
54
  end
49
55
 
50
56
  if !server_url.nil?
@@ -54,14 +60,22 @@ module OpenApiSDK
54
60
  end
55
61
 
56
62
  server_idx = 0 if server_idx.nil?
63
+ hooks = SDKHooks::Hooks.new
57
64
  @sdk_configuration = SDKConfiguration.new(
58
65
  client,
66
+ hooks,
59
67
  retry_config,
68
+ timeout_ms,
60
69
  security,
61
70
  security_source,
62
71
  server_url,
63
72
  server_idx
64
73
  )
74
+
75
+ original_server_url = @sdk_configuration.get_server_details.first
76
+ new_server_url, @sdk_configuration.client = hooks.sdk_init(base_url: original_server_url, client: client)
77
+ @sdk_configuration.server_url = new_server_url if new_server_url != original_server_url
78
+
65
79
  init_sdks
66
80
  end
67
81
 
@@ -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::CreateReferralsEmbedTokenRequestBody)).returns(::OpenApiSDK::Operations::CreateReferralsEmbedTokenResponse) }
25
- def referrals(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::CreateReferralsEmbedTokenRequestBody), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::CreateReferralsEmbedTokenResponse) }
26
+ def referrals(request, timeout_ms = nil)
26
27
  # referrals - Create a new referrals embed token
27
28
  # Create a new referrals embed token for the given partner/tenant.
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: 'createReferralsEmbedToken',
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
 
@@ -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::ListEventsRequest)).returns(::OpenApiSDK::Operations::ListEventsResponse) }
25
- def list(request)
25
+ sig { params(request: T.nilable(::OpenApiSDK::Operations::ListEventsRequest), timeout_ms: T.nilable(Integer)).returns(::OpenApiSDK::Operations::ListEventsResponse) }
26
+ def list(request, timeout_ms = nil)
26
27
  # list - Retrieve a list of events
27
28
  # Retrieve a paginated list of events for the authenticated workspace.
28
29
  url, params = @sdk_configuration.get_server_details
@@ -33,13 +34,61 @@ module OpenApiSDK
33
34
  headers['Accept'] = 'application/json'
34
35
  headers['user-agent'] = @sdk_configuration.user_agent
35
36
 
37
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
38
+
39
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
40
+ timeout ||= @sdk_configuration.timeout
41
+
36
42
  connection = @sdk_configuration.client
37
43
 
38
- r = connection.get(url) do |req|
39
- req.headers = headers
40
- req.params = query_params
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?
44
+ hook_ctx = SDKHooks::HookContext.new(
45
+ base_url: base_url,
46
+ oauth2_scopes: [],
47
+ operation_id: 'listEvents',
48
+ security_source: @sdk_configuration.security_source
49
+ )
50
+
51
+ error = T.let(nil, T.nilable(StandardError))
52
+ r = T.let(nil, T.nilable(Faraday::Response))
53
+
54
+ begin
55
+ r = connection.get(url) do |req|
56
+ req.headers.merge!(headers)
57
+ req.options.timeout = timeout unless timeout.nil?
58
+ req.params = query_params
59
+ Utils.configure_request_security(req, security)
60
+
61
+ @sdk_configuration.hooks.before_request(
62
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
63
+ hook_ctx: hook_ctx
64
+ ),
65
+ request: req
66
+ )
67
+ end
68
+ rescue StandardError => e
69
+ error = e
70
+ ensure
71
+ if r.nil? || Utils.error_status?(r.status)
72
+ r = @sdk_configuration.hooks.after_error(
73
+ error: error,
74
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
75
+ hook_ctx: hook_ctx
76
+ ),
77
+ response: r
78
+ )
79
+ else
80
+ r = @sdk_configuration.hooks.after_success(
81
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
82
+ hook_ctx: hook_ctx
83
+ ),
84
+ response: r
85
+ )
86
+ end
87
+
88
+ if r.nil?
89
+ raise error if !error.nil?
90
+ raise 'no response'
91
+ end
43
92
  end
44
93
 
45
94
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')