chore: remove service token endpoint which is unused (#8797)

This commit is contained in:
sriram veeraghanta 2026-03-25 13:13:58 +05:30 committed by GitHub
parent d91b5a274b
commit f3c7c057b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 34 deletions

View file

@ -3,7 +3,7 @@
# See the LICENSE file for details. # See the LICENSE file for details.
from django.urls import path from django.urls import path
from plane.app.views import ApiTokenEndpoint, ServiceApiTokenEndpoint from plane.app.views import ApiTokenEndpoint
urlpatterns = [ urlpatterns = [
# API Tokens # API Tokens
@ -17,10 +17,5 @@ urlpatterns = [
ApiTokenEndpoint.as_view(), ApiTokenEndpoint.as_view(),
name="api-tokens-details", name="api-tokens-details",
), ),
path(
"workspaces/<str:slug>/service-api-tokens/",
ServiceApiTokenEndpoint.as_view(),
name="service-api-tokens",
),
## End API Tokens ## End API Tokens
] ]

View file

@ -165,7 +165,7 @@ from .module.issue import ModuleIssueViewSet
from .module.archive import ModuleArchiveUnarchiveEndpoint from .module.archive import ModuleArchiveUnarchiveEndpoint
from .api import ApiTokenEndpoint, ServiceApiTokenEndpoint from .api import ApiTokenEndpoint
from .page.base import ( from .page.base import (
PageViewSet, PageViewSet,

View file

@ -13,9 +13,8 @@ from rest_framework import status
# Module import # Module import
from .base import BaseAPIView from .base import BaseAPIView
from plane.db.models import APIToken, Workspace from plane.db.models import APIToken
from plane.app.serializers import APITokenSerializer, APITokenReadSerializer from plane.app.serializers import APITokenSerializer, APITokenReadSerializer
from plane.app.permissions import WorkspaceEntityPermission
class ApiTokenEndpoint(BaseAPIView): class ApiTokenEndpoint(BaseAPIView):
@ -61,28 +60,3 @@ class ApiTokenEndpoint(BaseAPIView):
serializer.save() serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class ServiceApiTokenEndpoint(BaseAPIView):
permission_classes = [WorkspaceEntityPermission]
def post(self, request: Request, slug: str) -> Response:
workspace = Workspace.objects.get(slug=slug)
api_token = APIToken.objects.filter(workspace=workspace, is_service=True).first()
if api_token:
return Response({"token": str(api_token.token)}, status=status.HTTP_200_OK)
else:
# Check the user type
user_type = 1 if request.user.is_bot else 0
api_token = APIToken.objects.create(
label=str(uuid4().hex),
description="Service Token",
user=request.user,
workspace=workspace,
user_type=user_type,
is_service=True,
)
return Response({"token": str(api_token.token)}, status=status.HTTP_201_CREATED)