1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +00:00
webvirtcloud/webvirtcloud/urls.py
catborise dcd7e32df7 feat(alerts): mail and webhook alerts, and /healthz for a monitor
A failed backup, a scheduled backup not taken, backups the daily check
finds missing and a job that ends uncertain could only be seen on the
pages. They are now queued as alerts in the transaction of the change
they tell of (never stopping it) and sent by the worker's periodic pass
to the Settings page's alert e-mail addresses (the server's SMTP
settings) and alert webhook (a JSON POST), each tried again for ten
passes on its own. A skip for a host in maintenance is no alert.
Setting values take 255 characters. /healthz answers 200 while the
database answers and the job worker runs, 503 otherwise, without a
login.
2026-11-19 16:10:37 +03:00

54 lines
2.2 KiB
Python

from django.conf import settings
from django.urls import include, path, re_path
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerSplitView,
)
from drf_spectacular.utils import extend_schema
from rest_framework.decorators import api_view
from rest_framework.exceptions import NotFound
from appsettings.views import appsettings
from console.views import console
from instances.views import index
from operations import views as operations_views
@extend_schema(exclude=True)
@api_view(["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"])
def api_not_found(request):
"""An API URL that names nothing: JSON, after the API's authentication, as
every other API answer. Only one with a trailing slash: one without is
redirected to it first."""
raise NotFound
urlpatterns = [
path("", index, name="index"),
path("admin/", include(("admin.urls", "admin"), namespace="admin")),
path("accounts/", include("accounts.urls")),
path("appsettings/", appsettings, name="appsettings"),
path("computes/", include("computes.urls")),
path("console/<int:compute_id>/<str:uuid>/", console, name="console"),
path("datasource/", include("datasource.urls")),
path("instances/", include("instances.urls")),
path("i18n/", include("django.conf.urls.i18n")),
path("logs/", include("logs.urls")),
path("jobs/", include("operations.urls")),
path("healthz", operations_views.healthz, name="healthz"),
path("backups/", include("vmbackups.urls")),
path('api/v1/', include("webvirtcloud.urls-api")),
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
re_path(r"^swagger\.(?P<format>json|yaml)$", SpectacularAPIView.as_view(), name="schema-json"),
path("swagger/", SpectacularSwaggerSplitView.as_view(url_name="schema"), name="schema-swagger-ui"),
path("redoc/", SpectacularRedocView.as_view(url_name="schema"), name="schema-redoc"),
re_path(r"^api/(?:.*/)?$", api_not_found),
]
# settings-dev installs the toolbar; WEBVIRTCLOUD_DEBUG alone does not
if "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]