Skip to content

Commit 51d16ee

Browse files
committed
fix legacy space references for charts on dashboards
1 parent fff9493 commit 51d16ee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/example1_copy_space.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
SPACE_UUID_MAP[s["uuid"]] = new_space["uuid"]
2626

2727
print('Getting all spaces and content')
28+
full_spaces = []
29+
for s in all_spaces:
30+
print(f'Getting all charts and dashboards for space {s["name"]}')
31+
full_spaces.append(source_client.space(s["uuid"], summary=False))
2832
full_spaces = [source_client.space(s["uuid"], summary=False) for s in all_spaces]
2933
all_charts = [chart for space in full_spaces for chart in space["queries"]]
3034
all_dashboards = [dashboard for space in full_spaces for dashboard in space["dashboards"]]
@@ -55,7 +59,9 @@
5559
if tile['type'] == 'saved_chart':
5660
if "belongsToDashboard" in tile["properties"] and tile["properties"]["belongsToDashboard"] == True:
5761
print(f'Copying chart that belongs to dashboard: {tile["properties"]["chartName"]}')
58-
chart = target_client.saved_chart(tile['properties']['savedChartUuid'])
62+
chart = source_client.saved_chart(tile['properties']['savedChartUuid'])
63+
if 'spaceUuid' in chart:
64+
chart['spaceUuid'] = SPACE_UUID_MAP[chart['spaceUuid']]
5965
new_chart = target_client.create_saved_chart({**chart, 'dashboardUuid': new_dashboard["uuid"]})
6066
CHART_UUID_MAP[chart["uuid"]] = new_chart["uuid"]
6167

0 commit comments

Comments
 (0)