) print("*** Existing query: ***") pprint(query) print("\n\n\n") filter_field = "event.name" # name (as it appears in the JSON) of the filter you want to update existing_filter_value = "disabled^_chromium^_rendering,update^_user^_facts" # existing filter value that you want to change to something else new_filter_value = "create_query" # new filter value # Only modify the body of the query object to change the filter value if the filter value is set to what we expected if query['filters'][filter_field] == existing_filter_value: query['filters'][filter_field] = new_filter_value # Now, create a new query with the updated query object post_query = looker.create_query(query, "id") print("*** New query: ***") pprint(post_query) print("\n\n\n") results = looker.run_query(post_query['id']) print("*** Query results after filter update: ***") pprint(results) # And update the existing look to use the new query (if desired) body = {"query_id": post_query['id']} look = looker.update_look(look_id, body) else: raise Exception("Existing filter value '" + existing_filter_value + "' not found")
content_usage_query = looker.create_query(query_body=content_usage_query_body) print('Query Created: ' + str(content_usage_query['id'])) new_look = {} new_look['space_id'] = space_id new_look['query_id'] = content_usage_query['id'] new_look['title'] = "Unused Content" look = looker.create_look(new_look) print('Look Saved: ' + str(look['id'])) ### ------- GET USER EMAILS FROM USER_IDs ------- data = looker.run_query(query_id=content_usage_query['id']) user_ids = {row['user_id'] for row in data} print('Users with unused content: ' + str(user_ids)) me = looker.get_current_user() user_list = looker.get_all_users() emails = {} for u in user_list: if u['id'] in user_ids: emails[u['id']] = u['email'] print('Emails will be sent to: ' + str(emails)) ### ------- CREATE SCHEDULE AND SEND NOTICE -------