### ------- HERE ARE PARAMETERS TO CONFIGURE ------- dashboard_id = 7 host = 'cs_eng' ### ------- OPEN THE CONFIG FILE and INSTANTIATE API ------- f = open('config.yml') params = yaml.load(f) f.close() my_host = params['hosts'][host]['host'] my_secret = params['hosts'][host]['secret'] my_token = params['hosts'][host]['token'] looker = LookerApi(host=my_host, token=my_token, secret=my_secret) dashboard = looker.get_dashboard(dashboard_id) # Collect dashboard filters dashboard_filters = [] filter_params = ['id', 'title', 'default_value', 'dashboard_id'] for dashboard_filter_object in dashboard['dashboard_filters']: dashboard_filter = { param: dashboard_filter_object[param] for param in filter_params } dashboard_filters.append(dashboard_filter) # Collect dashboard queries and associated filter listerners query_params = [ 'model', 'view', 'fields', 'pivots', 'filters', 'sorts', 'query_timezone', 'limit', 'total', 'row_total', 'fill_fields', 'dynamic_fields'
params = yaml.load(f) f.close() host = 'localhost' my_host = params['hosts'][host]['host'] my_secret = params['hosts'][host]['secret'] my_token = params['hosts'][host]['token'] looker = LookerApi(host=my_host, token=my_token, secret=my_secret) looks_to_delete = [] soft_delete = {"deleted": True} #applies to both look and dashboard patchs for dashboard_id in args.dashboards.split(','): dashboard_looks = looker.get_dashboard( dashboard_id, fields="dashboard_elements(look_id)") if dashboard_looks: looks_to_delete = looks_to_delete + [ look['look_id'] for look in dashboard_looks['dashboard_elements'] ] dashboard_updated = looker.update_dashboard(dashboard_id, body=soft_delete, fields='id') pprint("Soft deleted dashboard id " + str(dashboard_updated['id'])) for look_id in looks_to_delete: look_updated = looker.update_look(look_id, body=soft_delete, fields='id') if look_updated: pprint("Soft deleted look id " + str(look_updated['id']))