{
  "StartAt": "SetupWorkflow",
  "States": {
    "SetupWorkflow": {
      "Type": "Pass",
      "Parameters": {
        "note": "State machine workflow setup",
        "start_time.$": "$$.Execution.StartTime",
        "execution_id.$": "$$.Execution.Id",
        "execution_name.$": "$$.Execution.Name",
        "status": "OK",
        "slack_channel": "#{slzNotificationSlackChannel}"
      },
      "ResultPath": "$.info",
      "Next": "ApolloApiScrapper"
    },
    "ApolloApiScrapper": {
      "Type": "Task",
      "Resource": "#{slzApolloApiScrapper_arn}",
      "Parameters": {
        "uow_id.$": "$.uow_id",
        "dsp.$": "$.dsp",
        "report_type.$": "$.report_type",
        "version.$": "$.version",
        "report_date.$": "$.report_date",
        "extension.$": "$.extension",
        "config_bucket.$": "$.config_bucket",
        "trace_id.$": "$.trace_id",
        "job_id.$": "$$.Execution.Name",
        "optional_config.$": "$.optional_config"
      },
      "Next": "SetUoWStatusNotInProgress",
      "ResultPath": "$.result",
      "Retry": [
        {
          "ErrorEquals": ["States.TaskFailed", "States.Timeout"],
          "IntervalSeconds": 5,
          "MaxAttempts": 2,
          "BackoffRate": 2
        }
      ],
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.info.error",
          "Next": "MarkAsFailed"
        }
      ]
    },
    "MarkAsFailed": {
      "Type": "Pass",
      "Result": "FAIL",
      "ResultPath": "$.info.status",
      "Next": "SetUoWStatusNotInProgress"
    },
    "SetUoWStatusNotInProgress": {
      "Type": "Task",
      "Resource": "#{slzUoWReset_arn}",
      "Parameters": {
        "uow_id.$": "$.uow_id",
        "trace_id.$": "$.trace_id",
        "optional_config.$": "$.optional_config"
      },
      "ResultPath": "$.result",
      "Next": "CheckJobStatus",
      "Catch": [
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.info.error",
          "Next": "FailureSlackNotify"
        }
      ],
      "Retry": [
        {
          "ErrorEquals": ["States.TaskFailed"],
          "IntervalSeconds": 3,
          "MaxAttempts": 3,
          "BackoffRate": 2
        }
      ]
    },
    "CheckJobStatus": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.info.status",
          "StringEquals": "FAIL",
          "Next": "FailureSlackNotify"
        }
      ],
      "Default": "Success"
    },
    "FailureSlackNotify": {
      "Type": "Task",
      "Resource": "#{slzSlackNotify_arn}",
      "Parameters": {
        "channel.$": "$.info.slack_channel",
        "message.$": "$.info"
      },
      "Catch": [
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.info.error",
          "Next": "Failed"
        }
      ],
      "Retry": [
        {
          "ErrorEquals": ["States.TaskFailed"],
          "IntervalSeconds": 3,
          "MaxAttempts": 3,
          "BackoffRate": 2
        }
      ],
      "Next": "Failed"
    },
    "Failed": {
      "Type": "Fail"
    },
    "Success": {
      "Type": "Succeed"
    }
  }
}
