Browse Source

chore(hybrid-cloud): Update OrgAuthTokenDetailsEndpoint to be a control silo endpoint (#54756)

Alberto Leal 1 year ago
parent
commit
3f9c3742b6
1 changed files with 27 additions and 6 deletions
  1. 27 6
      src/sentry/api/endpoints/org_auth_token_details.py

+ 27 - 6
src/sentry/api/endpoints/org_auth_token_details.py

@@ -4,18 +4,27 @@ from rest_framework.response import Response
 
 from sentry import analytics, audit_log
 from sentry.api.base import control_silo_endpoint
-from sentry.api.bases.organization import OrganizationEndpoint, OrgAuthTokenPermission
+from sentry.api.bases.organization import ControlSiloOrganizationEndpoint, OrgAuthTokenPermission
 from sentry.api.exceptions import ResourceDoesNotExist
 from sentry.api.serializers import serialize
-from sentry.models.organization import Organization
 from sentry.models.orgauthtoken import OrgAuthToken
+from sentry.services.hybrid_cloud.organization.model import (
+    RpcOrganization,
+    RpcUserOrganizationContext,
+)
 
 
 @control_silo_endpoint
-class OrgAuthTokenDetailsEndpoint(OrganizationEndpoint):
+class OrgAuthTokenDetailsEndpoint(ControlSiloOrganizationEndpoint):
     permission_classes = (OrgAuthTokenPermission,)
 
-    def get(self, request: Request, organization: Organization, token_id) -> Response:
+    def get(
+        self,
+        request: Request,
+        organization_context: RpcUserOrganizationContext,
+        organization: RpcOrganization,
+        token_id: int,
+    ) -> Response:
         try:
             instance = OrgAuthToken.objects.get(
                 organization_id=organization.id, date_deactivated__isnull=True, id=token_id
@@ -25,7 +34,13 @@ class OrgAuthTokenDetailsEndpoint(OrganizationEndpoint):
 
         return Response(serialize(instance, request.user, token=None))
 
-    def put(self, request: Request, organization, token_id):
+    def put(
+        self,
+        request: Request,
+        organization_context: RpcUserOrganizationContext,
+        organization: RpcOrganization,
+        token_id: int,
+    ):
         try:
             instance = OrgAuthToken.objects.get(
                 organization_id=organization.id, id=token_id, date_deactivated__isnull=True
@@ -42,7 +57,13 @@ class OrgAuthTokenDetailsEndpoint(OrganizationEndpoint):
 
         return Response(status=204)
 
-    def delete(self, request: Request, organization, token_id):
+    def delete(
+        self,
+        request: Request,
+        organization_context: RpcUserOrganizationContext,
+        organization: RpcOrganization,
+        token_id: int,
+    ):
         try:
             instance = OrgAuthToken.objects.get(
                 organization_id=organization.id, id=token_id, date_deactivated__isnull=True