workflow:
  id: pagerduty-example
  name: PagerDuty workflow example
  description: retrieve PagerDuty incident, create event and incident
  triggers:
    - type: manual
  steps:
    - name: check-incident-exist-pd-fingerprint
      if: "{{ incident.fingerprint }} != ''"
      provider:
        type: pagerduty
        config: "{{ providers.PagerDuty }}"
        with:
          incident_id: "{{ incident.fingerprint }}"
    - name: check-incident-exist-pd-incident-key-dedup-key
      provider:
        type: pagerduty
        config: "{{ providers.PagerDuty }}"
        with:
          incident_key: "7f3baa50-e7ef-4891-bd4a-d1ee310dff8f"
  actions:
    - name: pd-create-event
      provider:
        type: pagerduty
        config: "{{ providers.PagerDuty }}"
        with:
          routing_key: 'your_routing_key' # optional, otherwise it will take from provider configuration$
          severity: critical
          source: keep
          component: job_service
          group: job
          class: job
          custom_details:
            environment: 'production'
            url: 'https://keep.example.org'
          links:
            - href: "https://keep.example.com/"
              text: "View in Keep"
          dedup: "{{ incident.id }}"
          event_type: trigger
          title: "TestEvent"
    - name: pd-create-inc
      provider:
        type: pagerduty
        config: "{{ providers.PagerDuty }}"
        with:
          source: keep
          alert_body:
            details:
              client: keep
              client_url: "https://keep.example.com/incidents/{{ incident.id }}"
              description: "{{ incident.user_summary }}"
              alert_count: "{{ incident.alerts_count }}"
              alerts: "{{ incident.alerts }}"
            type: incident_body
          dedup: "{{ incident.id }}"
          status: "triggered"
          service_id: "{{ incident.service_id }}"
          requester: email@example.com
          severity: "{{ incident.severity }}"
          title: "{{ incident.user_generated_name }}"
