def METHOD_NAME(
    function_id: int,
) -> Response:
    pto: PeriodicTask = (
        Block.query.filter_by(id=function_id, type_id=BlockType.ScheduledFunction.value)
        .join(PeriodicTask)
        .with_entities(PeriodicTask)
    ).first()
    if not pto:
        raise NotExist("scheduled function not found")
    u = get_current_user_object()
    if not u.has_manage_access(pto.block) and not u.is_admin:
        raise AccessDenied()
    db.session.delete(pto)
    db.session.delete(pto.block)
    db.session.commit()
    return ok_response()