Knowledge Drop

Use Python SDK to convert All Dashboards to Dashboards-Next on an instance

  • 7 July 2021
  • 0 replies
  • 11 views

Userlevel 4
Badge

Last tested: Oct 22, 2020
 

Love dashboards-next, but hate having to convert legacy dashboards one folder at a time? This script will convert them all for you. You just need to use the Python SDK,
 

import looker_sdk

import csv

import pandas as pd

import time

i=0

list_of_dashboards = []

dashboards_next_list = []

legacy = []

# from typing import cast, MutableSequence, Sequence

####Initialize API/SDK for more info go here: https://pypi.org/project/looker-sdk/

from looker_sdk import methods40, models40

sdk = looker_sdk.init40() # or init40() for v4.0 API

me = sdk.me()

list_de_dashboards = sdk.all_dashboards()

while i < len(list_de_dashboards):

if sdk.dashboard(dashboard_id=list_de_dashboards[i].id).preferred_viewer == "dashboards-next":

dashboards_next_list.append(list_de_dashboards[i].id)

else:

legacy.append(list_de_dashboards[i].id)

i = i + 1

time.sleep(1.0)

print(i)

#print("list of dashboards-next")

#print(dashboards_next_list)

#print("list of LEGACY")

#print(legacy)

n = 0

while n < len(legacy):

sdk.update_dashboard(dashboard_id=legacy[n], body=models40.WriteDashboard(preferred_viewer="dashboards-next"))

print(dashboards_next_list[n])

n = n + 1

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply