# (c) cavaliba.com - data - urls.py

from django.urls import path

from app_data import ajax, views, views_editor, views_iam, views_iam_permission, views_task

# url namespace
app_name = "app_data"

urlpatterns = [
    path("", views.private, name="private"),
    # anon
    # path('anon',  views.anonymous, name='anonymous'),
    # PRIVATE
    path("private/", views.private, name="private"),
    path("private/", views.private, name="class_list"),
    path("private/instance/detail/<int:id>/", views.instance_detail, name="instance_detail"),
    path("private/instance/edit/<int:id>/", views.instance_edit, name="instance_edit"),
    path("private/instance/delete/<int:id>/", views.instance_delete, name="instance_delete"),
    path("private/instance/enable/<int:id>/", views.instance_enable, name="instance_enable"),
    path("private/instance/disable/<int:id>/", views.instance_disable, name="instance_disable"),
    # IAM
    path("private/user/pref/", views_iam.preferences, name="user_pref"),
    path("private/debug/", views_iam.debug_env, name="debug"),
    path("private/instance/impersonate/<int:id>/", views_iam.impersonate, name="impersonate_user"),
    path("private/logout/", views_iam.logout, name="logout"),
    path("private/instance/email_test/<int:id>/", views_iam.email_test, name="email_test_user"),
    path("private/instance/sms_test/<int:id>/", views_iam.sms_test, name="sms_test_user"),
    # IAM - permissions
    path("private/permissions/", views_iam_permission.list, name="permission_list"),
    path("private/permissions/edit/", views_iam_permission.edit, name="permission_edit"),
    path("private/permissions/edit/<int:pid>/", views_iam_permission.edit, name="permission_edit"),
    path(
        "private/permissions/delete/<int:pid>/",
        views_iam_permission.delete,
        name="permission_delete",
    ),
    path("private/schema/list/<slug:classname>/", views.instance_list, name="instance_list"),
    # backward compat with home/dashboard
    path("private/c/<slug:classname>/list/", views.instance_list, name="instance_list"),
    path("private/schema/new/<slug:classname>", views.instance_new, name="instance_new"),
    path("private/file/<str:fileid>/", views.file_display, name="file_display"),
    # YAML / texteditor
    path("private/texteditor/", views_editor.texteditor, name="texteditor"),
    path("private/texteditor/<int:id>/", views_editor.texteditor, name="texteditor"),
    path("private/texteditor/<slug:classname>/", views_editor.texteditor, name="texteditor"),
    path(
        "private/texteditor/<slug:classname>/<int:id>/", views_editor.texteditor, name="texteditor"
    ),
    path("private/import/", views_editor.texteditor, name="data_import"),
    # export
    path("private/export/", views.data_export, name="data_export"),
    # ajax
    path("private/ajax/", ajax.ajax_instance, name="ajax_instance"),
    # tasks - v3.33
    path("private/tasks/", views_task.task_list, name="task_list"),
    path("private/tasks/navbar/", views_task.task_navbar_partial, name="task_navbar_partial"),
    path("private/tasks/<uuid:handle>/", views_task.task_detail, name="task_detail"),
    path("private/tasks/<uuid:handle>/stop/", views_task.task_stop, name="task_stop"),
]
