{
    "Comment": "Complete review steps.",
    "StartAt": "Remove From Index",
    "States": {
        "Remove From Index": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}deindex-product-metadata",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Split On Resolution",
            "ResultPath": null
        },
        "Split On Resolution": {
            "Type": "Choice",
            "Choices": [
                {
                    "Variable": "$.resolution",
                    "StringEquals": "approve",
                    "Next": "Fetch Product Status"
                },
                {
                    "Variable": "$.resolution",
                    "StringEquals": "reject",
                    "Next": "Complete - ows-product-digital"
                }
            ],
            "Default": "Send Failure Notification"
        },
        "Fetch Product Status": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}complete-fetch-status",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Split On Product Status",
            "ResultPath": "$.product_status",
            "ResultSelector": {
                "release_status.$": "$.Payload.release_status",
                "error_correction_status.$": "$.Payload.error_correction_status",
                "release_correction_id.$": "$.Payload.release_correction_id"
            }
        },
        "Split On Product Status": {
            "Type": "Choice",
            "Choices": [
                {
                    "And": [
                        {
                            "Variable": "$.product_status.release_status",
                            "StringEquals": "in_content"
                        },
                        {
                            "Variable": "$.product_status.error_correction_status",
                            "StringEquals": "submitted"
                        }
                    ],
                    "Next": "Apply Release Corrections"
                },
                {
                    "Variable": "$.product_status.release_status",
                    "StringEquals": "transfer_to_content",
                    "Next": "Complete - ows-product-digital"
                }
            ],
            "Default": "Complete - ows-product-review"
        },
        "Apply Release Corrections": {
            "Type": "Parallel",
            "Branches": [
                {
                    "StartAt": "Apply Metadata",
                    "States": {
                        "Apply Metadata": {
                            "Type": "Task",
                            "Resource": "arn:aws:states:::lambda:invoke",
                            "Parameters": {
                                "FunctionName": "${lambda_prefix}revision-apply-metadata",
                                "Payload": {
                                    "product_id.$": "$.product_id",
                                    "release_correction_id.$": "$.product_status.release_correction_id"
                                }
                            },
                            "Retry": [
                                {
                                    "ErrorEquals": [
                                        "States.ALL"
                                    ],
                                    "IntervalSeconds": ${default_interval_seconds},
                                    "MaxAttempts": ${default_max_attempts},
                                    "BackoffRate": ${default_backoff_rate}
                                }
                            ],
                            "End": true,
                            "ResultPath": null
                        }
                    }
                },
                {
                    "StartAt": "Apply Lyrics",
                    "States": {
                        "Apply Lyrics": {
                            "Type": "Task",
                            "Resource": "arn:aws:states:::lambda:invoke",
                            "Parameters": {
                                "FunctionName": "${lambda_prefix}revision-apply-lyrics",
                                "Payload": {
                                    "product_id.$": "$.product_id",
                                    "release_correction_id.$": "$.product_status.release_correction_id"
                                }
                            },
                            "Retry": [
                                {
                                    "ErrorEquals": [
                                        "States.ALL"
                                    ],
                                    "IntervalSeconds": ${default_interval_seconds},
                                    "MaxAttempts": ${default_max_attempts},
                                    "BackoffRate": ${default_backoff_rate}
                                }
                            ],
                            "End": true,
                            "ResultPath": null
                        }
                    }
                },
                {
                    "StartAt": "Apply Tracks",
                    "States": {
                        "Apply Tracks": {
                            "Type": "Task",
                            "Resource": "arn:aws:states:::lambda:invoke",
                            "Parameters": {
                                "FunctionName": "${lambda_prefix}revision-apply-tracks",
                                "Payload": {
                                    "product_id.$": "$.product_id",
                                    "release_correction_id.$": "$.product_status.release_correction_id"
                                }
                            },
                            "Retry": [
                                {
                                    "ErrorEquals": [
                                        "States.ALL"
                                    ],
                                    "IntervalSeconds": ${default_interval_seconds},
                                    "MaxAttempts": ${default_max_attempts},
                                    "BackoffRate": ${default_backoff_rate}
                                }
                            ],
                            "End": true,
                            "ResultPath": null
                        }
                    }
                },
                {
                    "StartAt": "Apply Assets",
                    "States": {
                        "Apply Assets": {
                            "Type": "Task",
                            "Resource": "arn:aws:states:::lambda:invoke",
                            "Parameters": {
                                "FunctionName": "${lambda_prefix}revision-apply-assets",
                                "Payload": {
                                    "product_id.$": "$.product_id",
                                    "release_correction_id.$": "$.product_status.release_correction_id"
                                }
                            },
                            "Retry": [
                                {
                                    "ErrorEquals": [
                                        "States.ALL"
                                    ],
                                    "IntervalSeconds": ${default_interval_seconds},
                                    "MaxAttempts": ${default_max_attempts},
                                    "BackoffRate": ${default_backoff_rate}
                                }
                            ],
                            "End": true,
                            "ResultPath": null
                        }
                    }
                }
            ],
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Complete - release-correction",
            "ResultPath": null
        },
        "Complete - release-correction": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}release-correction-complete",
                "Payload": {
                    "product_id.$": "$.product_id",
                    "release_correction_id.$": "$.product_status.release_correction_id"
                }
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Complete - ows-product-review",
            "ResultPath": null
        },
        "Complete - ows-product-digital": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}complete-product-digital",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Complete - ows-product-review",
            "ResultPath": null
        },
        "Complete - ows-product-review": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}complete-product-review",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Publish Event",
            "ResultPath": null
        },
        "Publish Event": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}complete-publish-event",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Send Failure Notification",
                    "ResultPath": "$.TaskError"
                }
            ],
            "Next": "Success",
            "ResultPath": null
        },
        "Send Failure Notification": {
            "Type": "Task",
            "Resource": "arn:aws:states:::lambda:invoke",
            "Parameters": {
                "FunctionName": "${lambda_prefix}failure-notify",
                "Payload.$": "States.JsonMerge($$, $, false)"
            },
            "Retry": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "IntervalSeconds": ${default_interval_seconds},
                    "MaxAttempts": ${default_max_attempts},
                    "BackoffRate": ${default_backoff_rate}
                }
            ],
            "Catch": [
                {
                    "ErrorEquals": [
                        "States.ALL"
                    ],
                    "Next": "Fail",
                    "ResultPath": "$.FailureNotifyLambdaError"
                }
            ],
            "Next": "Fail",
            "ResultPath": null
        },
        "Fail": {
            "Type": "Fail",
            "ErrorPath": "$.TaskError.Error",
            "CausePath": "$.TaskError.Cause"
        },
        "Success": {
            "Type": "Succeed"
        }
    }
}