---
# schema
#
#   POLICY:
#     STATE:
#       INPUT_EVENT:
#         state: OUTPUT_STATE
#         action:
#           cmd: ["notify" "METHOD" "RECEIVER" "TEMPLATE"] | ["timeout" "SECONDS"] | ["assign"]
#           on_sucess: OUTPUT_EVENT
#           on_failure: OUTPUT_EVENT
#           on_error: OUTPUT_EVENT
#
# first state must be "Inited" and now only support "default" policy
default:
  Inited:
    CreatedEvent:
      state: Created
      action:
        cmd: ["assign"]
        on_sucess: AssignEvent
        on_error: ErrorOnAssigningEvent
  Created:
    AssignEvent:
      state: Assigned
      action:
        cmd: ["notify"]
        on_sucess: NotifyEvent
    ErrorOnAssigningEvent:
      state: WaitErrorHandled
      action:
        cmd: ["notify", "card", "cc"]
        on_sucess: NotifyErrorHandlerEvent
  Assigned:
    NotifyEvent:
      state: Notified1Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
  Notified1Times:
    TimeoutEvent:
      state: Notified1TimesTimeout
      action:
        cmd: ["notify", "urgent"]
        on_sucess: NotifyEvent
        on_failure: AcknowledgeEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified1TimesTimeout:
    NotifyEvent:
      state: Notified2Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified2Times:
    TimeoutEvent:
      state: Notified2TimesTimeout
      action:
        cmd: ["notify", "phone"]
        on_sucess: NotifyEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified2TimesTimeout:
    NotifyEvent:
      state: Notified3Times
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified3Times:
    TimeoutEvent:
      state: Notified3TimesTimeout
      action:
        cmd: ["notify", "card", "escalation"]
        on_sucess: NotifyEscalationEvent
        on_error: NotifyEscalationErrorEvent
    AcknowledgeEvent:
      state: Acknowledged
  Notified3TimesTimeout:
    NotifyEscalationEvent:
      state: NotifiedEscalation
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    NotifyEscalationErrorEvent:
      state: NotifyEscalationError
      action:
        cmd: ["notify", "card", "firemaster"]
        on_sucess: NotifyFiremasterEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedEscalation:
    TimeoutEvent:
      state: NotifiedEscalationTimeout
      action:
        cmd: ["notify", "card", "escalation"]
        on_sucess: NotifyEscalationEvent
        on_error: NotifyEscalationErrorEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifyEscalationError:
    NotifyFiremasterEvent:
      state: NotifiedFiremaster
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedEscalationTimeout:
    NotifyEscalationEvent:
      state: NotifiedEscalation
      action:
        cmd: ["timeout", "20"]
        on_sucess: TimeoutEvent
    NotifyEscalationErrorEvent:
      state: NotifyEscalationError
      action:
        cmd: ["notify", "card", "firemaster"]
        on_sucess: NotifyFiremasterEvent
    AcknowledgeEvent:
      state: Acknowledged
  NotifiedFiremaster:
    TimeoutEvent:
      state: NoResponse
    AcknowledgeEvent:
      state: Acknowledged
  NoResponse:
    AcknowledgeEvent:
      state: Acknowledged
  Acknowledged:
  WaitErrorHandled:
    NotifyErrorHandlerEvent:
      state: BadEnd
  BadEnd:
