Skip to content

Commit

Permalink
Restore missing newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Byers committed Mar 21, 2018
1 parent 75633f1 commit a53994f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions stream_alert/alert_processor/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
Copyright 2017-present, Airbnb Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -41,6 +44,7 @@ def get_instance(cls, invoked_function_arn):

def __init__(self, invoked_function_arn):
"""Initialization logic that can be cached across invocations.
Args:
invoked_function_arn (str): The ARN of the alert processor when it was invoked.
This is used to calculate region, account, and prefix.
Expand All @@ -61,8 +65,10 @@ def __init__(self, invoked_function_arn):
@staticmethod
def _build_alert_payload(record):
"""Transform a raw Dynamo record into a payload ready for dispatching.
Args:
record (dict): A row in the Dynamo alerts table
Returns:
OrderedDict: An alert payload ready to be sent to output dispatchers.
"""
Expand All @@ -84,8 +90,10 @@ def _build_alert_payload(record):

def _create_dispatcher(self, output):
"""Create a dispatcher for the given output.
Args:
output (str): Alert output, e.g. "aws-sns:topic-name"
Returns:
OutputDispatcher: Based on the output type.
Returns None if the output is invalid or not defined in the config.
Expand All @@ -108,6 +116,7 @@ def _create_dispatcher(self, output):
@staticmethod
def _send_alert(alert_payload, output, dispatcher):
"""Send a single alert to the given output.
Returns:
bool: True if the alert was sent successfully.
"""
Expand Down Expand Up @@ -145,8 +154,10 @@ def _update_alerts_table(self, rule_name, alert_id, results):

def run(self, event):
"""Run the alert processor!
Args:
event (dict): Invocation event (record from Dynamo table)
Returns:
dict(str, bool): Maps each output to whether it was sent successfully.
Invalid outputs are excluded from the result.
Expand All @@ -166,6 +177,7 @@ def run(self, event):

def handler(event, context):
"""StreamAlert Alert Processor - entry point
Args:
event (dict): Record from the alerts Dynamo table: {
'AlertID': str, # UUID
Expand All @@ -184,6 +196,7 @@ def handler(event, context):
'SourceService': str, # Service which generated the alert (e.g. "sns", "slack")
}
context (AWSLambdaContext): Lambda invocation context
Returns:
dict(str, bool): Maps each output to whether it was sent successfully.
For example, {'aws-firehose:sample': False, 'slack:example-channel': True}.
Expand Down

0 comments on commit a53994f

Please sign in to comment.