Knowledge Drop

How to sync a LookML Dashboards with a UDD Dashboards using the API

  • 7 July 2021
  • 1 reply
  • 156 views

Last tested: Aug 26, 2019
 

You may find yourself in a situation where you want to make changes to a User Defined Dashboard, and have those changes be reflected in an existing LookML Dashboard. This is possible via the API:

  1. dashboard()
    1. Insert the UDD id and run
    2. Copy the Response Body
  2. update_dashboard()
    1. Insert the Response Body from step 1 with one modification:
    2. Insert the LookML Dashboard ID (the part after the :: in the LookML Dashboard url) into the lookml_link_id parameter and run
  3. dashboard()
    1. Insert the LookML Dashboard ID and run
    2. Copy the Response Body
  4. sync_lookml_dashboard()
    1. Paste the Response Body from step 3
    2. You should see the UDD ID in the response body, confirming the sync has been successful.

 

This content is subject to limited support.                

 

 


1 reply

Userlevel 2

Hi all, here is the example snippet using Looker Python SDK for this use case. 

 

The following script will link a LookML dashboard (`thelook::users`) with a user-defined dashboard (UDD) id=1, abbreviated as dashboard, and then update the dashboard to reflect the LookML dashboard.

 

import looker_sdk
import os

# Auth in using the `os` module. Alternatively, use an `.ini` file
os.environ['LOOKERSDK_BASE_URL'] = 'url'
os.environ['LOOKERSDK_CLIENT_ID'] = 'foo'
os.environ['LOOKERSDK_CLIENT_SECRET'] = 'bar'

sdk = looker_sdk.init40()

# Link a LookML dashboard with a dashboard by updating `lookml_link_id`. To get the value for `lookml_link_id`, look at the URL of your LookML dashboard. Example: https://my-instance.com/dashboards-next/thelook::users then `thelook::users` would be the ID of this LookML dashboard

from looker_sdk.sdk.api40.models import WriteDashboard
sdk.update_dashboard(dashboard_id="1",body=WriteDashboard(
lookml_link_id="thelook::users"
))

# Sync the LookML dashboard with the dashboard (the dashboard will reflect what is currently defined in the LookML dashboard)
lookml = sdk.sync_lookml_dashboard(lookml_dashboard_id="thelook::users",body=WriteDashboard())
print(lookml) # expecting a list containing ids of all dashboards that have been linked to this LookML dashboard, in this example, expecting id 1

 

Reply