|
@@ -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
|