class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema() if 'TEMPLATE_PATH' in app.config: self.sender = AlarmSender(app.config['TEMPLATE_PATH'], app.config['GROUP_ALERTS']) else: self.sender = AlarmSender(group_alerts=app.config['GROUP_ALERTS']) @api_v2.expect(message) def post(self, connector): alerts = self.schema.load(request.get_json()).data self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS']) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema( exclude_fields=app.config['LABELS_EXCLUDED'], exclude_annotations=app.config['ANNOTATIONS_EXCLUDED']) self.sender = AlarmSender( template_path=app.config.get('TEMPLATE_PATH'), group_alerts_by=app.config['GROUP_ALERTS_BY'], teams_client_config=app.config.get('TEAMS_CLIENT_CONFIG')) @api_v2.expect(message) def post(self, connector): alerts = self.schema.load(request.get_json()) self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS'][connector]) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema() self.sender = AlarmSender( template_path=app.config.get('TEMPLATE_PATH'), teams_client_config=app.config.get('TEAMS_CLIENT_CONFIG')) @api_v1.expect(message) def post(self): _show_deprecated_warning( "Call to deprecated function. It will be removed in future versions. " "Please view the README file.") alerts = self.schema.load(request.get_json()) self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS']['Connector']) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema() if app.config['TEMPLATE_PATH']: self.sender = AlarmSender(app.config['TEMPLATE_PATH'], app.config['GROUP_ALERTS_BY']) else: self.sender = AlarmSender( group_alerts_by=app.config['GROUP_ALERTS_BY']) @api_v2.expect(message) def post(self, connector): log.debug('JSON received is:\n%s', str(request.get_json())) alerts = self.schema.load(request.get_json()) self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS'][connector]) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema() if 'TEMPLATE_PATH' in app.config: self.sender = AlarmSender(app.config['TEMPLATE_PATH']) else: self.sender = AlarmSender() @api_v1.expect(message) def post(self): _show_deprecated_warning( "Call to deprecated function. It will be removed in future versions. " "Please view the README file.") alerts = self.schema.load(request.get_json()).data self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS']['Connector']) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema( exclude_fields=app.config['LABELS_EXCLUDED']) if app.config['TEMPLATE_PATH']: self.sender = AlarmSender(app.config['TEMPLATE_PATH'], app.config['GROUP_ALERTS_BY']) else: self.sender = AlarmSender( group_alerts_by=app.config['GROUP_ALERTS_BY']) @api_v2.expect(message) def post(self, connector): alerts = self.schema.load(request.get_json()) self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS'][connector]) return 'OK', 201
class AlertReceiver(Resource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.schema = MessageSchema() if 'TEMPLATE_PATH' in app.config: self.sender = AlarmSender(app.config['TEMPLATE_PATH']) else: self.sender = AlarmSender() @api_v2.expect(message) def post(self, connector): alerts = self.schema.load(request.get_json()).data if 'Critical' in app.config['MICROSOFT_TEAMS']: critical_alerts = [ alert for alert in alerts if alert.severity is 'critical' ] self.sender.send_alarms(critical_alerts, app.config['MICROSOFT_TEAMS']['Critical']) self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS'][connector]) return 'OK', 201