-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add monkeypatch for grafana-api package
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://github.com/m0nhawk/grafana_api/pull/85/files | ||
|
||
def update_dashboard(self, dashboard): | ||
""" | ||
:param dashboard: | ||
:return: | ||
""" | ||
|
||
# When the "folderId" is not available within the dashboard payload, | ||
# populate it from the nested "meta" object, if given. | ||
if "folderId" not in dashboard: | ||
if "meta" in dashboard and "folderId" in dashboard["meta"]: | ||
dashboard = dashboard.copy() | ||
dashboard["folderId"] = dashboard["meta"]["folderId"] | ||
|
||
put_dashboard_path = "/dashboards/db" | ||
r = self.api.POST(put_dashboard_path, json=dashboard) | ||
return r | ||
|
||
|
||
def monkeypatch_grafana_api(): | ||
import grafana_api.api.dashboard as dashboard | ||
dashboard.Dashboard.update_dashboard = update_dashboard |