func NewTaskStateChangeEvent(task *apitask.Task, reason string) (TaskStateChange, error) {
	var event TaskStateChange
	taskKnownStatus := task.GetKnownStatus()
	if !taskKnownStatus.BackendRecognized() {
		return event, errors.Errorf(
			"create task state change event api: status not recognized by ECS: %v",
			taskKnownStatus)
	}
	if task.GetSentStatus() >= taskKnownStatus {
		return event, errors.Errorf(
			"create task state change event api: status [%s] already sent",
			taskKnownStatus.String())
	}

	event = TaskStateChange{
		TaskARN: task.Arn,
		Status:  taskKnownStatus,
		Reason:  reason,
		Task:    task,
	}

	event.SetTaskTimestamps()

	return event, nil
}
func NewTaskStateChangeEvent(task *apitask.Task, reason string) (TaskStateChange, error) {
	var event TaskStateChange
	taskKnownStatus := task.GetKnownStatus()
	if !taskKnownStatus.BackendRecognized() {
		return event, errors.Errorf(
			"create task state change event api: status not recognized by ECS: %v",
			taskKnownStatus)
	}
	if task.GetSentStatus() >= taskKnownStatus {
		return event, errors.Errorf(
			"create task state change event api: status [%s] already sent",
			taskKnownStatus.String())
	}

	event = TaskStateChange{
		TaskARN: task.Arn,
		Status:  taskKnownStatus,
		Reason:  reason,
		Task:    task,
	}

	event.SetTaskTimestamps()

	return event, nil
}
// NewTaskStateChangeEvent creates a new task state change event