Skip to content

Commit 61796fd

Browse files
author
Serhiy Yevtushenko
committed
Merge branch 'issue-237-fix' of https://github.com/serhiy-yevtushenko/grafana-client into issue-237-fix
2 parents 0604513 + d0b8737 commit 61796fd

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Acquire sources
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121

2222
# Fixup for `setuptools_scm`
2323
# https://github.com/pypa/setuptools_scm/issues/480

.github/workflows/release-github.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
permissions: write-all
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v5
2323
with:
2424
fetch-depth: 0
2525
- name: tags

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
'pypy-3.9', 'pypy-3.10',
3939
]
4040
steps:
41-
- uses: actions/checkout@v4
41+
- uses: actions/checkout@v5
4242

4343
- name: Setup Python
4444
uses: actions/setup-python@v5

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
@@ -116,6 +116,13 @@ def test_update_alertrule_disable_provenance(self, m):
116116
self.assertIn("X-Disable-Provenance", headers)
117117
self.assertEqual(headers["X-Disable-Provenance"], "true")
118118

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()
125+
119126
@requests_mock.Mocker()
120127
def test_delete_mute_timing(self, m):
121128
JSON_RESPONSE = {}

0 commit comments

Comments
 (0)