Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions grafana_client/elements/_async/alertingprovisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ async def set_notification_policy_tree(self, notification_policy_tree, disable_p
set_notification_policy_tree_path = "/v1/provisioning/policies"
return await self.client.PUT(set_notification_policy_tree_path, json=notification_policy_tree, headers=headers)

async def delete_notification_policy_tree(self):
"""
Removes notification policy tree
@return:
"""
delete_notification_policy_tree_path = "/v1/provisioning/policies"
return await self.client.DELETE(delete_notification_policy_tree_path)

async def get_mute_timings(self):
"""
Gets all mute timings
Expand Down
8 changes: 8 additions & 0 deletions grafana_client/elements/alertingprovisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def set_notification_policy_tree(self, notification_policy_tree, disable_provena
set_notification_policy_tree_path = "/v1/provisioning/policies"
return self.client.PUT(set_notification_policy_tree_path, json=notification_policy_tree, headers=headers)

def delete_notification_policy_tree(self):
"""
Removes notification policy tree
@return:
"""
delete_notification_policy_tree_path = "/v1/provisioning/policies"
return self.client.DELETE(delete_notification_policy_tree_path)

def get_mute_timings(self):
"""
Gets all mute timings
Expand Down
7 changes: 7 additions & 0 deletions test/elements/test_alertingprovisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,10 @@ def test_update_alertrule_disable_provenance(self, m):
headers = history[0].headers
self.assertIn("X-Disable-Provenance", headers)
self.assertEqual(headers["X-Disable-Provenance"], "true")

@requests_mock.Mocker()
def test_delete_notification_policy_tree(self, m):
JSON_RESPONSE = {"receiver": "grafana-default-email", "group_by": ["grafana_folder", "alertname"]}

m.delete("http://localhost/api/v1/provisioning/policies", json=JSON_RESPONSE)
self.grafana.alertingprovisioning.delete_notification_policy_tree()