class_docstr: GithubOutput handles all alert dispatching for Github
class_docstr_tok: ["GithubOutput","handles","all","alert","dispatching","for","Github"]
docstr: Send alert to Github
  
          Publishing:
              This output provides a default issue title and a very basic issue body containing
              the alert record. To override:
  
              - @github.title (str):
                      Override the Issue's title
  
              - @github.body (str):
                      Overrides the default github issue body. Remember: this string is in Github's
                      syntax, so it supports markdown and respects linebreaks characters (e.g. 
  ).
  
          Args:
              alert (Alert): Alert instance which triggered a rule
              descriptor (str): Output descriptor
  
          Returns:
              bool: True if alert was sent successfully, False otherwise
          
docstr_tok: ["Send","alert","to","Github","Publishing",":","This","output","provides","a","default","issue","title","and","a","very","basic","issue","body","containing","the","alert","record",".","To","override",":","-","@","github.title","(","str",")",":","Override","the","Issue","'s","title","-","@","github.body","(","str",")",":","Overrides","the","default","github","issue","body",".","Remember",":","this","string","is","in","Github's","syntax",",","so","it","supports","markdown","and","respects","linebreaks","characters","(","e.g",".",")",".","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 Github
  
      Publishing:
          This output provides a default issue title and a very basic issue body containing
          the alert record. To override:
  
          - @github.title (str):
                  Override the Issue's title
  
          - @github.body (str):
                  Overrides the default github issue body. Remember: this string is in Github's
                  syntax, so it supports markdown and respects linebreaks characters (e.g. \n).
  
      Args:
          alert (Alert): Alert instance which triggered a rule
          descriptor (str): Output descriptor
  
      Returns:
          bool: True if alert was sent successfully, False otherwise
      """
      credentials = self._load_creds(descriptor)
      if not credentials:
          return False
  
      username_password = "{}:{}".format(
          credentials["username"], credentials["access_token"]
      )
      encoded_credentials = base64.b64encode(username_password.encode())
      headers = {
          "Authorization": "Basic {}".format(
              encoded_credentials.decode()
          )
      }
      url = "{}/repos/{}/issues".format(
          credentials["api"], credentials["repository"]
      )
  
      publication = compose_alert(alert, self, descriptor)
  
      # Default presentation to the output
      default_title = "StreamAlert: {}".format(alert.rule_name)
      default_body = "### Description\n{}\n\n### Event data\n\n```\n{}\n```".format(
          alert.rule_description,
          json.dumps(alert.record, indent=2, sort_keys=True),
      )
  
      # Override presentation defaults
      issue_title = publication.get("@github.title", default_title)
      issue_body = publication.get("@github.body", default_body)
  
      # Github Issue to be created
      issue = {
          "title": issue_title,
          "body": issue_body,
          "labels": credentials["labels"].split(","),
      }
  
      LOGGER.debug(
          "sending alert to Github repository %s",
          credentials["repository"],
      )
  
      try:
          self._post_request_retry(url, issue, headers)
      except OutputRequestFailure:
          return False
  
      return True
  
file_path: streamalert/streamalert/alert_processor/outputs/github.py
imports: from collections import OrderedDict
  import base64
  import json
  from streamalert.alert_processor.helpers import compose_alert
  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 3 for calling the GithubOutput obj's underlying member method code with example usage: obj._dispatch(alert, descriptor) and returns: True, False, False