{
  "StartAt": "SetupWorkflow",
  "States": {
    "SetupWorkflow": {
      "Type": "Pass",
      "Parameters": {
        "note": "State machine workflow setup",
        "start_time.$": "$$.Execution.StartTime",
        "execution_id.$": "$$.Execution.Id",
        "status": "OK",
        "slack_channel": "#{slzNotificationSlackChannel}"
      },
      "ResultPath": "$.info",
      "Next": "GdprEmailDownloader"
    },
    "GdprEmailDownloader": {
      "Type": "Task",
      "Resource": "#{slzGdprEmailDownloader_arn}",
      "Parameters": {
        "uow_id.$": "$.uow_id",
        "dsp.$": "$.dsp",
        "report_type.$": "$.report_type",
        "subtype.$": "$.subtype",
        "version.$": "$.version",
        "report_date.$": "$.report_date",
        "licensor.$": "$.licensor",
        "extension.$": "$.extension",
        "trace_id.$": "$.trace_id",
        "job_id.$": "$$.Execution.Name",
        "optional_config.$": "$.optional_config"
      },
      "Next": "SetUoWStatusNotInProgress",
      "ResultPath": "$.result.gdprEmailDownloader",
      "Retry": [
        {
          "ErrorEquals": ["States.TaskFailed"],
          "IntervalSeconds": 5,
          "MaxAttempts": 2,
          "BackoffRate": 2
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.info.error",
          "Next": "FailureSlackNotify"
        }
      ]
    },
    "SetUoWStatusNotInProgress": {
      "Type": "Task",
      "Resource": "#{slzUoWReset_arn}",
      "Parameters": {
        "uow_id.$": "$.uow_id",
        "trace_id.$": "$.trace_id",
        "optional_config.$": "$.optional_config"
      },
      "ResultPath": "$.result.set_uow_not_inprogress",
      "Next": "Success",
      "Catch": [
        {
          "ErrorEquals": [ "States.ALL" ],
          "ResultPath": "$.info.error",
          "Next": "FailureSlackNotify"
        }
      ],
      "Retry": [
        {
          "ErrorEquals": ["States.TaskFailed"],
          "IntervalSeconds": 3,
          "MaxAttempts": 2,
          "BackoffRate": 2
        }
      ]
    },
    "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"
    }
  }
}
