{
  "Comment": "Handles parsing a DDEX document and ingesting information from it into the Orchard",
  "StartAt": "CheckForSentinelFile",
  "States": {
    "CheckForSentinelFile": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.detail.requestParameters.key",
          "StringMatches": "*/${filename_pattern}",
          "Next": "ParseDDEX"
        }
      ],
      "Default": "FailState"
    },
    "ParseDDEX": {
      "Type": "Task",
      "Resource": "${lambda_parse_ddex_arn}:qa",
      "Parameters": {
        "bucket.$": "$.detail.requestParameters.bucketName",
        "key.$": "$.detail.requestParameters.key",
        "ddex_provider.$": "$.detail.requestParameters.ddex_provider",
        "execution_name.$": "$$.Execution.Name",
        "state_machine_name.$": "$$.StateMachine.Name",
        "execution_start_time.$": "$$.Execution.StartTime"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "CreateIngestionLockFile"
    },
    "CreateIngestionLockFile": {
      "Type": "Task",
      "Resource": "${lambda_create_ingestion_lock_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "LockfileExistsException"
          ],
          "IntervalSeconds": 60,
          "MaxAttempts": 60,
          "BackoffRate": 1
        },
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "LookupSwitchboardDeal"
    },
    "LookupSwitchboardDeal": {
      "Type": "Task",
      "Resource": "${lambda_lookup_switchboard_deal_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "CheckPurgedRelease"
    },
    "CheckPurgedRelease": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.is_purged_release",
          "BooleanEquals": true,
          "Next": "HandlePurgedRelease"
        }
      ],
      "Default": "PrepDDEX"
    },
    "PrepDDEX": {
      "Type": "Task",
      "Resource": "${lambda_prep_sme_ddex_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "ValidateDDEX"
    },
    "ValidateDDEX": {
      "Type": "Task",
      "Resource": "${lambda_validate_ddex_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "ProcessParticipants"
    },
    "CreateVideo": {
      "Type": "Task",
      "Resource": "${lambda_create_video_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "LookupVideoProduct"
    },
    "LookupVideoProduct": {
      "Type": "Task",
      "Resource": "${lambda_lookup_video_product_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "VideoUpdateException"
          ],
          "Next": "EmailSuccess",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "ProcessVideoProduct"
    },
    "ProcessVideoProduct": {
      "Type": "Parallel",
      "Branches": [
        {
          "StartAt": "ProcessVideos",
          "States": {
            "ProcessVideos": {
              "Type": "Map",
              "MaxConcurrency": 20,
              "ItemsPath": "$.video.assets",
              "Parameters": {
                "context.$": "$",
                "asset.$": "$$.Map.Item.Value"
              },
              "Iterator": {
                "StartAt": "ProcessVideoAssets",
                "States": {
                  "ProcessVideoAssets": {
                    "Type": "Parallel",
                    "Branches": [
                      {
                        "StartAt": "VideoAssetFound",
                        "States": {
                          "VideoAssetFound": {
                            "Type": "Choice",
                            "Choices": [
                              {
                                "Variable": "$.asset",
                                "IsNull": false,
                                "Next": "HandleVideoAsset"
                              }
                            ],
                            "Default": "MissingVideoAsset"
                          },
                          "HandleVideoAsset": {
                            "Type": "Task",
                            "Resource": "${lambda_handle_video_asset_arn}:qa",
                            "HeartbeatSeconds": 60,
                            "TimeoutSeconds": 3600,
                            "Catch": [
                              {
                                "ErrorEquals": [
                                  "States.ALL"
                                ],
                                "Next": "CatchHandleVideoAssetError",
                                "ResultPath": "$.errors"
                              }
                            ],
                            "Retry": [
                              {
                                "ErrorEquals": [
                                  "States.Timeout",
                                  "Lambda.ServiceException",
                                  "Lambda.AWSLambdaException",
                                  "Lambda.SdkClientException",
                                  "Lambda.TooManyRequestsException"
                                ],
                                "IntervalSeconds": 5,
                                "MaxAttempts": 5,
                                "BackoffRate": 3
                              }
                            ],
                            "Next": "PollVideoAssetStatus"
                          },
                          "PollVideoAssetStatus": {
                            "Type": "Task",
                            "Resource": "${lambda_poll_video_asset_status_arn}:qa",
                            "HeartbeatSeconds": 60,
                            "TimeoutSeconds": 3600,
                            "Catch": [
                              {
                                "ErrorEquals": [
                                  "States.ALL"
                                ],
                                "Next": "CatchHandleVideoAssetError",
                                "ResultPath": "$.errors"
                              }
                            ],
                            "Retry": [
                              {
                                "ErrorEquals": [
                                  "VideoException"
                                ],
                                "IntervalSeconds": 60,
                                "MaxAttempts": 120,
                                "BackoffRate": 1
                              },
                              {
                                "ErrorEquals": [
                                  "States.Timeout",
                                  "Lambda.ServiceException",
                                  "Lambda.AWSLambdaException",
                                  "Lambda.SdkClientException",
                                  "Lambda.TooManyRequestsException"
                                ],
                                "IntervalSeconds": 5,
                                "MaxAttempts": 5,
                                "BackoffRate": 3
                              }
                            ],
                            "End": true
                          },
                          "CatchHandleVideoAssetError": {
                            "Type": "Succeed"
                          },
                          "MissingVideoAsset": {
                            "Type": "Succeed"
                          }
                        }
                      }
                    ],
                    "End": true
                  }
                }
              },
              "End": true
            }
          }
        },
        {
          "StartAt": "ProcessVideoCarveouts",
          "States": {
            "ProcessVideoCarveouts": {
              "Type": "Task",
              "Resource": "${lambda_set_carveouts_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchVideoCarveoutErrors",
                  "ResultPath": "$.errors"
                }
              ],
              "End": true
            },
            "CatchVideoCarveoutErrors": {
              "Type": "Succeed"
            }
          }
        },
        {
          "StartAt": "ProcessVideoPricing",
          "States": {
            "ProcessVideoPricing": {
              "Type": "Task",
              "Resource": "${lambda_set_pricing_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "ResultPath": "$.errors",
                  "Next": "CatchVideoPricingErrors"
                }
              ],
              "End": true
            },
            "CatchVideoPricingErrors": {
              "Type": "Succeed"
            }
          }
        },
        {
          "StartAt": "SetVideoReleaseDate",
          "States": {
            "SetVideoReleaseDate": {
              "Type": "Task",
              "Resource": "${lambda_set_main_release_date_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchVideoReleaseDateErrors",
                  "ResultPath": "$.errors"
                }
              ],
              "End": true
            },
            "CatchVideoReleaseDateErrors": {
              "Type": "Succeed"
            }
          }
        },
        {
          "StartAt": "SetVideoMetadata",
          "States": {
            "SetVideoMetadata": {
              "Type": "Task",
              "Resource": "${lambda_set_video_metadata_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchVideoMetadataErrors",
                  "ResultPath": "$.errors"
                }
              ],
              "End": true
            },
            "CatchVideoMetadataErrors": {
              "Type": "Succeed"
            }
          }
        }
      ],
      "Next": "DetectErrors"
    },
    "HandlePurgedRelease": {
      "Type": "Task",
      "Resource": "${lambda_handle_purged_release_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "EmailSuccess"
    },
    "CreateTracks": {
      "Type": "Task",
      "Resource": "${lambda_create_tracks_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "ProcessCarveouts"
    },
    "ProcessCarveouts": {
      "Type": "Task",
      "Resource": "${lambda_set_carveouts_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "ProcessProductData"
    },
    "SetProject": {
      "Type": "Task",
      "Resource": "${lambda_set_project_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        },
        {
          "ErrorEquals": [
            "DuplicateProjectCodeException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 3,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "SetProjectException"
          ],
          "Next": "EmailSuccess",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "CheckVideoRelease"
    },
    "CheckVideoRelease": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.product.release_type",
          "StringMatches": "VideoSingle",
          "Next": "CreateVideo"
        }
      ],
      "Default": "SetProduct"
    },
    "SetProduct": {
      "Type": "Task",
      "Resource": "${lambda_set_product_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "SetProductException"
          ],
          "Next": "EmailSuccess",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "GetOrchardProductMetadata"
    },
    "GetOrchardProductMetadata": {
      "Type": "Task",
      "Resource": "${lambda_retrieve_orchard_metadata_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "SetReleaseCorrection"
    },
    "SetReleaseCorrection": {
      "Type": "Task",
      "Resource": "${lambda_set_release_correction_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "CreateTracks"
    },
    "ProcessParticipants": {
      "Type": "Task",
      "Resource": "${lambda_process_participants_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "SetProject"
    },
    "ProcessProductData": {
      "Type": "Parallel",
      "Branches": [
        {
          "StartAt": "ProcessTrackAssets",
          "States": {
            "ProcessTrackAssets": {
              "Type": "Map",
              "MaxConcurrency": 12,
              "ItemsPath": "$.tracks",
              "Parameters": {
                "track.$": "$$.Map.Item.Value",
                "context": {
                  "product.$": "$.product",
                  "error_correction.$": "$.error_correction",
                  "is_purged_release.$": "$.is_purged_release",
                  "bucket.$": "$.bucket",
                  "key.$": "$.key",
                  "errors.$": "$.errors",
                  "message_id.$": "$.message_id",
                  "message_thread_id.$": "$.message_thread_id",
                  "update_indicator.$": "$.update_indicator",
                  "maintenance_owner.$": "$.maintenance_owner",
                  "orchard_label.$": "$.orchard_label",
                  "execution_name.$": "$.execution_name",
                  "state_machine_name.$": "$.state_machine_name",
                  "execution_start_time.$": "$.execution_start_time",
                  "project_id.$": "$.project_id",
                  "warnings.$": "$.warnings",
                  "ddex_provider.$": "$.ddex_provider",
                  "correlation_id.$": "$.correlation_id",
                  "deal_coordinators.$": "$.deal_coordinators",
                  "has_switchboard_deal.$": "$.has_switchboard_deal"
                }
              },
              "Iterator": {
                "StartAt": "AssetFound",
                "States": {
                  "AssetFound": {
                    "Type": "Choice",
                    "Choices": [
                      {
                        "Variable": "$.track.asset",
                        "IsNull": false,
                        "Next": "HandleAudioAsset"
                      }
                    ],
                    "Default": "MissingAsset"
                  },
                  "HandleAudioAsset": {
                    "Type": "Task",
                    "Resource": "${lambda_handle_audio_asset_arn}:qa",
                    "HeartbeatSeconds": 60,
                    "TimeoutSeconds": 3600,
                    "Catch": [
                      {
                        "ErrorEquals": [
                          "States.ALL"
                        ],
                        "Next": "CatchHandleAudioAssetError"
                      }
                    ],
                    "Retry": [
                      {
                        "ErrorEquals": [
                          "States.Timeout",
                          "Lambda.ServiceException",
                          "Lambda.AWSLambdaException",
                          "Lambda.SdkClientException",
                          "Lambda.TooManyRequestsException"
                        ],
                        "IntervalSeconds": 5,
                        "MaxAttempts": 5,
                        "BackoffRate": 3
                      }
                    ],
                    "Next": "PollAudioAssetStatus"
                  },
                  "PollAudioAssetStatus": {
                    "Type": "Task",
                    "Resource": "${lambda_poll_audio_asset_status_arn}:qa",
                    "HeartbeatSeconds": 60,
                    "TimeoutSeconds": 3600,
                    "Catch": [
                      {
                        "ErrorEquals": [
                          "States.ALL"
                        ],
                        "Next": "CatchHandleAudioAssetError"
                      }
                    ],
                    "Retry": [
                      {
                        "ErrorEquals": [
                          "AudioException"
                        ],
                        "IntervalSeconds": 60,
                        "MaxAttempts": 120,
                        "BackoffRate": 1
                      },
                      {
                        "ErrorEquals": [
                          "States.Timeout",
                          "Lambda.ServiceException",
                          "Lambda.AWSLambdaException",
                          "Lambda.SdkClientException",
                          "Lambda.TooManyRequestsException"
                        ],
                        "IntervalSeconds": 5,
                        "MaxAttempts": 5,
                        "BackoffRate": 3
                      }
                    ],
                    "OutputPath": "$.errors",
                    "End": true
                  },
                  "CatchHandleAudioAssetError": {
                    "Type": "Succeed"
                  },
                  "MissingAsset": {
                    "Type": "Pass",
                    "Result": {
                      "errors": null
                    },
                    "End": true
                  }
                }
              },
              "End": true
            }
          }
        },
        {
          "StartAt": "ProcessTrackMetadata",
          "States": {
            "ProcessTrackMetadata": {
              "Type": "Map",
              "MaxConcurrency": 1,
              "ItemsPath": "$.tracks",
              "Parameters": {
                "track.$": "$$.Map.Item.Value",
                "context": {
                  "product.$": "$.product",
                  "error_correction.$": "$.error_correction",
                  "is_purged_release.$": "$.is_purged_release",
                  "bucket.$": "$.bucket",
                  "key.$": "$.key",
                  "errors.$": "$.errors",
                  "message_id.$": "$.message_id",
                  "message_thread_id.$": "$.message_thread_id",
                  "update_indicator.$": "$.update_indicator",
                  "maintenance_owner.$": "$.maintenance_owner",
                  "orchard_label.$": "$.orchard_label",
                  "execution_name.$": "$.execution_name",
                  "state_machine_name.$": "$.state_machine_name",
                  "execution_start_time.$": "$.execution_start_time",
                  "project_id.$": "$.project_id",
                  "warnings.$": "$.warnings",
                  "ddex_provider.$": "$.ddex_provider",
                  "correlation_id.$": "$.correlation_id",
                  "deal_coordinators.$": "$.deal_coordinators",
                  "has_switchboard_deal.$": "$.has_switchboard_deal"
                }
              },
              "Iterator": {
                "StartAt": "SetTrackMetadata",
                "States": {
                  "SetTrackMetadata": {
                    "Type": "Task",
                    "Resource": "${lambda_set_track_metadata_arn}:qa",
                    "HeartbeatSeconds": 60,
                    "TimeoutSeconds": 3600,
                    "Catch": [
                      {
                        "ErrorEquals": [
                          "States.ALL"
                        ],
                        "Next": "CatchSetTrackMetadataError"
                      }
                    ],
                    "Retry": [
                      {
                        "ErrorEquals": [
                          "States.Timeout",
                          "Lambda.ServiceException",
                          "Lambda.AWSLambdaException",
                          "Lambda.SdkClientException",
                          "Lambda.TooManyRequestsException",
                          "SetTrackMetadataException"
                        ],
                        "IntervalSeconds": 5,
                        "MaxAttempts": 5,
                        "BackoffRate": 3
                      }
                    ],
                    "OutputPath": "$.errors",
                    "End": true
                  },
                  "CatchSetTrackMetadataError": {
                    "Type": "Succeed"
                  }
                }
              },
              "End": true
            }
          }
        },
        {
          "StartAt": "ArtworkFound",
          "States": {
            "ArtworkFound": {
              "Type": "Choice",
              "Choices": [
                {
                  "Variable": "$.product.artwork",
                  "IsNull": false,
                  "Next": "HandleArtwork"
                }
              ],
              "Default": "MissingArtwork"
            },
            "HandleArtwork": {
              "Type": "Task",
              "Resource": "${lambda_handle_artwork_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchHandleArtworkErrors"
                }
              ],
              "Next": "PollArtworkAssetStatus"
            },
            "PollArtworkAssetStatus": {
              "Type": "Task",
              "Resource": "${lambda_poll_artwork_asset_status_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "ArtworkException"
                  ],
                  "IntervalSeconds": 60,
                  "MaxAttempts": 120,
                  "BackoffRate": 1
                },
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchHandleArtworkErrors"
                }
              ],
              "OutputPath": "$.errors",
              "End": true
            },
            "CatchHandleArtworkErrors": {
              "Type": "Succeed"
            },
            "MissingArtwork": {
              "Type": "Succeed",
              "OutputPath": "$.errors"
            }
          }
        },
        {
          "StartAt": "ProcessPricing",
          "States": {
            "ProcessPricing": {
              "Type": "Task",
              "Resource": "${lambda_set_pricing_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "ResultPath": "$.errors",
                  "Next": "CatchPricingErrors"
                }
              ],
              "End": true
            },
            "CatchPricingErrors": {
              "Type": "Succeed"
            }
          }
        },
        {
          "StartAt": "SetMainReleaseDate",
          "States": {
            "SetMainReleaseDate": {
              "Type": "Task",
              "Resource": "${lambda_set_main_release_date_arn}:qa",
              "HeartbeatSeconds": 60,
              "TimeoutSeconds": 3600,
              "Retry": [
                {
                  "ErrorEquals": [
                    "States.Timeout",
                    "Lambda.ServiceException",
                    "Lambda.AWSLambdaException",
                    "Lambda.SdkClientException",
                    "Lambda.TooManyRequestsException"
                  ],
                  "IntervalSeconds": 5,
                  "MaxAttempts": 5,
                  "BackoffRate": 3
                }
              ],
              "Catch": [
                {
                  "ErrorEquals": [
                    "States.ALL"
                  ],
                  "Next": "CatchReleaseDateErrors"
                }
              ],
              "Next": "StoreLinksAndPreOrder"
            },
            "CatchReleaseDateErrors": {
              "Type": "Succeed"
            },
            "StoreLinksAndPreOrder": {
              "Type": "Parallel",
              "Branches": [
                {
                  "StartAt": "SetPreOrderInfo",
                  "States": {
                    "SetPreOrderInfo": {
                      "Type": "Task",
                      "Resource": "${lambda_set_preorder_info_arn}:qa",
                      "HeartbeatSeconds": 60,
                      "TimeoutSeconds": 3600,
                      "Retry": [
                        {
                          "ErrorEquals": [
                            "States.Timeout",
                            "Lambda.ServiceException",
                            "Lambda.AWSLambdaException",
                            "Lambda.SdkClientException",
                            "Lambda.TooManyRequestsException"
                          ],
                          "IntervalSeconds": 5,
                          "MaxAttempts": 5,
                          "BackoffRate": 3.0
                        }
                      ],
                      "Catch": [
                        {
                          "ErrorEquals": [
                            "States.ALL"
                          ],
                          "Next": "CatchPreorderInfoErrors"
                        }
                      ],
                      "OutputPath": "$.errors",
                      "End": true
                    },
                    "CatchPreorderInfoErrors": {
                      "Type": "Succeed"
                    }
                  }
                }
              ],
              "End": true
            }
          }
        }
      ],
      "Next": "DetectErrors"
    },
    "DetectErrors": {
      "Type": "Task",
      "Resource": "${lambda_detect_errors_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Next": "CheckErrors"
    },
    "CheckErrors": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.errors",
          "IsPresent": true,
          "Next": "EmailErrors"
        }
      ],
      "Default": "ValidateProduct"
    },
    "ValidateProduct": {
      "Type": "Task",
      "Resource": "${lambda_validate_product_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Catch": [
        {
          "ErrorEquals": [
            "ProductValidationException"
          ],
          "Next": "EmailSuccess",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3.0
        }
      ],
      "Next": "CheckErrorsAfterValidateProduct"
    },
    "CheckErrorsAfterValidateProduct": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.errors",
          "IsPresent": true,
          "Next": "EmailErrors"
        }
      ],
      "Default": "SubmitProduct"
    },
    "SubmitProduct": {
      "Type": "Task",
      "Resource": "${lambda_submit_product_arn}:qa",
      "Catch": [
        {
          "ErrorEquals": [
            "SubmitVideoProductValidationException"
          ],
          "Next": "EmailSuccess",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException",
            "SubmitProductValidationException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        },
        {
          "ErrorEquals": [
            "SubmitProductGraphQLException"
          ],
          "IntervalSeconds": 15,
          "MaxAttempts": 1
        }
      ],
      "Next": "EmailSuccess"
    },
    "EmailSuccess": {
      "Type": "Task",
      "Resource": "${lambda_report_errors_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "EmailErrors",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "RemoveIngestionLockFileSuccess"
    },
    "EmailErrors": {
      "Type": "Task",
      "Resource": "${lambda_report_errors_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "TriggerVideoResolutionFixException"
          ],
          "Next": "FixVideoResolution",
          "ResultPath": "$.errors"
        },
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "RemoveIngestionLockFileFailure",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "RemoveIngestionLockFileFailure"
    },
    "RemoveIngestionLockFileSuccess": {
      "Type": "Task",
      "Resource": "${lambda_remove_ingestion_lock_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "WriteCatalogIngestionFailure",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "SkipForVideoResolutionFix"
    },
    "SkipForVideoResolutionFix": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.errors",
          "IsPresent": false,
          "Next": "WriteCatalogIngestionSuccess"
        },
        {
          "Variable": "$.errors",
          "IsNull": true,
          "Next": "WriteCatalogIngestionSuccess"
        },
        {
          "Variable": "$.errors.Error",
          "StringMatches": "TriggerVideoResolutionFixException",
          "Next": "SuccessState"
        }
      ],
      "Default": "WriteCatalogIngestionSuccess"
    },
    "RemoveIngestionLockFileFailure": {
      "Type": "Task",
      "Resource": "${lambda_remove_ingestion_lock_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "WriteCatalogIngestionFailure",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "WriteCatalogIngestionFailure"
    },
    "WriteCatalogIngestionSuccess": {
      "Type": "Task",
      "Resource": "${lambda_write_catalog_ingestion_arn}:qa",
      "Parameters": {
        "context.$": "$",
        "status": "Success"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "SendSuccessXML",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "SendSuccessXML"
    },
    "WriteCatalogIngestionFailure": {
      "Type": "Task",
      "Resource": "${lambda_write_catalog_ingestion_arn}:qa",
      "Parameters": {
        "context.$": "$",
        "status": "Failure"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "SendSuccessXML",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "SendSuccessXML"
    },
    "SendSuccessXML": {
      "Type": "Task",
      "Resource": "${lambda_send_sme_ack_arn}:qa",
      "HeartbeatSeconds": 60,
      "TimeoutSeconds": 3600,
      "Parameters": {
        "context.$": "$",
        "status": "Success"
      },
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 5,
          "BackoffRate": 3
        }
      ],
      "End": true
    },
    "SuccessState": {
      "Type": "Succeed"
    },
    "FailState": {
      "Type": "Fail"
    },
    "FixVideoResolution": {
      "Type": "Task",
      "Resource": "${lambda_fix_video_resolution_arn}:qa",
      "Retry": [
        {
          "ErrorEquals": [
            "States.Timeout",
            "Lambda.ServiceException",
            "Lambda.AWSLambdaException",
            "Lambda.SdkClientException",
            "Lambda.TooManyRequestsException"
          ],
          "IntervalSeconds": 5,
          "MaxAttempts": 3,
          "BackoffRate": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "RemoveIngestionLockFileFailure",
          "ResultPath": "$.errors"
        }
      ],
      "Next": "RemoveIngestionLockFileSuccess"
    }
  }
}
