---
extractors:
  webhook_event: "{{ .JiraWebhookEvent.WebhookEvent }}"
  changed_fields: "{{range .JiraWebhookEvent.Changelog.Items}}<{{.Field}}>{{end}}"
  status_cat: "{{ .JiraWebhookEvent.Issue.Fields.Status.StatusCategory.Key }}"
  priority: "{{ .JiraWebhookEvent.Issue.Fields.Priority.Name }}"
  # MIGRATE RELATED
  alert_required: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10223 }}{{ .value }}{{ end }}"
  auto_recovered: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10256 }}{{ . }}{{ end }}"
  alarm: "{{ with .JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10150 }}{{ .value }}{{ end }}"
  stability_governance: "{{ (.JiraWebhookEvent.Issue.Fields.Unknowns.customfield_10160 | tryUnmarshalJson).labels.stability_governance }}"
  changed_to: "{{range .JiraWebhookEvent.Changelog.Items}}<{{.ToString}}>{{end}}"
routes:
  - receiver: UpdateToEscalateToL3Event
    match:
      webhook_event: jira:issue_updated
      changed_fields: <status>
      changed_to: <ESCALATE TO L3>
  - receiver: UpdateL2AssigneeEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <L2 assignee>
  - receiver: UpdatedStatusToIndeterminateEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: .*<status>.*
      status_cat: "indeterminate"
  - receiver: CreatedEvent
    match:
      webhook_event: jira:issue_created
  - receiver: UpdateAssigneeWhenInProgressEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <assignee>
      status_cat: "indeterminate"
      priority: Critical
  - receiver: UpdatedAssigneeEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <assignee>
  - receiver: UrgentUpdatedPriorityEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <priority>
      priority: ^(P0|P1)$
      "!alert_required": ^No$
      "!alarm": ^No$
  - receiver: UpdatedPriorityEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <priority>
  - receiver: UpdatedFixVersionEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: <Fix Version>
  - receiver: UpdatedStatusToDoneEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: .*<status>.*
      status_cat: "done"
  - receiver: UpdatedStatusToNewEvent
    match:
      webhook_event: jira:issue_updated
      changed_fields: .*<status>.*
      status_cat: "new"
  - receiver: AutoRecoveredEvent
    match:
      webhook_event: jira:issue_updated
      auto_recovered: .*YES.*
      "!stability_governance": ^(errorlog-governance|errorlog-tcocp)$