class_docstr: LambdaOutput handles all alert dispatching to AWS Lambda
class_docstr_tok: ["LambdaOutput","handles","all","alert","dispatching","to","AWS","Lambda"]
docstr: Send alert to a Lambda function
  
  The alert gets dumped to a JSON string to be sent to the Lambda function
  
  Publishing:
      By default this output sends the JSON-serialized alert record as the payload to the
      lambda function. You can override this:
  
      - @aws-lambda.alert_data (dict):
              Overrides the alert record. Will instead send this dict, JSON-serialized, to
              Lambda as the payload.
  
  Args:
      alert (Alert): Alert instance which triggered a rule
      descriptor (str): Output descriptor
  
  Returns:
      bool: True if alert was sent successfully, False otherwise
code: def _dispatch(self, alert, descriptor):
      """Send alert to a Lambda function
  
      The alert gets dumped to a JSON string to be sent to the Lambda function
  
      Publishing:
          By default this output sends the JSON-serialized alert record as the payload to the
          lambda function. You can override this:
  
          - @aws-lambda.alert_data (dict):
                  Overrides the alert record. Will instead send this dict, JSON-serialized, to
                  Lambda as the payload.
  
      Args:
          alert (Alert): Alert instance which triggered a rule
          descriptor (str): Output descriptor
  
      Returns:
          bool: True if alert was sent successfully, False otherwise
      """
      creds = self._load_creds(descriptor)
      if not creds:
          LOGGER.error(
              "No credentials found for descriptor: %s", descriptor
          )
          return False
  
      # Create the publication
      publication = compose_alert(alert, self, descriptor)
  
      # Defaults
      default_alert_data = alert.record
  
      # Override with publisher
      alert_data = publication.get(
          "@aws-lambda.alert_data", default_alert_data
      )
      alert_string = json.dumps(alert_data, separators=(",", ":"))
  
      client = self._build_client(creds)
  
      function_name = creds["lambda_function_arn"]
      qualifier = creds.get("function_qualifier", False)
  
      LOGGER.debug("Sending alert to Lambda function %s", function_name)
      invocation_opts = {
          "FunctionName": function_name,
          "InvocationType": "Event",
          "Payload": alert_string,
      }
  
      # Use the qualifier if it's available. Passing an empty qualifier in
      # with `Qualifier=''` or `Qualifier=None` does not work
      if qualifier:
          invocation_opts["Qualifier"] = qualifier
  
      client.invoke(**invocation_opts)
  
      return True
  
imports: from abc import abstractmethod
  from collections import OrderedDict
  from email.mime.application import MIMEApplication
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  from datetime import datetime
  import json
  import uuid
  import backoff
  from botocore.exceptions import ClientError
  import boto3
  from streamalert.alert_processor.helpers import compose_alert, elide_string_middle
  from streamalert.alert_processor.outputs.output_base import OutputDispatcher, OutputProperty, StreamAlertOutput
  from streamalert.shared.backoff_handlers import backoff_handler, success_handler, giveup_handler
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 2 for calling the LambdaOutputV2 obj's underlying member method code with example usage: obj._dispatch(alert, descriptor) and returns: True, False