def post(self): req = request.get_json(True) require_fields(req, ('options', 'name', 'query_id')) query = models.Query.get_by_id_and_org(req['query_id'], self.current_org) require_access(query.groups, self.current_user, view_only) alert = models.Alert(name=req['name'], query_rel=query, user=self.current_user, options=req['options']) models.db.session.add(alert) models.db.session.flush() models.db.session.commit() self.record_event({ 'action': 'create', 'timestamp': int(time.time()), 'object_id': alert.id, 'object_type': 'alert' }) return alert.to_dict()
def post(self): req = request.get_json(True) require_fields(req, ("options", "name", "query_id")) query = models.Query.get_by_id_and_org(req["query_id"], self.current_org) require_access(query, self.current_user, view_only) alert = models.Alert( name=req["name"], query_rel=query, user=self.current_user, rearm=req.get("rearm"), options=req["options"], ) models.db.session.add(alert) models.db.session.flush() models.db.session.commit() self.record_event({ "action": "create", "object_id": alert.id, "object_type": "alert" }) return serialize_alert(alert)
def post(self): req = request.get_json(True) require_fields(req, ('options', 'name', 'query_id')) query = models.Query.get_by_id_and_org(req['query_id'], self.current_org) require_access(query, self.current_user, view_only) alert = models.Alert( name=req['name'], query_rel=query, user=self.current_user, rearm=req.get('rearm'), options=req['options'], ) models.db.session.add(alert) models.db.session.flush() models.db.session.commit() self.record_event({ 'action': 'create', 'object_id': alert.id, 'object_type': 'alert' }) return serialize_alert(alert)