2022-08-19 14:03:07 +05:00
|
|
|
from django.urls import include, path, re_path
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
from common.api_helpers.optional_slash_router import OptionalSlashRouter, optional_slash_path
|
|
|
|
|
|
|
|
|
|
from .views import UserNotificationPolicyView, auth
|
|
|
|
|
from .views.alert_group import AlertGroupView
|
2023-11-29 14:11:31 +02:00
|
|
|
from .views.alert_group_table_settings import AlertGroupTableColumnsViewSet
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.alert_receive_channel import AlertReceiveChannelView
|
|
|
|
|
from .views.alert_receive_channel_template import AlertReceiveChannelTemplateView
|
2022-08-19 14:03:07 +05:00
|
|
|
from .views.alerts import AlertDetailView
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.channel_filter import ChannelFilterView
|
2024-08-15 14:31:35 -04:00
|
|
|
from .views.direct_paging import DirectPagingAPIView
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.escalation_chain import EscalationChainViewSet
|
|
|
|
|
from .views.escalation_policy import EscalationPolicyView
|
|
|
|
|
from .views.features import FeaturesAPIView
|
|
|
|
|
from .views.integration_heartbeat import IntegrationHeartBeatView
|
2023-11-06 10:31:12 +00:00
|
|
|
from .views.labels import AlertGroupLabelsViewSet, LabelsViewSet
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.live_setting import LiveSettingViewSet
|
2022-07-12 13:59:17 +03:00
|
|
|
from .views.on_call_shifts import OnCallShiftView
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.organization import (
|
|
|
|
|
CurrentOrganizationView,
|
|
|
|
|
GetChannelVerificationCode,
|
|
|
|
|
GetTelegramVerificationCode,
|
2024-04-11 11:51:56 -03:00
|
|
|
OrganizationConfigChecksView,
|
feat: convert `organization.general_log_channel_id` to `organization.default_slack_channel` (#5191)
# What this PR does
Related to https://github.com/grafana/oncall-private/issues/2947
Right now `general_log_channel_id` is just a string value representing
the Slack Channel ID (ex. `C043HQ70QMB`). This PR migrates this instead
to be a foreign key relationship on the `slack_slackchannel` table and
updates all references to `general_log_channel_id`.
Tested migrations locally:
```bash
Operations to perform:
Apply all migrations: [redacted secret grafana-admin-creds:admin-user], alerts, auth, auth_token, base, contenttypes, email, exotel, fcm_django, google, heartbeat, labels, mobile_app, oss_installation, phone_notifications, schedules, sessions, slack, social_django, telegram, twilioapp, user_management, webhooks, zvonok
Running migrations:
Applying user_management.0024_organization_general_log_slack_channel... OK
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Starting migration to populate general_log_slack_channel field.
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Total organizations to process: 1
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Organization 1 updated with SlackChannel 2 (slack_id: C043LL6RTS7).
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Finished migration. Total organizations processed: 1. Organizations updated: 1. Missing SlackChannels: 0.
Applying user_management.0025_auto_20241017_1919... OK
```
## Future incoming PRs
- Drop `Organization.general_log_channel_id` column
- Migrate `ChannelFilter.slack_channel_id` and
`ResolutionNoteSlackMessage.slack_channel_id` to use foreign key
relationships
## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
show up in the autogenerated release notes.
2024-11-01 06:41:38 +01:00
|
|
|
SetDefaultSlackChannel,
|
2022-06-03 08:09:47 -06:00
|
|
|
)
|
|
|
|
|
from .views.preview_template_options import PreviewTemplateOptionsView
|
|
|
|
|
from .views.public_api_tokens import PublicApiTokenView
|
|
|
|
|
from .views.resolution_note import ResolutionNoteView
|
|
|
|
|
from .views.route_regex_debugger import RouteRegexDebuggerView
|
|
|
|
|
from .views.schedule import ScheduleView
|
2023-07-21 21:35:19 +02:00
|
|
|
from .views.shift_swap import ShiftSwapViewSet
|
2022-06-03 08:09:47 -06:00
|
|
|
from .views.slack_channel import SlackChannelView
|
|
|
|
|
from .views.slack_team_settings import (
|
|
|
|
|
AcknowledgeReminderOptionsAPIView,
|
|
|
|
|
SlackTeamSettingsAPIView,
|
|
|
|
|
UnAcknowledgeTimeoutOptionsAPIView,
|
|
|
|
|
)
|
|
|
|
|
from .views.team import TeamViewSet
|
|
|
|
|
from .views.telegram_channels import TelegramChannelViewSet
|
|
|
|
|
from .views.user import CurrentUserView, UserView
|
|
|
|
|
from .views.user_group import UserGroupViewSet
|
2023-03-10 14:00:06 -03:00
|
|
|
from .views.webhooks import WebhooksView
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
app_name = "api-internal"
|
|
|
|
|
|
|
|
|
|
router = OptionalSlashRouter()
|
|
|
|
|
router.register(r"users", UserView, basename="user")
|
|
|
|
|
router.register(r"teams", TeamViewSet, basename="team")
|
|
|
|
|
router.register(r"alertgroups", AlertGroupView, basename="alertgroup")
|
|
|
|
|
router.register(r"notification_policies", UserNotificationPolicyView, basename="notification_policy")
|
|
|
|
|
router.register(r"escalation_policies", EscalationPolicyView, basename="escalation_policy")
|
|
|
|
|
router.register(r"escalation_chains", EscalationChainViewSet, basename="escalation_chain")
|
|
|
|
|
router.register(r"alert_receive_channels", AlertReceiveChannelView, basename="alert_receive_channel")
|
|
|
|
|
router.register(
|
|
|
|
|
r"alert_receive_channel_templates", AlertReceiveChannelTemplateView, basename="alert_receive_channel_template"
|
|
|
|
|
)
|
|
|
|
|
router.register(r"channel_filters", ChannelFilterView, basename="channel_filter")
|
|
|
|
|
router.register(r"schedules", ScheduleView, basename="schedule")
|
2023-03-10 14:00:06 -03:00
|
|
|
router.register(r"webhooks", WebhooksView, basename="webhooks")
|
2022-06-03 08:09:47 -06:00
|
|
|
router.register(r"resolution_notes", ResolutionNoteView, basename="resolution_note")
|
|
|
|
|
router.register(r"telegram_channels", TelegramChannelViewSet, basename="telegram_channel")
|
|
|
|
|
router.register(r"slack_channels", SlackChannelView, basename="slack_channel")
|
|
|
|
|
router.register(r"user_groups", UserGroupViewSet, basename="user_group")
|
|
|
|
|
router.register(r"heartbeats", IntegrationHeartBeatView, basename="integration_heartbeat")
|
|
|
|
|
router.register(r"tokens", PublicApiTokenView, basename="api_token")
|
|
|
|
|
router.register(r"live_settings", LiveSettingViewSet, basename="live_settings")
|
2022-07-12 13:59:17 +03:00
|
|
|
router.register(r"oncall_shifts", OnCallShiftView, basename="oncall_shifts")
|
2023-08-04 16:12:33 +02:00
|
|
|
router.register(r"shift_swaps", ShiftSwapViewSet, basename="shift_swap")
|
2023-07-21 21:35:19 +02:00
|
|
|
|
2022-06-03 08:09:47 -06:00
|
|
|
urlpatterns = [
|
|
|
|
|
path("", include(router.urls)),
|
|
|
|
|
optional_slash_path("user", CurrentUserView.as_view(), name="api-user"),
|
feat: convert `organization.general_log_channel_id` to `organization.default_slack_channel` (#5191)
# What this PR does
Related to https://github.com/grafana/oncall-private/issues/2947
Right now `general_log_channel_id` is just a string value representing
the Slack Channel ID (ex. `C043HQ70QMB`). This PR migrates this instead
to be a foreign key relationship on the `slack_slackchannel` table and
updates all references to `general_log_channel_id`.
Tested migrations locally:
```bash
Operations to perform:
Apply all migrations: [redacted secret grafana-admin-creds:admin-user], alerts, auth, auth_token, base, contenttypes, email, exotel, fcm_django, google, heartbeat, labels, mobile_app, oss_installation, phone_notifications, schedules, sessions, slack, social_django, telegram, twilioapp, user_management, webhooks, zvonok
Running migrations:
Applying user_management.0024_organization_general_log_slack_channel... OK
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Starting migration to populate general_log_slack_channel field.
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Total organizations to process: 1
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Organization 1 updated with SlackChannel 2 (slack_id: C043LL6RTS7).
source=engine:app google_trace_id=none logger=apps.user_management.migrations.0025_auto_20241017_1919 Finished migration. Total organizations processed: 1. Organizations updated: 1. Missing SlackChannels: 0.
Applying user_management.0025_auto_20241017_1919... OK
```
## Future incoming PRs
- Drop `Organization.general_log_channel_id` column
- Migrate `ChannelFilter.slack_channel_id` and
`ResolutionNoteSlackMessage.slack_channel_id` to use foreign key
relationships
## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
show up in the autogenerated release notes.
2024-11-01 06:41:38 +01:00
|
|
|
optional_slash_path("set_general_channel", SetDefaultSlackChannel.as_view(), name="set-default-slack-channel"),
|
2023-07-21 17:38:58 +02:00
|
|
|
optional_slash_path("organization", CurrentOrganizationView.as_view(), name="api-organization"),
|
2024-04-11 11:51:56 -03:00
|
|
|
optional_slash_path(
|
|
|
|
|
"organization/config-checks",
|
|
|
|
|
OrganizationConfigChecksView.as_view(),
|
|
|
|
|
name="api-organization-config-checks",
|
|
|
|
|
),
|
2023-07-21 17:38:58 +02:00
|
|
|
# TODO: remove current_team routes in future release
|
2022-06-03 08:09:47 -06:00
|
|
|
optional_slash_path("current_team", CurrentOrganizationView.as_view(), name="api-current-team"),
|
|
|
|
|
optional_slash_path(
|
|
|
|
|
"current_team/get_telegram_verification_code",
|
|
|
|
|
GetTelegramVerificationCode.as_view(),
|
|
|
|
|
name="api-get-telegram-verification-code",
|
|
|
|
|
),
|
|
|
|
|
optional_slash_path(
|
|
|
|
|
"current_team/get_channel_verification_code",
|
|
|
|
|
GetChannelVerificationCode.as_view(),
|
|
|
|
|
name="api-get-channel-verification-code",
|
|
|
|
|
),
|
|
|
|
|
optional_slash_path("slack_settings", SlackTeamSettingsAPIView.as_view(), name="slack-settings"),
|
|
|
|
|
optional_slash_path(
|
|
|
|
|
"slack_settings/acknowledge_remind_options",
|
|
|
|
|
AcknowledgeReminderOptionsAPIView.as_view(),
|
|
|
|
|
name="acknowledge-reminder-options",
|
|
|
|
|
),
|
|
|
|
|
optional_slash_path(
|
|
|
|
|
"slack_settings/unacknowledge_timeout_options",
|
|
|
|
|
UnAcknowledgeTimeoutOptionsAPIView.as_view(),
|
|
|
|
|
name="unacknowledge-timeout-options",
|
|
|
|
|
),
|
|
|
|
|
optional_slash_path("features", FeaturesAPIView.as_view(), name="features"),
|
|
|
|
|
optional_slash_path(
|
|
|
|
|
"preview_template_options", PreviewTemplateOptionsView.as_view(), name="preview_template_options"
|
|
|
|
|
),
|
|
|
|
|
optional_slash_path("route_regex_debugger", RouteRegexDebuggerView.as_view(), name="route_regex_debugger"),
|
2022-08-19 14:03:07 +05:00
|
|
|
re_path(r"^alerts/(?P<id>\w+)/?$", AlertDetailView.as_view(), name="alerts-detail"),
|
2023-01-17 12:19:08 -03:00
|
|
|
optional_slash_path("direct_paging", DirectPagingAPIView.as_view(), name="direct_paging"),
|
2022-06-03 08:09:47 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
urlpatterns += [
|
|
|
|
|
# For some reason frontend is using url without / at the end. Hacking here to avoid 301's :(
|
2024-04-02 14:59:03 -04:00
|
|
|
# TODO: I'm fairly certain this is not needed anymore, it looks like the frontend instead
|
|
|
|
|
# makes calls w/ a trailing slash.. we can probably get rid of social-auth-with-no-slash
|
|
|
|
|
path(r"login/<backend>", auth.overridden_login_social_auth, name="social-auth-with-no-slash"),
|
|
|
|
|
path(r"login/<backend>/", auth.overridden_login_social_auth, name="social-auth"),
|
|
|
|
|
path(r"complete/<backend>/", auth.overridden_complete_social_auth, name="complete-social-auth"),
|
|
|
|
|
path(r"disconnect/<backend>", auth.overridden_disconnect_social_auth, name="disconnect-social-auth"),
|
2022-06-03 08:09:47 -06:00
|
|
|
]
|
2023-10-20 09:30:11 +02:00
|
|
|
|
|
|
|
|
urlpatterns += [
|
|
|
|
|
re_path(r"^labels/keys/?$", LabelsViewSet.as_view({"get": "get_keys"}), name="get_keys"),
|
|
|
|
|
re_path(
|
|
|
|
|
r"^labels/id/(?P<key_id>[\w\-]+)/?$",
|
|
|
|
|
LabelsViewSet.as_view({"get": "get_key", "put": "rename_key"}),
|
|
|
|
|
name="get_update_key",
|
|
|
|
|
),
|
2025-01-14 11:02:23 +01:00
|
|
|
re_path(
|
|
|
|
|
r"^labels/name/(?P<key_name>[\w\-]+)/?$",
|
|
|
|
|
LabelsViewSet.as_view({"get": "get_key_by_name"}),
|
|
|
|
|
name="get_key_by_name",
|
|
|
|
|
),
|
2023-10-20 09:30:11 +02:00
|
|
|
re_path(
|
|
|
|
|
r"^labels/id/(?P<key_id>[\w\-]+)/values/?$", LabelsViewSet.as_view({"post": "add_value"}), name="add_value"
|
|
|
|
|
),
|
|
|
|
|
re_path(
|
|
|
|
|
r"^labels/id/(?P<key_id>[\w\-]+)/values/(?P<value_id>[\w\-]+)/?$",
|
|
|
|
|
LabelsViewSet.as_view({"put": "rename_value", "get": "get_value"}),
|
|
|
|
|
name="get_update_value",
|
|
|
|
|
),
|
|
|
|
|
re_path(r"^labels/?$", LabelsViewSet.as_view({"post": "create_label"}), name="create_label"),
|
|
|
|
|
]
|
2023-11-06 10:31:12 +00:00
|
|
|
|
|
|
|
|
# Alert group labels
|
|
|
|
|
urlpatterns += [
|
|
|
|
|
re_path(
|
|
|
|
|
r"^alertgroups/labels/keys/?$",
|
|
|
|
|
AlertGroupLabelsViewSet.as_view({"get": "get_keys"}),
|
|
|
|
|
name="alert_group_labels-get_keys",
|
|
|
|
|
),
|
|
|
|
|
re_path(
|
|
|
|
|
r"^alertgroups/labels/id/(?P<key_id>.+/?$)",
|
|
|
|
|
AlertGroupLabelsViewSet.as_view({"get": "get_key"}),
|
|
|
|
|
name="alert_group_labels-get_key",
|
|
|
|
|
),
|
|
|
|
|
]
|
2023-11-29 14:11:31 +02:00
|
|
|
|
|
|
|
|
# Alert group table settings
|
|
|
|
|
urlpatterns += [
|
|
|
|
|
re_path(
|
|
|
|
|
r"^alertgroup_table_settings/?$",
|
|
|
|
|
AlertGroupTableColumnsViewSet.as_view(
|
|
|
|
|
{"get": "get_columns", "put": "update_user_columns", "post": "update_organization_columns"}
|
|
|
|
|
),
|
|
|
|
|
name="alert_group_table-columns_settings",
|
|
|
|
|
),
|
|
|
|
|
re_path(
|
|
|
|
|
r"^alertgroup_table_settings/reset?$",
|
|
|
|
|
AlertGroupTableColumnsViewSet.as_view({"post": "reset_user_columns"}),
|
|
|
|
|
name="alert_group_table-reset_columns_settings",
|
|
|
|
|
),
|
|
|
|
|
]
|