class StackOperationService {

    public FlowIdentifier updateStatus(Long stackId, StatusRequest status, boolean updateCluster, User user) {
        Stack stack = stackService.getByIdWithLists(stackId);
        Cluster cluster = null;
        if (stack.getCluster() != null) {
            cluster = clusterService.findOneWithLists(stack.getCluster().getId()).orElse(null);
        }
        switch (status) {
            case SYNC:
                return sync(stack, false, user);
            case FULL_SYNC:
                return sync(stack, true, user);
            case REPAIR_FAILED_NODES:
                return repairFailedNodes(stack, user);
            case STOPPED:
                return stop(stack, cluster, updateCluster, user);
            case STARTED:
                return start(stack, cluster, updateCluster, user);
            default:
                throw new BadRequestException("Cannot update the status of stack because status request not valid.");
        }
    }

}