noresponse 8.1.1 → 8.1.3

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/no_response/lists.rb +908 -0
  3. data/lib/no_response/models/operations/createlistentry_request.rb +52 -0
  4. data/lib/no_response/models/operations/createlistentry_request.rbi +26 -0
  5. data/lib/no_response/models/operations/createlistentry_response.rb +32 -0
  6. data/lib/no_response/models/operations/createlistentry_response.rbi +20 -0
  7. data/lib/no_response/models/operations/deletelistentry_request.rb +51 -0
  8. data/lib/no_response/models/operations/deletelistentry_request.rbi +26 -0
  9. data/lib/no_response/models/operations/deletelistentry_response.rb +28 -0
  10. data/lib/no_response/models/operations/deletelistentry_response.rbi +14 -0
  11. data/lib/no_response/models/operations/listlistentries_request.rb +41 -0
  12. data/lib/no_response/models/operations/listlistentries_request.rbi +20 -0
  13. data/lib/no_response/models/operations/listlistentries_response.rb +32 -0
  14. data/lib/no_response/models/operations/listlistentries_response.rbi +20 -0
  15. data/lib/no_response/models/operations.rb +6 -0
  16. data/lib/no_response/models/shared/accountriskreason.rb +11 -2
  17. data/lib/no_response/models/shared/accountriskreason.rbi +6 -0
  18. data/lib/no_response/models/shared/conflicterrorcode.rb +3 -0
  19. data/lib/no_response/models/shared/listentry.rb +124 -0
  20. data/lib/no_response/models/shared/listentry.rbi +62 -0
  21. data/lib/no_response/models/shared/listentryaction.rb +19 -0
  22. data/lib/no_response/models/shared/listentryaction.rbi +9 -0
  23. data/lib/no_response/models/shared/listentrykind.rb +19 -0
  24. data/lib/no_response/models/shared/listentrykind.rbi +9 -0
  25. data/lib/no_response/models/shared/listentrylist.rb +32 -0
  26. data/lib/no_response/models/shared/listentrylist.rbi +14 -0
  27. data/lib/no_response/models/shared/listentryrequest.rb +77 -0
  28. data/lib/no_response/models/shared/listentryrequest.rbi +32 -0
  29. data/lib/no_response/models/shared/reasoncode.rb +1 -0
  30. data/lib/no_response/models/shared/riskreason.rb +11 -2
  31. data/lib/no_response/models/shared/riskreason.rbi +6 -0
  32. data/lib/no_response/models/shared.rb +5 -0
  33. data/lib/no_response/noresponseclient.rb +2 -1
  34. data/lib/no_response/sdkconfiguration.rb +2 -2
  35. data/lib/noresponse.rb +1 -0
  36. metadata +25 -2
