insightconnect-plugin-runtime 5.5.5__py3-none-any.whl → 5.6.0__py3-none-any.whl

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.
@@ -207,3 +207,9 @@ class PluginException(ConnectionTestException):
207
207
  return "An error occurred during plugin execution!\n\n{cause} {assistance}".format(
208
208
  cause=self.cause, assistance=self.assistance
209
209
  )
210
+
211
+
212
+ class APIException(PluginException):
213
+ def __init__(self, cause=None, assistance=None, data=None, preset=None, status_code=None):
214
+ super().__init__(cause, assistance, data, preset)
215
+ self.status_code = status_code
@@ -243,7 +243,8 @@ def response_handler(
243
243
  if hasattr(exception, "data") and data is not None:
244
244
  exception.data = data
245
245
  elif status_code_preset:
246
- exception = PluginException(preset=status_code_preset, data=data)
246
+ exception = PluginException(preset=status_code_preset)
247
+ exception.data = data
247
248
 
248
249
  raise exception
249
250
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: insightconnect-plugin-runtime
3
- Version: 5.5.5
3
+ Version: 5.6.0
4
4
  Summary: InsightConnect Plugin Runtime
5
5
  Home-page: https://github.com/rapid7/komand-plugin-sdk-python
6
6
  Author: Rapid7 Integrations Alliance
@@ -211,6 +211,7 @@ contributed. Black is installed as a test dependency and the hook can be initial
211
211
  after cloning this repository.
212
212
 
213
213
  ## Changelog
214
+ * 5.6.0 - Add APIException class for error handling | Fix error in response_handler where data of type Response was not correctly being returned
214
215
  * 5.5.5 - Address bug with typing for type `Dict` in Python 3.8
215
216
  * 5.5.4 - Support pagination parameters within AWS client.
216
217
  * 5.5.3 - Adding in a new endpoint that can be called to run a task connection test
@@ -3,8 +3,8 @@ insightconnect_plugin_runtime/action.py,sha256=8gsOONf7mzY83O3DNjCBIafk7C7acnf7m
3
3
  insightconnect_plugin_runtime/cli.py,sha256=Pb-Janu-XfRlSXxPHh30OIquljWptrhhS51C3clJqh4,8939
4
4
  insightconnect_plugin_runtime/connection.py,sha256=4bHHV2B0UFGsAtvLu1fiYQRwx7fissUakHPUyjLQO0E,2340
5
5
  insightconnect_plugin_runtime/dispatcher.py,sha256=ru7njnyyWE1-oD-VbZJ-Z8tELwvDf69rM7Iezs4rbnw,1774
6
- insightconnect_plugin_runtime/exceptions.py,sha256=7aYNoGgmV6SugHAQqeQYm1zo2LZm0vgXEGqHmYD7NCo,8260
7
- insightconnect_plugin_runtime/helper.py,sha256=XlMGpW2LQYo5KjhJeJtaYRCEDDWjrA9ZW1jP9FDpKpE,31155
6
+ insightconnect_plugin_runtime/exceptions.py,sha256=Pvcdkx81o6qC2qU661x-DzNjuIMP82x52nPMSEqEo4s,8491
7
+ insightconnect_plugin_runtime/helper.py,sha256=kXUt_yq6-9_wMdCIkS1fC3dddE8uwH9tcRITXvrJHIM,31178
8
8
  insightconnect_plugin_runtime/metrics.py,sha256=hf_Aoufip_s4k4o8Gtzz90ymZthkaT2e5sXh5B4LcF0,3186
9
9
  insightconnect_plugin_runtime/plugin.py,sha256=s2YVyygPcNeXeDi3X_JmaCiLHXZWIqz4mlLJy6p7-UA,24904
10
10
  insightconnect_plugin_runtime/schema.py,sha256=jTNc6KAMqFpaDVWrAYhkVC6e8I63P3X7uVlJkAr1hiY,583
@@ -67,8 +67,8 @@ tests/unit/test_api.py,sha256=uZ1dWMmgQ-ZePYjmcZfjc-qOTJsjs20Wic0Uf4U12-8,4441
67
67
  tests/unit/test_aws_action.py,sha256=eei4uPDx1Y8WcYgAWhiyqBYv5OOHGiZrCvajXC7RHdM,9597
68
68
  tests/unit/test_custom_encoder.py,sha256=KLYyVOTq9MEkZXyhVHqjm5LVSW6uJS4Davgghsw9DGk,2207
69
69
  tests/unit/test_endpoints.py,sha256=LuXOfLBu47rDjGa5YEsOwTZBEdvQdl_C6-r46oxWZA8,6401
70
- tests/unit/test_exceptions.py,sha256=t8c67n3ZQPpyzzYPN6TZHpNeE8uKlOSfHJPk71QONuU,4668
71
- tests/unit/test_helpers.py,sha256=NaZBnVVsQuRb_0uxPjCyptEd5408Ok_AIPjhetGLPjk,16043
70
+ tests/unit/test_exceptions.py,sha256=Y4F-ij8WkEJkUU3mPvxlEchqE9NCdxDvR8bJzPVVNao,5328
71
+ tests/unit/test_helpers.py,sha256=_1jlU-h-GNY9MLQ8nV_or4zkTI911AmHKtvFyamKjfU,16297
72
72
  tests/unit/test_metrics.py,sha256=PjjTrB9w7uQ2Q5UN-893-SsH3EGJuBseOMHSD1I004s,7979
73
73
  tests/unit/test_oauth.py,sha256=nbFG0JH1x04ExXqSe-b5BGdt_hJs7DP17eUa6bQzcYI,2093
74
74
  tests/unit/test_plugin.py,sha256=ZTNAZWwZhDIAbxkVuWhnz9FzmojbijgMmsLWM2mXQI0,4160
@@ -78,7 +78,7 @@ tests/unit/test_server_spec.py,sha256=je97BaktgK0Fiz3AwFPkcmHzYtOJJNqJV_Fw5hrvqX
78
78
  tests/unit/test_trigger.py,sha256=E53mAUoVyponWu_4IQZ0IC1gQ9lakBnTn_9vKN2IZfg,1692
79
79
  tests/unit/test_variables.py,sha256=OUEOqGYZA3Nd5oKk5GVY3hcrWKHpZpxysBJcO_v5gzs,291
80
80
  tests/unit/utils.py,sha256=VooVmfpIgxmglNdtmT32AkEDFxHxyRHLK8RsCWjjYRY,2153
81
- insightconnect_plugin_runtime-5.5.5.dist-info/METADATA,sha256=r5fE44VH3fBDRvvbWrg4XzwK5fA4zz8zCwRLI2DVWU4,13843
82
- insightconnect_plugin_runtime-5.5.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
83
- insightconnect_plugin_runtime-5.5.5.dist-info/top_level.txt,sha256=AJtyJOpiFzHxsbHUICTcUKXyrGQ3tZxhrEHsPjJBvEA,36
84
- insightconnect_plugin_runtime-5.5.5.dist-info/RECORD,,
81
+ insightconnect_plugin_runtime-5.6.0.dist-info/METADATA,sha256=5zYfXPKpqKNmeylm7-7KdhwXgujAZ3mmfxQTiEpjeJ8,13988
82
+ insightconnect_plugin_runtime-5.6.0.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
83
+ insightconnect_plugin_runtime-5.6.0.dist-info/top_level.txt,sha256=AJtyJOpiFzHxsbHUICTcUKXyrGQ3tZxhrEHsPjJBvEA,36
84
+ insightconnect_plugin_runtime-5.6.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,4 +1,4 @@
1
- from insightconnect_plugin_runtime.exceptions import PluginException
1
+ from insightconnect_plugin_runtime.exceptions import PluginException, APIException
2
2
  from unittest import TestCase
3
3
 
4
4
 
@@ -85,3 +85,20 @@ class TestExceptions(TestCase):
85
85
  raise (PluginException(preset=test_data.get("preset")))
86
86
  assert context.exception.cause == test_data.get("expected_cause")
87
87
  assert context.exception.assistance == test_data.get("expected_assistance")
88
+
89
+ def test_api_exception(self):
90
+ with self.assertRaises(APIException) as context:
91
+ raise (
92
+ APIException(
93
+ preset=PluginException.Preset.NOT_FOUND,
94
+ status_code=404,
95
+ data="example",
96
+ )
97
+ )
98
+ assert context.exception.cause == "Invalid or unreachable endpoint provided."
99
+ assert (
100
+ context.exception.assistance
101
+ == "Verify the URLs or endpoints in your configuration are correct."
102
+ )
103
+ assert context.exception.data == "example"
104
+ assert context.exception.status_code == 404
@@ -439,7 +439,11 @@ class TestRequestsHelpers(TestCase):
439
439
  ):
440
440
  request = requests.Request(method=method, url=url, json=None)
441
441
  with self.assertRaises(PluginException) as error:
442
- helper.make_request(_request=request, exception_custom_configs=exp_config)
442
+ helper.make_request(
443
+ _request=request,
444
+ exception_custom_configs=exp_config,
445
+ exception_data_location=ResponseExceptionData.RESPONSE,
446
+ )
443
447
  assert (isinstance(error, exception_type), True)
444
448
  if test_name == "custom404":
445
449
  self.assertEqual(
@@ -450,6 +454,8 @@ class TestRequestsHelpers(TestCase):
450
454
  error.exception.assistance,
451
455
  "CustomAssistance",
452
456
  )
457
+ self.assertEqual(error.exception.data.text, "example")
458
+ self.assertEqual(error.exception.data.status_code, 404)
453
459
 
454
460
  @parameterized.expand(
455
461
  [