noresponse 8.1.2 → 8.2.0

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/no_response/accounts.rb +2068 -0
  3. data/lib/no_response/assessments.rb +890 -0
  4. data/lib/no_response/lists.rb +2 -2
  5. data/lib/no_response/models/operations/associatecredential_request.rb +33 -0
  6. data/lib/no_response/models/operations/associatecredential_request.rbi +20 -0
  7. data/lib/no_response/models/operations/associatecredential_response.rb +34 -0
  8. data/lib/no_response/models/operations/associatecredential_response.rbi +20 -0
  9. data/lib/no_response/models/operations/bindprovisionalaccount_request.rb +37 -0
  10. data/lib/no_response/models/operations/bindprovisionalaccount_request.rbi +20 -0
  11. data/lib/no_response/models/operations/bindprovisionalaccount_response.rb +32 -0
  12. data/lib/no_response/models/operations/bindprovisionalaccount_response.rbi +20 -0
  13. data/lib/no_response/models/operations/exportaccount_request.rb +37 -0
  14. data/lib/no_response/models/operations/exportaccount_request.rbi +20 -0
  15. data/lib/no_response/models/operations/exportaccount_response.rb +32 -0
  16. data/lib/no_response/models/operations/exportaccount_response.rbi +20 -0
  17. data/lib/no_response/models/operations/getaccountdecision_request.rb +37 -0
  18. data/lib/no_response/models/operations/getaccountdecision_request.rbi +20 -0
  19. data/lib/no_response/models/operations/getaccountdecision_response.rb +34 -0
  20. data/lib/no_response/models/operations/getaccountdecision_response.rbi +20 -0
  21. data/lib/no_response/models/operations/getassessmentversion_request.rb +48 -0
  22. data/lib/no_response/models/operations/getassessmentversion_request.rbi +26 -0
  23. data/lib/no_response/models/operations/getassessmentversion_response.rb +32 -0
  24. data/lib/no_response/models/operations/getassessmentversion_response.rbi +20 -0
  25. data/lib/no_response/models/operations/listaccountcredentials_request.rb +45 -0
  26. data/lib/no_response/models/operations/listaccountcredentials_request.rbi +26 -0
  27. data/lib/no_response/models/operations/listaccountcredentials_response.rb +32 -0
  28. data/lib/no_response/models/operations/listaccountcredentials_response.rbi +20 -0
  29. data/lib/no_response/models/operations/listaccountoutcomes_request.rb +45 -0
  30. data/lib/no_response/models/operations/listaccountoutcomes_request.rbi +26 -0
  31. data/lib/no_response/models/operations/listaccountoutcomes_response.rb +32 -0
  32. data/lib/no_response/models/operations/listaccountoutcomes_response.rbi +20 -0
  33. data/lib/no_response/models/operations/listrequestdiagnostics_request.rb +84 -0
  34. data/lib/no_response/models/operations/listrequestdiagnostics_request.rbi +50 -0
  35. data/lib/no_response/models/operations/listrequestdiagnostics_response.rb +34 -0
  36. data/lib/no_response/models/operations/listrequestdiagnostics_response.rbi +20 -0
  37. data/lib/no_response/models/operations/recordaccountoutcome_request.rb +48 -0
  38. data/lib/no_response/models/operations/recordaccountoutcome_request.rbi +26 -0
  39. data/lib/no_response/models/operations/recordaccountoutcome_response.rb +32 -0
  40. data/lib/no_response/models/operations/recordaccountoutcome_response.rbi +20 -0
  41. data/lib/no_response/models/operations/retireaccountcredential_request.rb +37 -0
  42. data/lib/no_response/models/operations/retireaccountcredential_request.rbi +20 -0
  43. data/lib/no_response/models/operations/retireaccountcredential_response.rb +34 -0
  44. data/lib/no_response/models/operations/retireaccountcredential_response.rbi +20 -0
  45. data/lib/no_response/models/operations/searchassessments_response.rb +32 -0
  46. data/lib/no_response/models/operations/searchassessments_response.rbi +20 -0
  47. data/lib/no_response/models/operations.rb +21 -0
  48. data/lib/no_response/models/shared/accountbinding.rb +83 -0
  49. data/lib/no_response/models/shared/accountbinding.rbi +44 -0
  50. data/lib/no_response/models/shared/accountbindingactor.rb +40 -0
  51. data/lib/no_response/models/shared/accountbindingactor.rbi +20 -0
  52. data/lib/no_response/models/shared/accountbindingrequest.rb +33 -0
  53. data/lib/no_response/models/shared/accountbindingrequest.rbi +14 -0
  54. data/lib/no_response/models/shared/accountdecisionsnapshot.rb +94 -0
  55. data/lib/no_response/models/shared/accountdecisionsnapshot.rbi +44 -0
  56. data/lib/no_response/models/shared/accountexport.rb +178 -0
  57. data/lib/no_response/models/shared/accountexport.rbi +92 -0
  58. data/lib/no_response/models/shared/accountoutcome.rb +152 -0
  59. data/lib/no_response/models/shared/accountoutcome.rbi +80 -0
  60. data/lib/no_response/models/shared/accountoutcomeactor.rb +40 -0
  61. data/lib/no_response/models/shared/accountoutcomeactor.rbi +20 -0
  62. data/lib/no_response/models/shared/accountoutcomepage.rb +65 -0
  63. data/lib/no_response/models/shared/accountoutcomepage.rbi +32 -0
  64. data/lib/no_response/models/shared/accountoutcomerequest.rb +71 -0
  65. data/lib/no_response/models/shared/accountoutcomerequest.rbi +32 -0
  66. data/lib/no_response/models/shared/assessmentrevision.rb +101 -0
  67. data/lib/no_response/models/shared/assessmentrevision.rbi +44 -0
  68. data/lib/no_response/models/shared/assessmentsearchpage.rb +68 -0
  69. data/lib/no_response/models/shared/assessmentsearchpage.rbi +32 -0
  70. data/lib/no_response/models/shared/assessmentsearchrequest.rb +146 -0
  71. data/lib/no_response/models/shared/assessmentsearchrequest.rbi +68 -0
  72. data/lib/no_response/models/shared/conflicterrorcode.rb +4 -0
  73. data/lib/no_response/models/shared/credentialassociation.rb +78 -0
  74. data/lib/no_response/models/shared/credentialassociation.rbi +44 -0
  75. data/lib/no_response/models/shared/credentialassociationactor.rb +40 -0
  76. data/lib/no_response/models/shared/credentialassociationactor.rbi +20 -0
  77. data/lib/no_response/models/shared/credentialassociationretiredby.rb +40 -0
  78. data/lib/no_response/models/shared/credentialassociationretiredby.rbi +20 -0
  79. data/lib/no_response/models/shared/credentialpage.rb +56 -0
  80. data/lib/no_response/models/shared/credentialpage.rbi +26 -0
  81. data/lib/no_response/models/shared/credentialrequest.rb +32 -0
  82. data/lib/no_response/models/shared/credentialrequest.rbi +14 -0
  83. data/lib/no_response/models/shared/decision.rb +18 -0
  84. data/lib/no_response/models/shared/decision.rbi +9 -0
  85. data/lib/no_response/models/shared/decisionreceipt.rb +112 -0
  86. data/lib/no_response/models/shared/decisionreceipt.rbi +50 -0
  87. data/lib/no_response/models/shared/exclusion.rb +23 -0
  88. data/lib/no_response/models/shared/exclusion.rbi +9 -0
  89. data/lib/no_response/models/shared/exportassessmentoutcome.rb +85 -0
  90. data/lib/no_response/models/shared/exportassessmentoutcome.rbi +44 -0
  91. data/lib/no_response/models/shared/reasoncode.rb +1 -0
  92. data/lib/no_response/models/shared/requestdiagnostic.rb +145 -0
  93. data/lib/no_response/models/shared/requestdiagnostic.rbi +80 -0
  94. data/lib/no_response/models/shared/requestdiagnosticpage.rb +40 -0
  95. data/lib/no_response/models/shared/requestdiagnosticpage.rbi +20 -0
  96. data/lib/no_response/models/shared.rb +23 -0
  97. data/lib/no_response/noresponseclient.rb +12 -1
  98. data/lib/no_response/requests.rb +320 -0
  99. data/lib/no_response/sdkconfiguration.rb +2 -2
  100. data/lib/noresponse.rb +1 -0
  101. metadata +91 -2
