Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API method get_alertrules_all #97

Merged
merged 1 commit into from
Jul 30, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Add missing argument `dashboard_uid` to `get_annotation` method.
Thanks, @nikita-b.
* Add API method `get_alertrules_all`. Thanks, @harish422.


## 3.5.0 (2022-12-07)
Expand Down
9 changes: 9 additions & 0 deletions grafana_client/elements/alertingprovisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ def __init__(self, client):
super(AlertingProvisioning, self).__init__(client)
self.client = client

def get_alertrules_all(self):
"""
Gets all alert rules
@return:
"""
get_alertrules_all_path = "/v1/provisioning/alert-rules"
r = self.client.GET(get_alertrules_all_path)
return r

def get_alertrule(self, alertrule_uid):
"""

Expand Down
6 changes: 6 additions & 0 deletions test/elements/test_alertingprovisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class AlertingProvisioningTestCase(unittest.TestCase):
def setUp(self):
self.grafana = GrafanaApi(("admin", "admin"), host="localhost", url_path_prefix="", protocol="http")

@requests_mock.Mocker()
def test_get_alertrules_all(self, m):
m.get("http://localhost/api/v1/provisioning/alert-rules", json=[ALERTRULE])
response = self.grafana.alertingprovisioning.get_alertrules_all()
self.assertEqual(response[0]["uid"], "bUUGqLiVk")

@requests_mock.Mocker()
def test_get_alertrule(self, m):
m.get("http://localhost/api/v1/provisioning/alert-rules/bUUGqLiVk", json=ALERTRULE)
Expand Down