---
extractors:
  component: "{{ with .JiraWebhookEvent.Issue.Fields.Components }}{{ (index . 0).Name }}{{ end }}"
  project: "{{ .JiraWebhookEvent.Issue.Fields.Project.Key }}"
  priority: "{{ .JiraWebhookEvent.Issue.Fields.Priority.Name }}"
  type: "{{ .JiraWebhookEvent.Issue.Fields.Type.Name }}"
  webhook_event: "{{ .JiraWebhookEvent.WebhookEvent }}"
  changed_fields: "{{range .JiraWebhookEvent.Changelog.Items}}<{{.Field}}>{{end}}"
  changed_to: "{{range .JiraWebhookEvent.Changelog.Items}}<{{.ToString}}>{{end}}"
  summary: "{{ .JiraWebhookEvent.Issue.Fields.Summary }}"
  status_cat: "{{ .JiraWebhookEvent.Issue.Fields.Status.StatusCategory.Key }}"
  status_name: "{{ .JiraWebhookEvent.Issue.Fields.Status.Name }}"
  ticket_environment: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10050 }}{{ .value }}{{ end }}"
  tidbcloud_org_asset: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10110 }}{{ (index . 0).objectId }}{{ end }}"
routes:
  # - receiver: ticket-notify-l2
  #   continue: true
  #   match:
  #     project: ^(APID|EMID|JPID|NAID|TCID|ST)$
  #     webhook_event: jira:issue_updated
  #     changed_fields: <L2 assignee>
  - receiver: ticket-cc
    continue: true
    match:
      project: ^(APID|EMID|JPID|NAID|TCID|ST)$
      webhook_event: jira:issue_updated
      changed_fields: <status>
      changed_to: <ESCALATE TO L2>
  - receiver: ticket-notify-assignee
    continue: true
    match:
      project: ^(APID|EMID|JPID|NAID|TCID|ST)$
      webhook_event: jira:issue_updated
      changed_fields: <assignee>
  # tidbcloud org asset mapping
  # wetech - 43824
  # bingoplus - 280501/467201
  # booboo - 419770
  # macari - 31049
  # cygames - 28684
  - receiver: guardian-jsm-ticket
    continue: true
    match:
      project: ^(TCID|ST)$
      webhook_event: jira:issue_created
      tidbcloud_org_asset: ^(43824|280501|467201|419770|31049|28684)$
