Example #1
0
    def from_alert(alert, text):
        note = Note(
            text=text,
            user=g.user,
            note_type=NoteType.alert,
            attributes=dict(
                resource=alert.resource,
                event=alert.event,
                environment=alert.environment,
                severity=alert.severity,
                status=alert.status
            ),
            alert=alert.id,
            customer=alert.customer
        )

        history = History(
            id=note.id,
            event=alert.event,
            severity=alert.severity,
            status=alert.status,
            value=alert.value,
            text=text,
            change_type=ChangeType.note,
            update_time=datetime.utcnow(),
            user=g.login
        )
        db.add_history(alert.id, history)
        return note.create()
Example #2
0
 def delete_note(self, note_id):
     history = History(id=note_id,
                       event=self.event,
                       severity=self.severity,
                       status=self.status,
                       value=self.value,
                       text='note dismissed',
                       change_type=ChangeType.dismiss,
                       update_time=datetime.utcnow(),
                       user=g.login)
     db.add_history(self.id, history)
     return Note.delete_by_id(note_id)
Example #3
0
 def add_note(self, text: str) -> Note:
     note = Note.from_alert(self, text)
     history = History(id=note.id,
                       event=self.event,
                       severity=self.severity,
                       status=self.status,
                       value=self.value,
                       text=text,
                       change_type=ChangeType.note,
                       update_time=datetime.utcnow(),
                       user=g.login)
     db.add_history(self.id, history)
     return note
Example #4
0
 def add_note(self, note: str) -> bool:
     history = History(id=self.id,
                       event=self.event,
                       severity=self.severity,
                       status=self.status,
                       value=self.value,
                       text=note,
                       change_type='note',
                       update_time=datetime.utcnow())
     return db.add_history(self.id, history)
Example #5
0
 def add_note(self, note: str) -> bool:
     history = History(
         id=self.id,
         event=self.event,
         severity=self.severity,
         status=self.status,
         value=self.value,
         text=note,
         change_type='note',
         update_time=datetime.utcnow(),
         user=g.login
     )
     return db.add_history(self.id, history)