class_docstr: SlackOutput handles all alert dispatching for Slack
class_docstr_tok: ["SlackOutput","handles","all","alert","dispatching","for","Slack"]
docstr: Supplies default fields to given attachments and validates their structure.
  
  You can test out custom attachments using this tool:
    https://api.slack.com/docs/messages/builder
  
  When publishers provider custom slack attachments to the SlackOutput, it offers increased
  flexibility, but requires more work. Publishers need to pay attention to the following:
  
  - Slack requires escaping the characters: '&', '>' and '<'
  - Slack messages have a limit of 4000 characters
  - Individual slack messages support a maximum of 20 attachments
  
  
  Args:
      custom_slack_attachments (list): A list of dicts that is provided by the publisher.
  
  Returns:
      list: The value to the "attachments" Slack API argument
docstr_tok: ["Supplies","default","fields","to","given","attachments","and","validates","their","structure",".","You","can","test","out","custom","attachments","using","this","tool",":","https",":","\/\/api.slack.com\/docs\/messages\/builder","When","publishers","provider","custom","slack","attachments","to","the","SlackOutput",",","it","offers","increased","flexibility",",","but","requires","more","work",".","Publishers","need","to","pay","attention","to","the","following",":","-","Slack","requires","escaping","the","characters",":","'","&","'",",","'",">","'","and","'","<","'","-","Slack","messages","have","a","limit","of","4000","characters","-","Individual","slack","messages","support","a","maximum","of","20","attachments","Args",":","custom_slack_attachments","(","list",")",":","A","list","of","dicts","that","is","provided","by","the","publisher",".","Returns",":","list",":","The","value","to","the","``","attachments","''","Slack","API","argument"]
code: def _standardize_custom_attachments(cls, custom_slack_attachments):
      """Supplies default fields to given attachments and validates their structure.
  
      You can test out custom attachments using this tool:
        https://api.slack.com/docs/messages/builder
  
      When publishers provider custom slack attachments to the SlackOutput, it offers increased
      flexibility, but requires more work. Publishers need to pay attention to the following:
  
      - Slack requires escaping the characters: '&', '>' and '<'
      - Slack messages have a limit of 4000 characters
      - Individual slack messages support a maximum of 20 attachments
  
  
      Args:
          custom_slack_attachments (list): A list of dicts that is provided by the publisher.
  
      Returns:
          list: The value to the "attachments" Slack API argument
      """
  
      attachments = []
  
      for custom_slack_attachment in custom_slack_attachments:
          attachment = cls._get_attachment_skeleton()
          attachment.update(custom_slack_attachment)
  
          # Enforce maximum text length; make sure to check size AFTER escaping in case
          # extra escape characters pushes it over the limit
          if len(attachment["text"]) > cls.MAX_MESSAGE_SIZE:
              LOGGER.warning(
                  "Custom attachment was truncated to length %d. Full message: %s",
                  cls.MAX_MESSAGE_SIZE,
                  attachment["text"],
              )
              attachment["text"] = elide_string_middle(
                  attachment["text"], cls.MAX_MESSAGE_SIZE
              )
  
          attachments.append(attachment)
  
          # Enforce maximum number of attachments
          if len(attachments) >= cls.MAX_ATTACHMENTS:
              LOGGER.warning(
                  "Message with %d custom attachments was truncated to %d attachments",
                  len(custom_slack_attachments),
                  cls.MAX_ATTACHMENTS,
              )
              break
  
      return attachments
  
file_path: streamalert/streamalert/alert_processor/outputs/slack.py
imports: import html
  from collections import OrderedDict
  from streamalert.alert_processor.helpers import compose_alert, elide_string_middle
  from streamalert.alert_processor.outputs.output_base import OutputDispatcher, OutputProperty, OutputRequestFailure, StreamAlertOutput
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 5 for calling the SlackOutput obj's underlying member method code with example usage: obj._standardize_custom_attachments(cls, custom_slack_attachments) and returns: attachments