parameters: (event, context)
return_statement: return {"evaluation_completed": "true"}
docstring: This lambda is called when one or more matches are found. If a single hash matches
      multiple datasets, this will be called only once.
  
      Action labels are generated for each match message, then an action is performed
      corresponding to each action label.
docstring_summary: This lambda is called when one or more matches are found. If a single hash matches
      multiple datasets, this will be called only once.
docstring_tokens: This lambda is called when one or more matches are found . If a single hash matches multiple datasets this will be called only once .
function: def lambda_handler(event, context):
      """
      This lambda is called when one or more matches are found. If a single hash matches
      multiple datasets, this will be called only once.
  
      Action labels are generated for each match message, then an action is performed
      corresponding to each action label.
      """
      config = ActionEvaluatorConfig.get()
  
      for sqs_record in event["Records"]:
          # TODO research max # sqs records / lambda_handler invocation
          sqs_record_body = json.loads(sqs_record["body"])
          match_message = MatchMessage.from_aws_json(sqs_record_body["Message"])
  
          logger.info("Evaluating match_message: %s", match_message)
  
          action_rules = get_action_rules()
  
          logger.info("Evaluating against action_rules: %s", action_rules)
  
          submitted_content = ContentObject.get_from_content_id(
              config.dynamo_db_table, match_message.content_key
          )
  
          action_label_to_action_rules = get_actions_to_take(
              match_message,
              action_rules,
              submitted_content.additional_fields,
          )
          action_labels = list(action_label_to_action_rules.keys())
          for action_label in action_labels:
              action_message = ActionMessage.from_match_message_action_label_action_rules_and_additional_fields(
                  match_message,
                  action_label,
                  action_label_to_action_rules[action_label],
                  list(submitted_content.additional_fields),
              )
  
              logger.info("Sending Action message: %s", action_message)
              config.sqs_client.send_message(
                  QueueUrl=config.actions_queue_url,
                  MessageBody=action_message.to_aws_json(),
              )
  
          writeback_message = WritebackMessage.from_match_message_and_type(
              match_message, WritebackTypes.SawThisToo
          )
          writeback_message.send_to_queue(config.sqs_client, config.writeback_queue_url)
  
      return {"evaluation_completed": "true"}
function_tokens: def lambda_handler ( event , context ) : config = ActionEvaluatorConfig . get ( ) for sqs_record in event [ "Records" ] : # TODO research max # sqs records / lambda_handler invocation sqs_record_body = json . loads ( sqs_record [ "body" ] ) match_message = MatchMessage . from_aws_json ( sqs_record_body [ "Message" ] ) logger . info ( "Evaluating match_message: %s" , match_message ) action_rules = get_action_rules ( ) logger . info ( "Evaluating against action_rules: %s" , action_rules ) submitted_content = ContentObject . get_from_content_id ( config . dynamo_db_table , match_message . content_key ) action_label_to_action_rules = get_actions_to_take ( match_message , action_rules , submitted_content . additional_fields , ) action_labels = list ( action_label_to_action_rules . keys ( ) ) for action_label in action_labels : action_message = ActionMessage . from_match_message_action_label_action_rules_and_additional_fields ( match_message , action_label , action_label_to_action_rules [ action_label ] , list ( submitted_content . additional_fields ) , ) logger . info ( "Sending Action message: %s" , action_message ) config . sqs_client . send_message ( QueueUrl = config . actions_queue_url , MessageBody = action_message . to_aws_json ( ) , ) writeback_message = WritebackMessage . from_match_message_and_type ( match_message , WritebackTypes . SawThisToo ) writeback_message . send_to_queue ( config . sqs_client , config . writeback_queue_url ) return { "evaluation_completed" : "true" }