Skip to content

Commit abac613

Browse files
authored
fix(hc): Move OrganizationApiKeyDetailsEndpoint to control silo (#52776)
The ApiKey model lives in the control silo.
1 parent 8944abd commit abac613

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/sentry/api/endpoints/organization_api_key_details.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
from rest_framework.response import Response
44

55
from sentry import audit_log
6-
from sentry.api.base import region_silo_endpoint
7-
from sentry.api.bases.organization import OrganizationAdminPermission, OrganizationEndpoint
6+
from sentry.api.base import control_silo_endpoint
7+
from sentry.api.bases.organization import (
8+
ControlSiloOrganizationEndpoint,
9+
OrganizationAdminPermission,
10+
)
811
from sentry.api.exceptions import ResourceDoesNotExist
912
from sentry.api.serializers import serialize
1013
from sentry.models import ApiKey
@@ -16,11 +19,11 @@ class Meta:
1619
fields = ("label", "scope_list", "allowed_origins")
1720

1821

19-
@region_silo_endpoint
20-
class OrganizationApiKeyDetailsEndpoint(OrganizationEndpoint):
22+
@control_silo_endpoint
23+
class OrganizationApiKeyDetailsEndpoint(ControlSiloOrganizationEndpoint):
2124
permission_classes = (OrganizationAdminPermission,)
2225

23-
def get(self, request: Request, organization, api_key_id) -> Response:
26+
def get(self, request: Request, organization_context, organization, api_key_id) -> Response:
2427
"""
2528
Retrieves API Key details
2629
`````````````````````````
@@ -37,7 +40,7 @@ def get(self, request: Request, organization, api_key_id) -> Response:
3740

3841
return Response(serialize(api_key, request.user))
3942

40-
def put(self, request: Request, organization, api_key_id) -> Response:
43+
def put(self, request: Request, organization_context, organization, api_key_id) -> Response:
4144
"""
4245
Update an API Key
4346
`````````````````
@@ -73,7 +76,7 @@ def put(self, request: Request, organization, api_key_id) -> Response:
7376

7477
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
7578

76-
def delete(self, request: Request, organization, api_key_id) -> Response:
79+
def delete(self, request: Request, organization_context, organization, api_key_id) -> Response:
7780
"""
7881
Deletes an API Key
7982
``````````````````

tests/sentry/api/endpoints/test_organization_api_key_details.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from sentry.models import ApiKey
22
from sentry.testutils import APITestCase
3-
from sentry.testutils.silo import region_silo_test
3+
from sentry.testutils.silo import control_silo_test
44

55
DEFAULT_SCOPES = ["project:read", "event:read", "team:read", "org:read", "member:read"]
66

@@ -16,7 +16,7 @@ def setUp(self):
1616
)
1717

1818

19-
@region_silo_test
19+
@control_silo_test(stable=True)
2020
class OrganizationApiKeyDetails(OrganizationApiKeyDetailsBase):
2121
def test_api_key_no_exist(self):
2222
self.get_error_response(self.organization.slug, 123456, status_code=404)
@@ -26,7 +26,7 @@ def test_get_api_details(self):
2626
assert response.data.get("id") == str(self.api_key.id)
2727

2828

29-
@region_silo_test
29+
@control_silo_test(stable=True)
3030
class OrganizationApiKeyDetailsPut(OrganizationApiKeyDetailsBase):
3131
method = "put"
3232

@@ -40,7 +40,7 @@ def test_update_api_key_details(self):
4040
assert api_key.allowed_origins == "sentry.io"
4141

4242

43-
@region_silo_test
43+
@control_silo_test(stable=True)
4444
class OrganizationApiKeyDetailsDelete(OrganizationApiKeyDetailsBase):
4545
method = "delete"
4646

0 commit comments

Comments
 (0)