# for value in spaces_content_metadata_ids.iteritems(): # ....print "metadata",json.loads(json.dumps(looker.get_all_content_metadata_access(value,fields='id,content_metadata_id,permission_type,user_id,group_id'))) df2 = pd.DataFrame(spacejson, columns=['id', 'name', 'content_metadata_id']).rename(index=str, columns={'id':'space_id','content_metadata_id': 'cmid', 'name': 'space_name'}) df2nonpersonalremoved = df2[df2.space_id.isin(non_personal_descendant_ids)] # You don't want to list User spaces because they shouldn't be audited df2usersremoved = df2nonpersonalremoved['space_name'] != 'Users' df_spaces_filtered = df2nonpersonalremoved[df2usersremoved] # Get the group names groups = looker.get_all_groups(fields='id,name,user_count') groupsdf = pd.DataFrame(groups, columns=['id', 'name', 'user_count' ]).rename(index=str, columns={'id': 'group_id', 'name': 'group_name', 'user_count': '# users'}) print 'All Spaces: \n', df_spaces_filtered print '+---------------+---------------+---------------+ \n' print 'Each Top Level Space and user/group access levels \n' # print spaces_content_metadata_ids, non_personal_descendant_ids # Put all the dataframes in a list so we can concatenate at the end using pd.concat and get rid of headers list_of_dataframes = [] inheriting_space_ids = [] admin_only_access_space_ids = []
### ------- 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) if args.groups: for source_group_id in args.groups.split(','): source_group_info = looker.get_group(group_id=source_group_id, fields='id,name') dest_group = looker.create_group(group_name=source_group_info['name'] + " " + "(Mirror)") create = looker.create_group_in_group( parent_group_id=dest_group['id'], child_group_id=source_group_info['id']) else: all_groups = looker.get_all_groups(fields='id,name') for source_group in all_groups: dest_group = looker.create_group(group_name=source_group['name'] + " " + "(Mirror)", fields='id') create = looker.create_group_in_group( parent_group_id=dest_group['id'], child_group_id=source_group['id'])