#NEWLINE# def _handle_pagerduty( self , client , thread_id , payload ) : #NEWLINE# #INDENT# messages = payload . get ( 'messages' ) #NEWLINE# for message in messages : #NEWLINE# #INDENT# incident = message [ 'data' ] [ 'incident' ] #NEWLINE# url = incident [ 'html_url' ] #NEWLINE# title = incident [ 'trigger_summary_data' ] [ 'subject' ] #NEWLINE# if incident . get ( 'assigned_to_user' , None ) : #NEWLINE# #INDENT# assignee = self . _user_for_email ( client , incident [ 'assigned_to_user' ] [ 'email' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assignee = 'nobody' #NEWLINE# #UNINDENT# if incident . get ( 'resolved_by_user' , None ) : #NEWLINE# #INDENT# resolver = self . _user_for_email ( client , incident [ 'resolved_by_user' ] [ 'email' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# resolver = 'nobody' #NEWLINE# #UNINDENT# if ( message [ 'type' ] == 'incident.trigger' ) : #NEWLINE# #INDENT# message = ( "New PagerDuty incident '%(title)s' assigned to %(assignee)s \n%(url)s" % { #NEWLINE# #INDENT# 'title' : title , #NEWLINE# 'assignee' : assignee , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) #NEWLINE# client . new_message ( thread_id , message , silent = False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( message [ 'type' ] == 'incident.resolve' ) : #NEWLINE# #INDENT# message = ( "PagerDuty incident '%(title)s' resolved by %(resolver)s \n%(url)s" % { #NEWLINE# #INDENT# 'title' : title , #NEWLINE# 'resolver' : resolver , #NEWLINE# 'url' : url , #NEWLINE# #UNINDENT# } ) #NEWLINE# client . new_message ( thread_id , message , silent = True )