Beispiel #1
0
source_looker = LookerApi(host=my_host, token=my_token, secret=my_secret)

### ------- GET THE SOURCE LOOK -------

look_body = source_looker.get_look_info(source_look_id,
                                        'query_id, query, title')
print "---- Source Look Body ----"
pp(look_body)

print "---- Source query ----"
query_body = source_looker.get_query(look_body['query_id'])
pp(query_body)

### ------- BUILD THE TARGET LOOK -------

print "---- New query ----"
new_query = dest_looker.create_query(query_body, 'id')
new_query_id = str(new_query['id'])
print new_query_id + " is the new query id"

new_look = {}
new_look['space_id'] = destination_space_id
new_look['query_id'] = new_query_id
new_look['title'] = look_body['title'] + "from teach"
dest_looker.create_look(new_look)

### ------- DONE -------

print "Done"
            "dashboard.id", "dashboard.user_id", "dashboard.space_id",
            "look.id", "look.user_id", "look.space_id"
        ]
    }
}

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: