This repository was archived by the owner on Sep 25, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 88
99#### GO TO ADMIN --> GROUPS AND FIND THE GROUP ID YOU WANT TO ADD THE PEOPLE TO. ADD IT BELOW
1010### Alternative would be to use the search groups endpoint
11+ ### Depending on the cleanliness of your source of emails, you may want to add more error handling
12+ ### EG check for structure, add users without Looker accounts to an output file, or even pass them into another endpoint where you create an account.
1113
12- sdk .search_groups ()
1314def add_csv_of_users_to_group (group_id :int , file_path :str ):
1415 data = []
1516 i = 0
@@ -18,21 +19,24 @@ def add_csv_of_users_to_group(group_id:int, file_path:str):
1819 for row in reader :
1920 data .append (str (row [i ]))
2021
21- ### loops through list and searches user
22- ### grabs user id and passes that through add user to group
22+ ## loops through list and searches user
23+ ## grabs user id and passes that through add user to group
2324 try :
2425 for email in data :
2526 for user in sdk .search_users (email = email ):
26- sdk .add_group_user (group_id = group_id , body = models40 .GroupIdForGroupUserInclusion (user_id = user .id ))
27+ #print(user.email)
28+ if user .id :
29+ sdk .add_group_user (group_id = group_id , body = models40 .GroupIdForGroupUserInclusion (user_id = user .id ))
30+ else :
31+ pass
32+
2733 except KeyError :
2834 print ('Key error \n ' )
29- print (email )
3035 pass
3136 except TypeError :
3237 print ('Type error \n ' )
33- print (email )
3438 pass
3539 except IndexError :
3640 print ('Index error \n ' )
37- print ( email )
38- pass
41+ pass
42+ add_csv_of_users_to_group ( 121 , "test.csv" )
You can’t perform that action at this time.
0 commit comments