Skip to content

Commit 8b6aad2

Browse files
authored
release v1.0.46
release v1.0.46
2 parents 14a442b + 5a4c3d6 commit 8b6aad2

File tree

4 files changed

+4
-66
lines changed

4 files changed

+4
-66
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Change Log
22

3-
4-
## v1.0.46 (2022-10-27)
3+
## v1.0.46 (2022-10-28)
54

65
- Bug fixes
6+
- remove `POST /api/internal/v1/custom_buttons/{id}/action` endpoint
77

88
## v1.0.45 (2022-10-27)
99

engine/apps/api/tests/test_custom_button.py

-33
Original file line numberDiff line numberDiff line change
@@ -447,39 +447,6 @@ def test_custom_button_delete_permissions(
447447
assert response.status_code == expected_status
448448

449449

450-
@pytest.mark.django_db
451-
@pytest.mark.parametrize(
452-
"role,expected_status",
453-
[
454-
(Role.ADMIN, status.HTTP_200_OK),
455-
(Role.EDITOR, status.HTTP_200_OK),
456-
(Role.VIEWER, status.HTTP_403_FORBIDDEN),
457-
],
458-
)
459-
def test_custom_button_action_permissions(
460-
make_organization_and_user_with_plugin_token,
461-
make_custom_action,
462-
make_user_auth_headers,
463-
role,
464-
expected_status,
465-
):
466-
organization, user, token = make_organization_and_user_with_plugin_token(role)
467-
custom_button = make_custom_action(organization=organization)
468-
client = APIClient()
469-
470-
url = reverse("api-internal:custom_button-action", kwargs={"pk": custom_button.public_primary_key})
471-
472-
with patch(
473-
"apps.api.views.custom_button.CustomButtonView.action",
474-
return_value=Response(
475-
status=status.HTTP_200_OK,
476-
),
477-
):
478-
response = client.post(url, format="json", **make_user_auth_headers(user, token))
479-
480-
assert response.status_code == expected_status
481-
482-
483450
@pytest.mark.django_db
484451
def test_get_custom_button_from_other_team_with_flag(
485452
make_organization_and_user_with_plugin_token,

engine/apps/api/views/custom_button.py

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
from django.core.exceptions import ObjectDoesNotExist
2-
from rest_framework import status
3-
from rest_framework.decorators import action
42
from rest_framework.exceptions import NotFound
53
from rest_framework.permissions import IsAuthenticated
6-
from rest_framework.response import Response
74
from rest_framework.viewsets import ModelViewSet
85

9-
from apps.alerts.models import AlertGroup, CustomButton
10-
from apps.alerts.tasks.custom_button_result import custom_button_result
11-
from apps.api.permissions import MODIFY_ACTIONS, READ_ACTIONS, ActionPermission, AnyRole, IsAdmin, IsAdminOrEditor
6+
from apps.alerts.models import CustomButton
7+
from apps.api.permissions import MODIFY_ACTIONS, READ_ACTIONS, ActionPermission, AnyRole, IsAdmin
128
from apps.api.serializers.custom_button import CustomButtonSerializer
139
from apps.auth_token.auth import PluginAuthentication
14-
from common.api_helpers.exceptions import BadRequest
1510
from common.api_helpers.mixins import PublicPrimaryKeyMixin, TeamFilteringMixin
1611
from common.insight_log import EntityEvent, write_resource_insight_log
1712

@@ -21,7 +16,6 @@ class CustomButtonView(TeamFilteringMixin, PublicPrimaryKeyMixin, ModelViewSet):
2116
permission_classes = (IsAuthenticated, ActionPermission)
2217
action_permissions = {
2318
IsAdmin: MODIFY_ACTIONS,
24-
IsAdminOrEditor: ("action",),
2519
AnyRole: READ_ACTIONS,
2620
}
2721

@@ -85,19 +79,3 @@ def perform_destroy(self, instance):
8579
event=EntityEvent.DELETED,
8680
)
8781
instance.delete()
88-
89-
@action(detail=True, methods=["post"])
90-
def action(self, request, pk):
91-
alert_group_id = request.query_params.get("alert_group", None)
92-
if alert_group_id is not None:
93-
custom_button = self.get_object()
94-
try:
95-
alert_group = AlertGroup.unarchived_objects.get(
96-
public_primary_key=alert_group_id, channel=custom_button.alert_receive_channel
97-
)
98-
custom_button_result.apply_async((custom_button.pk, alert_group.pk, self.request.user.pk))
99-
except AlertGroup.DoesNotExist:
100-
raise BadRequest(detail="AlertGroup does not exist or archived")
101-
return Response(status=status.HTTP_200_OK)
102-
else:
103-
raise BadRequest(detail="AlertGroup is required")

grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.ts

-7
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,6 @@ export class AlertReceiveChannelStore extends BaseStore {
314314
});
315315
}
316316

317-
async doCustomButtonAction(actionId: ActionDTO['id'], alertId: Alert['pk']) {
318-
return await makeRequest(`/custom_buttons/${actionId}/action/`, {
319-
method: 'POST',
320-
params: { alert_group: alertId },
321-
});
322-
}
323-
324317
async getAccessLogs(alertReceiveChannelId: AlertReceiveChannel['id']) {
325318
const { integration_log } = await makeRequest(`/alert_receive_channel_access_log/${alertReceiveChannelId}/`, {});
326319

0 commit comments

Comments
 (0)