2021-08-27 16:20:49 +02:00
|
|
|
from typing import Any, List
|
|
|
|
|
2023-06-15 10:33:19 +02:00
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib import admin
|
|
|
|
from django.urls import include
|
2021-08-27 16:20:49 +02:00
|
|
|
from django.urls.conf import path
|
2020-11-24 23:26:28 +01:00
|
|
|
from rest_framework_extensions.routers import NestedRegistryItem
|
|
|
|
|
2022-12-30 06:31:15 +01:00
|
|
|
from ee.api import integration, time_to_see_data
|
2020-11-24 23:26:28 +01:00
|
|
|
from posthog.api.routing import DefaultRouterPlusPlus
|
2020-08-14 11:23:55 +02:00
|
|
|
|
2022-06-22 14:26:13 +02:00
|
|
|
from .api import (
|
|
|
|
authentication,
|
2022-10-19 08:58:36 +02:00
|
|
|
billing,
|
2022-06-22 14:26:13 +02:00
|
|
|
dashboard_collaborator,
|
|
|
|
debug_ch_queries,
|
|
|
|
explicit_team_member,
|
2022-11-24 02:36:29 +01:00
|
|
|
feature_flag_role_access,
|
2022-06-22 14:26:13 +02:00
|
|
|
hooks,
|
|
|
|
license,
|
2022-11-24 02:36:29 +01:00
|
|
|
organization_resource_access,
|
|
|
|
role,
|
2022-11-03 02:15:47 +01:00
|
|
|
sentry_stats,
|
2022-06-22 14:26:13 +02:00
|
|
|
subscription,
|
|
|
|
)
|
2023-09-18 14:35:59 +02:00
|
|
|
from .session_recordings import session_recording_playlist
|
2020-08-14 11:23:55 +02:00
|
|
|
|
|
|
|
|
2022-02-08 17:22:09 +01:00
|
|
|
def extend_api_router(
|
|
|
|
root_router: DefaultRouterPlusPlus,
|
|
|
|
*,
|
|
|
|
projects_router: NestedRegistryItem,
|
2022-11-24 02:36:29 +01:00
|
|
|
organizations_router: NestedRegistryItem,
|
2022-09-05 14:38:54 +02:00
|
|
|
project_dashboards_router: NestedRegistryItem,
|
2022-11-24 02:36:29 +01:00
|
|
|
project_feature_flags_router: NestedRegistryItem,
|
2022-02-08 17:22:09 +01:00
|
|
|
) -> None:
|
2022-10-19 08:58:36 +02:00
|
|
|
root_router.register(r"billing-v2", billing.BillingViewset, "billing")
|
2020-11-24 23:26:28 +01:00
|
|
|
root_router.register(r"license", license.LicenseViewSet)
|
2020-12-07 16:06:14 +01:00
|
|
|
root_router.register(r"debug_ch_queries", debug_ch_queries.DebugCHQueries, "debug_ch_queries")
|
2022-12-30 06:31:15 +01:00
|
|
|
root_router.register(r"time_to_see_data", time_to_see_data.TimeToSeeDataViewSet, "query_metrics")
|
2022-07-01 12:07:15 +02:00
|
|
|
root_router.register(r"integrations", integration.PublicIntegrationViewSet)
|
2022-11-24 02:36:29 +01:00
|
|
|
organization_roles_router = organizations_router.register(
|
|
|
|
r"roles",
|
|
|
|
role.RoleViewSet,
|
|
|
|
"organization_roles",
|
|
|
|
["organization_id"],
|
|
|
|
)
|
|
|
|
organization_roles_router.register(
|
|
|
|
r"role_memberships",
|
|
|
|
role.RoleMembershipViewSet,
|
|
|
|
"organization_role_memberships",
|
|
|
|
["organization_id", "role_id"],
|
|
|
|
)
|
|
|
|
project_feature_flags_router.register(
|
|
|
|
r"role_access",
|
|
|
|
feature_flag_role_access.FeatureFlagRoleAccessViewSet,
|
|
|
|
"feature_flag_role_access",
|
|
|
|
["team_id", "feature_flag_id"],
|
|
|
|
)
|
|
|
|
organizations_router.register(
|
|
|
|
r"resource_access",
|
|
|
|
organization_resource_access.OrganizationResourceAccessViewSet,
|
|
|
|
"organization_resource_access",
|
|
|
|
["organization_id"],
|
|
|
|
)
|
2020-11-24 23:26:28 +01:00
|
|
|
projects_router.register(r"hooks", hooks.HookViewSet, "project_hooks", ["team_id"])
|
2021-09-22 18:29:59 +02:00
|
|
|
projects_router.register(
|
|
|
|
r"explicit_members", explicit_team_member.ExplicitTeamMemberViewSet, "project_explicit_members", ["team_id"]
|
|
|
|
)
|
2022-02-08 17:22:09 +01:00
|
|
|
project_dashboards_router.register(
|
|
|
|
r"collaborators",
|
|
|
|
dashboard_collaborator.DashboardCollaboratorViewSet,
|
|
|
|
"project_dashboard_collaborators",
|
|
|
|
["team_id", "dashboard_id"],
|
|
|
|
)
|
2021-08-27 16:20:49 +02:00
|
|
|
|
2022-06-22 14:26:13 +02:00
|
|
|
projects_router.register(r"subscriptions", subscription.SubscriptionViewSet, "subscriptions", ["team_id"])
|
2022-11-10 17:37:56 +01:00
|
|
|
projects_router.register(
|
|
|
|
r"session_recording_playlists",
|
|
|
|
session_recording_playlist.SessionRecordingPlaylistViewSet,
|
|
|
|
"project_session_recording_playlists",
|
|
|
|
["team_id"],
|
|
|
|
)
|
2022-06-22 14:26:13 +02:00
|
|
|
|
2021-08-27 16:20:49 +02:00
|
|
|
|
2023-06-15 10:33:19 +02:00
|
|
|
# The admin interface is disabled on self-hosted instances, as its misuse can be unsafe
|
|
|
|
admin_urlpatterns = (
|
2023-06-15 14:03:08 +02:00
|
|
|
[path("admin/", include("loginas.urls")), path("admin/", admin.site.urls)] if settings.ADMIN_PORTAL_ENABLED else []
|
2023-06-15 10:33:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-03 02:15:47 +01:00
|
|
|
urlpatterns: List[Any] = [
|
|
|
|
path("api/saml/metadata/", authentication.saml_metadata_view),
|
2022-12-19 12:59:19 +01:00
|
|
|
path("api/sentry_stats/", sentry_stats.sentry_stats),
|
2023-06-15 10:33:19 +02:00
|
|
|
*admin_urlpatterns,
|
2022-11-03 02:15:47 +01:00
|
|
|
]
|