#NEWLINE# def main( client , emails ) : #NEWLINE# #INDENT# user_list_service = client . GetService ( 'AdwordsUserListService' , 'v201601' ) #NEWLINE# user_list = { #NEWLINE# #INDENT# 'xsi_type' : 'CrmBasedUserList' , #NEWLINE# 'name' : ( 'Customer relationship management list #%d' % uuid . uuid4 ( ) ) , #NEWLINE# 'description' : 'A list of customers that originated from email addresses' , #NEWLINE# 'membershipLifeSpan' : 180 , #NEWLINE# 'optOutLink' : 'http://endpoint1.example.com/optout' , #NEWLINE# #UNINDENT# } #NEWLINE# operations = [ { #NEWLINE# #INDENT# 'operator' : 'ADD' , #NEWLINE# 'operand' : user_list , #NEWLINE# #UNINDENT# } ] #NEWLINE# result = user_list_service . mutate ( operations ) #NEWLINE# user_list_id = result [ 'value' ] [ 0 ] [ 'id' ] #NEWLINE# hashed_emails = HashEmails ( emails ) #NEWLINE# mutate_members_operation = { #NEWLINE# #INDENT# 'operand' : { #NEWLINE# #INDENT# 'userListId' : user_list_id , #NEWLINE# 'dataType' : 'EMAIL_SHA256' , #NEWLINE# 'members' : hashed_emails , #NEWLINE# #UNINDENT# } , #NEWLINE# 'operator' : 'ADD' , #NEWLINE# #UNINDENT# } #NEWLINE# response = user_list_service . mutateMembers ( [ mutate_members_operation ] ) #NEWLINE# if ( 'userLists' in mutate_members_operation ) : #NEWLINE# #INDENT# for user_list in response [ 'userLists' ] : #NEWLINE# #INDENT# print ( ( 'User list with name "%s" and ID "%d" was added.' % ( user_list [ 'name' ] , user_list [ 'id' ] ) ) )