File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1212from .client import GrafanaClient
1313from .elements import (
1414 Admin ,
15+ Alerting ,
1516 AlertingProvisioning ,
1617 Annotations ,
1718 Dashboard ,
@@ -57,6 +58,7 @@ def __init__(
5758 )
5859 self .url = None
5960 self .admin = Admin (self .client )
61+ self .alerting = Alerting (self .client )
6062 self .alertingprovisioning = AlertingProvisioning (self .client )
6163 self .dashboard = Dashboard (self .client )
6264 self .dashboard_versions = DashboardVersions (self .client )
Original file line number Diff line number Diff line change 11from .admin import Admin
2+ from .alerting import Alerting
23from .alertingprovisioning import AlertingProvisioning
34from .annotations import Annotations
45from .base import Base
Original file line number Diff line number Diff line change 1+ from .base import Base
2+
3+
4+ class Alerting (Base ):
5+ def __init__ (self , client ):
6+ super (Alerting , self ).__init__ (client )
7+ self .client = client
8+
9+ def get_alertrule (self , folder_name , alertrule_name ):
10+ """
11+ :param folder_name:
12+ :param alertrule_name:
13+ :return:
14+ """
15+ get_alertrule_path = "/ruler/grafana/api/v1/rules/%s/%s" % (folder_name , alertrule_name )
16+ r = self .client .GET (get_alertrule_path )
17+ return r
18+
19+ def create_alertrule (self , folder_name , alertrule ):
20+ """
21+ :param folder_name:
22+ :param alertrule:
23+ :return:
24+ """
25+ create_alertrule_path = "/ruler/grafana/api/v1/rules/%s" % folder_name
26+ r = self .client .POST (create_alertrule_path , json = alertrule )
27+ return r
28+
29+ def update_alertrule (self , folder_name , alertrule ):
30+ """
31+ @param folder_name:
32+ @param alertrule:
33+ @return:
34+ """
35+
36+ update_alertrule_path = "/ruler/grafana/api/v1/rules/%s" % folder_name
37+ r = self .client .POST (update_alertrule_path , json = alertrule )
38+ return r
39+
40+ def delete_alertrule (self , folder_name , alertrule_name ):
41+ """
42+ :param folder_name:
43+ :param alertrule_name:
44+ @return:
45+ """
46+
47+ delete_alertrule_path = "/ruler/grafana/api/v1/rules/%s/%s" % (folder_name , alertrule_name )
48+ r = self .client .DELETE (delete_alertrule_path )
49+ return r
You can’t perform that action at this time.
0 commit comments