class_docstr: TeamsOutput handles all alert dispatching for Microsoft Teams
class_docstr_tok: ["TeamsOutput","handles","all","alert","dispatching","for","Microsoft","Teams"]
docstr: Format the message to be sent to Teams
  
  Args:
      alert (Alert): The alert
      publication (dict): Alert relevant to the triggered rule
      webhook_url (str): The webhook_url to send the card too
  
  Returns:
      pymsteams.connectorcard: The message to be sent to Teams
          The card will look like (by Default):
              StreamAlert Rule Triggered: rule_name
              Rule Description:
              This will be the docstring from the rule, sent as the rule_description
  
              Record:
                key   value
                key   value
                ...
docstr_tok: ["Format","the","message","to","be","sent","to","Teams","Args",":","alert","(","Alert",")",":","The","alert","publication","(","dict",")",":","Alert","relevant","to","the","triggered","rule","webhook_url","(","str",")",":","The","webhook_url","to","send","the","card","too","Returns",":","pymsteams.connectorcard",":","The","message","to","be","sent","to","Teams","The","card","will","look","like","(","by","Default",")",":","StreamAlert","Rule","Triggered",":","rule_name","Rule","Description",":","This","will","be","the","docstring","from","the","rule",",","sent","as","the","rule_description","Record",":","key","value","key","value","..."]
code: def _format_message(cls, alert, publication, webhook_url):
      """Format the message to be sent to Teams
  
      Args:
          alert (Alert): The alert
          publication (dict): Alert relevant to the triggered rule
          webhook_url (str): The webhook_url to send the card too
  
      Returns:
          pymsteams.connectorcard: The message to be sent to Teams
              The card will look like (by Default):
                  StreamAlert Rule Triggered: rule_name
                  Rule Description:
                  This will be the docstring from the rule, sent as the rule_description
  
                  Record:
                    key   value
                    key   value
                    ...
      """
      # Presentation defaults
      default_title = "StreamAlert Rule Triggered: {}".format(
          alert.rule_name
      )
      default_description = alert.rule_description
      default_color = "E81123"  # Red in Hexstring format
  
      # Special field that Publishers can use to customize the message
      title = publication.get("@teams.title", default_title)
      description = publication.get(
          "@teams.description", default_description
      )
      card_color = publication.get("@teams.card_color", default_color)
      with_record = publication.get("@teams.with_record", True)
  
      # Instantiate the card with the url
      teams_card = pymsteams.connectorcard(webhook_url)
  
      # Set the cards title, text and color
      teams_card.title(title)
      teams_card.text(description)
      teams_card.color(card_color)
  
      # Add the Alert Section
      teams_card.addSection(cls._generate_alert_section(alert))
  
      if with_record:
          # Add the record Section
          teams_card.addSection(
              cls._generate_record_section(alert.record)
          )
  
      if "@teams.additional_card_sections" in publication:
          teams_card = cls._add_additional_sections(
              teams_card, publication["@teams.additional_card_sections"]
          )
  
      if "@teams.buttons" in publication:
          teams_card = cls._add_buttons(
              teams_card, publication["@teams.buttons"]
          )
  
      return teams_card
  
file_path: streamalert/streamalert/alert_processor/outputs/teams.py
imports: from collections import OrderedDict
  import pymsteams
  from pymsteams import TeamsWebhookException
  from streamalert.alert_processor.helpers import compose_alert
  from streamalert.alert_processor.outputs.output_base import OutputDispatcher, OutputProperty, StreamAlertOutput
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 2 for calling the TeamsOutput obj's underlying member method code with example usage: obj._format_message(cls, alert, publication, webhook_url) and returns: teams_card