version_1.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. tokendomainpolicies_router = SimpleRouter()
  7. tokendomainpolicies_router.register(
  8. r"", views.TokenDomainPolicyViewSet, basename="token_domain_policies"
  9. )
  10. auth_urls = [
  11. # User management
  12. path("", views.AccountCreateView.as_view(), name="register"),
  13. path("account/", views.AccountView.as_view(), name="account"),
  14. path("account/delete/", views.AccountDeleteView.as_view(), name="account-delete"),
  15. path(
  16. "account/change-email/",
  17. views.AccountChangeEmailView.as_view(),
  18. name="account-change-email",
  19. ),
  20. path(
  21. "account/reset-password/",
  22. views.AccountResetPasswordView.as_view(),
  23. name="account-reset-password",
  24. ),
  25. path("login/", views.AccountLoginView.as_view(), name="login"),
  26. path("logout/", views.AccountLogoutView.as_view(), name="logout"),
  27. # Token management
  28. path("tokens/", include(tokens_router.urls)),
  29. path(
  30. "tokens/<uuid:token_id>/policies/",
  31. views.TokenPoliciesRoot.as_view(),
  32. name="token-policies-root",
  33. ),
  34. path(
  35. "tokens/<uuid:token_id>/policies/domain/",
  36. include(tokendomainpolicies_router.urls),
  37. ),
  38. ]
  39. domains_router = SimpleRouter()
  40. domains_router.register(r"", views.DomainViewSet, basename="domain")
  41. api_urls = [
  42. # API home
  43. path("", views.Root.as_view(), name="root"),
  44. # Domain and RRSet management
  45. path("domains/", include(domains_router.urls)),
  46. path("domains/<name>/rrsets/", views.RRsetList.as_view(), name="rrsets"),
  47. path(
  48. "domains/<name>/rrsets/.../<type>/",
  49. views.RRsetDetail.as_view(),
  50. kwargs={"subname": ""},
  51. ),
  52. re_path(
  53. r"^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)\.\.\./(?P<type>[^/]+)/$",
  54. views.RRsetDetail.as_view(),
  55. name="rrset",
  56. ),
  57. path(
  58. "domains/<name>/rrsets/@/<type>/",
  59. views.RRsetDetail.as_view(),
  60. kwargs={"subname": ""},
  61. ),
  62. re_path(
  63. r"^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)@/(?P<type>[^/]+)/$",
  64. views.RRsetDetail.as_view(),
  65. name="rrset@",
  66. ),
  67. path("domains/<name>/rrsets/<subname>/<type>/", views.RRsetDetail.as_view()),
  68. # DynDNS update
  69. path("dyndns/update", views.DynDNS12UpdateView.as_view(), name="dyndns12update"),
  70. # Serials
  71. path("serials/", views.SerialListView.as_view(), name="serial"),
  72. # Donation
  73. path("donation/", views.DonationList.as_view(), name="donation"),
  74. # Authenticated Actions
  75. path(
  76. "v/activate-account/<code>/",
  77. views.AuthenticatedActivateUserActionView.as_view(),
  78. name="confirm-activate-account",
  79. ),
  80. path(
  81. "v/change-email/<code>/",
  82. views.AuthenticatedChangeEmailUserActionView.as_view(),
  83. name="confirm-change-email",
  84. ),
  85. path(
  86. "v/change-outreach-preference/<code>/",
  87. views.AuthenticatedChangeOutreachPreferenceUserActionView.as_view(),
  88. name="confirm-change-outreach-preference",
  89. ),
  90. path(
  91. "v/confirm-account/<code>/",
  92. views.AuthenticatedConfirmAccountUserActionView.as_view(),
  93. name="confirm-confirm-account",
  94. ),
  95. path(
  96. "v/reset-password/<code>/",
  97. views.AuthenticatedResetPasswordUserActionView.as_view(),
  98. name="confirm-reset-password",
  99. ),
  100. path(
  101. "v/delete-account/<code>/",
  102. views.AuthenticatedDeleteUserActionView.as_view(),
  103. name="confirm-delete-account",
  104. ),
  105. path(
  106. "v/renew-domain/<code>/",
  107. views.AuthenticatedRenewDomainBasicUserActionView.as_view(),
  108. name="confirm-renew-domain",
  109. ),
  110. # CAPTCHA
  111. path("captcha/", views.CaptchaView.as_view(), name="captcha"),
  112. ]
  113. app_name = "desecapi"
  114. urlpatterns = [
  115. path("auth/", include(auth_urls)),
  116. path("", include(api_urls)),
  117. ]