@@ -0,0 +1,908 @@
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 Lists
16
+ extend T::Sig
17
+
18
+ sig { params(sdk_config: SDKConfiguration).void }
19
+ def initialize(sdk_config)
20
+ @sdk_configuration = sdk_config
21
+ end
22
+
23
+ sig { params(base_url: String, url_variables: T.nilable(T::Hash[Symbol, T.any(String, T::Enum)])).returns(String) }
24
+ def get_url(base_url:, url_variables: nil)
25
+ sd_base_url, sd_options = @sdk_configuration.get_server_details
26
+
27
+ if base_url.nil?
28
+ base_url = sd_base_url
29
+ end
30
+
31
+ if url_variables.nil?
32
+ url_variables = sd_options
33
+ end
34
+
35
+ return Utils.template_url(base_url, url_variables)
36
+ end
37
+
38
+ sig {
39
+ params(
40
+ workspace_id: ::String,
41
+ environment: Models::Shared::KeyEnvironment,
42
+ retries: T.nilable(Utils::RetryConfig),
43
+ timeout_ms: T.nilable(Integer),
44
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
45
+ )
46
+ .returns(Models::Operations::ListListEntriesResponse)
47
+ }
48
+ def list(workspace_id:, environment:, retries: nil, timeout_ms: nil, http_headers: nil)
49
+ # list - List an environment's list entries.
50
+ # Lists every entry of the signing key's environment's list, newest first: each an email or an email domain that decides the accounts it matches, block or allow, whatever their score. Requires the management scope; the other environment answers 404 not_found. Read-only and safe to retry.
51
+ request = Models::Operations::ListListEntriesRequest.new(
52
+ workspace_id: workspace_id,
53
+ environment: environment
54
+ )
55
+ url, params = @sdk_configuration.get_server_details
56
+ base_url = Utils.template_url(url, params)
57
+ url = Utils.generate_url(
58
+ Models::Operations::ListListEntriesRequest,
59
+ base_url,
60
+ "/v1/workspaces/{workspace_id}/lists/{environment}",
61
+ request
62
+ )
63
+ headers = {}
64
+ headers = T.cast(headers, T::Hash[String, String])
65
+ headers["Accept"] = "application/json"
66
+ headers["user-agent"] = @sdk_configuration.user_agent
67
+ retries ||= @sdk_configuration.retry_config
68
+ retries ||= Utils::RetryConfig.new(
69
+ backoff: Utils::BackoffStrategy.new(
70
+ exponent: 2.0,
71
+ initial_interval: 500,
72
+ max_elapsed_time: 30_000,
73
+ max_interval: 8000
74
+ ),
75
+ retry_connection_errors: true,
76
+ strategy: "backoff"
77
+ )
78
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
79
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
80
+
81
+ security = @sdk_configuration.security_source&.call
82
+
83
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
84
+ timeout ||= @sdk_configuration.timeout
85
+
86
+ connection = @sdk_configuration.client.dup
87
+ connection.use(Utils::RetryMiddleware, retry_options)
88
+
89
+ hook_ctx = SDKHooks::HookContext.new(
90
+ config: @sdk_configuration,
91
+ base_url: base_url,
92
+ oauth2_scopes: nil,
93
+ operation_id: "listListEntries",
94
+ security_source: @sdk_configuration.security_source
95
+ )
96
+
97
+ error = T.let(nil, T.nilable(StandardError))
98
+ http_response = T.let(nil, T.nilable(Faraday::Response))
99
+
100
+ begin
101
+ http_response = T.must(connection).get(url) do |req|
102
+ req.headers.merge!(headers)
103
+ req.options.timeout = timeout unless timeout.nil?
104
+ Utils.configure_request_security(req, security)
105
+ http_headers&.each do |key, value|
106
+ req.headers[key.to_s] = value
107
+ end
108
+
109
+ @sdk_configuration.hooks.before_request(
110
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
111
+ hook_ctx: hook_ctx
112
+ ),
113
+ request: req
114
+ )
115
+ end
116
+
117
+ rescue StandardError => e
118
+ error = e
119
+ ensure
120
+ if http_response.nil? || Utils.error_status?(http_response.status)
121
+ http_response = @sdk_configuration.hooks.after_error(
122
+ error: error,
123
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
124
+ hook_ctx: hook_ctx
125
+ ),
126
+ response: http_response
127
+ )
128
+ else
129
+ http_response = @sdk_configuration.hooks.after_success(
130
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
131
+ hook_ctx: hook_ctx
132
+ ),
133
+ response: http_response
134
+ )
135
+ end
136
+
137
+ if http_response.nil?
138
+ raise error if !error.nil?
139
+ raise "no response"
140
+ end
141
+ end
142
+
143
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
144
+ if Utils.match_status_code(http_response.status, ["200"])
145
+ if Utils.match_content_type(content_type, "application/json")
146
+ @sdk_configuration.hooks.after_success(
147
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
148
+ hook_ctx: hook_ctx
149
+ ),
150
+ response: http_response
151
+ )
152
+ response_data = http_response.env.response_body
153
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::ListEntryList)
154
+ result = obj
155
+ response = Models::Operations::ListListEntriesResponse.new(
156
+ result: result,
157
+ headers: http_response.headers
158
+ )
159
+
160
+ return response
161
+ else
162
+ raise(
163
+ ::NoResponse::Models::Errors::APIStatusError.new(
164
+ status_code: http_response.status,
165
+ body: http_response.env.response_body,
166
+ raw_response: http_response
167
+ ),
168
+ "Unknown content type received"
169
+ )
170
+ end
171
+ elsif Utils.match_status_code(http_response.status, ["400"])
172
+ if Utils.match_content_type(content_type, "application/problem+json")
173
+ @sdk_configuration.hooks.after_success(
174
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
175
+ hook_ctx: hook_ctx
176
+ ),
177
+ response: http_response
178
+ )
179
+ response_data = http_response.env.response_body
180
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
181
+ raise obj
182
+ else
183
+ raise(
184
+ ::NoResponse::Models::Errors::APIStatusError.new(
185
+ status_code: http_response.status,
186
+ body: http_response.env.response_body,
187
+ raw_response: http_response
188
+ ),
189
+ "Unknown content type received"
190
+ )
191
+ end
192
+ elsif Utils.match_status_code(http_response.status, ["401"])
193
+ if Utils.match_content_type(content_type, "application/problem+json")
194
+ @sdk_configuration.hooks.after_success(
195
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
196
+ hook_ctx: hook_ctx
197
+ ),
198
+ response: http_response
199
+ )
200
+ response_data = http_response.env.response_body
201
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
202
+ raise obj
203
+ else
204
+ raise(
205
+ ::NoResponse::Models::Errors::APIStatusError.new(
206
+ status_code: http_response.status,
207
+ body: http_response.env.response_body,
208
+ raw_response: http_response
209
+ ),
210
+ "Unknown content type received"
211
+ )
212
+ end
213
+ elsif Utils.match_status_code(http_response.status, ["403"])
214
+ if Utils.match_content_type(content_type, "application/problem+json")
215
+ @sdk_configuration.hooks.after_success(
216
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
217
+ hook_ctx: hook_ctx
218
+ ),
219
+ response: http_response
220
+ )
221
+ response_data = http_response.env.response_body
222
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
223
+ raise obj
224
+ else
225
+ raise(
226
+ ::NoResponse::Models::Errors::APIStatusError.new(
227
+ status_code: http_response.status,
228
+ body: http_response.env.response_body,
229
+ raw_response: http_response
230
+ ),
231
+ "Unknown content type received"
232
+ )
233
+ end
234
+ elsif Utils.match_status_code(http_response.status, ["404"])
235
+ if Utils.match_content_type(content_type, "application/problem+json")
236
+ @sdk_configuration.hooks.after_success(
237
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
238
+ hook_ctx: hook_ctx
239
+ ),
240
+ response: http_response
241
+ )
242
+ response_data = http_response.env.response_body
243
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
244
+ raise obj
245
+ else
246
+ raise(
247
+ ::NoResponse::Models::Errors::APIStatusError.new(
248
+ status_code: http_response.status,
249
+ body: http_response.env.response_body,
250
+ raw_response: http_response
251
+ ),
252
+ "Unknown content type received"
253
+ )
254
+ end
255
+ elsif Utils.match_status_code(http_response.status, ["409"])
256
+ if Utils.match_content_type(content_type, "application/problem+json")
257
+ @sdk_configuration.hooks.after_success(
258
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
259
+ hook_ctx: hook_ctx
260
+ ),
261
+ response: http_response
262
+ )
263
+ response_data = http_response.env.response_body
264
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
265
+ raise obj
266
+ else
267
+ raise(
268
+ ::NoResponse::Models::Errors::APIStatusError.new(
269
+ status_code: http_response.status,
270
+ body: http_response.env.response_body,
271
+ raw_response: http_response
272
+ ),
273
+ "Unknown content type received"
274
+ )
275
+ end
276
+ elsif Utils.match_status_code(http_response.status, ["429"])
277
+ if Utils.match_content_type(content_type, "application/problem+json")
278
+ @sdk_configuration.hooks.after_success(
279
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
280
+ hook_ctx: hook_ctx
281
+ ),
282
+ response: http_response
283
+ )
284
+ response_data = http_response.env.response_body
285
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
286
+ raise obj
287
+ else
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
+ "Unknown content type received"
295
+ )
296
+ end
297
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
298
+ raise(
299
+ ::NoResponse::Models::Errors::APIStatusError.new(
300
+ status_code: http_response.status,
301
+ body: http_response.env.response_body,
302
+ raw_response: http_response
303
+ ),
304
+ "API error occurred"
305
+ )
306
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
307
+ raise(
308
+ ::NoResponse::Models::Errors::APIStatusError.new(
309
+ status_code: http_response.status,
310
+ body: http_response.env.response_body,
311
+ raw_response: http_response
312
+ ),
313
+ "API error occurred"
314
+ )
315
+ else
316
+ raise(
317
+ ::NoResponse::Models::Errors::APIStatusError.new(
318
+ status_code: http_response.status,
319
+ body: http_response.env.response_body,
320
+ raw_response: http_response
321
+ ),
322
+ "Unknown status code received"
323
+ )
324
+
325
+ end
326
+ end
327
+
328
+ sig {
329
+ params(
330
+ body: Models::Shared::ListEntryRequest,
331
+ workspace_id: ::String,
332
+ environment: Models::Shared::KeyEnvironment,
333
+ retries: T.nilable(Utils::RetryConfig),
334
+ timeout_ms: T.nilable(Integer),
335
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
336
+ )
337
+ .returns(Models::Operations::CreateListEntryResponse)
338
+ }
339
+ def create(body:, workspace_id:, environment:, retries: nil, timeout_ms: nil, http_headers: nil)
340
+ # create - Add an entry to an environment's list.
341
+ # Adds an exact email (kind email) or an email domain (kind email_domain) to the signing key's environment's list with the action block or allow, and answers the entry with its value in canonical form. An account matches when one of its assessments sent the email, or an email of the domain: a block entry decides block for every flow and an allow entry allow, block winning when both match, and the account's risk carries list_match with the entry's id while its score is unchanged. Every matching account is re-decided at once and sends account.risk_changed when its decision changes. A value already on the list answers 409 list_entry_exists, a full list 409 list_limit_reached, and an entry matching more than 5,000 accounts 409 list_entry_too_broad. Requires the management scope; the other environment answers 404 not_found.
342
+ request = Models::Operations::CreateListEntryRequest.new(
343
+ workspace_id: workspace_id,
344
+ environment: environment,
345
+ body: body
346
+ )
347
+ url, params = @sdk_configuration.get_server_details
348
+ base_url = Utils.template_url(url, params)
349
+ url = Utils.generate_url(
350
+ Models::Operations::CreateListEntryRequest,
351
+ base_url,
352
+ "/v1/workspaces/{workspace_id}/lists/{environment}",
353
+ request
354
+ )
355
+ headers = {}
356
+ headers = T.cast(headers, T::Hash[String, String])
357
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
358
+ headers["content-type"] = req_content_type
359
+ raise StandardError, "request body is required" if data.nil? && form.nil?
360
+
361
+ if form && !form.empty?
362
+ body = Utils.encode_form(form)
363
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
364
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
365
+ else
366
+ body = data
367
+ end
368
+
369
+ headers["Accept"] = "application/json"
370
+ headers["user-agent"] = @sdk_configuration.user_agent
371
+ retries ||= @sdk_configuration.retry_config
372
+ retries ||= Utils::RetryConfig.new(
373
+ backoff: Utils::BackoffStrategy.new(
374
+ exponent: 2.0,
375
+ initial_interval: 500,
376
+ max_elapsed_time: 30_000,
377
+ max_interval: 8000
378
+ ),
379
+ retry_connection_errors: true,
380
+ strategy: "backoff"
381
+ )
382
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
383
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
384
+
385
+ security = @sdk_configuration.security_source&.call
386
+
387
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
388
+ timeout ||= @sdk_configuration.timeout
389
+
390
+ connection = @sdk_configuration.client.dup
391
+ connection.use(Utils::RetryMiddleware, retry_options)
392
+
393
+ hook_ctx = SDKHooks::HookContext.new(
394
+ config: @sdk_configuration,
395
+ base_url: base_url,
396
+ oauth2_scopes: nil,
397
+ operation_id: "createListEntry",
398
+ security_source: @sdk_configuration.security_source
399
+ )
400
+
401
+ error = T.let(nil, T.nilable(StandardError))
402
+ http_response = T.let(nil, T.nilable(Faraday::Response))
403
+
404
+ begin
405
+ http_response = T.must(connection).post(url) do |req|
406
+ req.body = body
407
+ req.headers.merge!(headers)
408
+ req.options.timeout = timeout unless timeout.nil?
409
+ Utils.configure_request_security(req, security)
410
+ http_headers&.each do |key, value|
411
+ req.headers[key.to_s] = value
412
+ end
413
+
414
+ @sdk_configuration.hooks.before_request(
415
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
416
+ hook_ctx: hook_ctx
417
+ ),
418
+ request: req
419
+ )
420
+ end
421
+
422
+ rescue StandardError => e
423
+ error = e
424
+ ensure
425
+ if http_response.nil? || Utils.error_status?(http_response.status)
426
+ http_response = @sdk_configuration.hooks.after_error(
427
+ error: error,
428
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
429
+ hook_ctx: hook_ctx
430
+ ),
431
+ response: http_response
432
+ )
433
+ else
434
+ http_response = @sdk_configuration.hooks.after_success(
435
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
436
+ hook_ctx: hook_ctx
437
+ ),
438
+ response: http_response
439
+ )
440
+ end
441
+
442
+ if http_response.nil?
443
+ raise error if !error.nil?
444
+ raise "no response"
445
+ end
446
+ end
447
+
448
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
449
+ if Utils.match_status_code(http_response.status, ["201"])
450
+ if Utils.match_content_type(content_type, "application/json")
451
+ @sdk_configuration.hooks.after_success(
452
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
453
+ hook_ctx: hook_ctx
454
+ ),
455
+ response: http_response
456
+ )
457
+ response_data = http_response.env.response_body
458
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::ListEntry)
459
+ result = obj
460
+ response = Models::Operations::CreateListEntryResponse.new(
461
+ result: result,
462
+ headers: http_response.headers
463
+ )
464
+
465
+ return response
466
+ else
467
+ raise(
468
+ ::NoResponse::Models::Errors::APIStatusError.new(
469
+ status_code: http_response.status,
470
+ body: http_response.env.response_body,
471
+ raw_response: http_response
472
+ ),
473
+ "Unknown content type received"
474
+ )
475
+ end
476
+ elsif Utils.match_status_code(http_response.status, ["400"])
477
+ if Utils.match_content_type(content_type, "application/problem+json")
478
+ @sdk_configuration.hooks.after_success(
479
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
480
+ hook_ctx: hook_ctx
481
+ ),
482
+ response: http_response
483
+ )
484
+ response_data = http_response.env.response_body
485
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
486
+ raise obj
487
+ else
488
+ raise(
489
+ ::NoResponse::Models::Errors::APIStatusError.new(
490
+ status_code: http_response.status,
491
+ body: http_response.env.response_body,
492
+ raw_response: http_response
493
+ ),
494
+ "Unknown content type received"
495
+ )
496
+ end
497
+ elsif Utils.match_status_code(http_response.status, ["401"])
498
+ if Utils.match_content_type(content_type, "application/problem+json")
499
+ @sdk_configuration.hooks.after_success(
500
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
501
+ hook_ctx: hook_ctx
502
+ ),
503
+ response: http_response
504
+ )
505
+ response_data = http_response.env.response_body
506
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
507
+ raise obj
508
+ else
509
+ raise(
510
+ ::NoResponse::Models::Errors::APIStatusError.new(
511
+ status_code: http_response.status,
512
+ body: http_response.env.response_body,
513
+ raw_response: http_response
514
+ ),
515
+ "Unknown content type received"
516
+ )
517
+ end
518
+ elsif Utils.match_status_code(http_response.status, ["403"])
519
+ if Utils.match_content_type(content_type, "application/problem+json")
520
+ @sdk_configuration.hooks.after_success(
521
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
522
+ hook_ctx: hook_ctx
523
+ ),
524
+ response: http_response
525
+ )
526
+ response_data = http_response.env.response_body
527
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
528
+ raise obj
529
+ else
530
+ raise(
531
+ ::NoResponse::Models::Errors::APIStatusError.new(
532
+ status_code: http_response.status,
533
+ body: http_response.env.response_body,
534
+ raw_response: http_response
535
+ ),
536
+ "Unknown content type received"
537
+ )
538
+ end
539
+ elsif Utils.match_status_code(http_response.status, ["404"])
540
+ if Utils.match_content_type(content_type, "application/problem+json")
541
+ @sdk_configuration.hooks.after_success(
542
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
543
+ hook_ctx: hook_ctx
544
+ ),
545
+ response: http_response
546
+ )
547
+ response_data = http_response.env.response_body
548
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
549
+ raise obj
550
+ else
551
+ raise(
552
+ ::NoResponse::Models::Errors::APIStatusError.new(
553
+ status_code: http_response.status,
554
+ body: http_response.env.response_body,
555
+ raw_response: http_response
556
+ ),
557
+ "Unknown content type received"
558
+ )
559
+ end
560
+ elsif Utils.match_status_code(http_response.status, ["409"])
561
+ if Utils.match_content_type(content_type, "application/problem+json")
562
+ @sdk_configuration.hooks.after_success(
563
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
564
+ hook_ctx: hook_ctx
565
+ ),
566
+ response: http_response
567
+ )
568
+ response_data = http_response.env.response_body
569
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
570
+ raise obj
571
+ else
572
+ raise(
573
+ ::NoResponse::Models::Errors::APIStatusError.new(
574
+ status_code: http_response.status,
575
+ body: http_response.env.response_body,
576
+ raw_response: http_response
577
+ ),
578
+ "Unknown content type received"
579
+ )
580
+ end
581
+ elsif Utils.match_status_code(http_response.status, ["429"])
582
+ if Utils.match_content_type(content_type, "application/problem+json")
583
+ @sdk_configuration.hooks.after_success(
584
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
585
+ hook_ctx: hook_ctx
586
+ ),
587
+ response: http_response
588
+ )
589
+ response_data = http_response.env.response_body
590
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
591
+ raise obj
592
+ else
593
+ raise(
594
+ ::NoResponse::Models::Errors::APIStatusError.new(
595
+ status_code: http_response.status,
596
+ body: http_response.env.response_body,
597
+ raw_response: http_response
598
+ ),
599
+ "Unknown content type received"
600
+ )
601
+ end
602
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
603
+ raise(
604
+ ::NoResponse::Models::Errors::APIStatusError.new(
605
+ status_code: http_response.status,
606
+ body: http_response.env.response_body,
607
+ raw_response: http_response
608
+ ),
609
+ "API error occurred"
610
+ )
611
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
612
+ raise(
613
+ ::NoResponse::Models::Errors::APIStatusError.new(
614
+ status_code: http_response.status,
615
+ body: http_response.env.response_body,
616
+ raw_response: http_response
617
+ ),
618
+ "API error occurred"
619
+ )
620
+ else
621
+ raise(
622
+ ::NoResponse::Models::Errors::APIStatusError.new(
623
+ status_code: http_response.status,
624
+ body: http_response.env.response_body,
625
+ raw_response: http_response
626
+ ),
627
+ "Unknown status code received"
628
+ )
629
+
630
+ end
631
+ end
632
+
633
+ sig {
634
+ params(
635
+ workspace_id: ::String,
636
+ environment: Models::Shared::KeyEnvironment,
637
+ list_entry_id: ::String,
638
+ retries: T.nilable(Utils::RetryConfig),
639
+ timeout_ms: T.nilable(Integer),
640
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
641
+ )
642
+ .returns(Models::Operations::DeleteListEntryResponse)
643
+ }
644
+ def delete(workspace_id:, environment:, list_entry_id:, retries: nil, timeout_ms: nil, http_headers: nil)
645
+ # delete - Remove an entry from an environment's list.
646
+ # Removes an entry from the signing key's environment's list and re-decides the accounts it matched, the 5,000 most recently assessed at most, each sending account.risk_changed when its decision changes. An unknown or already removed entry answers 404 not_found. Requires the management scope.
647
+ request = Models::Operations::DeleteListEntryRequest.new(
648
+ workspace_id: workspace_id,
649
+ environment: environment,
650
+ list_entry_id: list_entry_id
651
+ )
652
+ url, params = @sdk_configuration.get_server_details
653
+ base_url = Utils.template_url(url, params)
654
+ url = Utils.generate_url(
655
+ Models::Operations::DeleteListEntryRequest,
656
+ base_url,
657
+ "/v1/workspaces/{workspace_id}/lists/{environment}/{list_entry_id}",
658
+ request
659
+ )
660
+ headers = {}
661
+ headers = T.cast(headers, T::Hash[String, String])
662
+ headers["Accept"] = "application/problem+json"
663
+ headers["user-agent"] = @sdk_configuration.user_agent
664
+ retries ||= @sdk_configuration.retry_config
665
+ retries ||= Utils::RetryConfig.new(
666
+ backoff: Utils::BackoffStrategy.new(
667
+ exponent: 2.0,
668
+ initial_interval: 500,
669
+ max_elapsed_time: 30_000,
670
+ max_interval: 8000
671
+ ),
672
+ retry_connection_errors: true,
673
+ strategy: "backoff"
674
+ )
675
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
676
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
677
+
678
+ security = @sdk_configuration.security_source&.call
679
+
680
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
681
+ timeout ||= @sdk_configuration.timeout
682
+
683
+ connection = @sdk_configuration.client.dup
684
+ connection.use(Utils::RetryMiddleware, retry_options)
685
+
686
+ hook_ctx = SDKHooks::HookContext.new(
687
+ config: @sdk_configuration,
688
+ base_url: base_url,
689
+ oauth2_scopes: nil,
690
+ operation_id: "deleteListEntry",
691
+ security_source: @sdk_configuration.security_source
692
+ )
693
+
694
+ error = T.let(nil, T.nilable(StandardError))
695
+ http_response = T.let(nil, T.nilable(Faraday::Response))
696
+
697
+ begin
698
+ http_response = T.must(connection).delete(url) do |req|
699
+ req.headers.merge!(headers)
700
+ req.options.timeout = timeout unless timeout.nil?
701
+ Utils.configure_request_security(req, security)
702
+ http_headers&.each do |key, value|
703
+ req.headers[key.to_s] = value
704
+ end
705
+
706
+ @sdk_configuration.hooks.before_request(
707
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
708
+ hook_ctx: hook_ctx
709
+ ),
710
+ request: req
711
+ )
712
+ end
713
+
714
+ rescue StandardError => e
715
+ error = e
716
+ ensure
717
+ if http_response.nil? || Utils.error_status?(http_response.status)
718
+ http_response = @sdk_configuration.hooks.after_error(
719
+ error: error,
720
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
721
+ hook_ctx: hook_ctx
722
+ ),
723
+ response: http_response
724
+ )
725
+ else
726
+ http_response = @sdk_configuration.hooks.after_success(
727
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
728
+ hook_ctx: hook_ctx
729
+ ),
730
+ response: http_response
731
+ )
732
+ end
733
+
734
+ if http_response.nil?
735
+ raise error if !error.nil?
736
+ raise "no response"
737
+ end
738
+ end
739
+
740
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
741
+ if Utils.match_status_code(http_response.status, ["204"])
742
+ @sdk_configuration.hooks.after_success(
743
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
744
+ hook_ctx: hook_ctx
745
+ ),
746
+ response: http_response
747
+ )
748
+ return Models::Operations::DeleteListEntryResponse.new(
749
+ headers: http_response.headers
750
+ )
751
+ elsif Utils.match_status_code(http_response.status, ["400"])
752
+ if Utils.match_content_type(content_type, "application/problem+json")
753
+ @sdk_configuration.hooks.after_success(
754
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
755
+ hook_ctx: hook_ctx
756
+ ),
757
+ response: http_response
758
+ )
759
+ response_data = http_response.env.response_body
760
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
761
+ raise obj
762
+ else
763
+ raise(
764
+ ::NoResponse::Models::Errors::APIStatusError.new(
765
+ status_code: http_response.status,
766
+ body: http_response.env.response_body,
767
+ raw_response: http_response
768
+ ),
769
+ "Unknown content type received"
770
+ )
771
+ end
772
+ elsif Utils.match_status_code(http_response.status, ["401"])
773
+ if Utils.match_content_type(content_type, "application/problem+json")
774
+ @sdk_configuration.hooks.after_success(
775
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
776
+ hook_ctx: hook_ctx
777
+ ),
778
+ response: http_response
779
+ )
780
+ response_data = http_response.env.response_body
781
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
782
+ raise obj
783
+ else
784
+ raise(
785
+ ::NoResponse::Models::Errors::APIStatusError.new(
786
+ status_code: http_response.status,
787
+ body: http_response.env.response_body,
788
+ raw_response: http_response
789
+ ),
790
+ "Unknown content type received"
791
+ )
792
+ end
793
+ elsif Utils.match_status_code(http_response.status, ["403"])
794
+ if Utils.match_content_type(content_type, "application/problem+json")
795
+ @sdk_configuration.hooks.after_success(
796
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
797
+ hook_ctx: hook_ctx
798
+ ),
799
+ response: http_response
800
+ )
801
+ response_data = http_response.env.response_body
802
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
803
+ raise obj
804
+ else
805
+ raise(
806
+ ::NoResponse::Models::Errors::APIStatusError.new(
807
+ status_code: http_response.status,
808
+ body: http_response.env.response_body,
809
+ raw_response: http_response
810
+ ),
811
+ "Unknown content type received"
812
+ )
813
+ end
814
+ elsif Utils.match_status_code(http_response.status, ["404"])
815
+ if Utils.match_content_type(content_type, "application/problem+json")
816
+ @sdk_configuration.hooks.after_success(
817
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
818
+ hook_ctx: hook_ctx
819
+ ),
820
+ response: http_response
821
+ )
822
+ response_data = http_response.env.response_body
823
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
824
+ raise obj
825
+ else
826
+ raise(
827
+ ::NoResponse::Models::Errors::APIStatusError.new(
828
+ status_code: http_response.status,
829
+ body: http_response.env.response_body,
830
+ raw_response: http_response
831
+ ),
832
+ "Unknown content type received"
833
+ )
834
+ end
835
+ elsif Utils.match_status_code(http_response.status, ["409"])
836
+ if Utils.match_content_type(content_type, "application/problem+json")
837
+ @sdk_configuration.hooks.after_success(
838
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
839
+ hook_ctx: hook_ctx
840
+ ),
841
+ response: http_response
842
+ )
843
+ response_data = http_response.env.response_body
844
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
845
+ raise obj
846
+ else
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
+ "Unknown content type received"
854
+ )
855
+ end
856
+ elsif Utils.match_status_code(http_response.status, ["429"])
857
+ if Utils.match_content_type(content_type, "application/problem+json")
858
+ @sdk_configuration.hooks.after_success(
859
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
860
+ hook_ctx: hook_ctx
861
+ ),
862
+ response: http_response
863
+ )
864
+ response_data = http_response.env.response_body
865
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
866
+ raise obj
867
+ else
868
+ raise(
869
+ ::NoResponse::Models::Errors::APIStatusError.new(
870
+ status_code: http_response.status,
871
+ body: http_response.env.response_body,
872
+ raw_response: http_response
873
+ ),
874
+ "Unknown content type received"
875
+ )
876
+ end
877
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
878
+ raise(
879
+ ::NoResponse::Models::Errors::APIStatusError.new(
880
+ status_code: http_response.status,
881
+ body: http_response.env.response_body,
882
+ raw_response: http_response
883
+ ),
884
+ "API error occurred"
885
+ )
886
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
887
+ raise(
888
+ ::NoResponse::Models::Errors::APIStatusError.new(
889
+ status_code: http_response.status,
890
+ body: http_response.env.response_body,
891
+ raw_response: http_response
892
+ ),
893
+ "API error occurred"
894
+ )
895
+ else
896
+ raise(
897
+ ::NoResponse::Models::Errors::APIStatusError.new(
898
+ status_code: http_response.status,
899
+ body: http_response.env.response_body,
900
+ raw_response: http_response
901
+ ),
902
+ "Unknown status code received"
903
+ )
904
+
905
+ end
906
+ end
907
+ end
908
+ end