noresponse 2.0.17 → 2.0.19

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/no_response/integrations.rb +1156 -0
  3. data/lib/no_response/models/operations/createintegration_response.rb +32 -0
  4. data/lib/no_response/models/operations/createintegration_response.rbi +20 -0
  5. data/lib/no_response/models/operations/createwebhookendpoint_response.rb +34 -0
  6. data/lib/no_response/models/operations/createwebhookendpoint_response.rbi +20 -0
  7. data/lib/no_response/models/operations/deleteintegration_request.rb +33 -0
  8. data/lib/no_response/models/operations/deleteintegration_request.rbi +14 -0
  9. data/lib/no_response/models/operations/deleteintegration_response.rb +28 -0
  10. data/lib/no_response/models/operations/deleteintegration_response.rbi +14 -0
  11. data/lib/no_response/models/operations/deletewebhookendpoint_request.rb +29 -0
  12. data/lib/no_response/models/operations/deletewebhookendpoint_request.rbi +14 -0
  13. data/lib/no_response/models/operations/deletewebhookendpoint_response.rb +28 -0
  14. data/lib/no_response/models/operations/deletewebhookendpoint_response.rbi +14 -0
  15. data/lib/no_response/models/operations/listintegrations_response.rb +32 -0
  16. data/lib/no_response/models/operations/listintegrations_response.rbi +20 -0
  17. data/lib/no_response/models/operations/listwebhookendpoints_response.rb +32 -0
  18. data/lib/no_response/models/operations/listwebhookendpoints_response.rbi +20 -0
  19. data/lib/no_response/models/operations/rotateintegrationsecret_request.rb +37 -0
  20. data/lib/no_response/models/operations/rotateintegrationsecret_request.rbi +20 -0
  21. data/lib/no_response/models/operations/rotateintegrationsecret_response.rb +32 -0
  22. data/lib/no_response/models/operations/rotateintegrationsecret_response.rbi +20 -0
  23. data/lib/no_response/models/operations/rotatewebhooksigningkey_request.rb +33 -0
  24. data/lib/no_response/models/operations/rotatewebhooksigningkey_request.rbi +20 -0
  25. data/lib/no_response/models/operations/rotatewebhooksigningkey_response.rb +32 -0
  26. data/lib/no_response/models/operations/rotatewebhooksigningkey_response.rbi +20 -0
  27. data/lib/no_response/models/operations/sendwebhooktestevent_request.rb +33 -0
  28. data/lib/no_response/models/operations/sendwebhooktestevent_request.rbi +20 -0
  29. data/lib/no_response/models/operations/sendwebhooktestevent_response.rb +32 -0
  30. data/lib/no_response/models/operations/sendwebhooktestevent_response.rbi +20 -0
  31. data/lib/no_response/models/operations.rb +14 -0
  32. data/lib/no_response/models/shared/assessmentquery.rb +1 -1
  33. data/lib/no_response/models/shared/assessmentrequest.rb +1 -1
  34. data/lib/no_response/models/shared/badrequesterrorcode.rb +1 -0
  35. data/lib/no_response/models/shared/conflicterrorcode.rb +3 -0
  36. data/lib/no_response/models/shared/integration.rb +112 -0
  37. data/lib/no_response/models/shared/integration.rbi +56 -0
  38. data/lib/no_response/models/shared/integrationhookpoint.rb +19 -0
  39. data/lib/no_response/models/shared/integrationhookpoint.rbi +9 -0
  40. data/lib/no_response/models/shared/integrationlist.rb +32 -0
  41. data/lib/no_response/models/shared/integrationlist.rbi +14 -0
  42. data/lib/no_response/models/shared/integrationplatform.rb +19 -0
  43. data/lib/no_response/models/shared/integrationplatform.rbi +9 -0
  44. data/lib/no_response/models/shared/integrationrequest.rb +62 -0
  45. data/lib/no_response/models/shared/integrationrequest.rbi +26 -0
  46. data/lib/no_response/models/shared/integrationrotationrequest.rb +33 -0
  47. data/lib/no_response/models/shared/integrationrotationrequest.rbi +14 -0
  48. data/lib/no_response/models/shared/responsemode.rb +4 -1
  49. data/lib/no_response/models/shared/scope.rb +1 -0
  50. data/lib/no_response/models/shared/signingkey.rb +49 -0
  51. data/lib/no_response/models/shared/signingkey.rbi +26 -0
  52. data/lib/no_response/models/shared/signingsecret.rb +49 -0
  53. data/lib/no_response/models/shared/signingsecret.rbi +26 -0
  54. data/lib/no_response/models/shared/webhookendpoint.rb +100 -0
  55. data/lib/no_response/models/shared/webhookendpoint.rbi +50 -0
  56. data/lib/no_response/models/shared/webhookendpointcreated.rb +41 -0
  57. data/lib/no_response/models/shared/webhookendpointcreated.rbi +20 -0
  58. data/lib/no_response/models/shared/webhookendpointlist.rb +32 -0
  59. data/lib/no_response/models/shared/webhookendpointlist.rbi +14 -0
  60. data/lib/no_response/models/shared/webhookendpointrequest.rb +42 -0
  61. data/lib/no_response/models/shared/webhookendpointrequest.rbi +20 -0
  62. data/lib/no_response/models/shared/webhookendpointstate.rb +20 -0
  63. data/lib/no_response/models/shared/webhookendpointstate.rbi +9 -0
  64. data/lib/no_response/models/shared/webhookkeyrotation.rb +65 -0
  65. data/lib/no_response/models/shared/webhookkeyrotation.rbi +32 -0
  66. data/lib/no_response/models/shared/webhookkeyrotationrequest.rb +23 -0
  67. data/lib/no_response/models/shared/webhookkeyrotationrequest.rbi +9 -0
  68. data/lib/no_response/models/shared/webhooktest.rb +86 -0
  69. data/lib/no_response/models/shared/webhooktest.rbi +38 -0
  70. data/lib/no_response/models/shared/webhooktestrequest.rb +39 -0
  71. data/lib/no_response/models/shared/webhooktestrequest.rbi +14 -0
  72. data/lib/no_response/models/shared/webhooktestrequestevent.rb +19 -0
  73. data/lib/no_response/models/shared/webhooktestrequestevent.rbi +9 -0
  74. data/lib/no_response/models/shared.rb +18 -0
  75. data/lib/no_response/noresponseclient.rb +3 -1
  76. data/lib/no_response/sdkconfiguration.rb +2 -2
  77. data/lib/no_response/webhookendpoints.rb +1444 -0
  78. data/lib/noresponse.rb +2 -0
  79. metadata +67 -1