@@ -1536,5 +1536,895 @@ module NoResponse
1536
1536
 
1537
1537
  end
1538
1538
  end
1539
+
1540
+ sig {
1541
+ params(
1542
+ request: Models::Shared::AssessmentSearchRequest,
1543
+ retries: T.nilable(Utils::RetryConfig),
1544
+ timeout_ms: T.nilable(Integer),
1545
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1546
+ )
1547
+ .returns(Models::Operations::SearchAssessmentsResponse)
1548
+ }
1549
+ def search(request:, retries: nil, timeout_ms: nil, http_headers: nil)
1550
+ # search - Search assessments across this environment
1551
+ # Search retained assessments created in [from,to), over at most 366 days. Filters use each assessment decision, rather than the current account decision. Results can change between pages. Keep the assessment version to retrieve the exact decision later. This read does not require an idempotency key.
1552
+ url, params = @sdk_configuration.get_server_details
1553
+ base_url = Utils.template_url(url, params)
1554
+ url = "#{base_url}/v1/assessments/search"
1555
+ headers = {}
1556
+ headers = T.cast(headers, T::Hash[String, String])
1557
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :request, :json)
1558
+ headers["content-type"] = req_content_type
1559
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1560
+
1561
+ if form && !form.empty?
1562
+ body = Utils.encode_form(form)
1563
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1564
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1565
+ else
1566
+ body = data
1567
+ end
1568
+
1569
+ headers["Accept"] = "application/json"
1570
+ headers["user-agent"] = @sdk_configuration.user_agent
1571
+ retries ||= @sdk_configuration.retry_config
1572
+ retries ||= Utils::RetryConfig.new(
1573
+ backoff: Utils::BackoffStrategy.new(
1574
+ exponent: 2.0,
1575
+ initial_interval: 500,
1576
+ max_elapsed_time: 30_000,
1577
+ max_interval: 8000
1578
+ ),
1579
+ retry_connection_errors: true,
1580
+ strategy: "backoff"
1581
+ )
1582
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1583
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1584
+
1585
+ security = @sdk_configuration.security_source&.call
1586
+
1587
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1588
+ timeout ||= @sdk_configuration.timeout
1589
+
1590
+ connection = @sdk_configuration.client.dup
1591
+ connection.use(Utils::RetryMiddleware, retry_options)
1592
+
1593
+ hook_ctx = SDKHooks::HookContext.new(
1594
+ config: @sdk_configuration,
1595
+ base_url: base_url,
1596
+ oauth2_scopes: nil,
1597
+ operation_id: "searchAssessments",
1598
+ security_source: @sdk_configuration.security_source
1599
+ )
1600
+
1601
+ error = T.let(nil, T.nilable(StandardError))
1602
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1603
+
1604
+ begin
1605
+ http_response = T.must(connection).post(url) do |req|
1606
+ req.body = body
1607
+ req.headers.merge!(headers)
1608
+ req.options.timeout = timeout unless timeout.nil?
1609
+ Utils.configure_request_security(req, security)
1610
+ http_headers&.each do |key, value|
1611
+ req.headers[key.to_s] = value
1612
+ end
1613
+
1614
+ @sdk_configuration.hooks.before_request(
1615
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1616
+ hook_ctx: hook_ctx
1617
+ ),
1618
+ request: req
1619
+ )
1620
+ end
1621
+
1622
+ rescue StandardError => e
1623
+ error = e
1624
+ ensure
1625
+ if http_response.nil? || Utils.error_status?(http_response.status)
1626
+ http_response = @sdk_configuration.hooks.after_error(
1627
+ error: error,
1628
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1629
+ hook_ctx: hook_ctx
1630
+ ),
1631
+ response: http_response
1632
+ )
1633
+ else
1634
+ http_response = @sdk_configuration.hooks.after_success(
1635
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1636
+ hook_ctx: hook_ctx
1637
+ ),
1638
+ response: http_response
1639
+ )
1640
+ end
1641
+
1642
+ if http_response.nil?
1643
+ raise error if !error.nil?
1644
+ raise "no response"
1645
+ end
1646
+ end
1647
+
1648
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1649
+ if Utils.match_status_code(http_response.status, ["200"])
1650
+ if Utils.match_content_type(content_type, "application/json")
1651
+ @sdk_configuration.hooks.after_success(
1652
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1653
+ hook_ctx: hook_ctx
1654
+ ),
1655
+ response: http_response
1656
+ )
1657
+ response_data = http_response.env.response_body
1658
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AssessmentSearchPage)
1659
+ result = obj
1660
+ response = Models::Operations::SearchAssessmentsResponse.new(
1661
+ result: result,
1662
+ headers: http_response.headers
1663
+ )
1664
+
1665
+ return response
1666
+ else
1667
+ raise(
1668
+ ::NoResponse::Models::Errors::APIStatusError.new(
1669
+ status_code: http_response.status,
1670
+ body: http_response.env.response_body,
1671
+ raw_response: http_response
1672
+ ),
1673
+ "Unknown content type received"
1674
+ )
1675
+ end
1676
+ elsif Utils.match_status_code(http_response.status, ["400"])
1677
+ if Utils.match_content_type(content_type, "application/problem+json")
1678
+ @sdk_configuration.hooks.after_success(
1679
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1680
+ hook_ctx: hook_ctx
1681
+ ),
1682
+ response: http_response
1683
+ )
1684
+ response_data = http_response.env.response_body
1685
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1686
+ raise obj
1687
+ else
1688
+ raise(
1689
+ ::NoResponse::Models::Errors::APIStatusError.new(
1690
+ status_code: http_response.status,
1691
+ body: http_response.env.response_body,
1692
+ raw_response: http_response
1693
+ ),
1694
+ "Unknown content type received"
1695
+ )
1696
+ end
1697
+ elsif Utils.match_status_code(http_response.status, ["401"])
1698
+ if Utils.match_content_type(content_type, "application/problem+json")
1699
+ @sdk_configuration.hooks.after_success(
1700
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1701
+ hook_ctx: hook_ctx
1702
+ ),
1703
+ response: http_response
1704
+ )
1705
+ response_data = http_response.env.response_body
1706
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1707
+ raise obj
1708
+ else
1709
+ raise(
1710
+ ::NoResponse::Models::Errors::APIStatusError.new(
1711
+ status_code: http_response.status,
1712
+ body: http_response.env.response_body,
1713
+ raw_response: http_response
1714
+ ),
1715
+ "Unknown content type received"
1716
+ )
1717
+ end
1718
+ elsif Utils.match_status_code(http_response.status, ["403"])
1719
+ if Utils.match_content_type(content_type, "application/problem+json")
1720
+ @sdk_configuration.hooks.after_success(
1721
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1722
+ hook_ctx: hook_ctx
1723
+ ),
1724
+ response: http_response
1725
+ )
1726
+ response_data = http_response.env.response_body
1727
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1728
+ raise obj
1729
+ else
1730
+ raise(
1731
+ ::NoResponse::Models::Errors::APIStatusError.new(
1732
+ status_code: http_response.status,
1733
+ body: http_response.env.response_body,
1734
+ raw_response: http_response
1735
+ ),
1736
+ "Unknown content type received"
1737
+ )
1738
+ end
1739
+ elsif Utils.match_status_code(http_response.status, ["404"])
1740
+ if Utils.match_content_type(content_type, "application/problem+json")
1741
+ @sdk_configuration.hooks.after_success(
1742
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1743
+ hook_ctx: hook_ctx
1744
+ ),
1745
+ response: http_response
1746
+ )
1747
+ response_data = http_response.env.response_body
1748
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1749
+ raise obj
1750
+ else
1751
+ raise(
1752
+ ::NoResponse::Models::Errors::APIStatusError.new(
1753
+ status_code: http_response.status,
1754
+ body: http_response.env.response_body,
1755
+ raw_response: http_response
1756
+ ),
1757
+ "Unknown content type received"
1758
+ )
1759
+ end
1760
+ elsif Utils.match_status_code(http_response.status, ["409"])
1761
+ if Utils.match_content_type(content_type, "application/problem+json")
1762
+ @sdk_configuration.hooks.after_success(
1763
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1764
+ hook_ctx: hook_ctx
1765
+ ),
1766
+ response: http_response
1767
+ )
1768
+ response_data = http_response.env.response_body
1769
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1770
+ raise obj
1771
+ else
1772
+ raise(
1773
+ ::NoResponse::Models::Errors::APIStatusError.new(
1774
+ status_code: http_response.status,
1775
+ body: http_response.env.response_body,
1776
+ raw_response: http_response
1777
+ ),
1778
+ "Unknown content type received"
1779
+ )
1780
+ end
1781
+ elsif Utils.match_status_code(http_response.status, ["429"])
1782
+ if Utils.match_content_type(content_type, "application/problem+json")
1783
+ @sdk_configuration.hooks.after_success(
1784
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1785
+ hook_ctx: hook_ctx
1786
+ ),
1787
+ response: http_response
1788
+ )
1789
+ response_data = http_response.env.response_body
1790
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1791
+ raise obj
1792
+ else
1793
+ raise(
1794
+ ::NoResponse::Models::Errors::APIStatusError.new(
1795
+ status_code: http_response.status,
1796
+ body: http_response.env.response_body,
1797
+ raw_response: http_response
1798
+ ),
1799
+ "Unknown content type received"
1800
+ )
1801
+ end
1802
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1803
+ raise(
1804
+ ::NoResponse::Models::Errors::APIStatusError.new(
1805
+ status_code: http_response.status,
1806
+ body: http_response.env.response_body,
1807
+ raw_response: http_response
1808
+ ),
1809
+ "API error occurred"
1810
+ )
1811
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1812
+ raise(
1813
+ ::NoResponse::Models::Errors::APIStatusError.new(
1814
+ status_code: http_response.status,
1815
+ body: http_response.env.response_body,
1816
+ raw_response: http_response
1817
+ ),
1818
+ "API error occurred"
1819
+ )
1820
+ else
1821
+ raise(
1822
+ ::NoResponse::Models::Errors::APIStatusError.new(
1823
+ status_code: http_response.status,
1824
+ body: http_response.env.response_body,
1825
+ raw_response: http_response
1826
+ ),
1827
+ "Unknown status code received"
1828
+ )
1829
+
1830
+ end
1831
+ end
1832
+
1833
+ sig {
1834
+ params(
1835
+ assessment_id: ::String,
1836
+ version: ::Integer,
1837
+ response_mode: T.nilable(Models::Shared::ResponseMode),
1838
+ retries: T.nilable(Utils::RetryConfig),
1839
+ timeout_ms: T.nilable(Integer),
1840
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1841
+ )
1842
+ .returns(Models::Operations::GetAssessmentVersionResponse)
1843
+ }
1844
+ def retrieve_version(assessment_id:, version:, response_mode: nil, retries: nil, timeout_ms: nil, http_headers: nil)
1845
+ # retrieve_version - Retrieve an exact assessment revision
1846
+ # Retrieve a retained assessment version with its original decision, policy, flow and depth. This response excludes the current account decision. Current retention and response-mode permissions still apply.
1847
+ request = Models::Operations::GetAssessmentVersionRequest.new(
1848
+ assessment_id: assessment_id,
1849
+ version: version,
1850
+ response_mode: response_mode
1851
+ )
1852
+ url, params = @sdk_configuration.get_server_details
1853
+ base_url = Utils.template_url(url, params)
1854
+ url = Utils.generate_url(
1855
+ Models::Operations::GetAssessmentVersionRequest,
1856
+ base_url,
1857
+ "/v1/assessments/{assessment_id}/versions/{version}",
1858
+ request
1859
+ )
1860
+ headers = {}
1861
+ headers = T.cast(headers, T::Hash[String, String])
1862
+ query_params = Utils.get_query_params(Models::Operations::GetAssessmentVersionRequest, request, nil)
1863
+ headers["Accept"] = "application/json"
1864
+ headers["user-agent"] = @sdk_configuration.user_agent
1865
+ retries ||= @sdk_configuration.retry_config
1866
+ retries ||= Utils::RetryConfig.new(
1867
+ backoff: Utils::BackoffStrategy.new(
1868
+ exponent: 2.0,
1869
+ initial_interval: 500,
1870
+ max_elapsed_time: 30_000,
1871
+ max_interval: 8000
1872
+ ),
1873
+ retry_connection_errors: true,
1874
+ strategy: "backoff"
1875
+ )
1876
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1877
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1878
+
1879
+ security = @sdk_configuration.security_source&.call
1880
+
1881
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1882
+ timeout ||= @sdk_configuration.timeout
1883
+
1884
+ connection = @sdk_configuration.client.dup
1885
+ connection.use(Utils::RetryMiddleware, retry_options)
1886
+
1887
+ hook_ctx = SDKHooks::HookContext.new(
1888
+ config: @sdk_configuration,
1889
+ base_url: base_url,
1890
+ oauth2_scopes: nil,
1891
+ operation_id: "getAssessmentVersion",
1892
+ security_source: @sdk_configuration.security_source
1893
+ )
1894
+
1895
+ error = T.let(nil, T.nilable(StandardError))
1896
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1897
+
1898
+ begin
1899
+ http_response = T.must(connection).get(url) do |req|
1900
+ req.headers.merge!(headers)
1901
+ req.options.timeout = timeout unless timeout.nil?
1902
+ req.params = query_params
1903
+ Utils.configure_request_security(req, security)
1904
+ http_headers&.each do |key, value|
1905
+ req.headers[key.to_s] = value
1906
+ end
1907
+
1908
+ @sdk_configuration.hooks.before_request(
1909
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1910
+ hook_ctx: hook_ctx
1911
+ ),
1912
+ request: req
1913
+ )
1914
+ end
1915
+
1916
+ rescue StandardError => e
1917
+ error = e
1918
+ ensure
1919
+ if http_response.nil? || Utils.error_status?(http_response.status)
1920
+ http_response = @sdk_configuration.hooks.after_error(
1921
+ error: error,
1922
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1923
+ hook_ctx: hook_ctx
1924
+ ),
1925
+ response: http_response
1926
+ )
1927
+ else
1928
+ http_response = @sdk_configuration.hooks.after_success(
1929
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1930
+ hook_ctx: hook_ctx
1931
+ ),
1932
+ response: http_response
1933
+ )
1934
+ end
1935
+
1936
+ if http_response.nil?
1937
+ raise error if !error.nil?
1938
+ raise "no response"
1939
+ end
1940
+ end
1941
+
1942
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1943
+ if Utils.match_status_code(http_response.status, ["200"])
1944
+ if Utils.match_content_type(content_type, "application/json")
1945
+ @sdk_configuration.hooks.after_success(
1946
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1947
+ hook_ctx: hook_ctx
1948
+ ),
1949
+ response: http_response
1950
+ )
1951
+ response_data = http_response.env.response_body
1952
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AssessmentRevision)
1953
+ result = obj
1954
+ response = Models::Operations::GetAssessmentVersionResponse.new(
1955
+ result: result,
1956
+ headers: http_response.headers
1957
+ )
1958
+
1959
+ return response
1960
+ else
1961
+ raise(
1962
+ ::NoResponse::Models::Errors::APIStatusError.new(
1963
+ status_code: http_response.status,
1964
+ body: http_response.env.response_body,
1965
+ raw_response: http_response
1966
+ ),
1967
+ "Unknown content type received"
1968
+ )
1969
+ end
1970
+ elsif Utils.match_status_code(http_response.status, ["400"])
1971
+ if Utils.match_content_type(content_type, "application/problem+json")
1972
+ @sdk_configuration.hooks.after_success(
1973
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1974
+ hook_ctx: hook_ctx
1975
+ ),
1976
+ response: http_response
1977
+ )
1978
+ response_data = http_response.env.response_body
1979
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1980
+ raise obj
1981
+ else
1982
+ raise(
1983
+ ::NoResponse::Models::Errors::APIStatusError.new(
1984
+ status_code: http_response.status,
1985
+ body: http_response.env.response_body,
1986
+ raw_response: http_response
1987
+ ),
1988
+ "Unknown content type received"
1989
+ )
1990
+ end
1991
+ elsif Utils.match_status_code(http_response.status, ["401"])
1992
+ if Utils.match_content_type(content_type, "application/problem+json")
1993
+ @sdk_configuration.hooks.after_success(
1994
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1995
+ hook_ctx: hook_ctx
1996
+ ),
1997
+ response: http_response
1998
+ )
1999
+ response_data = http_response.env.response_body
2000
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2001
+ raise obj
2002
+ else
2003
+ raise(
2004
+ ::NoResponse::Models::Errors::APIStatusError.new(
2005
+ status_code: http_response.status,
2006
+ body: http_response.env.response_body,
2007
+ raw_response: http_response
2008
+ ),
2009
+ "Unknown content type received"
2010
+ )
2011
+ end
2012
+ elsif Utils.match_status_code(http_response.status, ["403"])
2013
+ if Utils.match_content_type(content_type, "application/problem+json")
2014
+ @sdk_configuration.hooks.after_success(
2015
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2016
+ hook_ctx: hook_ctx
2017
+ ),
2018
+ response: http_response
2019
+ )
2020
+ response_data = http_response.env.response_body
2021
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2022
+ raise obj
2023
+ else
2024
+ raise(
2025
+ ::NoResponse::Models::Errors::APIStatusError.new(
2026
+ status_code: http_response.status,
2027
+ body: http_response.env.response_body,
2028
+ raw_response: http_response
2029
+ ),
2030
+ "Unknown content type received"
2031
+ )
2032
+ end
2033
+ elsif Utils.match_status_code(http_response.status, ["404"])
2034
+ if Utils.match_content_type(content_type, "application/problem+json")
2035
+ @sdk_configuration.hooks.after_success(
2036
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2037
+ hook_ctx: hook_ctx
2038
+ ),
2039
+ response: http_response
2040
+ )
2041
+ response_data = http_response.env.response_body
2042
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2043
+ raise obj
2044
+ else
2045
+ raise(
2046
+ ::NoResponse::Models::Errors::APIStatusError.new(
2047
+ status_code: http_response.status,
2048
+ body: http_response.env.response_body,
2049
+ raw_response: http_response
2050
+ ),
2051
+ "Unknown content type received"
2052
+ )
2053
+ end
2054
+ elsif Utils.match_status_code(http_response.status, ["409"])
2055
+ if Utils.match_content_type(content_type, "application/problem+json")
2056
+ @sdk_configuration.hooks.after_success(
2057
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2058
+ hook_ctx: hook_ctx
2059
+ ),
2060
+ response: http_response
2061
+ )
2062
+ response_data = http_response.env.response_body
2063
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2064
+ raise obj
2065
+ else
2066
+ raise(
2067
+ ::NoResponse::Models::Errors::APIStatusError.new(
2068
+ status_code: http_response.status,
2069
+ body: http_response.env.response_body,
2070
+ raw_response: http_response
2071
+ ),
2072
+ "Unknown content type received"
2073
+ )
2074
+ end
2075
+ elsif Utils.match_status_code(http_response.status, ["429"])
2076
+ if Utils.match_content_type(content_type, "application/problem+json")
2077
+ @sdk_configuration.hooks.after_success(
2078
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2079
+ hook_ctx: hook_ctx
2080
+ ),
2081
+ response: http_response
2082
+ )
2083
+ response_data = http_response.env.response_body
2084
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2085
+ raise obj
2086
+ else
2087
+ raise(
2088
+ ::NoResponse::Models::Errors::APIStatusError.new(
2089
+ status_code: http_response.status,
2090
+ body: http_response.env.response_body,
2091
+ raw_response: http_response
2092
+ ),
2093
+ "Unknown content type received"
2094
+ )
2095
+ end
2096
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2097
+ raise(
2098
+ ::NoResponse::Models::Errors::APIStatusError.new(
2099
+ status_code: http_response.status,
2100
+ body: http_response.env.response_body,
2101
+ raw_response: http_response
2102
+ ),
2103
+ "API error occurred"
2104
+ )
2105
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2106
+ raise(
2107
+ ::NoResponse::Models::Errors::APIStatusError.new(
2108
+ status_code: http_response.status,
2109
+ body: http_response.env.response_body,
2110
+ raw_response: http_response
2111
+ ),
2112
+ "API error occurred"
2113
+ )
2114
+ else
2115
+ raise(
2116
+ ::NoResponse::Models::Errors::APIStatusError.new(
2117
+ status_code: http_response.status,
2118
+ body: http_response.env.response_body,
2119
+ raw_response: http_response
2120
+ ),
2121
+ "Unknown status code received"
2122
+ )
2123
+
2124
+ end
2125
+ end
2126
+
2127
+ sig {
2128
+ params(
2129
+ body: Models::Shared::AccountBindingRequest,
2130
+ assessment_id: ::String,
2131
+ retries: T.nilable(Utils::RetryConfig),
2132
+ timeout_ms: T.nilable(Integer),
2133
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2134
+ )
2135
+ .returns(Models::Operations::BindProvisionalAccountResponse)
2136
+ }
2137
+ def bind_account(body:, assessment_id:, retries: nil, timeout_ms: nil, http_headers: nil)
2138
+ # bind_account - Bind a provisional signup account
2139
+ # One-time association to an opaque stable customer account. The assessment is its natural idempotency key. Repeating the same binding returns its first receipt; a conflicting target is refused. No arbitrary account merging.
2140
+ request = Models::Operations::BindProvisionalAccountRequest.new(
2141
+ assessment_id: assessment_id,
2142
+ body: body
2143
+ )
2144
+ url, params = @sdk_configuration.get_server_details
2145
+ base_url = Utils.template_url(url, params)
2146
+ url = Utils.generate_url(
2147
+ Models::Operations::BindProvisionalAccountRequest,
2148
+ base_url,
2149
+ "/v1/assessments/{assessment_id}/bind",
2150
+ request
2151
+ )
2152
+ headers = {}
2153
+ headers = T.cast(headers, T::Hash[String, String])
2154
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
2155
+ headers["content-type"] = req_content_type
2156
+ raise StandardError, "request body is required" if data.nil? && form.nil?
2157
+
2158
+ if form && !form.empty?
2159
+ body = Utils.encode_form(form)
2160
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
2161
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
2162
+ else
2163
+ body = data
2164
+ end
2165
+
2166
+ headers["Accept"] = "application/json"
2167
+ headers["user-agent"] = @sdk_configuration.user_agent
2168
+ retries ||= @sdk_configuration.retry_config
2169
+ retries ||= Utils::RetryConfig.new(
2170
+ backoff: Utils::BackoffStrategy.new(
2171
+ exponent: 2.0,
2172
+ initial_interval: 500,
2173
+ max_elapsed_time: 30_000,
2174
+ max_interval: 8000
2175
+ ),
2176
+ retry_connection_errors: true,
2177
+ strategy: "backoff"
2178
+ )
2179
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2180
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2181
+
2182
+ security = @sdk_configuration.security_source&.call
2183
+
2184
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2185
+ timeout ||= @sdk_configuration.timeout
2186
+
2187
+ connection = @sdk_configuration.client.dup
2188
+ connection.use(Utils::RetryMiddleware, retry_options)
2189
+
2190
+ hook_ctx = SDKHooks::HookContext.new(
2191
+ config: @sdk_configuration,
2192
+ base_url: base_url,
2193
+ oauth2_scopes: nil,
2194
+ operation_id: "bindProvisionalAccount",
2195
+ security_source: @sdk_configuration.security_source
2196
+ )
2197
+
2198
+ error = T.let(nil, T.nilable(StandardError))
2199
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2200
+
2201
+ begin
2202
+ http_response = T.must(connection).post(url) do |req|
2203
+ req.body = body
2204
+ req.headers.merge!(headers)
2205
+ req.options.timeout = timeout unless timeout.nil?
2206
+ Utils.configure_request_security(req, security)
2207
+ http_headers&.each do |key, value|
2208
+ req.headers[key.to_s] = value
2209
+ end
2210
+
2211
+ @sdk_configuration.hooks.before_request(
2212
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2213
+ hook_ctx: hook_ctx
2214
+ ),
2215
+ request: req
2216
+ )
2217
+ end
2218
+
2219
+ rescue StandardError => e
2220
+ error = e
2221
+ ensure
2222
+ if http_response.nil? || Utils.error_status?(http_response.status)
2223
+ http_response = @sdk_configuration.hooks.after_error(
2224
+ error: error,
2225
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2226
+ hook_ctx: hook_ctx
2227
+ ),
2228
+ response: http_response
2229
+ )
2230
+ else
2231
+ http_response = @sdk_configuration.hooks.after_success(
2232
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2233
+ hook_ctx: hook_ctx
2234
+ ),
2235
+ response: http_response
2236
+ )
2237
+ end
2238
+
2239
+ if http_response.nil?
2240
+ raise error if !error.nil?
2241
+ raise "no response"
2242
+ end
2243
+ end
2244
+
2245
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2246
+ if Utils.match_status_code(http_response.status, ["200", "201"])
2247
+ if Utils.match_content_type(content_type, "application/json")
2248
+ @sdk_configuration.hooks.after_success(
2249
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2250
+ hook_ctx: hook_ctx
2251
+ ),
2252
+ response: http_response
2253
+ )
2254
+ response_data = http_response.env.response_body
2255
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AccountBinding)
2256
+ result = obj
2257
+ response = Models::Operations::BindProvisionalAccountResponse.new(
2258
+ result: result,
2259
+ headers: http_response.headers
2260
+ )
2261
+
2262
+ return response
2263
+ else
2264
+ raise(
2265
+ ::NoResponse::Models::Errors::APIStatusError.new(
2266
+ status_code: http_response.status,
2267
+ body: http_response.env.response_body,
2268
+ raw_response: http_response
2269
+ ),
2270
+ "Unknown content type received"
2271
+ )
2272
+ end
2273
+ elsif Utils.match_status_code(http_response.status, ["400"])
2274
+ if Utils.match_content_type(content_type, "application/problem+json")
2275
+ @sdk_configuration.hooks.after_success(
2276
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2277
+ hook_ctx: hook_ctx
2278
+ ),
2279
+ response: http_response
2280
+ )
2281
+ response_data = http_response.env.response_body
2282
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2283
+ raise obj
2284
+ else
2285
+ raise(
2286
+ ::NoResponse::Models::Errors::APIStatusError.new(
2287
+ status_code: http_response.status,
2288
+ body: http_response.env.response_body,
2289
+ raw_response: http_response
2290
+ ),
2291
+ "Unknown content type received"
2292
+ )
2293
+ end
2294
+ elsif Utils.match_status_code(http_response.status, ["401"])
2295
+ if Utils.match_content_type(content_type, "application/problem+json")
2296
+ @sdk_configuration.hooks.after_success(
2297
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2298
+ hook_ctx: hook_ctx
2299
+ ),
2300
+ response: http_response
2301
+ )
2302
+ response_data = http_response.env.response_body
2303
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2304
+ raise obj
2305
+ else
2306
+ raise(
2307
+ ::NoResponse::Models::Errors::APIStatusError.new(
2308
+ status_code: http_response.status,
2309
+ body: http_response.env.response_body,
2310
+ raw_response: http_response
2311
+ ),
2312
+ "Unknown content type received"
2313
+ )
2314
+ end
2315
+ elsif Utils.match_status_code(http_response.status, ["403"])
2316
+ if Utils.match_content_type(content_type, "application/problem+json")
2317
+ @sdk_configuration.hooks.after_success(
2318
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2319
+ hook_ctx: hook_ctx
2320
+ ),
2321
+ response: http_response
2322
+ )
2323
+ response_data = http_response.env.response_body
2324
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2325
+ raise obj
2326
+ else
2327
+ raise(
2328
+ ::NoResponse::Models::Errors::APIStatusError.new(
2329
+ status_code: http_response.status,
2330
+ body: http_response.env.response_body,
2331
+ raw_response: http_response
2332
+ ),
2333
+ "Unknown content type received"
2334
+ )
2335
+ end
2336
+ elsif Utils.match_status_code(http_response.status, ["404"])
2337
+ if Utils.match_content_type(content_type, "application/problem+json")
2338
+ @sdk_configuration.hooks.after_success(
2339
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2340
+ hook_ctx: hook_ctx
2341
+ ),
2342
+ response: http_response
2343
+ )
2344
+ response_data = http_response.env.response_body
2345
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2346
+ raise obj
2347
+ else
2348
+ raise(
2349
+ ::NoResponse::Models::Errors::APIStatusError.new(
2350
+ status_code: http_response.status,
2351
+ body: http_response.env.response_body,
2352
+ raw_response: http_response
2353
+ ),
2354
+ "Unknown content type received"
2355
+ )
2356
+ end
2357
+ elsif Utils.match_status_code(http_response.status, ["409"])
2358
+ if Utils.match_content_type(content_type, "application/problem+json")
2359
+ @sdk_configuration.hooks.after_success(
2360
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2361
+ hook_ctx: hook_ctx
2362
+ ),
2363
+ response: http_response
2364
+ )
2365
+ response_data = http_response.env.response_body
2366
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2367
+ raise obj
2368
+ else
2369
+ raise(
2370
+ ::NoResponse::Models::Errors::APIStatusError.new(
2371
+ status_code: http_response.status,
2372
+ body: http_response.env.response_body,
2373
+ raw_response: http_response
2374
+ ),
2375
+ "Unknown content type received"
2376
+ )
2377
+ end
2378
+ elsif Utils.match_status_code(http_response.status, ["429"])
2379
+ if Utils.match_content_type(content_type, "application/problem+json")
2380
+ @sdk_configuration.hooks.after_success(
2381
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2382
+ hook_ctx: hook_ctx
2383
+ ),
2384
+ response: http_response
2385
+ )
2386
+ response_data = http_response.env.response_body
2387
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2388
+ raise obj
2389
+ else
2390
+ raise(
2391
+ ::NoResponse::Models::Errors::APIStatusError.new(
2392
+ status_code: http_response.status,
2393
+ body: http_response.env.response_body,
2394
+ raw_response: http_response
2395
+ ),
2396
+ "Unknown content type received"
2397
+ )
2398
+ end
2399
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2400
+ raise(
2401
+ ::NoResponse::Models::Errors::APIStatusError.new(
2402
+ status_code: http_response.status,
2403
+ body: http_response.env.response_body,
2404
+ raw_response: http_response
2405
+ ),
2406
+ "API error occurred"
2407
+ )
2408
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2409
+ raise(
2410
+ ::NoResponse::Models::Errors::APIStatusError.new(
2411
+ status_code: http_response.status,
2412
+ body: http_response.env.response_body,
2413
+ raw_response: http_response
2414
+ ),
2415
+ "API error occurred"
2416
+ )
2417
+ else
2418
+ raise(
2419
+ ::NoResponse::Models::Errors::APIStatusError.new(
2420
+ status_code: http_response.status,
2421
+ body: http_response.env.response_body,
2422
+ raw_response: http_response
2423
+ ),
2424
+ "Unknown status code received"
2425
+ )
2426
+
2427
+ end
2428
+ end
1539
2429
  end
1540
2430
  end