from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import UserViewSet, TagViewSet, AttachmentViewSet, CommentViewSet, AuditLogViewSet, AppConfigViewSet
from .auth import LoginView, LogoutView, RegisterView, MeView, session_check, CSRFView, ChangePasswordView
from .microsoft_auth import MicrosoftLoginView, MicrosoftCallbackView
from .sidebar_views import SidebarBadgesView
from .rbac_views import AdminUserViewSet, PermissionCatalogView, RoleViewSet
from .setup_views import SetupStatusView, SetupInviteView

router = DefaultRouter()
router.register(r"users", UserViewSet, basename="user")
router.register(r"tags", TagViewSet, basename="tag")
router.register(r"attachments", AttachmentViewSet, basename="attachment")
router.register(r"comments", CommentViewSet, basename="comment")
router.register(r"audit-logs", AuditLogViewSet, basename="auditlog")
router.register(r"app-config", AppConfigViewSet, basename="app-config")
router.register(r"rbac/roles", RoleViewSet, basename="rbac-role")
router.register(r"rbac/users", AdminUserViewSet, basename="rbac-user")

urlpatterns = [
    path("", include(router.urls)),
    path("rbac/permissions/", PermissionCatalogView.as_view(), name="rbac-permissions"),
    path("setup/status/", SetupStatusView.as_view(), name="setup-status"),
    path("setup/invite/", SetupInviteView.as_view(), name="setup-invite"),
    path("auth/login/", LoginView.as_view(), name="login"),
    path("auth/logout/", LogoutView.as_view(), name="logout"),
    path("auth/register/", RegisterView.as_view(), name="register"),
    path("auth/me/", MeView.as_view(), name="me"),
    path("auth/session/", session_check, name="session-check"),
    path("auth/csrf/", CSRFView.as_view(), name="csrf"),
    path("auth/change-password/", ChangePasswordView.as_view(), name="change-password"),
    path("auth/microsoft/login/", MicrosoftLoginView.as_view(), name="ms-login"),
    path("auth/microsoft/callback/", MicrosoftCallbackView.as_view(), name="ms-callback"),
    path("sidebar/badges/", SidebarBadgesView.as_view(), name="sidebar-badges"),
]