From 6a82981041307dbd5921c2b29e8bf364c2d2d420 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 12:35:20 +0300 Subject: [PATCH 01/10] Enable Amazon EventBridge notification --- signal_analog/detectors.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/signal_analog/detectors.py b/signal_analog/detectors.py index 0375c78f..4d78db37 100644 --- a/signal_analog/detectors.py +++ b/signal_analog/detectors.py @@ -180,6 +180,27 @@ def __init__(self, vo_id, routing_key): } +class AmazonEventBridgeNotification(Notification): + """An Amazon EventBridge notification for detector rules.""" + + def __init__(self, aeb_id): + """Initializes a new Amazon EventBridge notification. + + This does not set up a Amazon EventBridge integration for you, one must already + exist before using this notification type. No validation is done to + ensure that a Amazon EventBridge integration id is valid. + + Arguments: + aeb_id: the Amazon EventBridge integration id to use + """ + util.assert_valid(aeb_id) + + self.options = { + 'type': 'AmazonEventBridge', + 'credentialId': aeb_id + } + + class WebhookNotification(Notification): """A Webhook notification for detector rules.""" From 8a981dab318d1077c77a80706ead8bd4ad7adab0 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 13:04:29 +0300 Subject: [PATCH 02/10] Add EQ (Equal) and NE (Not Equal) combinators --- signal_analog/combinators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/signal_analog/combinators.py b/signal_analog/combinators.py index 68a565e0..2688c100 100644 --- a/signal_analog/combinators.py +++ b/signal_analog/combinators.py @@ -99,6 +99,22 @@ def __init__(self, left, right): super(GTE, self).__init__('>=', left, right) +class EQ(NAryCombinator): + """Equal combinator for comparing SignalFlow objects. + """ + + def __init__(self, left, right): + super(EQ, self).__init__('==', left, right) + + +class NE(NAryCombinator): + """Not Equal combinator for comparing SignalFlow objects. + """ + + def __init__(self, left, right): + super(NE, self).__init__('!=', left, right) + + class Mul(NAryCombinator): """Multiplication combinator for performing math on SignalFlow objects. """ From 3b332c4ee15473a16f89139192e238891fd1425d Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 14:22:42 +0300 Subject: [PATCH 03/10] Add tests for new combinators and notification type --- tests/test_signal_analog_combinators.py | 12 ++++++++++++ tests/test_signal_analog_detectors.py | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/test_signal_analog_combinators.py b/tests/test_signal_analog_combinators.py index d9d0f93f..55452c34 100644 --- a/tests/test_signal_analog_combinators.py +++ b/tests/test_signal_analog_combinators.py @@ -82,6 +82,18 @@ def test_binary_combinator_gte(f, ff): assert str(comb.GTE(f, ff)) == "{0} >= {1}".format(str(f), str(ff)) +@given(flows(), flows()) +def test_binary_combinator_eq(f, ff): + """EQ combinator should always intersperse '==' in the elements.""" + assert str(comb.EQ(f, ff)) == "{0} == {1}".format(str(f), str(ff)) + + +@given(flows(), flows()) +def test_binary_combinator_ne(f, ff): + """NE combinator should always intersperse '!=' in the elements.""" + assert str(comb.NE(f, ff)) == "{0} != {1}".format(str(f), str(ff)) + + @given(flows()) def test_combinator_not(expr): """Not combinator should always prefix 'not' to its expression.""" diff --git a/tests/test_signal_analog_detectors.py b/tests/test_signal_analog_detectors.py index 09b12ff0..42f540b9 100644 --- a/tests/test_signal_analog_detectors.py +++ b/tests/test_signal_analog_detectors.py @@ -14,6 +14,7 @@ SlackNotification, HipChatNotification, \ ServiceNowNotification, \ VictorOpsNotification, \ + AmazonEventBridgeNotification, \ WebhookNotification, TeamNotification, \ TeamEmailNotification, Rule, Severity, \ Time, TimeConfig, VisualizationOptions, \ @@ -114,6 +115,14 @@ def test_victorops_valid(): assert n.options['routingKey'] == routing +def test_amazoneventbridge_valid(): + aeb_id = 'foo' + n = AmazonEventBridgeNotification(aeb_id) + + assert n.options['type'] == 'AmazonEventBridge' + assert n.options['credentialId'] == aeb_id + + def test_webhook_valid(): url = 'foo.com' secret = 'foo' From b59e020c0f78fc53b0b2327e8095e977b60c29fb Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 16:59:54 +0300 Subject: [PATCH 04/10] Remove flake8 workaround --- requirements_dev.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index d94e3bc4..9f970f77 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -5,8 +5,7 @@ click coverage email_validator enum34 -# https://github.com/PyCQA/pycodestyle/issues/728 --e git+https://gitlab.com/pycqa/flake8@9631dac5#egg=flake8 +flake8 hypothesis mock pytest From 3802bbd2a39d2fa295051f207990fa2705f665dc Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 17:55:45 +0300 Subject: [PATCH 05/10] Decrease flows() generation --- tests/generators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/generators.py b/tests/generators.py index 9b300965..6724b486 100644 --- a/tests/generators.py +++ b/tests/generators.py @@ -17,7 +17,8 @@ def ascii(): def flows(): return recursive( filters() | datas() | consts() | graphites() | newrelics(), - lambda children: whens() | detects()) + lambda children: whens() | detects(), + max_leaves=5) @composite From 3ea40b234c8ed9ce90eb99033fead6792feddb2b Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 20:28:16 +0300 Subject: [PATCH 06/10] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ea24f33..909e89d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.10.0 (2023-7-19) + +* Added `AmazonEventBridgeNotification` for Amazon EventBridge integration within detectors. +* Added combinators `EQ` (Equal) and `NE` (Not Equal). + ## 2.9.3 (2020-3-18) * Added `Alerts` in `signal_analog.flow` module to allow linking Detectors to Charts. From 80e5399d42521e784d47e39bb076e485eeaa5a08 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 21:27:15 +0300 Subject: [PATCH 07/10] Specify max_size for ascii() --- tests/generators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generators.py b/tests/generators.py index 6724b486..b7647a67 100644 --- a/tests/generators.py +++ b/tests/generators.py @@ -11,7 +11,7 @@ def ascii(): return text( characters(min_codepoint=1, max_codepoint=128, blacklist_categories=['Cc', 'Cs']), - min_size=1) + min_size=1, max_size=5) def flows(): From c64dbe9fdd3f71790118e4be485a631b95193e21 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 21:32:53 +0300 Subject: [PATCH 08/10] Avoid tagging on bumpversion run --- setup.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 869f064d..471f34aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [bumpversion] current_version = 2.9.3 commit = True -tag = True +tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}.{release}{build} {major}.{minor}.{patch} @@ -18,7 +18,7 @@ replace = __version__ = '{new_version}' [bumpversion:part:release] optional_value = prod first_value = dev -values = +values = dev prod From 97ae3544b5d09e1a1fe0fec1b7c711f9b2aded71 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 21:34:54 +0300 Subject: [PATCH 09/10] =?UTF-8?q?Bump=20version:=202.9.3=20=E2=86=92=202.1?= =?UTF-8?q?0.0.dev0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 7 +++---- setup.py | 2 +- signal_analog/__init__.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 471f34aa..7670b3cc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [bumpversion] -current_version = 2.9.3 +current_version = 2.10.0.dev0 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? -serialize = +serialize = {major}.{minor}.{patch}.{release}{build} {major}.{minor}.{patch} @@ -18,7 +18,7 @@ replace = __version__ = '{new_version}' [bumpversion:part:release] optional_value = prod first_value = dev -values = +values = dev prod @@ -34,4 +34,3 @@ test = pytest [tool:pytest] addopts = -n auto - diff --git a/setup.py b/setup.py index 5a23682f..0d389921 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( name='signal_analog', - version='2.9.3', + version='2.10.0.dev0', description='A troposphere-like library for managing SignalFx' + 'Charts, Dashboards, and Detectors.', long_description=readme + '\n\n' + history, diff --git a/signal_analog/__init__.py b/signal_analog/__init__.py index 25b27f50..fdc58ac9 100644 --- a/signal_analog/__init__.py +++ b/signal_analog/__init__.py @@ -9,7 +9,7 @@ __author__ = """Fernando Freire""" __email__ = 'Lst-nike.plus.platform.sharedinfrastructure@nike.com' -__version__ = '2.9.3' +__version__ = '2.10.0.dev0' logging_config = pkg_resources.resource_string( __name__, 'logging.yaml').decode('utf-8') From 3efe4c1875298d9b5488f57e65eff1f90b286d93 Mon Sep 17 00:00:00 2001 From: bebyx Date: Wed, 19 Jul 2023 21:37:27 +0300 Subject: [PATCH 10/10] =?UTF-8?q?Bump=20version:=202.10.0.dev0=20=E2=86=92?= =?UTF-8?q?=202.10.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.cfg | 2 +- setup.py | 2 +- signal_analog/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7670b3cc..cddec03f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.10.0.dev0 +current_version = 2.10.0 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? diff --git a/setup.py b/setup.py index 0d389921..2307d8aa 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( name='signal_analog', - version='2.10.0.dev0', + version='2.10.0', description='A troposphere-like library for managing SignalFx' + 'Charts, Dashboards, and Detectors.', long_description=readme + '\n\n' + history, diff --git a/signal_analog/__init__.py b/signal_analog/__init__.py index fdc58ac9..9f736023 100644 --- a/signal_analog/__init__.py +++ b/signal_analog/__init__.py @@ -9,7 +9,7 @@ __author__ = """Fernando Freire""" __email__ = 'Lst-nike.plus.platform.sharedinfrastructure@nike.com' -__version__ = '2.10.0.dev0' +__version__ = '2.10.0' logging_config = pkg_resources.resource_string( __name__, 'logging.yaml').decode('utf-8')