Skip to content

Commit 755ef50

Browse files
serhiy-yevtushenkoSerhiy Yevtushenko
andauthored
fix: added method for removal of notification policy tree (#236)
Co-authored-by: Serhiy Yevtushenko <[email protected]>
1 parent d45166b commit 755ef50

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

grafana_client/elements/_async/alertingprovisioning.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ async def set_notification_policy_tree(self, notification_policy_tree, disable_p
145145
set_notification_policy_tree_path = "/v1/provisioning/policies"
146146
return await self.client.PUT(set_notification_policy_tree_path, json=notification_policy_tree, headers=headers)
147147

148+
async def delete_notification_policy_tree(self):
149+
"""
150+
Removes notification policy tree
151+
@return:
152+
"""
153+
delete_notification_policy_tree_path = "/v1/provisioning/policies"
154+
return await self.client.DELETE(delete_notification_policy_tree_path)
155+
148156
async def get_mute_timings(self):
149157
"""
150158
Gets all mute timings

grafana_client/elements/alertingprovisioning.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ def set_notification_policy_tree(self, notification_policy_tree, disable_provena
145145
set_notification_policy_tree_path = "/v1/provisioning/policies"
146146
return self.client.PUT(set_notification_policy_tree_path, json=notification_policy_tree, headers=headers)
147147

148+
def delete_notification_policy_tree(self):
149+
"""
150+
Removes notification policy tree
151+
@return:
152+
"""
153+
delete_notification_policy_tree_path = "/v1/provisioning/policies"
154+
return self.client.DELETE(delete_notification_policy_tree_path)
155+
148156
def get_mute_timings(self):
149157
"""
150158
Gets all mute timings

test/elements/test_alertingprovisioning.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,10 @@ def test_update_alertrule_disable_provenance(self, m):
115115
headers = history[0].headers
116116
self.assertIn("X-Disable-Provenance", headers)
117117
self.assertEqual(headers["X-Disable-Provenance"], "true")
118+
119+
@requests_mock.Mocker()
120+
def test_delete_notification_policy_tree(self, m):
121+
JSON_RESPONSE = {"receiver": "grafana-default-email", "group_by": ["grafana_folder", "alertname"]}
122+
123+
m.delete("http://localhost/api/v1/provisioning/policies", json=JSON_RESPONSE)
124+
self.grafana.alertingprovisioning.delete_notification_policy_tree()

0 commit comments

Comments
 (0)