#NEWLINE# @ classmethod #NEWLINE# @ gen . coroutine #NEWLINE# def TerminateAccountOperation( cls , client , user_id , merged_with = None ) : #NEWLINE# #INDENT# 'Invokes User.TerminateAccount via operation execution.' #NEWLINE# @ gen . coroutine #NEWLINE# def _VisitIdentity( identity_key ) : #NEWLINE# #INDENT# 'Unlink this identity from the user.' #NEWLINE# ( yield Identity . UnlinkIdentityOperation ( client , user_id , identity_key . hash_key ) ) #NEWLINE# #UNINDENT# ( yield gen . Task ( Device . MuteAlerts , client , user_id ) ) #NEWLINE# query_expr = ( 'identity.user_id={id}' , { #NEWLINE# #INDENT# 'id' : user_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# ( yield gen . Task ( Identity . VisitIndexKeys , client , query_expr , _VisitIdentity ) ) #NEWLINE# timestamp = Operation . GetCurrent ( ) . timestamp #NEWLINE# payload = ( 'terminate' if ( merged_with is None ) else ( 'merge=%s' % merged_with ) ) #NEWLINE# analytics = Analytics . Create ( entity = ( 'us:%d' % user_id ) , type = Analytics . USER_TERMINATE , timestamp = timestamp , payload = payload ) #NEWLINE# ( yield gen . Task ( analytics . Update , client ) ) #NEWLINE# ( yield gen . Task ( User . TerminateAccount , client , user_id , merged_with = merged_with ) ) #NEWLINE# ( yield NotificationManager . NotifyTerminateAccount ( client , user_id ) )