@@ -151,11 +151,7 @@ def delete_alertmanager_silence_by_id(
151
151
RequestsMethods .DELETE ,
152
152
)
153
153
154
- if (
155
- api_call == dict ()
156
- or api_call .get ("message" )
157
- != "silence deleted"
158
- ):
154
+ if api_call == dict () or api_call .get ("message" ) != "silence deleted" :
159
155
logging .error (f"Please, check the error: { api_call } ." )
160
156
raise Exception
161
157
else :
@@ -258,7 +254,9 @@ def create_or_update_alertmanager_silence(
258
254
json .dumps (silence_json_dict ),
259
255
)
260
256
261
- if api_call == dict () or (api_call .get ("id" ) is None and api_call .get ("silenceID" ) is None ):
257
+ if api_call == dict () or (
258
+ api_call .get ("id" ) is None and api_call .get ("silenceID" ) is None
259
+ ):
262
260
logging .error (f"Check the error: { api_call } ." )
263
261
raise Exception
264
262
else :
@@ -661,7 +659,12 @@ def create_or_update_ruler_group_by_namespace(
661
659
None
662
660
"""
663
661
664
- if len (datasource_uid ) != 0 and len (namespace ) != 0 and len (group_name ) != 0 and rules != list ():
662
+ if (
663
+ len (datasource_uid ) != 0
664
+ and len (namespace ) != 0
665
+ and len (group_name ) != 0
666
+ and rules != list ()
667
+ ):
665
668
rules_json_list : list = list ()
666
669
667
670
for rule in rules :
@@ -696,7 +699,9 @@ def create_or_update_ruler_group_by_namespace(
696
699
else :
697
700
logging .info ("You successfully created an ruler group." )
698
701
else :
699
- logging .error ("There is no datasource_uid, namespace, name or rules defined." )
702
+ logging .error (
703
+ "There is no datasource_uid, namespace, name or rules defined."
704
+ )
700
705
raise ValueError
701
706
702
707
def delete_ruler_group (
@@ -729,7 +734,9 @@ def delete_ruler_group(
729
734
else :
730
735
logging .info ("You successfully deleted a ruler group." )
731
736
else :
732
- logging .error ("There is no datasource_uid, namespace or group_name defined." )
737
+ logging .error (
738
+ "There is no datasource_uid, namespace or group_name defined."
739
+ )
733
740
raise ValueError
734
741
735
742
def get_ruler_group (
@@ -761,7 +768,9 @@ def get_ruler_group(
761
768
else :
762
769
return api_call
763
770
else :
764
- logging .error ("There is no datasource_uid, namespace or group_name defined." )
771
+ logging .error (
772
+ "There is no datasource_uid, namespace or group_name defined."
773
+ )
765
774
raise ValueError
766
775
767
776
def test_rule (self , data_query : list ) -> dict :
@@ -823,7 +832,11 @@ def test_rule(self, data_query: list) -> dict:
823
832
raise ValueError
824
833
825
834
def test_datasource_uid_rule (
826
- self , expr : str , condition : str , data_query : list , datasource_uid : str = "grafana"
835
+ self ,
836
+ expr : str ,
837
+ condition : str ,
838
+ data_query : list ,
839
+ datasource_uid : str = "grafana" ,
827
840
) -> dict :
828
841
"""The method includes a functionality to test a datasource uid rule specified by the expr, the condition, a list of data queries and the datasource_uid
829
842
@@ -841,7 +854,12 @@ def test_datasource_uid_rule(
841
854
api_call (dict): Returns the result of the specified datasource_uid rule
842
855
"""
843
856
844
- if len (datasource_uid ) != 0 and len (expr ) != 0 and len (condition ) != 0 and data_query != list ():
857
+ if (
858
+ len (datasource_uid ) != 0
859
+ and len (expr ) != 0
860
+ and len (condition ) != 0
861
+ and data_query != list ()
862
+ ):
845
863
datasource_rule_query_objects_json : list = list ()
846
864
datasource_rule_query_object_json : dict = dict ()
847
865
@@ -1045,9 +1063,7 @@ def create_or_update_ngalert_organization_configuration(
1045
1063
"You successfully created an NGAlert organization configuration."
1046
1064
)
1047
1065
else :
1048
- logging .error (
1049
- "There is no alert_managers or alertmanagers_choice defined."
1050
- )
1066
+ logging .error ("There is no alert_managers or alertmanagers_choice defined." )
1051
1067
raise ValueError
1052
1068
1053
1069
def get_ngalert_alertmanagers_by_organization (self ) -> dict :
0 commit comments