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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## unreleased
- Fixed `update_dashboard` to also handle `folderUid` well. Thanks, @CantankerousBullMoose.

## 4.3.0 (2025-02-08)
- Added support for querying all data source-managed alerts. Thanks, @dmyerscough.
Expand Down
13 changes: 7 additions & 6 deletions grafana_client/elements/_async/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ async def update_dashboard(self, 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"]
# When `folderId` or `folderUid` are not available within the dashboard payload,
# populate them from the nested `meta` object, when given.
for attribute in ["folderId", "folderUid"]:
if attribute not in dashboard:
if "meta" in dashboard and attribute in dashboard["meta"]:
dashboard = dashboard.copy()
dashboard[attribute] = dashboard["meta"][attribute]

put_dashboard_path = "/dashboards/db"
return await self.client.POST(put_dashboard_path, json=dashboard)
Expand Down
13 changes: 7 additions & 6 deletions grafana_client/elements/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ def update_dashboard(self, 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"]
# When `folderId` or `folderUid` are not available within the dashboard payload,
# populate them from the nested `meta` object, when given.
for attribute in ["folderId", "folderUid"]:
if attribute not in dashboard:
if "meta" in dashboard and attribute in dashboard["meta"]:
dashboard = dashboard.copy()
dashboard[attribute] = dashboard["meta"][attribute]

put_dashboard_path = "/dashboards/db"
return self.client.POST(put_dashboard_path, json=dashboard)
Expand Down
Loading