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

Knowledge Drop

Last tested: Aug 12, 2022
 

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

  1. dashboard()
    1. Insert the UDD id and run
    2. Notice the lookml_link_id in the response body, this is what we want to update.
  2. update_dashboard()
    1. Insert the LookML Dashboard ID (the part with the :: in the LookML Dashboard url) into the earlier part of the response body from step 1 to update just the lookml_link_id parameter and run {lookml_link_id="thelook::users"2zIIop_XWkhl3CrZKhR0B1oO9ee_kALBFrk3PZQJ5cH_JFG5JyZn-eN6eHZU4hZoKtI43dhW0SBPyghBSxZ0C1Ht8_wdD9aNcrQ9xzKGbA1sqhoJPp-GJvJ5XmYv0jH_m6cVNAK8eAmdj-aO6u0ESqD-kTUz_SrXI9lw8-DzVENHDETi5dI5TtdQqzI

  3. sync_lookml_dashboard()
    1. Enter the Lookml dashboard ID and paste a simple body like {"lookml_link_id": "thelook::users"}
    2. You should see the UDD ID in the response body, confirming the sync has been successful.
      _pmjjwLSOFdExMYpHy2jXTgVZEmbh7tYh43IhZkK_BmTT2wY7FLvzoQJ-jhkDc4mFxRgAzhPcaIbQrJK3ZA8STMg-t4KJQAhVuor0OlXCR6kgSZcf5bqIbu6hbMxEHQ1ANy7vo2i0iaKybFinCkXptcqbSjPVa2PLjPoOOaJXabku3MtccFc6KfWFyg

This content is subject to limited support.                

Comments
lantrann
Staff

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
Version history
Last update:
‎07-07-2021 01:12 PM
Updated by: