You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.0 KiB

10 years ago
10 years ago
10 years ago
10 years ago
  1. from urllib.parse import quote, unquote
  2. from django.urls import path, register_converter
  3. from hc.api import views
  4. class QuoteConverter:
  5. regex = r"[\w%~_.-]+"
  6. def to_python(self, value):
  7. return unquote(value)
  8. def to_url(self, value):
  9. return quote(value, safe="")
  10. class SHA1Converter:
  11. regex = "[A-z0-9]{40}"
  12. def to_python(self, value):
  13. return value
  14. def to_url(self, value):
  15. return value
  16. register_converter(QuoteConverter, "quoted")
  17. register_converter(SHA1Converter, "sha1")
  18. urlpatterns = [
  19. path("ping/<uuid:code>/", views.ping, name="hc-ping-slash"),
  20. path("ping/<uuid:code>", views.ping, name="hc-ping"),
  21. path("ping/<uuid:code>/fail", views.ping, {"action": "fail"}, name="hc-fail"),
  22. path("ping/<uuid:code>/start", views.ping, {"action": "start"}, name="hc-start"),
  23. path("api/v1/checks/", views.checks),
  24. path("api/v1/checks/<uuid:code>", views.single, name="hc-api-single"),
  25. path("api/v1/checks/<sha1:unique_key>", views.get_check_by_unique_key),
  26. path("api/v1/checks/<uuid:code>/pause", views.pause, name="hc-api-pause"),
  27. path("api/v1/notifications/<uuid:code>/bounce", views.bounce, name="hc-api-bounce"),
  28. path(
  29. "api/v1/notifications/<uuid:code>/status",
  30. views.notification_status,
  31. name="hc-api-notification-status",
  32. ),
  33. path("api/v1/checks/<uuid:code>/pings/", views.pings, name="hc-api-pings"),
  34. path("api/v1/checks/<uuid:code>/flips/", views.flips_by_uuid, name="hc-api-flips"),
  35. path("api/v1/checks/<sha1:unique_key>/flips/", views.flips_by_unique_key),
  36. path("api/v1/channels/", views.channels),
  37. path(
  38. "badge/<slug:badge_key>/<slug:signature>/<quoted:tag>.<slug:fmt>",
  39. views.badge,
  40. name="hc-badge",
  41. ),
  42. path(
  43. "badge/<slug:badge_key>/<slug:signature>.<slug:fmt>",
  44. views.badge,
  45. {"tag": "*"},
  46. name="hc-badge-all",
  47. ),
  48. path("api/v1/metrics/", views.metrics),
  49. path("api/v1/status/", views.status),
  50. ]