add in a debug api and refactor appviewset (bug 887324)