def process_actions(self, actions):
        """Process the actions we want to take

        Args:
            actions (`list`): List of actions we want to take

        Returns:
            `list` of notifications
        """
        notices = {}
        notification_contacts = {}
        for action in actions:
            resource = action['resource']
            action_status = ActionStatus.SUCCEED

            try:
                if action['action'] == AuditActions.REMOVE:
                    action_status = self.process_action(
                        resource,
                        AuditActions.REMOVE
                    )
                    if action_status == ActionStatus.SUCCEED:
                        db.session.delete(action['issue'].issue)

                elif action['action'] == AuditActions.STOP:
                    action_status = self.process_action(
                        resource,
                        AuditActions.STOP
                    )
                    if action_status == ActionStatus.SUCCEED:
                        action['issue'].update({
                            'missing_tags': action['missing_tags'],
                            'notes': action['notes'],
                            'last_alert': action['last_alert'],
                            'state': action['action']
                        })

                elif action['action'] == AuditActions.FIXED:
                    db.session.delete(action['issue'].issue)

                elif action['action'] == AuditActions.ALERT:
                    action['issue'].update({
                        'missing_tags': action['missing_tags'],
                        'notes': action['notes'],
                        'last_alert': action['last_alert'],
                        'state': action['action']
                    })

                db.session.commit()

                if action_status == ActionStatus.SUCCEED:
                    for owner in [
                        dict(t) for t in {tuple(d.items()) for d in (action['owners'] + self.permanent_emails)}
                    ]:
                        if owner['value'] not in notification_contacts:
                            contact = NotificationContact(type=owner['type'], value=owner['value'])
                            notification_contacts[owner['value']] = contact
                            notices[contact] = {
                                'fixed': [],
                                'not_fixed': []
                            }
                        else:
                            contact = notification_contacts[owner['value']]

                        if action['action'] == AuditActions.FIXED:
                            notices[contact]['fixed'].append(action)
                        else:
                            notices[contact]['not_fixed'].append(action)
            except Exception as ex:
                self.log.exception('Unexpected error while processing resource {}/{}/{}/{}'.format(
                    action['resource'].account.account_name,
                    action['resource'].id,
                    action['resource'],
                    ex
                ))

        return notices
def process_actions ( self , actions ) : notices = { } notification_contacts = { } for action in actions : resource = action [ 'resource' ] action_status = ActionStatus . SUCCEED try : if action [ 'action' ] == AuditActions . REMOVE : action_status = self . process_action ( resource , AuditActions . REMOVE ) if action_status == ActionStatus . SUCCEED : db . session . delete ( action [ 'issue' ] . issue ) elif action [ 'action' ] == AuditActions . STOP : action_status = self . process_action ( resource , AuditActions . STOP ) if action_status == ActionStatus . SUCCEED : action [ 'issue' ] . update ( { 'missing_tags' : action [ 'missing_tags' ] , 'notes' : action [ 'notes' ] , 'last_alert' : action [ 'last_alert' ] , 'state' : action [ 'action' ] } ) elif action [ 'action' ] == AuditActions . FIXED : db . session . delete ( action [ 'issue' ] . issue ) elif action [ 'action' ] == AuditActions . ALERT : action [ 'issue' ] . update ( { 'missing_tags' : action [ 'missing_tags' ] , 'notes' : action [ 'notes' ] , 'last_alert' : action [ 'last_alert' ] , 'state' : action [ 'action' ] } ) db . session . commit ( ) if action_status == ActionStatus . SUCCEED : for owner in [ dict ( t ) for t in { tuple ( d . items ( ) ) for d in ( action [ 'owners' ] + self . permanent_emails ) } ] : if owner [ 'value' ] not in notification_contacts : contact = NotificationContact ( type = owner [ 'type' ] , value = owner [ 'value' ] ) notification_contacts [ owner [ 'value' ] ] = contact notices [ contact ] = { 'fixed' : [ ] , 'not_fixed' : [ ] } else : contact = notification_contacts [ owner [ 'value' ] ] if action [ 'action' ] == AuditActions . FIXED : notices [ contact ] [ 'fixed' ] . append ( action ) else : notices [ contact ] [ 'not_fixed' ] . append ( action ) except Exception as ex : self . log . exception ( 'Unexpected error while processing resource {}/{}/{}/{}' . format ( action [ 'resource' ] . account . account_name , action [ 'resource' ] . id , action [ 'resource' ] , ex ) ) return notices
Process the actions we want to take

        Args:
            actions (`list`): List of actions we want to take

        Returns:
            `list` of notifications