@@ -0,0 +1,1156 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require "faraday"
5
+ require "faraday/multipart"
6
+ require "faraday/retry"
7
+ require "sorbet-runtime"
8
+
9
+ require_relative "sdk_hooks/hooks"
10
+ require_relative "utils/retries"
11
+
12
+ module NoResponse
13
+ extend T::Sig
14
+
15
+ class Integrations
16
+ extend T::Sig
17
+
18
+ # Hosted endpoints that answer your sign-up and sign-in hooks.
19
+
20
+ sig { params(sdk_config: SDKConfiguration).void }
21
+ def initialize(sdk_config)
22
+ @sdk_configuration = sdk_config
23
+ end
24
+
25
+ sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
26
+ def get_url(base_url:, url_variables: nil)
27
+ sd_base_url, sd_options = @sdk_configuration.get_server_details
28
+
29
+ if base_url.nil?
30
+ base_url = sd_base_url
31
+ end
32
+
33
+ if url_variables.nil?
34
+ url_variables = sd_options
35
+ end
36
+
37
+ return Utils.template_url(base_url, url_variables)
38
+ end
39
+
40
+ sig {
41
+ params(
42
+ request: Models::Shared::IntegrationRequest,
43
+ timeout_ms: T.nilable(Integer),
44
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
45
+ )
46
+ .returns(Models::Operations::CreateIntegrationResponse)
47
+ }
48
+ def create(request:, timeout_ms: nil, http_headers: nil)
49
+ # create - Register a hosted provider integration.
50
+ # Registers a WorkOS or Auth0 integration and returns its hosted endpoint, url, so a sign-up or sign-in is scored with no server of your own. For WorkOS, send the Actions signing secret from the WorkOS dashboard and point the user registration and authentication Actions at url. For Auth0, the answer's secret is the shared secret of the NoResponse Auth0 Action, shown once: store it as an Action secret. hook_points defaults to both pre_registration and post_login; an event that is not listed is allowed without an assessment. The endpoint waits for the full assessment for at most 2.5 seconds (WorkOS) or 4.5 seconds (Auth0), denies only when risk.block is true and allows on any failure. Requires the integrations scope; at most 10 per account. Not idempotent: a retry after a lost answer registers another integration.
51
+ url, params = @sdk_configuration.get_server_details
52
+ base_url = Utils.template_url(url, params)
53
+ url = "#{base_url}/v1/integrations"
54
+ headers = {}
55
+ headers = T.cast(headers, T::Hash[String, String])
56
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
57
+ headers["content-type"] = req_content_type
58
+ raise StandardError, "request body is required" if data.nil? && form.nil?
59
+
60
+ if form && !form.empty?
61
+ body = Utils.encode_form(form)
62
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
63
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
64
+ else
65
+ body = data
66
+ end
67
+
68
+ headers["Accept"] = "application/json"
69
+ headers["user-agent"] = @sdk_configuration.user_agent
70
+
71
+ security = @sdk_configuration.security_source&.call
72
+
73
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
74
+ timeout ||= @sdk_configuration.timeout
75
+
76
+ connection = @sdk_configuration.client
77
+
78
+ hook_ctx = SDKHooks::HookContext.new(
79
+ config: @sdk_configuration,
80
+ base_url: base_url,
81
+ oauth2_scopes: nil,
82
+ operation_id: "createIntegration",
83
+ security_source: @sdk_configuration.security_source
84
+ )
85
+
86
+ error = T.let(nil, T.nilable(StandardError))
87
+ http_response = T.let(nil, T.nilable(Faraday::Response))
88
+
89
+ begin
90
+ http_response = T.must(connection).post(url) do |req|
91
+ req.body = body
92
+ req.headers.merge!(headers)
93
+ req.options.timeout = timeout unless timeout.nil?
94
+ Utils.configure_request_security(req, security)
95
+ http_headers&.each do |key, value|
96
+ req.headers[key.to_s] = value
97
+ end
98
+
99
+ @sdk_configuration.hooks.before_request(
100
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
101
+ hook_ctx: hook_ctx
102
+ ),
103
+ request: req
104
+ )
105
+ end
106
+
107
+ rescue StandardError => e
108
+ error = e
109
+ ensure
110
+ if http_response.nil? || Utils.error_status?(http_response.status)
111
+ http_response = @sdk_configuration.hooks.after_error(
112
+ error: error,
113
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
114
+ hook_ctx: hook_ctx
115
+ ),
116
+ response: http_response
117
+ )
118
+ else
119
+ http_response = @sdk_configuration.hooks.after_success(
120
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
121
+ hook_ctx: hook_ctx
122
+ ),
123
+ response: http_response
124
+ )
125
+ end
126
+
127
+ if http_response.nil?
128
+ raise error if !error.nil?
129
+ raise "no response"
130
+ end
131
+ end
132
+
133
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
134
+ if Utils.match_status_code(http_response.status, ["201"])
135
+ if Utils.match_content_type(content_type, "application/json")
136
+ @sdk_configuration.hooks.after_success(
137
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
138
+ hook_ctx: hook_ctx
139
+ ),
140
+ response: http_response
141
+ )
142
+ response_data = http_response.env.response_body
143
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Integration)
144
+ result = obj
145
+ response = Models::Operations::CreateIntegrationResponse.new(
146
+ result: result,
147
+ headers: http_response.headers
148
+ )
149
+
150
+ return response
151
+ else
152
+ raise(
153
+ ::NoResponse::Models::Errors::APIStatusError.new(
154
+ status_code: http_response.status,
155
+ body: http_response.env.response_body,
156
+ raw_response: http_response
157
+ ),
158
+ "Unknown content type received"
159
+ )
160
+ end
161
+ elsif Utils.match_status_code(http_response.status, ["400"])
162
+ if Utils.match_content_type(content_type, "application/problem+json")
163
+ @sdk_configuration.hooks.after_success(
164
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
165
+ hook_ctx: hook_ctx
166
+ ),
167
+ response: http_response
168
+ )
169
+ response_data = http_response.env.response_body
170
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
171
+ raise obj
172
+ else
173
+ raise(
174
+ ::NoResponse::Models::Errors::APIStatusError.new(
175
+ status_code: http_response.status,
176
+ body: http_response.env.response_body,
177
+ raw_response: http_response
178
+ ),
179
+ "Unknown content type received"
180
+ )
181
+ end
182
+ elsif Utils.match_status_code(http_response.status, ["401"])
183
+ if Utils.match_content_type(content_type, "application/problem+json")
184
+ @sdk_configuration.hooks.after_success(
185
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
186
+ hook_ctx: hook_ctx
187
+ ),
188
+ response: http_response
189
+ )
190
+ response_data = http_response.env.response_body
191
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
192
+ raise obj
193
+ else
194
+ raise(
195
+ ::NoResponse::Models::Errors::APIStatusError.new(
196
+ status_code: http_response.status,
197
+ body: http_response.env.response_body,
198
+ raw_response: http_response
199
+ ),
200
+ "Unknown content type received"
201
+ )
202
+ end
203
+ elsif Utils.match_status_code(http_response.status, ["403"])
204
+ if Utils.match_content_type(content_type, "application/problem+json")
205
+ @sdk_configuration.hooks.after_success(
206
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
207
+ hook_ctx: hook_ctx
208
+ ),
209
+ response: http_response
210
+ )
211
+ response_data = http_response.env.response_body
212
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
213
+ raise obj
214
+ else
215
+ raise(
216
+ ::NoResponse::Models::Errors::APIStatusError.new(
217
+ status_code: http_response.status,
218
+ body: http_response.env.response_body,
219
+ raw_response: http_response
220
+ ),
221
+ "Unknown content type received"
222
+ )
223
+ end
224
+ elsif Utils.match_status_code(http_response.status, ["404"])
225
+ if Utils.match_content_type(content_type, "application/problem+json")
226
+ @sdk_configuration.hooks.after_success(
227
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
228
+ hook_ctx: hook_ctx
229
+ ),
230
+ response: http_response
231
+ )
232
+ response_data = http_response.env.response_body
233
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
234
+ raise obj
235
+ else
236
+ raise(
237
+ ::NoResponse::Models::Errors::APIStatusError.new(
238
+ status_code: http_response.status,
239
+ body: http_response.env.response_body,
240
+ raw_response: http_response
241
+ ),
242
+ "Unknown content type received"
243
+ )
244
+ end
245
+ elsif Utils.match_status_code(http_response.status, ["409"])
246
+ if Utils.match_content_type(content_type, "application/problem+json")
247
+ @sdk_configuration.hooks.after_success(
248
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
249
+ hook_ctx: hook_ctx
250
+ ),
251
+ response: http_response
252
+ )
253
+ response_data = http_response.env.response_body
254
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
255
+ raise obj
256
+ else
257
+ raise(
258
+ ::NoResponse::Models::Errors::APIStatusError.new(
259
+ status_code: http_response.status,
260
+ body: http_response.env.response_body,
261
+ raw_response: http_response
262
+ ),
263
+ "Unknown content type received"
264
+ )
265
+ end
266
+ elsif Utils.match_status_code(http_response.status, ["429"])
267
+ if Utils.match_content_type(content_type, "application/problem+json")
268
+ @sdk_configuration.hooks.after_success(
269
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
270
+ hook_ctx: hook_ctx
271
+ ),
272
+ response: http_response
273
+ )
274
+ response_data = http_response.env.response_body
275
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
276
+ raise obj
277
+ else
278
+ raise(
279
+ ::NoResponse::Models::Errors::APIStatusError.new(
280
+ status_code: http_response.status,
281
+ body: http_response.env.response_body,
282
+ raw_response: http_response
283
+ ),
284
+ "Unknown content type received"
285
+ )
286
+ end
287
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
288
+ raise(
289
+ ::NoResponse::Models::Errors::APIStatusError.new(
290
+ status_code: http_response.status,
291
+ body: http_response.env.response_body,
292
+ raw_response: http_response
293
+ ),
294
+ "API error occurred"
295
+ )
296
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
297
+ raise(
298
+ ::NoResponse::Models::Errors::APIStatusError.new(
299
+ status_code: http_response.status,
300
+ body: http_response.env.response_body,
301
+ raw_response: http_response
302
+ ),
303
+ "API error occurred"
304
+ )
305
+ else
306
+ raise(
307
+ ::NoResponse::Models::Errors::APIStatusError.new(
308
+ status_code: http_response.status,
309
+ body: http_response.env.response_body,
310
+ raw_response: http_response
311
+ ),
312
+ "Unknown status code received"
313
+ )
314
+
315
+ end
316
+ end
317
+
318
+ sig {
319
+ params(
320
+ retries: T.nilable(Utils::RetryConfig),
321
+ timeout_ms: T.nilable(Integer),
322
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
323
+ )
324
+ .returns(Models::Operations::ListIntegrationsResponse)
325
+ }
326
+ def list(retries: nil, timeout_ms: nil, http_headers: nil)
327
+ # list - List the tenant's integrations.
328
+ # Every integration, oldest first. Listings carry no secrets. Requires the integrations scope.
329
+ url, params = @sdk_configuration.get_server_details
330
+ base_url = Utils.template_url(url, params)
331
+ url = "#{base_url}/v1/integrations"
332
+ headers = {}
333
+ headers = T.cast(headers, T::Hash[String, String])
334
+ headers["Accept"] = "application/json"
335
+ headers["user-agent"] = @sdk_configuration.user_agent
336
+ retries ||= @sdk_configuration.retry_config
337
+ retries ||= Utils::RetryConfig.new(
338
+ backoff: Utils::BackoffStrategy.new(
339
+ exponent: 2.0,
340
+ initial_interval: 500,
341
+ max_elapsed_time: 30_000,
342
+ max_interval: 8000
343
+ ),
344
+ retry_connection_errors: true,
345
+ strategy: "backoff"
346
+ )
347
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
348
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
349
+
350
+ security = @sdk_configuration.security_source&.call
351
+
352
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
353
+ timeout ||= @sdk_configuration.timeout
354
+
355
+ connection = @sdk_configuration.client.dup
356
+ connection.use(Utils::RetryMiddleware, retry_options)
357
+
358
+ hook_ctx = SDKHooks::HookContext.new(
359
+ config: @sdk_configuration,
360
+ base_url: base_url,
361
+ oauth2_scopes: nil,
362
+ operation_id: "listIntegrations",
363
+ security_source: @sdk_configuration.security_source
364
+ )
365
+
366
+ error = T.let(nil, T.nilable(StandardError))
367
+ http_response = T.let(nil, T.nilable(Faraday::Response))
368
+
369
+ begin
370
+ http_response = T.must(connection).get(url) do |req|
371
+ req.headers.merge!(headers)
372
+ req.options.timeout = timeout unless timeout.nil?
373
+ Utils.configure_request_security(req, security)
374
+ http_headers&.each do |key, value|
375
+ req.headers[key.to_s] = value
376
+ end
377
+
378
+ @sdk_configuration.hooks.before_request(
379
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
380
+ hook_ctx: hook_ctx
381
+ ),
382
+ request: req
383
+ )
384
+ end
385
+
386
+ rescue StandardError => e
387
+ error = e
388
+ ensure
389
+ if http_response.nil? || Utils.error_status?(http_response.status)
390
+ http_response = @sdk_configuration.hooks.after_error(
391
+ error: error,
392
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
393
+ hook_ctx: hook_ctx
394
+ ),
395
+ response: http_response
396
+ )
397
+ else
398
+ http_response = @sdk_configuration.hooks.after_success(
399
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
400
+ hook_ctx: hook_ctx
401
+ ),
402
+ response: http_response
403
+ )
404
+ end
405
+
406
+ if http_response.nil?
407
+ raise error if !error.nil?
408
+ raise "no response"
409
+ end
410
+ end
411
+
412
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
413
+ if Utils.match_status_code(http_response.status, ["200"])
414
+ if Utils.match_content_type(content_type, "application/json")
415
+ @sdk_configuration.hooks.after_success(
416
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
417
+ hook_ctx: hook_ctx
418
+ ),
419
+ response: http_response
420
+ )
421
+ response_data = http_response.env.response_body
422
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::IntegrationList)
423
+ result = obj
424
+ response = Models::Operations::ListIntegrationsResponse.new(
425
+ result: result,
426
+ headers: http_response.headers
427
+ )
428
+
429
+ return response
430
+ else
431
+ raise(
432
+ ::NoResponse::Models::Errors::APIStatusError.new(
433
+ status_code: http_response.status,
434
+ body: http_response.env.response_body,
435
+ raw_response: http_response
436
+ ),
437
+ "Unknown content type received"
438
+ )
439
+ end
440
+ elsif Utils.match_status_code(http_response.status, ["400"])
441
+ if Utils.match_content_type(content_type, "application/problem+json")
442
+ @sdk_configuration.hooks.after_success(
443
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
444
+ hook_ctx: hook_ctx
445
+ ),
446
+ response: http_response
447
+ )
448
+ response_data = http_response.env.response_body
449
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
450
+ raise obj
451
+ else
452
+ raise(
453
+ ::NoResponse::Models::Errors::APIStatusError.new(
454
+ status_code: http_response.status,
455
+ body: http_response.env.response_body,
456
+ raw_response: http_response
457
+ ),
458
+ "Unknown content type received"
459
+ )
460
+ end
461
+ elsif Utils.match_status_code(http_response.status, ["401"])
462
+ if Utils.match_content_type(content_type, "application/problem+json")
463
+ @sdk_configuration.hooks.after_success(
464
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
465
+ hook_ctx: hook_ctx
466
+ ),
467
+ response: http_response
468
+ )
469
+ response_data = http_response.env.response_body
470
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
471
+ raise obj
472
+ else
473
+ raise(
474
+ ::NoResponse::Models::Errors::APIStatusError.new(
475
+ status_code: http_response.status,
476
+ body: http_response.env.response_body,
477
+ raw_response: http_response
478
+ ),
479
+ "Unknown content type received"
480
+ )
481
+ end
482
+ elsif Utils.match_status_code(http_response.status, ["403"])
483
+ if Utils.match_content_type(content_type, "application/problem+json")
484
+ @sdk_configuration.hooks.after_success(
485
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
486
+ hook_ctx: hook_ctx
487
+ ),
488
+ response: http_response
489
+ )
490
+ response_data = http_response.env.response_body
491
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
492
+ raise obj
493
+ else
494
+ raise(
495
+ ::NoResponse::Models::Errors::APIStatusError.new(
496
+ status_code: http_response.status,
497
+ body: http_response.env.response_body,
498
+ raw_response: http_response
499
+ ),
500
+ "Unknown content type received"
501
+ )
502
+ end
503
+ elsif Utils.match_status_code(http_response.status, ["404"])
504
+ if Utils.match_content_type(content_type, "application/problem+json")
505
+ @sdk_configuration.hooks.after_success(
506
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
507
+ hook_ctx: hook_ctx
508
+ ),
509
+ response: http_response
510
+ )
511
+ response_data = http_response.env.response_body
512
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
513
+ raise obj
514
+ else
515
+ raise(
516
+ ::NoResponse::Models::Errors::APIStatusError.new(
517
+ status_code: http_response.status,
518
+ body: http_response.env.response_body,
519
+ raw_response: http_response
520
+ ),
521
+ "Unknown content type received"
522
+ )
523
+ end
524
+ elsif Utils.match_status_code(http_response.status, ["409"])
525
+ if Utils.match_content_type(content_type, "application/problem+json")
526
+ @sdk_configuration.hooks.after_success(
527
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
528
+ hook_ctx: hook_ctx
529
+ ),
530
+ response: http_response
531
+ )
532
+ response_data = http_response.env.response_body
533
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
534
+ raise obj
535
+ else
536
+ raise(
537
+ ::NoResponse::Models::Errors::APIStatusError.new(
538
+ status_code: http_response.status,
539
+ body: http_response.env.response_body,
540
+ raw_response: http_response
541
+ ),
542
+ "Unknown content type received"
543
+ )
544
+ end
545
+ elsif Utils.match_status_code(http_response.status, ["429"])
546
+ if Utils.match_content_type(content_type, "application/problem+json")
547
+ @sdk_configuration.hooks.after_success(
548
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
549
+ hook_ctx: hook_ctx
550
+ ),
551
+ response: http_response
552
+ )
553
+ response_data = http_response.env.response_body
554
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
555
+ raise obj
556
+ else
557
+ raise(
558
+ ::NoResponse::Models::Errors::APIStatusError.new(
559
+ status_code: http_response.status,
560
+ body: http_response.env.response_body,
561
+ raw_response: http_response
562
+ ),
563
+ "Unknown content type received"
564
+ )
565
+ end
566
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
567
+ raise(
568
+ ::NoResponse::Models::Errors::APIStatusError.new(
569
+ status_code: http_response.status,
570
+ body: http_response.env.response_body,
571
+ raw_response: http_response
572
+ ),
573
+ "API error occurred"
574
+ )
575
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
576
+ raise(
577
+ ::NoResponse::Models::Errors::APIStatusError.new(
578
+ status_code: http_response.status,
579
+ body: http_response.env.response_body,
580
+ raw_response: http_response
581
+ ),
582
+ "API error occurred"
583
+ )
584
+ else
585
+ raise(
586
+ ::NoResponse::Models::Errors::APIStatusError.new(
587
+ status_code: http_response.status,
588
+ body: http_response.env.response_body,
589
+ raw_response: http_response
590
+ ),
591
+ "Unknown status code received"
592
+ )
593
+
594
+ end
595
+ end
596
+
597
+ sig {
598
+ params(
599
+ integration_id: ::String,
600
+ retries: T.nilable(Utils::RetryConfig),
601
+ timeout_ms: T.nilable(Integer),
602
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
603
+ )
604
+ .returns(Models::Operations::DeleteIntegrationResponse)
605
+ }
606
+ def delete(integration_id:, retries: nil, timeout_ms: nil, http_headers: nil)
607
+ # delete - Delete an integration.
608
+ # Removes the integration and its secrets; its endpoint answers 404 from then on, so remove the Action from the provider first. Requires the integrations scope. An unknown or already deleted integration answers 404.
609
+ request = Models::Operations::DeleteIntegrationRequest.new(
610
+ integration_id: integration_id
611
+ )
612
+ url, params = @sdk_configuration.get_server_details
613
+ base_url = Utils.template_url(url, params)
614
+ url = Utils.generate_url(
615
+ Models::Operations::DeleteIntegrationRequest,
616
+ base_url,
617
+ "/v1/integrations/{integration_id}",
618
+ request
619
+ )
620
+ headers = {}
621
+ headers = T.cast(headers, T::Hash[String, String])
622
+ headers["Accept"] = "application/problem+json"
623
+ headers["user-agent"] = @sdk_configuration.user_agent
624
+ retries ||= @sdk_configuration.retry_config
625
+ retries ||= Utils::RetryConfig.new(
626
+ backoff: Utils::BackoffStrategy.new(
627
+ exponent: 2.0,
628
+ initial_interval: 500,
629
+ max_elapsed_time: 30_000,
630
+ max_interval: 8000
631
+ ),
632
+ retry_connection_errors: true,
633
+ strategy: "backoff"
634
+ )
635
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
636
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
637
+
638
+ security = @sdk_configuration.security_source&.call
639
+
640
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
641
+ timeout ||= @sdk_configuration.timeout
642
+
643
+ connection = @sdk_configuration.client.dup
644
+ connection.use(Utils::RetryMiddleware, retry_options)
645
+
646
+ hook_ctx = SDKHooks::HookContext.new(
647
+ config: @sdk_configuration,
648
+ base_url: base_url,
649
+ oauth2_scopes: nil,
650
+ operation_id: "deleteIntegration",
651
+ security_source: @sdk_configuration.security_source
652
+ )
653
+
654
+ error = T.let(nil, T.nilable(StandardError))
655
+ http_response = T.let(nil, T.nilable(Faraday::Response))
656
+
657
+ begin
658
+ http_response = T.must(connection).delete(url) do |req|
659
+ req.headers.merge!(headers)
660
+ req.options.timeout = timeout unless timeout.nil?
661
+ Utils.configure_request_security(req, security)
662
+ http_headers&.each do |key, value|
663
+ req.headers[key.to_s] = value
664
+ end
665
+
666
+ @sdk_configuration.hooks.before_request(
667
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
668
+ hook_ctx: hook_ctx
669
+ ),
670
+ request: req
671
+ )
672
+ end
673
+
674
+ rescue StandardError => e
675
+ error = e
676
+ ensure
677
+ if http_response.nil? || Utils.error_status?(http_response.status)
678
+ http_response = @sdk_configuration.hooks.after_error(
679
+ error: error,
680
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
681
+ hook_ctx: hook_ctx
682
+ ),
683
+ response: http_response
684
+ )
685
+ else
686
+ http_response = @sdk_configuration.hooks.after_success(
687
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
688
+ hook_ctx: hook_ctx
689
+ ),
690
+ response: http_response
691
+ )
692
+ end
693
+
694
+ if http_response.nil?
695
+ raise error if !error.nil?
696
+ raise "no response"
697
+ end
698
+ end
699
+
700
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
701
+ if Utils.match_status_code(http_response.status, ["204"])
702
+ @sdk_configuration.hooks.after_success(
703
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
704
+ hook_ctx: hook_ctx
705
+ ),
706
+ response: http_response
707
+ )
708
+ return Models::Operations::DeleteIntegrationResponse.new(
709
+ headers: {}
710
+ )
711
+ elsif Utils.match_status_code(http_response.status, ["400"])
712
+ if Utils.match_content_type(content_type, "application/problem+json")
713
+ @sdk_configuration.hooks.after_success(
714
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
715
+ hook_ctx: hook_ctx
716
+ ),
717
+ response: http_response
718
+ )
719
+ response_data = http_response.env.response_body
720
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
721
+ raise obj
722
+ else
723
+ raise(
724
+ ::NoResponse::Models::Errors::APIStatusError.new(
725
+ status_code: http_response.status,
726
+ body: http_response.env.response_body,
727
+ raw_response: http_response
728
+ ),
729
+ "Unknown content type received"
730
+ )
731
+ end
732
+ elsif Utils.match_status_code(http_response.status, ["401"])
733
+ if Utils.match_content_type(content_type, "application/problem+json")
734
+ @sdk_configuration.hooks.after_success(
735
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
736
+ hook_ctx: hook_ctx
737
+ ),
738
+ response: http_response
739
+ )
740
+ response_data = http_response.env.response_body
741
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
742
+ raise obj
743
+ else
744
+ raise(
745
+ ::NoResponse::Models::Errors::APIStatusError.new(
746
+ status_code: http_response.status,
747
+ body: http_response.env.response_body,
748
+ raw_response: http_response
749
+ ),
750
+ "Unknown content type received"
751
+ )
752
+ end
753
+ elsif Utils.match_status_code(http_response.status, ["403"])
754
+ if Utils.match_content_type(content_type, "application/problem+json")
755
+ @sdk_configuration.hooks.after_success(
756
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
757
+ hook_ctx: hook_ctx
758
+ ),
759
+ response: http_response
760
+ )
761
+ response_data = http_response.env.response_body
762
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
763
+ raise obj
764
+ else
765
+ raise(
766
+ ::NoResponse::Models::Errors::APIStatusError.new(
767
+ status_code: http_response.status,
768
+ body: http_response.env.response_body,
769
+ raw_response: http_response
770
+ ),
771
+ "Unknown content type received"
772
+ )
773
+ end
774
+ elsif Utils.match_status_code(http_response.status, ["404"])
775
+ if Utils.match_content_type(content_type, "application/problem+json")
776
+ @sdk_configuration.hooks.after_success(
777
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
778
+ hook_ctx: hook_ctx
779
+ ),
780
+ response: http_response
781
+ )
782
+ response_data = http_response.env.response_body
783
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
784
+ raise obj
785
+ else
786
+ raise(
787
+ ::NoResponse::Models::Errors::APIStatusError.new(
788
+ status_code: http_response.status,
789
+ body: http_response.env.response_body,
790
+ raw_response: http_response
791
+ ),
792
+ "Unknown content type received"
793
+ )
794
+ end
795
+ elsif Utils.match_status_code(http_response.status, ["409"])
796
+ if Utils.match_content_type(content_type, "application/problem+json")
797
+ @sdk_configuration.hooks.after_success(
798
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
799
+ hook_ctx: hook_ctx
800
+ ),
801
+ response: http_response
802
+ )
803
+ response_data = http_response.env.response_body
804
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
805
+ raise obj
806
+ else
807
+ raise(
808
+ ::NoResponse::Models::Errors::APIStatusError.new(
809
+ status_code: http_response.status,
810
+ body: http_response.env.response_body,
811
+ raw_response: http_response
812
+ ),
813
+ "Unknown content type received"
814
+ )
815
+ end
816
+ elsif Utils.match_status_code(http_response.status, ["429"])
817
+ if Utils.match_content_type(content_type, "application/problem+json")
818
+ @sdk_configuration.hooks.after_success(
819
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
820
+ hook_ctx: hook_ctx
821
+ ),
822
+ response: http_response
823
+ )
824
+ response_data = http_response.env.response_body
825
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
826
+ raise obj
827
+ else
828
+ raise(
829
+ ::NoResponse::Models::Errors::APIStatusError.new(
830
+ status_code: http_response.status,
831
+ body: http_response.env.response_body,
832
+ raw_response: http_response
833
+ ),
834
+ "Unknown content type received"
835
+ )
836
+ end
837
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
838
+ raise(
839
+ ::NoResponse::Models::Errors::APIStatusError.new(
840
+ status_code: http_response.status,
841
+ body: http_response.env.response_body,
842
+ raw_response: http_response
843
+ ),
844
+ "API error occurred"
845
+ )
846
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
847
+ raise(
848
+ ::NoResponse::Models::Errors::APIStatusError.new(
849
+ status_code: http_response.status,
850
+ body: http_response.env.response_body,
851
+ raw_response: http_response
852
+ ),
853
+ "API error occurred"
854
+ )
855
+ else
856
+ raise(
857
+ ::NoResponse::Models::Errors::APIStatusError.new(
858
+ status_code: http_response.status,
859
+ body: http_response.env.response_body,
860
+ raw_response: http_response
861
+ ),
862
+ "Unknown status code received"
863
+ )
864
+
865
+ end
866
+ end
867
+
868
+ sig {
869
+ params(
870
+ body: Models::Shared::IntegrationRotationRequest,
871
+ integration_id: ::String,
872
+ timeout_ms: T.nilable(Integer),
873
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
874
+ )
875
+ .returns(Models::Operations::RotateIntegrationSecretResponse)
876
+ }
877
+ def rotate(body:, integration_id:, timeout_ms: nil, http_headers: nil)
878
+ # rotate - Replace an integration's secret.
879
+ # For Auth0, send {} and the answer's secret is the new shared secret, shown once. For WorkOS, regenerate the Actions secret in the WorkOS dashboard and send it as signing_secret. The replaced secret is still accepted for 24 hours (previous_secret_expires_at). Requires the integrations scope. Not idempotent: a retry after a lost answer rotates again.
880
+ request = Models::Operations::RotateIntegrationSecretRequest.new(
881
+ integration_id: integration_id,
882
+ body: body
883
+ )
884
+ url, params = @sdk_configuration.get_server_details
885
+ base_url = Utils.template_url(url, params)
886
+ url = Utils.generate_url(
887
+ Models::Operations::RotateIntegrationSecretRequest,
888
+ base_url,
889
+ "/v1/integrations/{integration_id}/rotate",
890
+ request
891
+ )
892
+ headers = {}
893
+ headers = T.cast(headers, T::Hash[String, String])
894
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
895
+ headers["content-type"] = req_content_type
896
+ raise StandardError, "request body is required" if data.nil? && form.nil?
897
+
898
+ if form && !form.empty?
899
+ body = Utils.encode_form(form)
900
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
901
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
902
+ else
903
+ body = data
904
+ end
905
+
906
+ headers["Accept"] = "application/json"
907
+ headers["user-agent"] = @sdk_configuration.user_agent
908
+
909
+ security = @sdk_configuration.security_source&.call
910
+
911
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
912
+ timeout ||= @sdk_configuration.timeout
913
+
914
+ connection = @sdk_configuration.client
915
+
916
+ hook_ctx = SDKHooks::HookContext.new(
917
+ config: @sdk_configuration,
918
+ base_url: base_url,
919
+ oauth2_scopes: nil,
920
+ operation_id: "rotateIntegrationSecret",
921
+ security_source: @sdk_configuration.security_source
922
+ )
923
+
924
+ error = T.let(nil, T.nilable(StandardError))
925
+ http_response = T.let(nil, T.nilable(Faraday::Response))
926
+
927
+ begin
928
+ http_response = T.must(connection).post(url) do |req|
929
+ req.body = body
930
+ req.headers.merge!(headers)
931
+ req.options.timeout = timeout unless timeout.nil?
932
+ Utils.configure_request_security(req, security)
933
+ http_headers&.each do |key, value|
934
+ req.headers[key.to_s] = value
935
+ end
936
+
937
+ @sdk_configuration.hooks.before_request(
938
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
939
+ hook_ctx: hook_ctx
940
+ ),
941
+ request: req
942
+ )
943
+ end
944
+
945
+ rescue StandardError => e
946
+ error = e
947
+ ensure
948
+ if http_response.nil? || Utils.error_status?(http_response.status)
949
+ http_response = @sdk_configuration.hooks.after_error(
950
+ error: error,
951
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
952
+ hook_ctx: hook_ctx
953
+ ),
954
+ response: http_response
955
+ )
956
+ else
957
+ http_response = @sdk_configuration.hooks.after_success(
958
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
959
+ hook_ctx: hook_ctx
960
+ ),
961
+ response: http_response
962
+ )
963
+ end
964
+
965
+ if http_response.nil?
966
+ raise error if !error.nil?
967
+ raise "no response"
968
+ end
969
+ end
970
+
971
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
972
+ if Utils.match_status_code(http_response.status, ["200"])
973
+ if Utils.match_content_type(content_type, "application/json")
974
+ @sdk_configuration.hooks.after_success(
975
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
976
+ hook_ctx: hook_ctx
977
+ ),
978
+ response: http_response
979
+ )
980
+ response_data = http_response.env.response_body
981
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::Integration)
982
+ result = obj
983
+ response = Models::Operations::RotateIntegrationSecretResponse.new(
984
+ result: result,
985
+ headers: http_response.headers
986
+ )
987
+
988
+ return response
989
+ else
990
+ raise(
991
+ ::NoResponse::Models::Errors::APIStatusError.new(
992
+ status_code: http_response.status,
993
+ body: http_response.env.response_body,
994
+ raw_response: http_response
995
+ ),
996
+ "Unknown content type received"
997
+ )
998
+ end
999
+ elsif Utils.match_status_code(http_response.status, ["400"])
1000
+ if Utils.match_content_type(content_type, "application/problem+json")
1001
+ @sdk_configuration.hooks.after_success(
1002
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1003
+ hook_ctx: hook_ctx
1004
+ ),
1005
+ response: http_response
1006
+ )
1007
+ response_data = http_response.env.response_body
1008
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1009
+ raise obj
1010
+ else
1011
+ raise(
1012
+ ::NoResponse::Models::Errors::APIStatusError.new(
1013
+ status_code: http_response.status,
1014
+ body: http_response.env.response_body,
1015
+ raw_response: http_response
1016
+ ),
1017
+ "Unknown content type received"
1018
+ )
1019
+ end
1020
+ elsif Utils.match_status_code(http_response.status, ["401"])
1021
+ if Utils.match_content_type(content_type, "application/problem+json")
1022
+ @sdk_configuration.hooks.after_success(
1023
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1024
+ hook_ctx: hook_ctx
1025
+ ),
1026
+ response: http_response
1027
+ )
1028
+ response_data = http_response.env.response_body
1029
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1030
+ raise obj
1031
+ else
1032
+ raise(
1033
+ ::NoResponse::Models::Errors::APIStatusError.new(
1034
+ status_code: http_response.status,
1035
+ body: http_response.env.response_body,
1036
+ raw_response: http_response
1037
+ ),
1038
+ "Unknown content type received"
1039
+ )
1040
+ end
1041
+ elsif Utils.match_status_code(http_response.status, ["403"])
1042
+ if Utils.match_content_type(content_type, "application/problem+json")
1043
+ @sdk_configuration.hooks.after_success(
1044
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1045
+ hook_ctx: hook_ctx
1046
+ ),
1047
+ response: http_response
1048
+ )
1049
+ response_data = http_response.env.response_body
1050
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1051
+ raise obj
1052
+ else
1053
+ raise(
1054
+ ::NoResponse::Models::Errors::APIStatusError.new(
1055
+ status_code: http_response.status,
1056
+ body: http_response.env.response_body,
1057
+ raw_response: http_response
1058
+ ),
1059
+ "Unknown content type received"
1060
+ )
1061
+ end
1062
+ elsif Utils.match_status_code(http_response.status, ["404"])
1063
+ if Utils.match_content_type(content_type, "application/problem+json")
1064
+ @sdk_configuration.hooks.after_success(
1065
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1066
+ hook_ctx: hook_ctx
1067
+ ),
1068
+ response: http_response
1069
+ )
1070
+ response_data = http_response.env.response_body
1071
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1072
+ raise obj
1073
+ else
1074
+ raise(
1075
+ ::NoResponse::Models::Errors::APIStatusError.new(
1076
+ status_code: http_response.status,
1077
+ body: http_response.env.response_body,
1078
+ raw_response: http_response
1079
+ ),
1080
+ "Unknown content type received"
1081
+ )
1082
+ end
1083
+ elsif Utils.match_status_code(http_response.status, ["409"])
1084
+ if Utils.match_content_type(content_type, "application/problem+json")
1085
+ @sdk_configuration.hooks.after_success(
1086
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1087
+ hook_ctx: hook_ctx
1088
+ ),
1089
+ response: http_response
1090
+ )
1091
+ response_data = http_response.env.response_body
1092
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1093
+ raise obj
1094
+ else
1095
+ raise(
1096
+ ::NoResponse::Models::Errors::APIStatusError.new(
1097
+ status_code: http_response.status,
1098
+ body: http_response.env.response_body,
1099
+ raw_response: http_response
1100
+ ),
1101
+ "Unknown content type received"
1102
+ )
1103
+ end
1104
+ elsif Utils.match_status_code(http_response.status, ["429"])
1105
+ if Utils.match_content_type(content_type, "application/problem+json")
1106
+ @sdk_configuration.hooks.after_success(
1107
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1108
+ hook_ctx: hook_ctx
1109
+ ),
1110
+ response: http_response
1111
+ )
1112
+ response_data = http_response.env.response_body
1113
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1114
+ raise obj
1115
+ else
1116
+ raise(
1117
+ ::NoResponse::Models::Errors::APIStatusError.new(
1118
+ status_code: http_response.status,
1119
+ body: http_response.env.response_body,
1120
+ raw_response: http_response
1121
+ ),
1122
+ "Unknown content type received"
1123
+ )
1124
+ end
1125
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1126
+ raise(
1127
+ ::NoResponse::Models::Errors::APIStatusError.new(
1128
+ status_code: http_response.status,
1129
+ body: http_response.env.response_body,
1130
+ raw_response: http_response
1131
+ ),
1132
+ "API error occurred"
1133
+ )
1134
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1135
+ raise(
1136
+ ::NoResponse::Models::Errors::APIStatusError.new(
1137
+ status_code: http_response.status,
1138
+ body: http_response.env.response_body,
1139
+ raw_response: http_response
1140
+ ),
1141
+ "API error occurred"
1142
+ )
1143
+ else
1144
+ raise(
1145
+ ::NoResponse::Models::Errors::APIStatusError.new(
1146
+ status_code: http_response.status,
1147
+ body: http_response.env.response_body,
1148
+ raw_response: http_response
1149
+ ),
1150
+ "Unknown status code received"
1151
+ )
1152
+
1153
+ end
1154
+ end
1155
+ end
1156
+ end