version_1.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from django.urls import include, path, re_path
  2. from rest_framework.routers import SimpleRouter
  3. from desecapi import views
  4. tokens_router = SimpleRouter()
  5. tokens_router.register(r'', views.TokenViewSet, basename='token')
  6. auth_urls = [
  7. # User management
  8. path('', views.AccountCreateView.as_view(), name='register'),
  9. path('account/', views.AccountView.as_view(), name='account'),
  10. path('account/delete/', views.AccountDeleteView.as_view(), name='account-delete'),
  11. path('account/change-email/', views.AccountChangeEmailView.as_view(), name='account-change-email'),
  12. path('account/reset-password/', views.AccountResetPasswordView.as_view(), name='account-reset-password'),
  13. path('login/', views.AccountLoginView.as_view(), name='login'),
  14. path('logout/', views.AccountLogoutView.as_view(), name='logout'),
  15. # Token management
  16. path('tokens/', include(tokens_router.urls)),
  17. ]
  18. api_urls = [
  19. # API home
  20. path('', views.Root.as_view(), name='root'),
  21. # Domain and RRSet management
  22. path('domains/', views.DomainList.as_view(), name='domain-list'),
  23. path('domains/<name>/', views.DomainDetail.as_view(), name='domain-detail'),
  24. path('domains/<name>/rrsets/', views.RRsetList.as_view(), name='rrsets'),
  25. path('domains/<name>/rrsets/.../<type>/', views.RRsetDetail.as_view(), kwargs={'subname': ''}),
  26. re_path(r'^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)\.\.\./(?P<type>[^/]+)/$',
  27. views.RRsetDetail.as_view(), name='rrset'),
  28. path('domains/<name>/rrsets/@/<type>/', views.RRsetDetail.as_view(), kwargs={'subname': ''}),
  29. re_path(r'^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)@/(?P<type>[^/]+)/$',
  30. views.RRsetDetail.as_view(), name='rrset@'),
  31. path('domains/<name>/rrsets/<subname>/<type>/', views.RRsetDetail.as_view()),
  32. # DynDNS update
  33. path('dyndns/update', views.DynDNS12Update.as_view(), name='dyndns12update'),
  34. # Donation
  35. path('donation/', views.DonationList.as_view(), name='donation'),
  36. # Authenticated Actions
  37. path('v/activate-account/<code>/', views.AuthenticatedActivateUserActionView.as_view(), name='confirm-activate-account'),
  38. path('v/change-email/<code>/', views.AuthenticatedChangeEmailUserActionView.as_view(), name='confirm-change-email'),
  39. path('v/reset-password/<code>/', views.AuthenticatedResetPasswordUserActionView.as_view(), name='confirm-reset-password'),
  40. path('v/delete-account/<code>/', views.AuthenticatedDeleteUserActionView.as_view(), name='confirm-delete-account'),
  41. # CAPTCHA
  42. path('captcha/', views.CaptchaView.as_view(), name='captcha'),
  43. ]
  44. app_name = 'desecapi'
  45. urlpatterns = [
  46. path('auth/', include(auth_urls)),
  47. path('', include(api_urls)),
  48. ]