oncall-engine/engine/engine/urls.py
Dominik Broj 2c4b34d3af
generate types, create http client and add exemplary usage (#3384)
# What this PR does

https://github.com/grafana/oncall/issues/3330

- add a script that generates TS type definitions based on OnCall API
OpenAPI schemas
- support adding custom properties on the frontend if needed
- add simple example of usage (for `'/labels/keys/'` endpoint)

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-29 05:16:13 +00:00

92 lines
3.8 KiB
Python

"""engine URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import URLPattern, URLResolver, include, path
from .views import HealthCheckView, MaintenanceModeStatusView, ReadinessCheckView, StartupProbeView
paths_to_work_even_when_maintenance_mode_is_active: list[URLPattern | URLResolver] = [
path("", HealthCheckView.as_view()),
path("health/", HealthCheckView.as_view()),
path("ready/", ReadinessCheckView.as_view()),
path("startupprobe/", StartupProbeView.as_view()),
path("api/internal/v1/maintenance-mode-status", MaintenanceModeStatusView.as_view()),
]
if not settings.DETACHED_INTEGRATIONS_SERVER:
paths_to_work_even_when_maintenance_mode_is_active += [
path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")),
]
urlpatterns: list[URLPattern | URLResolver] = [
*paths_to_work_even_when_maintenance_mode_is_active,
path("api/gi/v1/", include("apps.api_for_grafana_incident.urls", namespace="api-gi")),
path("api/internal/v1/", include("apps.api.urls", namespace="api-internal")),
path("api/internal/v1/", include("social_django.urls", namespace="social")),
path("api/internal/v1/plugin/", include("apps.grafana_plugin.urls", namespace="grafana-plugin")),
path("twilioapp/", include("apps.twilioapp.urls")),
path("api/v1/", include("apps.public_api.urls", namespace="api-public")),
path("mobile_app/v1/", include("apps.mobile_app.urls", namespace="mobile_app")),
path("api/internal/v1/mobile_app/", include("apps.mobile_app.urls", namespace="mobile_app_tmp")),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.FEATURE_PROMETHEUS_EXPORTER_ENABLED:
urlpatterns += [
path("metrics/", include("apps.metrics_exporter.urls")),
]
if settings.FEATURE_SLACK_INTEGRATION_ENABLED:
urlpatterns += [
path("api/internal/v1/slack/", include("apps.slack.urls")),
]
if settings.FEATURE_TELEGRAM_INTEGRATION_ENABLED:
urlpatterns += [path("telegram/", include("apps.telegram.urls"))]
if settings.FEATURE_SLACK_INTEGRATION_ENABLED:
urlpatterns += [
path("slack/", include("apps.slack.urls")),
]
if settings.IS_OPEN_SOURCE:
urlpatterns += [
path("api/internal/v1/", include("apps.oss_installation.urls", namespace="oss_installation")),
path("zvonok/", include("apps.zvonok.urls")),
]
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
path("__debug__/", include(debug_toolbar.urls)),
] + urlpatterns
if settings.SILK_PROFILER_ENABLED:
urlpatterns += [
# need django admin enabled to be able to access silk
path(settings.ONCALL_DJANGO_ADMIN_PATH, admin.site.urls),
path(settings.SILK_PATH, include("silk.urls", namespace="silk")),
]
if settings.DRF_SPECTACULAR_ENABLED:
from drf_spectacular.views import SpectacularSwaggerView, SpectacularYAMLAPIView
urlpatterns += [
path("internal/schema/", SpectacularYAMLAPIView.as_view(api_version="internal/v1"), name="schema"),
path("internal/schema/swagger-ui/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui"),
]